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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Show live Assistant retry countdowns
rcourtmanab2e2bc69cdc
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 903dcb6d28..e9352422d6 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -358,7 +358,11 @@ runtime cost control, and shared AI transport surfaces.`packages/ui/src/components/session-retry.tsx`; Pulse adapts that principleby surfacing route changes through workflow/model rows and by yielding tothe next configured route quickly instead of hiding repeated startup- retries behind a static waiting label.+ retries behind a static waiting label. Provider retry workflow states that+ include `retry_after_ms` must render as live countdowns derived from the+ workflow `started_at` timestamp while the turn is active, matching+ OpenCode's visible retry wait behavior instead of freezing the first retry+ label.Assistant completion events must carry the effective model route that actuallycompleted the turn, and the drawer must update the in-flight transcript rowwhen `provider_fallback` names the next route so message labels, cost@@ -504,7 +508,10 @@ runtime cost control, and shared AI transport surfaces.same typed `StreamEvent` objects (`session`, `workflow_state`, `thinking`,`tool_start`, `tool_progress`, `tool_cancel`, `tool_end`, `content`,`done`) through the normal `useChat` reducer rather than rendering a- separate mock transcript.+ separate mock transcript. The local `provider-retry` fixture must exercise+ the real `provider_retry` workflow state, including attempt metadata and+ `retry_after_ms`, so browser proof of retry countdown behavior does not+ depend on external provider availability or API spend.This fixture is a local development primitive, not a product mode: it mustnot bypass backend governance in production, persist as a server session, orintroduce any UI-only event shape that real providers cannot emit.@@ -1890,9 +1897,11 @@ hidden server log. The referenced OpenCode source at fetched `dev` committhat contract at the owning stream boundary: `WorkflowStateData` carries`attempt`, `max_attempts`, and `retry_after_ms`, and `AgenticLoop` emits`provider_retry` before sleeping between transient pre-output provider-attempts. The frontend active-turn footer renders that same typed workflow state-as compact attempt/backoff progress, so the user sees Pulse moving through a-retry instead of staring at an obsolete provider-wait message.+attempts. The frontend active-turn footer and live transcript workflow row+render that same typed workflow state as compact attempt/backoff progress,+counting down `retry_after_ms` from `started_at` while the turn remains active,+so the user sees Pulse moving through a retry instead of staring at an obsolete+provider-wait message.Assistant workflow progress is also a live typed activity row while a turn isin flight, not only hidden footer state. The referenced OpenCode source atdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 192c6b7f76..8015650173 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -571,7 +571,11 @@ payload shape change when the portal presents compact client rows.sequence must exercise a buffered `tool_start` -> `tool_end` burst with noprovider delay between the two events, followed by a paced content/terminalstep, so browser proof can verify that fast command activity remains- perceptible without a real provider request.+ perceptible without a real provider request. At least one fixture-backed+ Assistant sequence must exercise `provider_retry` with `attempt`,+ `max_attempts`, and `retry_after_ms` metadata plus a paced retry window, so+ browser proof can verify visible retry countdown behavior without a real+ provider request, VPN dependency, or API spend.34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.Legacy Assistant SSE routes in this handler that still use the olderexecute envelope, including `/api/ai/execute/stream` anddiff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex 91bff1d1ce..6ee16301e6 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -241,6 +241,49 @@ describe('AIChatAPI', () => {});});+ it('runs the provider-retry dev stream fixture without opening a provider request', async () => {+ const onEvent = vi.fn();++ await AIChatAPI.chat('/fixture provider-retry', undefined, 'deepseek:deepseek-chat', onEvent);++ expect(apiFetchMock).not.toHaveBeenCalled();+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([+ 'session',+ 'workflow_state',+ 'workflow_state',+ 'workflow_state',+ 'workflow_state',+ 'content',+ 'done',+ ]);+ expect(onEvent.mock.calls[3][0]).toMatchObject({+ type: 'workflow_state',+ data: {+ phase: 'provider_retry',+ message: 'DeepSeek failed before output; retrying through OpenRouter.',+ attempt: 2,+ max_attempts: 3,+ retry_after_ms: 3200,+ },+ });+ expect(onEvent.mock.calls[4][0]).toMatchObject({+ type: 'workflow_state',+ data: {+ phase: 'provider_start',+ message: 'Retrying through OpenRouter with deepseek/deepseek-chat.',+ provider: 'openrouter',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ });+ expect(onEvent.mock.calls[6][0]).toMatchObject({+ type: 'done',+ data: {+ session_id: 'dev-fixture-provider-retry',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ });+ });+it('runs the compacted-artifact dev stream fixture without opening a provider request', async () => {const onEvent = vi.fn();diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.tsindex eb6d226a48..ab9d3c2546 100644--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts@@ -4,6 +4,7 @@ export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = ['/fixture devices','/fixture assistant-stream','/fixture tool-burst',+ '/fixture provider-retry','/fixture compacted-artifact','/fixture skipped-tool',] as const;@@ -161,10 +162,8 @@ const buildSkippedToolFixtureEvents = (model?: string): AIChatStreamEvent[] => [data: {id: 'fixture-tool-skipped',name: 'pulse_read',- input:- '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',- raw_input:- 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ raw_input: 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',},},{@@ -217,10 +216,8 @@ const buildToolBurstFixtureEvents = (model?: string): AIChatStreamEvent[] => [data: {id: 'fixture-tool-burst',name: 'pulse_read',- input:- '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',- raw_input:- 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ raw_input: 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',},},{@@ -228,10 +225,8 @@ const buildToolBurstFixtureEvents = (model?: string): AIChatStreamEvent[] => [data: {id: 'fixture-tool-burst',name: 'pulse_read',- input:- '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',- raw_input:- 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ raw_input: 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',output: '4358',success: true,},@@ -253,6 +248,65 @@ const buildToolBurstFixtureEvents = (model?: string): AIChatStreamEvent[] => [},];+const buildProviderRetryFixtureEvents = (): AIChatStreamEvent[] => [+ {+ type: 'session',+ data: { id: 'dev-fixture-provider-retry' },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'request_start',+ message: 'Preparing Pulse context.',+ },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'provider_start',+ message: 'Sent request to DeepSeek; waiting for the first token.',+ provider: 'deepseek',+ model: 'deepseek:deepseek-chat',+ },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'provider_retry',+ message: 'DeepSeek failed before output; retrying through OpenRouter.',+ provider: 'deepseek',+ model: 'deepseek:deepseek-chat',+ attempt: 2,+ max_attempts: 3,+ retry_after_ms: 3200,+ },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'provider_start',+ message: 'Retrying through OpenRouter with deepseek/deepseek-chat.',+ provider: 'openrouter',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ },+ {+ type: 'content',+ data: {+ text: 'The provider retry fixture switched to OpenRouter after the direct provider failed before output.',+ },+ },+ {+ type: 'done',+ data: {+ session_id: 'dev-fixture-provider-retry',+ model: 'openrouter:deepseek/deepseek-chat',+ input_tokens: 73,+ output_tokens: 29,+ },+ },+];+const buildCompactedArtifactFixtureEvents = (model?: string): AIChatStreamEvent[] => [{type: 'session',@@ -323,6 +377,9 @@ const buildFixtureEvents = (prompt: string, model?: string): AIChatStreamEvent[]if (normalized === '/fixture tool-burst') {return buildToolBurstFixtureEvents(model);}+ if (normalized === '/fixture provider-retry') {+ return buildProviderRetryFixtureEvents();+ }return buildDeviceCountFixtureEvents(model);};@@ -331,6 +388,14 @@ const fixtureStepDelay = (event: AIChatStreamEvent,defaultDelayMs: number,): number => {+ if (defaultDelayMs <= 0) return 0;+ if (+ normalizedPrompt === '/fixture provider-retry' &&+ event.type === 'workflow_state' &&+ event.data.phase === 'provider_retry'+ ) {+ return 1600;+ }if (normalizedPrompt !== '/fixture tool-burst') return defaultDelayMs;if (event.type === 'tool_start') return 0;return defaultDelayMs;diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsxindex 1c3a9125fe..79ea497ae4 100644--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx@@ -378,7 +378,10 @@ export const MessageItem: Component<MessageItemProps> = (props) => {onCleanup(() => window.clearInterval(interval));});const formatWorkflowStatus = (status?: WorkflowStatus, includeElapsed = false) => {- const message = formatAssistantWorkflowStatus(status);+ const message = formatAssistantWorkflowStatus(+ status,+ props.message.isStreaming ? statusNow() : undefined,+ );if (!message) return '';let elapsedSuffix = '';if (includeElapsed && status?.startedAt) {@@ -587,8 +590,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {<Matchwhen={- evt.type === 'workflow_status' &&- shouldRenderWorkflowStatusEvent(evt)+ evt.type === 'workflow_status' && shouldRenderWorkflowStatusEvent(evt)}><divdiff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex 52dca28629..add231aa76 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -467,7 +467,10 @@ beforeEach(() => {localStorage.clear();});-afterEach(cleanup);+afterEach(() => {+ cleanup();+ vi.useRealTimers();+});// ── Tests ──────────────────────────────────────────────────────────────────@@ -4607,6 +4610,35 @@ describe('AIChat', () => {expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();});+ it('shows live provider retry countdowns in the active turn status', () => {+ vi.useFakeTimers();+ vi.setSystemTime(2_300);+ mockChat.isLoading.mockReturnValue(true);+ mockChat.messages.mockReturnValue([+ {+ id: 'msg-1',+ role: 'assistant' as const,+ content: '',+ timestamp: new Date(1_000),+ isStreaming: true,+ streamEvents: [],+ workflowStatus: {+ phase: 'provider_retry',+ message: 'Provider connection failed before any output; retrying.',+ attempt: 2,+ maxAttempts: 3,+ retryAfterMs: 3200,+ startedAt: 1_000,+ },+ },+ ]);+ renderChat();++ expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(+ 'Provider connection failed before any output; retrying. · attempt 2/3 · retrying in 1.9s',+ );+ });+it('prefers the selected model route over placeholder request-start progress', () => {const startedAt = Date.now() - 1_000;mockChat.isLoading.mockReturnValue(true);diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsxindex 7b79606386..c65bc41727 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx@@ -29,9 +29,7 @@ vi.mock('../ToolExecutionBlock', () => ({{props.tool.input}</div>),- ToolCancellationBlock: (props: {- tool: { name: string; input: string; reason?: string };- }) => (+ ToolCancellationBlock: (props: { tool: { name: string; input: string; reason?: string } }) => (<div role="status" aria-label="Assistant tool canceled"><span>{props.tool.name.replace(/^pulse_/, '')}</span><span>skipped</span>@@ -647,6 +645,50 @@ describe('MessageItem', () => {expect(screen.queryByText('Thinking...')).not.toBeInTheDocument();});+ it('counts down provider retry workflow rows while the turn is live', () => {+ vi.useFakeTimers();+ vi.setSystemTime(2_300);++ render(() => (+ <MessageItem+ message={makeMessage({+ role: 'assistant',+ content: '',+ isStreaming: true,+ pendingTools: [],+ streamEvents: [+ {+ type: 'workflow_status',+ workflowStatus: {+ phase: 'provider_retry',+ message: 'Provider connection failed before any output; retrying.',+ attempt: 2,+ maxAttempts: 3,+ retryAfterMs: 3200,+ startedAt: 1_000,+ },+ },+ ],+ workflowStatus: {+ phase: 'provider_retry',+ message: 'Provider connection failed before any output; retrying.',+ attempt: 2,+ maxAttempts: 3,+ retryAfterMs: 3200,+ startedAt: 1_000,+ },+ })}+ {...makeHandlers()}+ />+ ));++ expect(+ screen.getByText(+ /Provider connection failed before any output; retrying\. · attempt 2\/3 · retrying in 1\.9s/,+ ),+ ).toBeInTheDocument();+ });+it('shows the latest burst workflow activity through one live transcript row', () => {const workflowStatusHistory = [{@@ -992,8 +1034,7 @@ describe('MessageItem', () => {toolCancel: {id: 'tool-1',name: 'pulse_read',- input:- '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',reason: 'current_resource unavailable',},},diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.tsindex 4e2810b0d4..c0fd0b3d73 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts@@ -183,6 +183,58 @@ describe('getAssistantActiveTurnStatus', () => {});});+ it('counts provider retry delay down from workflow start time', () => {+ const startedAt = 1_000;+ expect(+ getAssistantActiveTurnStatus(+ [+ assistantMessage({+ workflowStatus: {+ phase: 'provider_retry',+ message: 'Provider connection failed before any output; retrying.',+ attempt: 2,+ maxAttempts: 2,+ retryAfterMs: 3200,+ startedAt,+ },+ }),+ ],+ true,+ 2_300,+ ),+ ).toEqual({+ type: 'thinking',+ text: 'Provider connection failed before any output; retrying. · attempt 2/2 · retrying in 1.9s',+ startedAt,+ });+ });++ it('keeps provider retry status explicit when the retry delay has elapsed', () => {+ const startedAt = 1_000;+ expect(+ getAssistantActiveTurnStatus(+ [+ assistantMessage({+ workflowStatus: {+ phase: 'provider_retry',+ message: 'Provider connection failed before any output; retrying.',+ attempt: 2,+ maxAttempts: 2,+ retryAfterMs: 3200,+ startedAt,+ },+ }),+ ],+ true,+ 4_500,+ ),+ ).toEqual({+ type: 'thinking',+ text: 'Provider connection failed before any output; retrying. · attempt 2/2 · retrying now',+ startedAt,+ });+ });+it('prefers live tool progress over generic tool labels', () => {expect(getAssistantActiveTurnStatus(diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.tsindex 8329e973a9..241c14884b 100644--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts@@ -43,7 +43,16 @@ const formatRetryDelay = (milliseconds?: number): string => {return `${Math.round(minutes)}m`;};-const formatRetryStatusSuffix = (status?: WorkflowStatus): string => {+const remainingRetryDelay = (status?: WorkflowStatus, now?: number): number | undefined => {+ const retryAfterMs = status?.retryAfterMs;+ if (!Number.isFinite(retryAfterMs) || !retryAfterMs || retryAfterMs <= 0) return undefined;+ const startedAt = status?.startedAt;+ if (typeof now !== 'number' || !Number.isFinite(now)) return retryAfterMs;+ if (typeof startedAt !== 'number' || !Number.isFinite(startedAt)) return retryAfterMs;+ return Math.max(0, retryAfterMs - Math.max(0, now - startedAt));+};++const formatRetryStatusSuffix = (status?: WorkflowStatus, now?: number): string => {const parts: string[] = [];if (status?.attempt && status.maxAttempts) {parts.push(`attempt ${status.attempt}/${status.maxAttempts}`);@@ -51,15 +60,16 @@ const formatRetryStatusSuffix = (status?: WorkflowStatus): string => {parts.push(`attempt ${status.attempt}`);}- const retryDelay = formatRetryDelay(status?.retryAfterMs);- if (retryDelay) {- parts.push(`retrying in ${retryDelay}`);+ const retryDelayMs = remainingRetryDelay(status, now);+ if (retryDelayMs !== undefined) {+ const retryDelay = formatRetryDelay(retryDelayMs);+ parts.push(retryDelay ? `retrying in ${retryDelay}` : 'retrying now');}return parts.length > 0 ? ` · ${parts.join(' · ')}` : '';};-export const formatAssistantWorkflowStatus = (status?: WorkflowStatus): string => {+export const formatAssistantWorkflowStatus = (status?: WorkflowStatus, now?: number): string => {const message = status?.message?.trim();if (!message) return '';@@ -69,7 +79,7 @@ export const formatAssistantWorkflowStatus = (status?: WorkflowStatus): string =toolLabel && !message.includes(tool || '') && !messageContainsToolLabel(message, toolLabel)? ` · ${toolLabel}`: '';- const retrySuffix = formatRetryStatusSuffix(status);+ const retrySuffix = formatRetryStatusSuffix(status, now);return `${message}${toolSuffix}${retrySuffix}`;};@@ -214,6 +224,7 @@ const toolCancelStatusText = (event: StreamDisplayEvent): string => {const latestStreamActivityStatus = (events?: StreamDisplayEvent[],+ now?: number,): AssistantActiveTurnStatusCandidate | null => {const completedToolKeys = new Set<string>();let current: AssistantActiveTurnStatusCandidate | null = null;@@ -264,7 +275,7 @@ const latestStreamActivityStatus = (break;}case 'workflow_status': {- const text = formatAssistantWorkflowStatus(event.workflowStatus);+ const text = formatAssistantWorkflowStatus(event.workflowStatus, now);if (text) {candidate = {type: event.workflowStatus?.tool ? 'tool' : 'thinking',@@ -338,8 +349,9 @@ const latestStreamActivityStatus = (const workflowStatusCandidate = (status: WorkflowStatus | undefined,+ now?: number,): AssistantActiveTurnStatusCandidate | null => {- const text = formatAssistantWorkflowStatus(status);+ const text = formatAssistantWorkflowStatus(status, now);if (!text) return null;return {type: status?.tool ? 'tool' : 'thinking',@@ -379,6 +391,7 @@ const hasVisibleAssistantOutput = (message: ChatMessage): boolean => {export const getAssistantActiveTurnStatus = (messages: ChatMessage[],isLoading: boolean,+ now?: number,): AssistantActiveTurnStatus | null => {if (!isLoading) return null;@@ -394,7 +407,7 @@ export const getAssistantActiveTurnStatus = (if (statePendingToolCandidate) {statusCandidates.push(statePendingToolCandidate);}- const eventStatusCandidate = latestStreamActivityStatus(assistantMessage.streamEvents);+ const eventStatusCandidate = latestStreamActivityStatus(assistantMessage.streamEvents, now);if (eventStatusCandidate) {statusCandidates.push(eventStatusCandidate);} else {@@ -405,7 +418,7 @@ export const getAssistantActiveTurnStatus = (}}if (assistantMessage.isStreaming !== false) {- const workflowCandidate = workflowStatusCandidate(assistantMessage.workflowStatus);+ const workflowCandidate = workflowStatusCandidate(assistantMessage.workflowStatus, now);if (workflowCandidate &&!(isInitialRequestStartStatus(assistantMessage.workflowStatus) && eventStatusCandidate)diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex a913dcca9e..876563924e 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -859,14 +859,14 @@ export const AIChat: Component<AIChatProps> = (props) => {const textBeforeCursor = text.slice(0, cursor);const textAfterCursor = text.slice(cursor);return (- textBeforeCursor.startsWith('/') &&- !/\s/.test(textBeforeCursor) &&- !textAfterCursor.trim()+ textBeforeCursor.startsWith('/') && !/\s/.test(textBeforeCursor) && !textAfterCursor.trim());};const closeSlashCommandAutocomplete = (options?: { clearTransientDraft?: boolean }) => {- const shouldClearDraft = Boolean(options?.clearTransientDraft && isTransientSlashCommandDraft());+ const shouldClearDraft = Boolean(+ options?.clearTransientDraft && isTransientSlashCommandDraft(),+ );setSlashCommandActive(false);setSlashCommandQuery('');if (!shouldClearDraft) return;@@ -2232,7 +2232,9 @@ export const AIChat: Component<AIChatProps> = (props) => {onCleanup(() => window.clearInterval(interval));});const currentStatusText = createMemo(() => {- const status = currentStatus();+ const status =+ getAssistantActiveTurnStatus(chat.messages(), chat.isLoading(), currentStatusNow()) ||+ currentStatus();if (!status) return '';if (!status.startedAt) return status.text;const elapsedSeconds = Math.max(0, Math.floor((currentStatusNow() - status.startedAt) / 1000));