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:
nocodeandClaude Opus 5 committed 2026-09-23 20:39:59 +02:00
1 parent 9c6297e00e
commit df89cc5893
6 files changed
+351 -1

No files matched your search

+4
View File
@@ -12,6 +12,7 @@ import {
import { logEvent } from '../../database/repositories/event-log-repository.js';
import { notify } from '../../services/notifications/notification-service.js';
import { splitRepository, repos } from '../../services/gitea/gitea-admin.js';
import { broadcast } from '../events.js';
import { HttpError, badRequest, forbidden } from '../http.js';
/** Runs a deployment for a target and records its outcome (M16-T07). */
@@ -156,6 +157,7 @@ export async function runDeployment(
triggeredBy,
});
markRunning(deployment.id);
broadcast('deployments', { id: deployment.id, status: 'running', target: target.name });
const payload = {
deploymentId: deployment.id,
@@ -177,12 +179,14 @@ export async function runDeployment(
else output = await runGiteaAction(target, payload);
finishDeployment(deployment.id, { status: 'success', log: output });
broadcast('deployments', { id: deployment.id, status: 'success', target: target.name });
logEvent({ guildId, type: 'deploy.success', actorId: triggeredBy, payload });
await announce(client, { ...payload, status: 'success' });
return { ...deployment, status: 'success', log: output };
} catch (error) {
const details = error.details ?? error.message;
finishDeployment(deployment.id, { status: 'failed', log: details, error: error.message });
broadcast('deployments', { id: deployment.id, status: 'failed', target: target.name });
log.error('Deployment failed', error);
logEvent({ guildId, type: 'deploy.failed', actorId: triggeredBy, payload });
await announce(client, { ...payload, status: 'failed', error: error.message });