Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Make Assistant progress live

rcourtman26d8baa6d824
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index a0cb863b0a..f4211fede2 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -6767,11 +6767,11 @@
{
"id": "codex-lane-followup-architecture-post-rc-canonicalization",
"agent_id": "codex",
- "summary": "Bound Assistant OpenAI-compatible first-token waits",
+ "summary": "Make Assistant progress events feel live",
"target_id": "v6-product-lane-expansion",
"claimed_at": "2026-06-05T21:57:48Z",
- "heartbeat_at": "2026-06-05T23:28:35Z",
- "expires_at": "2026-06-06T01:28:35Z",
+ "heartbeat_at": "2026-06-05T23:42:47Z",
+ "expires_at": "2026-06-06T01:42:47Z",
"work_item": {
"kind": "lane-followup",
"id": "architecture-post-rc-canonicalization"
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 4637cb4e01..5a88672183 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -198,9 +198,11 @@ runtime cost control, and shared AI transport surfaces.
stream progress arrives, must show the current effective model route while
the turn is still streaming, and must render late workflow progress in the
assistant row instead of only in drawer chrome. Workflow status is live
- progress, not answer content; once visible assistant text, tool progress,
- approvals, or questions begin, stale workflow text must clear so the row does
- not keep saying it is waiting on a phase that has already been superseded.
+ progress, not answer content or a delayed walkthrough; each new
+ `workflow_state` replaces the active status immediately instead of waiting
+ behind a dwell queue. Once visible assistant text, tool progress, approvals,
+ or questions begin, stale workflow text must clear so the row does not keep
+ saying it is waiting on a phase that has already been superseded.
OpenCode-parity Assistant UX work must reference OpenCode's actual source
implementation for message parts, tool-state mutation, and progress
rendering before changing Pulse behavior; parity means adapting the proven
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
index dd7588ed82..1034437428 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -897,11 +897,7 @@ describe('useChat', () => {
);
expect(assistant.content).not.toContain('pulse_read');
expect(assistant.content).not.toContain('raw arguments');
- expect(assistant.streamEvents?.map((e) => e.type)).toEqual([
- 'content',
- 'tool',
- 'content',
- ]);
+ expect(assistant.streamEvents?.map((e) => e.type)).toEqual(['content', 'tool', 'content']);
dispose();
});
@@ -974,74 +970,59 @@ describe('useChat', () => {
dispose();
});
- it('paces rapid workflow progress as one replacing live status', async () => {
- vi.useFakeTimers();
+ it('replaces rapid workflow progress immediately as one live status', async () => {
const { getFireEvent } = setupWithEventCapture();
const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));
- try {
- await chat.sendMessage('hi');
- const fire = getFireEvent();
-
- fire({
- type: 'workflow_state',
- data: {
- phase: 'context',
- message: 'Reading current Pulse inventory with pulse_query.',
- tool: 'pulse_query',
- },
- });
- fire({
- type: 'workflow_state',
- data: {
- phase: 'context',
- message: 'Built compact inventory context for the model.',
- tool: 'pulse_query',
- },
- });
- fire({
- type: 'workflow_state',
- data: {
- phase: 'provider_start',
- message: 'Sent request to OpenRouter; waiting for the first token.',
- },
- });
+ await chat.sendMessage('hi');
+ const fire = getFireEvent();
- let assistant = chat.messages().find((m) => m.role === 'assistant')!;
- expect(assistant.streamEvents).toEqual([]);
- expect(assistant.workflowStatus).toEqual(
- expect.objectContaining({
- message: 'Reading current Pulse inventory with pulse_query.',
- }),
- );
+ fire({
+ type: 'workflow_state',
+ data: {
+ phase: 'context',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ tool: 'pulse_query',
+ },
+ });
+ let assistant = chat.messages().find((m) => m.role === 'assistant')!;
+ expect(assistant.streamEvents).toEqual([]);
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ message: 'Reading current Pulse inventory with pulse_query.',
+ }),
+ );
- await vi.advanceTimersByTimeAsync(449);
- assistant = chat.messages().find((m) => m.role === 'assistant')!;
- expect(assistant.workflowStatus).toEqual(
- expect.objectContaining({
- message: 'Reading current Pulse inventory with pulse_query.',
- }),
- );
+ fire({
+ type: 'workflow_state',
+ data: {
+ phase: 'context',
+ message: 'Built compact inventory context for the model.',
+ tool: 'pulse_query',
+ },
+ });
+ assistant = chat.messages().find((m) => m.role === 'assistant')!;
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ message: 'Built compact inventory context for the model.',
+ }),
+ );
- await vi.advanceTimersByTimeAsync(1);
- assistant = chat.messages().find((m) => m.role === 'assistant')!;
- expect(assistant.workflowStatus).toEqual(
- expect.objectContaining({
- message: 'Built compact inventory context for the model.',
- }),
- );
+ fire({
+ type: 'workflow_state',
+ data: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ },
+ });
+ assistant = chat.messages().find((m) => m.role === 'assistant')!;
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ }),
+ );
- await vi.advanceTimersByTimeAsync(450);
- assistant = chat.messages().find((m) => m.role === 'assistant')!;
- expect(assistant.workflowStatus).toEqual(
- expect.objectContaining({
- message: 'Sent request to OpenRouter; waiting for the first token.',
- }),
- );
- } finally {
- dispose();
- vi.useRealTimers();
- }
+ dispose();
});
it('clears workflow progress when visible answer content starts streaming', async () => {
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index 939d7e88bb..6159796dad 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -30,7 +30,6 @@ import type {
const generateId = () => Math.random().toString(36).substring(2, 9);
type AssistantInterruption = NonNullable<ChatMessage['interruption']>;
-const WORKFLOW_STATUS_MIN_DWELL_MS = 450;
const createInitialAssistantWorkflowStatus = (): WorkflowStatus => ({
phase: 'request_start',
@@ -38,11 +37,6 @@ const createInitialAssistantWorkflowStatus = (): WorkflowStatus => ({
startedAt: Date.now(),
});
-interface WorkflowStatusQueue {
- statuses: WorkflowStatus[];
- timer: number | undefined;
-}
-
export interface UseChatOptions {
sessionId?: string;
model?: string;
@@ -98,8 +92,6 @@ export function useChat(options: UseChatOptions = {}) {
let isDrainingQueuedFollowUps = false;
const suppressedRawContentMessageIds = new Set<string>();
const outputArtifactStreamStates = new Map<string, AssistantOutputArtifactStreamState>();
- const workflowStatusQueues = new Map<string, WorkflowStatusQueue>();
- const lastDisplayedWorkflowStatuses = new Map<string, WorkflowStatus>();
const outputArtifactStateFor = (assistantId: string) => {
let state = outputArtifactStreamStates.get(assistantId);
@@ -127,82 +119,21 @@ export function useChat(options: UseChatOptions = {}) {
(a.state || '') === (b.state || '') &&
(a.tool || '') === (b.tool || '');
- const clearWorkflowStatusQueue = (assistantId: string) => {
- const queue = workflowStatusQueues.get(assistantId);
- if (queue?.timer !== undefined) {
- window.clearTimeout(queue.timer);
- }
- workflowStatusQueues.delete(assistantId);
- lastDisplayedWorkflowStatuses.delete(assistantId);
- };
-
- const clearAllWorkflowStatusQueues = () => {
- for (const assistantId of workflowStatusQueues.keys()) {
- clearWorkflowStatusQueue(assistantId);
- }
- lastDisplayedWorkflowStatuses.clear();
- };
-
const setAssistantWorkflowStatus = (
assistantId: string,
requestId: number,
workflowStatus: WorkflowStatus,
) => {
if (requestId !== activeRequestId) return;
- lastDisplayedWorkflowStatuses.set(assistantId, workflowStatus);
setMessages((prev) =>
- prev.map((msg) => (msg.id === assistantId ? { ...msg, workflowStatus } : msg)),
+ prev.map((msg) => {
+ if (msg.id !== assistantId) return msg;
+ if (workflowStatusesMatch(msg.workflowStatus, workflowStatus)) return msg;
+ return { ...msg, workflowStatus };
+ }),
);
};
- const drainWorkflowStatusQueue = (assistantId: string, requestId: number) => {
- const queue = workflowStatusQueues.get(assistantId);
- if (!queue) return;
-
- const nextStatus = queue.statuses.shift();
- if (!nextStatus) {
- queue.timer = undefined;
- return;
- }
-
- setAssistantWorkflowStatus(assistantId, requestId, nextStatus);
- queue.timer = window.setTimeout(() => {
- if (requestId !== activeRequestId) {
- clearWorkflowStatusQueue(assistantId);
- return;
- }
- const currentQueue = workflowStatusQueues.get(assistantId);
- if (!currentQueue) return;
- currentQueue.timer = undefined;
- if (currentQueue.statuses.length > 0) {
- drainWorkflowStatusQueue(assistantId, requestId);
- }
- }, WORKFLOW_STATUS_MIN_DWELL_MS);
- };
-
- const enqueueWorkflowStatus = (
- assistantId: string,
- requestId: number,
- workflowStatus: WorkflowStatus,
- ) => {
- let queue = workflowStatusQueues.get(assistantId);
- if (!queue) {
- queue = { statuses: [], timer: undefined };
- workflowStatusQueues.set(assistantId, queue);
- }
-
- const lastQueuedStatus = queue.statuses[queue.statuses.length - 1];
- const lastDisplayedStatus = lastDisplayedWorkflowStatuses.get(assistantId);
- if (workflowStatusesMatch(lastQueuedStatus || lastDisplayedStatus, workflowStatus)) {
- return;
- }
-
- queue.statuses.push(workflowStatus);
- if (queue.timer === undefined) {
- drainWorkflowStatusQueue(assistantId, requestId);
- }
- };
-
const abortBackendSession = (targetSessionId: string): Promise<void> | null => {
const normalizedSessionId = targetSessionId.trim();
if (!normalizedSessionId) return null;
@@ -231,7 +162,6 @@ export function useChat(options: UseChatOptions = {}) {
abortControllerRef = null;
}
activeRequestId += 1;
- clearAllWorkflowStatusQueues();
setMessages((prev) =>
prev.map((msg) =>
@@ -285,7 +215,6 @@ export function useChat(options: UseChatOptions = {}) {
// Cleanup on unmount
onCleanup(() => {
- clearAllWorkflowStatusQueues();
void cancelActiveRequest();
});
@@ -598,7 +527,7 @@ export function useChat(options: UseChatOptions = {}) {
);
}
if (workflowStatus) {
- enqueueWorkflowStatus(assistantId, requestId, workflowStatus);
+ setAssistantWorkflowStatus(assistantId, requestId, workflowStatus);
}
return;
}
@@ -610,7 +539,6 @@ export function useChat(options: UseChatOptions = {}) {
try {
switch (event.type) {
case 'content': {
- clearWorkflowStatusQueue(assistantId);
if (suppressedRawContentMessageIds.has(assistantId)) {
return msg;
}
@@ -651,7 +579,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'tool_start': {
- clearWorkflowStatusQueue(assistantId);
clearSuppressedOutputBoundary(assistantId);
const data = (event.data || {}) as {
id?: string;
@@ -690,7 +617,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'tool_end': {
- clearWorkflowStatusQueue(assistantId);
clearSuppressedOutputBoundary(assistantId);
const data = event.data as {
id?: string;
@@ -795,7 +721,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'approval_needed': {
- clearWorkflowStatusQueue(assistantId);
clearSuppressedOutputBoundary(assistantId);
const data = event.data as {
command: string;
@@ -878,7 +803,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'question': {
- clearWorkflowStatusQueue(assistantId);
clearSuppressedOutputBoundary(assistantId);
const data = event.data as { question_id: string; questions: Array<any> };
@@ -915,7 +839,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'done': {
- clearWorkflowStatusQueue(assistantId);
const pendingText = suppressedRawContentMessageIds.has(assistantId)
? ''
: flushPendingAssistantOutputText(outputArtifactStateFor(assistantId));
@@ -949,7 +872,6 @@ export function useChat(options: UseChatOptions = {}) {
}
case 'error': {
- clearWorkflowStatusQueue(assistantId);
clearSuppressedOutputBoundary(assistantId);
const errorMsg = extractErrorMessage(event.data);
// Keep any content streamed before the failure; surface the error
@@ -1053,7 +975,6 @@ export function useChat(options: UseChatOptions = {}) {
streamEvents: [],
workflowStatus: initialWorkflowStatus,
};
- lastDisplayedWorkflowStatuses.set(assistantId, initialWorkflowStatus);
if (options?.queuedMessageId) {
setMessages((prev) => [
@@ -1178,7 +1099,6 @@ export function useChat(options: UseChatOptions = {}) {
// Clear messages and reset session (for starting fresh)
const clearMessages = () => {
void cancelActiveRequest();
- clearAllWorkflowStatusQueues();
setQueuedFollowUps([]);
setMessages([]);
setSessionId(''); // Clear session so next message creates a new one
@@ -1187,7 +1107,6 @@ export function useChat(options: UseChatOptions = {}) {
// Load session messages
const loadSession = async (id: string): Promise<boolean> => {
void cancelActiveRequest();
- clearAllWorkflowStatusQueues();
setQueuedFollowUps([]);
try {
const msgs = await AIChatAPI.getMessages(id);
@@ -1222,7 +1141,6 @@ export function useChat(options: UseChatOptions = {}) {
// next chat stream so the UI does not create empty server-side sessions.
const newSession = async (): Promise<boolean> => {
void cancelActiveRequest();
- clearAllWorkflowStatusQueues();
setQueuedFollowUps([]);
setSessionId('');
setMessages([]);