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.

Show Assistant provider retries immediately

rcourtmana06d7686b68d
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 2d79f47224..e7ad1fbd36 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -2257,12 +2257,13 @@ hidden server log. The referenced OpenCode source at fetched `dev` commit
`packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx`. Pulse adapts
that 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 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.
+ `provider_retry` before sleeping between transient pre-output provider
+ attempts. The frontend active-turn footer and live transcript workflow row
+ render that same typed workflow state immediately 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. Retry workflow states are not
+ held behind workflow-history pacing.
Assistant workflow progress is also a live typed activity row while a turn is
in flight, not only hidden footer state. The referenced OpenCode source at
@@ -2280,12 +2281,14 @@ same typed status, and visible assistant content, reasoning, tool,
approval/question, terminal `done`, and terminal `error` events clear that row.
The frontend now also keeps a bounded live-only `workflowStatusHistory` for the
active assistant message so the reducer preserves state continuity while
-backend preparation, context, provider-start, retry, and fallback labels are
-being replaced. The shared workflow-status presentation helper owns both the
-transcript row and the active-turn composer footer so the two live surfaces show
-the latest canonical workflow state immediately. The transcript and footer
-therefore show current motion while the provider is starting, retrying, or
-reasoning, but completed answers do not retain stale internal-progress prose.
+ backend preparation, context, and provider-start labels are being replaced. The
+ shared workflow-status presentation helper owns both the transcript row and the
+ active-turn composer footer so the two live surfaces show the latest canonical
+ workflow state immediately. Retry/backoff and stream-idle liveness states cut
+ through pacing because they are current route health, not neutral setup motion.
+ The transcript and footer therefore show current motion while the provider is
+ starting, retrying, or reasoning, but completed answers do not retain stale
+ internal-progress prose.
Stream-idle heartbeats are part of that same visible workflow state. When the
frontend knows the selected provider/model route from the backend workflow event
or the streaming assistant message, the idle heartbeat must render as
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index 6c82525105..a269542e32 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -865,6 +865,60 @@ describe('MessageItem', () => {
).not.toBeInTheDocument();
});
+ it('lets provider retry workflow activity cut through live transcript pacing', () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(1_200);
+
+ const workflowStatusHistory = [
+ {
+ phase: 'request_start',
+ message: 'Preparing Pulse context.',
+ startedAt: 1_000,
+ },
+ {
+ phase: 'provider_start',
+ message: 'OpenRouter is starting the response.',
+ startedAt: 1_100,
+ },
+ {
+ phase: 'provider_retry',
+ message: 'Provider connection failed before any output; retrying.',
+ attempt: 2,
+ maxAttempts: 3,
+ retryAfterMs: 3200,
+ startedAt: 1_200,
+ },
+ ];
+
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content: '',
+ isStreaming: true,
+ pendingTools: [],
+ workflowStatusHistory,
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: workflowStatusHistory[2],
+ },
+ ],
+ workflowStatus: workflowStatusHistory[2],
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(
+ screen.getByText(
+ 'Provider connection failed before any output; retrying. · attempt 2/3 · retrying in 3.2s',
+ ),
+ ).toBeInTheDocument();
+ expect(screen.queryByText('Preparing Pulse context.')).not.toBeInTheDocument();
+ expect(screen.queryByText('OpenRouter is starting the response.')).not.toBeInTheDocument();
+ });
+
it('keeps separated transcript workflow rows tied to their own streamed status', () => {
vi.useFakeTimers();
vi.setSystemTime(2_000);
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
index e7c8b5f78b..fccf56aa21 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -296,6 +296,101 @@ describe('getAssistantActiveTurnStatus', () => {
});
});
+ it('lets provider retry workflow progress cut through active turn pacing', () => {
+ const workflowStatusHistory = [
+ {
+ phase: 'request_start',
+ message: 'Preparing Pulse context.',
+ startedAt: 1_000,
+ },
+ {
+ phase: 'provider_start',
+ message: 'OpenRouter is starting the response.',
+ startedAt: 1_100,
+ },
+ {
+ phase: 'provider_retry',
+ message: 'Provider connection failed before any output; retrying.',
+ attempt: 2,
+ maxAttempts: 3,
+ retryAfterMs: 3200,
+ startedAt: 1_200,
+ },
+ ];
+
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: true,
+ workflowStatusHistory,
+ workflowStatus: workflowStatusHistory[2],
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: workflowStatusHistory[2],
+ startedAt: 1_200,
+ updatedAt: 1_200,
+ },
+ ],
+ }),
+ ],
+ true,
+ 1_200,
+ ),
+ ).toEqual({
+ type: 'thinking',
+ text: 'Provider connection failed before any output; retrying. · attempt 2/3 · retrying in 3.2s',
+ startedAt: 1_200,
+ });
+ });
+
+ it('lets stream idle liveness cut through active turn pacing', () => {
+ const workflowStatusHistory = [
+ {
+ phase: 'request_start',
+ message: 'Preparing Pulse context.',
+ startedAt: 1_000,
+ },
+ {
+ phase: 'provider_start',
+ message: 'OpenRouter is starting the response.',
+ startedAt: 1_100,
+ },
+ {
+ phase: 'stream_idle',
+ message: 'OpenRouter is still working; waiting for more response data.',
+ startedAt: 1_200,
+ },
+ ];
+
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: true,
+ workflowStatusHistory,
+ workflowStatus: workflowStatusHistory[2],
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: workflowStatusHistory[2],
+ startedAt: 1_200,
+ updatedAt: 1_200,
+ },
+ ],
+ }),
+ ],
+ true,
+ 1_200,
+ ),
+ ).toEqual({
+ type: 'thinking',
+ text: 'OpenRouter is still working; waiting for more response data.',
+ startedAt: 1_200,
+ });
+ });
+
it('prefers workflow progress over selected model route evidence', () => {
const startedAt = Date.now() - 1_000;
expect(
diff --git a/frontend-modern/src/components/AI/Chat/workflowStatusPacing.ts b/frontend-modern/src/components/AI/Chat/workflowStatusPacing.ts
index 28fbc42ff5..41c8b31503 100644
--- a/frontend-modern/src/components/AI/Chat/workflowStatusPacing.ts
+++ b/frontend-modern/src/components/AI/Chat/workflowStatusPacing.ts
@@ -22,6 +22,16 @@ const workflowStatusesMatch = (a?: WorkflowStatus, b?: WorkflowStatus) =>
const isDurableStreamBoundary = (event: StreamDisplayEvent) =>
event.type !== 'workflow_status' && event.type !== 'model_switch';
+const immediateWorkflowStatusPhases = new Set(['provider_retry', 'stream_idle']);
+
+const isImmediateWorkflowStatus = (status?: WorkflowStatus) => {
+ const phase = status?.phase?.trim().toLowerCase();
+ return (
+ (phase ? immediateWorkflowStatusPhases.has(phase) : false) ||
+ Boolean(status?.attempt || status?.retryAfterMs)
+ );
+};
+
const latestWorkflowEventIndex = (
events: StreamDisplayEvent[] | undefined,
currentStatus: WorkflowStatus | undefined,
@@ -79,6 +89,8 @@ export const pacedWorkflowStatusForDisplay = (
events: StreamDisplayEvent[] | undefined,
now?: number,
): WorkflowStatus | undefined => {
+ if (isImmediateWorkflowStatus(currentStatus)) return currentStatus;
+
const workflowIndex = latestWorkflowEventIndex(events, currentStatus);
if (workflowIndex >= 0 && hasEarlierDurableBoundary(events, workflowIndex)) {
return currentStatus;