diff --git a/ui/src/archie/ComposerView.vue b/ui/src/archie/ComposerView.vue index 785978645..1063337f6 100644 --- a/ui/src/archie/ComposerView.vue +++ b/ui/src/archie/ComposerView.vue @@ -1,15 +1,19 @@ - + - - No messages yet - - - - - Run - - - - {{ m.body }} - - Delivery attempts - - - {{ a.channel }} - Attempt {{ a.attempt }} - {{ a.ok ? "Delivered" : "Failed" }} - {{ a.duration_ms }} ms - - {{ a.response }} - {{ a.error }} + + + + {{ approvals.length }} pending + + + + + + {{ request.action }} + {{ request.summary }} + + Respond by + View run + + + Approve + Deny + + - - - Approve - Deny - - Expires - + + + + Recent activity + Jump to latest + + + No messages yet + + + + + + {{ m.title }} + + View run + + + Details for {{ m.title }} + {{ m.body }} + + + Delivery attempts + + + {{ a.channel }} + Attempt {{ a.attempt }} + {{ a.ok ? "Delivered" : "Failed" }} + {{ a.duration_ms }} ms + + {{ a.response }} + {{ a.error }} + + + + + + - + diff --git a/ui/src/archie/api.ts b/ui/src/archie/api.ts index 19272ba42..af38405ce 100644 --- a/ui/src/archie/api.ts +++ b/ui/src/archie/api.ts @@ -321,6 +321,17 @@ export const latestMessages = (signal?: AbortSignal) => get("/api/com export const messagesAfter = (seq: number, signal?: AbortSignal) => get(`/api/composer/messages?after=${seq}`, signal); +export interface PendingApproval { + id: string; + run_id: string; + action: string; + summary: string; + deadline: string; + step_deadline?: string; +} + +export const pendingApprovals = (signal?: AbortSignal) => get("/api/approvals", signal); + /** Answers an approval request the composer is showing. */ export async function answerApproval(id: string, approved: boolean): Promise { const res = await fetch(`/api/approvals/${encodeURIComponent(id)}/answer`, { @@ -649,25 +660,31 @@ export const listJudges = (signal?: AbortSignal) => get("/api/co export const runTrail = (id: string, signal?: AbortSignal) => get(`/api/runs/${encodeURIComponent(id)}`, signal); /** - * Yields each new composer message's seq as the server announces it. Returns - * when the server ends the stream (a subscriber that fell behind is cut off), - * so the caller reconnects and catches up from its cursor. + * Yields sequence numbers for new messages. Subscribe before fetching missed + * messages so updates published during catch-up are queued. If the server + * disconnects a slow subscriber, the caller reconnects from its last sequence. */ -export async function* composerStream(signal: AbortSignal): AsyncGenerator { +export async function* composerStream(signal: AbortSignal, onConnected?: () => Promise): AsyncGenerator { const res = await request("/api/composer/stream", signal); if (!res.body) return; const reader = res.body.pipeThrough(new TextDecoderStream()).getReader(); let buffered = ""; - for (;;) { - const { value, done } = await reader.read(); - if (done) return; - buffered += value; - let end: number; - while ((end = buffered.indexOf("\n\n")) >= 0) { - const frame = buffered.slice(0, end); - buffered = buffered.slice(end + 2); - const data = frame.split("\n").find((line) => line.startsWith("data: ")); - if (data) yield (JSON.parse(data.slice(6)) as { seq: number }).seq; + try { + await onConnected?.(); + for (;;) { + const { value, done } = await reader.read(); + if (done) return; + buffered += value; + let end: number; + while ((end = buffered.indexOf("\n\n")) >= 0) { + const frame = buffered.slice(0, end); + buffered = buffered.slice(end + 2); + const data = frame.split("\n").find((line) => line.startsWith("data: ")); + if (data) yield (JSON.parse(data.slice(6)) as { seq: number }).seq; + } } + } finally { + void reader.cancel().catch(() => undefined); + reader.releaseLock(); } }
{{ m.body }}
{{ request.summary }}
{{ m.title }}