feat(web): push live updates to the dashboard
Reading a page and wondering whether it is still true is a poor way to watch a deployment, and polling every page on a timer costs far more than it returns. The server keeps one `text/event-stream` per open tab and publishes on it: a write once it has actually succeeded, tagged with the page it concerns, a deployment when it starts and when it ends, an incoming Gitea webhook, plus a tick and a heartbeat that stops proxies closing an idle stream. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
6 files changed
+351
-1
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import { ACCESS_LEVELS } from '../../config/constants.js';
|
||||
import { registerAuthRoutes } from '../auth/routes.js';
|
||||
import { openEventStream } from '../events.js';
|
||||
import { registerCommunityRoutes } from './community.js';
|
||||
import { registerConfigurationRoutes } from './configuration.js';
|
||||
import { registerDeploymentRoutes } from './deployments.js';
|
||||
@@ -30,6 +32,15 @@ export function registerApiRoutes(router, { setupOnly = false } = {}) {
|
||||
registerAuthRoutes(router);
|
||||
registerConfigurationRoutes(router);
|
||||
|
||||
// Long-lived stream the pages listen to instead of polling (M16-T12).
|
||||
router.get(
|
||||
'/api/events',
|
||||
({ request, response, actor }) => {
|
||||
openEventStream(request, response, actor);
|
||||
},
|
||||
{ access: ACCESS_LEVELS.STAFF },
|
||||
);
|
||||
|
||||
// In bootstrap mode the bot is not connected and the database may be empty:
|
||||
// only the wizard makes sense.
|
||||
if (setupOnly) return router;
|
||||
|
||||
Reference in new issue
Block a user