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.

Pace Assistant workflow status in active footer

rcourtman40063925bd3e
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8dea0c2fde..08aa04edac 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -320,7 +320,11 @@ runtime cost control, and shared AI transport surfaces.
`workflow_state` replaces the canonical active status immediately. The
browser may retain a bounded in-flight presentation history of those replaced
labels and pace one visible workflow row through them when backend/network
- coalescing would otherwise make the row jump straight to the last state.
+ coalescing would otherwise make the row jump straight to the last state. The
+ active-turn composer footer must use that same paced workflow-label
+ presentation when its current status is workflow-derived, so the footer does
+ not jump straight to the last coalesced preparation/provider state while the
+ transcript row is still stepping through the same live sequence.
That history must stay live-only: once visible assistant text, tool progress,
approvals, questions, terminal `done`, terminal `error`, or explicit Stop
take over, stale workflow text and the presentation history must clear so
@@ -329,7 +333,7 @@ runtime cost control, and shared AI transport surfaces.
start timestamp so the drawer can show elapsed wait/run time for long
provider starts and tool calls instead of repeating a timeless waiting label.
The referenced OpenCode source at fetched `origin/dev` commit
- `4519a1da329c1a4fc384054e7203ba7d06928205` mutates typed message parts as
+ `0875203a6c726d7a37b5ffbb770cc433c98e7cd6` mutates typed message parts as
events arrive in `packages/opencode/src/cli/cmd/tui/context/sync.tsx`
(`message.part.updated` and `message.part.delta`) and represents session
activity as separately updated status in
@@ -1707,9 +1711,12 @@ 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 one row can visibly step through bursty preparation,
context, provider-start, retry, and fallback labels instead of showing them all
-only after the final state arrives. The transcript therefore shows current
-motion while the provider is starting, retrying, or reasoning, but completed
-answers do not retain stale internal-progress prose.
+only after the final state arrives. The shared workflow-status presentation
+helper owns both the transcript row and the active-turn composer footer so the
+two live surfaces advance through the same short sequence before settling on the
+latest canonical workflow state. 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.
Primary nav moved to governed platform/runtime destinations on 2026-05-16 and
was clarified on 2026-05-25 through `frontend-modern/src/App.tsx` and
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 0e2e3900fa..c6e85d9956 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -27,6 +27,10 @@ import { getAssistantAnswerText } from './assistantAnswerText';
import { stripAssistantOutputArtifacts } from './assistantOutputHygiene';
import { formatAssistantWorkflowStatus } from './activeTurnStatus';
import { groupStreamEventsForDisplay } from './streamEventGrouping';
+import {
+ createPacedWorkflowStatus,
+ normalizeWorkflowStatusSequence,
+} from './workflowStatusPresentation';
import type {
ChatMessage,
ModelRouteRecoveryOption,
@@ -85,7 +89,6 @@ const markdownClass =
const TEXT_RENDER_PACE_MS = 24;
const TEXT_RENDER_SNAP = /[\s.,!?;:)\]]/;
-const WORKFLOW_STATUS_RENDER_PACE_MS = 420;
const textRenderStep = (size: number) => {
if (size <= 12) return 2;
@@ -129,127 +132,6 @@ const schedulePacedTextCleanup = (key: string) => {
);
};
-const workflowStatusRenderKey = (status?: WorkflowStatus) =>
- status
- ? [
- status?.phase || '',
- status?.message || '',
- status?.state || '',
- status?.tool || '',
- status?.attempt || 0,
- status?.maxAttempts || 0,
- status?.retryAfterMs || 0,
- status?.startedAt || 0,
- ].join('\u001f')
- : '';
-
-const normalizeWorkflowStatusSequence = (statuses: Array<WorkflowStatus | undefined>) => {
- const sequence: WorkflowStatus[] = [];
- for (const status of statuses) {
- if (!status || !formatAssistantWorkflowStatus(status)) continue;
- const previous = sequence[sequence.length - 1];
- if (workflowStatusRenderKey(previous) === workflowStatusRenderKey(status)) continue;
- sequence.push(status);
- }
- return sequence;
-};
-
-interface PacedWorkflowStatusClock {
- firstKey: string;
- startedAt: number;
-}
-
-const pacedWorkflowStatusCache = new Map<string, PacedWorkflowStatusClock>();
-const pacedWorkflowStatusCleanupTimers = new Map<string, ReturnType<typeof setTimeout>>();
-
-const cancelPacedWorkflowStatusCleanup = (key: string) => {
- const timer = pacedWorkflowStatusCleanupTimers.get(key);
- if (!timer) return;
- clearTimeout(timer);
- pacedWorkflowStatusCleanupTimers.delete(key);
-};
-
-const deletePacedWorkflowStatusCache = (key: string) => {
- cancelPacedWorkflowStatusCleanup(key);
- pacedWorkflowStatusCache.delete(key);
-};
-
-const schedulePacedWorkflowStatusCleanup = (key: string) => {
- cancelPacedWorkflowStatusCleanup(key);
- pacedWorkflowStatusCleanupTimers.set(
- key,
- setTimeout(() => {
- pacedWorkflowStatusCleanupTimers.delete(key);
- pacedWorkflowStatusCache.delete(key);
- }, 1000),
- );
-};
-
-const createPacedWorkflowStatus = (
- getStatuses: () => WorkflowStatus[],
- live: () => boolean,
- cacheKey: () => string,
-) => {
- const [now, setNow] = createSignal(Date.now());
- let interval: ReturnType<typeof setInterval> | undefined;
-
- createEffect(() => {
- const statuses = getStatuses();
- if (!live()) {
- if (interval) {
- clearInterval(interval);
- interval = undefined;
- }
- const key = cacheKey();
- if (key) deletePacedWorkflowStatusCache(key);
- return;
- }
-
- const key = cacheKey();
- if (key) {
- cancelPacedWorkflowStatusCleanup(key);
- }
-
- if (statuses.length > 1 && !interval) {
- interval = setInterval(() => setNow(Date.now()), WORKFLOW_STATUS_RENDER_PACE_MS);
- } else if (statuses.length <= 1 && interval) {
- clearInterval(interval);
- interval = undefined;
- }
- });
-
- onCleanup(() => {
- if (interval) {
- clearInterval(interval);
- }
- const key = cacheKey();
- if (key) schedulePacedWorkflowStatusCleanup(key);
- });
-
- return createMemo(() => {
- const statuses = getStatuses();
- if (statuses.length === 0) return undefined;
- if (!live()) return statuses[statuses.length - 1];
- if (statuses.length === 1) return statuses[0];
-
- const key = cacheKey();
- const firstKey = workflowStatusRenderKey(statuses[0]);
- if (!key || !firstKey) return statuses[0];
-
- const cached = pacedWorkflowStatusCache.get(key);
- const startedAt = cached?.firstKey === firstKey ? cached.startedAt : now();
- if (!cached || cached.firstKey !== firstKey) {
- pacedWorkflowStatusCache.set(key, { firstKey, startedAt });
- }
-
- const index = Math.min(
- statuses.length - 1,
- Math.floor(Math.max(0, now() - startedAt) / WORKFLOW_STATUS_RENDER_PACE_MS),
- );
- return statuses[index] || statuses[statuses.length - 1];
- });
-};
-
const createPacedText = (getText: () => string, live: () => boolean, cacheKey: () => string) => {
const initialText = getText();
const initialKey = cacheKey();
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 85af8b2830..baee1dc5da 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-li
import { Show, createSignal } from 'solid-js';
import type { ChatMessage, ModelInfo, ModelRouteRecoveryOption } from '../types';
import type { QueuedFollowUp } from '../hooks/useChat';
+import { WORKFLOW_STATUS_RENDER_PACE_MS } from '../workflowStatusPresentation';
// ── Hoisted mocks (vi.mock factories reference these) ──────────────────────
@@ -3929,9 +3930,7 @@ describe('AIChat', () => {
},
]);
- expect(mockChat.setModel).not.toHaveBeenCalledWith(
- 'openrouter:deepseek/deepseek-v4-pro',
- );
+ expect(mockChat.setModel).not.toHaveBeenCalledWith('openrouter:deepseek/deepseek-v4-pro');
setMessages([
{
@@ -3957,9 +3956,7 @@ describe('AIChat', () => {
]);
await waitFor(() => {
- expect(mockChat.setModel).toHaveBeenCalledWith(
- 'openrouter:deepseek/deepseek-v4-pro',
- );
+ expect(mockChat.setModel).toHaveBeenCalledWith('openrouter:deepseek/deepseek-v4-pro');
});
expect(localStorage.getItem('pulse:ai_chat_models_by_session')).toBe(
JSON.stringify({ 'session-1': 'openrouter:deepseek/deepseek-v4-pro' }),
@@ -4036,9 +4033,7 @@ describe('AIChat', () => {
JSON.stringify({ 'session-1': 'openai:gpt-4o' }),
);
});
- expect(mockChat.setModel).not.toHaveBeenCalledWith(
- 'openrouter:deepseek/deepseek-v4-pro',
- );
+ expect(mockChat.setModel).not.toHaveBeenCalledWith('openrouter:deepseek/deepseek-v4-pro');
expect(localStorage.getItem('pulse:ai_chat_recent_models')).toBe(
JSON.stringify(['openai:gpt-4o']),
);
@@ -4461,6 +4456,71 @@ describe('AIChat', () => {
expect(screen.queryByText('Generating response...')).not.toBeInTheDocument();
});
+ it('paces burst workflow progress in the active turn status footer', async () => {
+ vi.useFakeTimers();
+ try {
+ const [isLoading, setIsLoading] = createSignal(false);
+ const [messages, setMessages] = createSignal<ChatMessage[]>([]);
+ const workflowStatusHistory = [
+ {
+ phase: 'request_start',
+ message: 'Preparing Pulse context.',
+ startedAt: 1_000,
+ },
+ {
+ phase: 'context',
+ message: 'Reading current Pulse inventory with pulse_query.',
+ tool: 'pulse_query',
+ startedAt: 1_100,
+ },
+ {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_200,
+ },
+ ];
+ mockChat.isLoading.mockImplementation(() => isLoading());
+ mockChat.messages.mockImplementation(() => messages());
+ renderChat();
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_RENDER_PACE_MS * 5);
+ setIsLoading(true);
+ setMessages([
+ {
+ id: 'msg-1',
+ role: 'assistant' as const,
+ content: '',
+ timestamp: new Date(),
+ isStreaming: true,
+ workflowStatusHistory,
+ workflowStatus: workflowStatusHistory[2],
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: workflowStatusHistory[2],
+ startedAt: 1_200,
+ updatedAt: 1_200,
+ },
+ ],
+ },
+ ]);
+
+ const status = screen.getByLabelText('Assistant active turn status');
+ expect(status).toHaveTextContent('Preparing Pulse context.');
+ expect(status).not.toHaveTextContent('Sent request to OpenRouter');
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_RENDER_PACE_MS);
+ expect(status).toHaveTextContent('Reading current Pulse inventory with pulse_query.');
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_RENDER_PACE_MS);
+ expect(status).toHaveTextContent(
+ 'Sent request to OpenRouter; waiting for the first token.',
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it('keeps pending tool progress visible in the active turn status', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index f5b89d35a2..9dd11f8822 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -146,7 +146,7 @@ import { AssistantCommandHelpDialog } from './AssistantCommandHelpDialog';
import { ModelSelector } from './ModelSelector';
import { MentionAutocomplete, type MentionResource } from './MentionAutocomplete';
import { SlashCommandAutocomplete } from './SlashCommandAutocomplete';
-import { getAssistantActiveTurnStatus } from './activeTurnStatus';
+import { formatAssistantWorkflowStatus, getAssistantActiveTurnStatus } from './activeTurnStatus';
import { getLastAssistantAnswerText } from './assistantAnswerText';
import {
getNextAssistantRecentModelRoute,
@@ -165,6 +165,10 @@ import {
formatAssistantTranscript,
hasAssistantTranscriptContent,
} from './transcriptExport';
+import {
+ createPacedWorkflowStatus,
+ normalizeWorkflowStatusSequence,
+} from './workflowStatusPresentation';
import type {
ChatMessage,
ModelRouteRecoveryOption,
@@ -1458,12 +1462,14 @@ export const AIChat: Component<AIChatProps> = (props) => {
!forkingSession(),
);
const hasUndoableUserTurn = createMemo(() =>
- chat.messages().some(
- (message) =>
- message.role === 'user' &&
- message.delivery !== 'queued' &&
- Boolean(message.content.trim()),
- ),
+ chat
+ .messages()
+ .some(
+ (message) =>
+ message.role === 'user' &&
+ message.delivery !== 'queued' &&
+ Boolean(message.content.trim()),
+ ),
);
const canUndoLastTurn = createMemo(
() =>
@@ -1998,9 +2004,64 @@ export const AIChat: Component<AIChatProps> = (props) => {
return '';
});
- const currentStatus = createMemo(() =>
- getAssistantActiveTurnStatus(chat.messages(), chat.isLoading()),
+ const activeAssistantMessage = createMemo(() => {
+ if (!chat.isLoading()) return undefined;
+ const messages = chat.messages();
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
+ const message = messages[index];
+ if (message.role === 'assistant' && message.isStreaming !== false) {
+ return message;
+ }
+ }
+ return undefined;
+ });
+ const activeWorkflowStatusSequence = createMemo(() => {
+ const message = activeAssistantMessage();
+ if (!message) return [];
+ return normalizeWorkflowStatusSequence([
+ ...(message.workflowStatusHistory || []),
+ message.workflowStatus,
+ ]);
+ });
+ const displayedActiveWorkflowStatus = createPacedWorkflowStatus(
+ () => activeWorkflowStatusSequence(),
+ () => chat.isLoading() && !!activeAssistantMessage(),
+ () => {
+ const message = activeAssistantMessage();
+ return message ? `${message.id}:workflow-footer` : '';
+ },
);
+ const currentStatus = createMemo(() => {
+ const status = getAssistantActiveTurnStatus(chat.messages(), chat.isLoading());
+ const message = activeAssistantMessage();
+ const latestWorkflowStatus = message?.workflowStatus;
+ const pacedWorkflowStatus = displayedActiveWorkflowStatus();
+ if (!status || !latestWorkflowStatus || !pacedWorkflowStatus) return status;
+
+ const latestWorkflowText = formatAssistantWorkflowStatus(latestWorkflowStatus);
+ const expectedType = latestWorkflowStatus.tool ? 'tool' : 'thinking';
+ const statusStartedAt = status.startedAt;
+ const workflowStartedAt = latestWorkflowStatus.startedAt;
+ if (
+ !latestWorkflowText ||
+ status.text !== latestWorkflowText ||
+ status.type !== expectedType ||
+ (statusStartedAt !== undefined &&
+ workflowStartedAt !== undefined &&
+ statusStartedAt !== workflowStartedAt)
+ ) {
+ return status;
+ }
+
+ const pacedText = formatAssistantWorkflowStatus(pacedWorkflowStatus);
+ if (!pacedText) return status;
+ return {
+ ...status,
+ type: pacedWorkflowStatus.tool ? 'tool' : 'thinking',
+ text: pacedText,
+ startedAt: pacedWorkflowStatus.startedAt,
+ };
+ });
const [currentStatusNow, setCurrentStatusNow] = createSignal(Date.now());
createEffect(() => {
const status = currentStatus();
@@ -2610,7 +2671,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
? { ...queuedDraft.sendOptions }
: restoredDraft?.request
? sendOptionsFromRestoredRequest(restoredDraft.request)
- : {};
+ : {};
if (!queuedDraft && !restoredDraft) {
if (typeof ctx.autonomousMode === 'boolean') {
sendOptions.autonomousMode = ctx.autonomousMode;
diff --git a/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts b/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts
new file mode 100644
index 0000000000..88eb4d895d
--- /dev/null
+++ b/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts
@@ -0,0 +1,127 @@
+import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
+import { formatAssistantWorkflowStatus } from './activeTurnStatus';
+import type { WorkflowStatus } from './types';
+
+export const WORKFLOW_STATUS_RENDER_PACE_MS = 420;
+
+export const workflowStatusRenderKey = (status?: WorkflowStatus) =>
+ status
+ ? [
+ status?.phase || '',
+ status?.message || '',
+ status?.state || '',
+ status?.tool || '',
+ status?.attempt || 0,
+ status?.maxAttempts || 0,
+ status?.retryAfterMs || 0,
+ status?.startedAt || 0,
+ ].join('\u001f')
+ : '';
+
+export const normalizeWorkflowStatusSequence = (statuses: Array<WorkflowStatus | undefined>) => {
+ const sequence: WorkflowStatus[] = [];
+ for (const status of statuses) {
+ if (!status || !formatAssistantWorkflowStatus(status)) continue;
+ const previous = sequence[sequence.length - 1];
+ if (workflowStatusRenderKey(previous) === workflowStatusRenderKey(status)) continue;
+ sequence.push(status);
+ }
+ return sequence;
+};
+
+interface PacedWorkflowStatusClock {
+ firstKey: string;
+ startedAt: number;
+}
+
+const pacedWorkflowStatusCache = new Map<string, PacedWorkflowStatusClock>();
+const pacedWorkflowStatusCleanupTimers = new Map<string, ReturnType<typeof setTimeout>>();
+
+const cancelPacedWorkflowStatusCleanup = (key: string) => {
+ const timer = pacedWorkflowStatusCleanupTimers.get(key);
+ if (!timer) return;
+ clearTimeout(timer);
+ pacedWorkflowStatusCleanupTimers.delete(key);
+};
+
+const deletePacedWorkflowStatusCache = (key: string) => {
+ cancelPacedWorkflowStatusCleanup(key);
+ pacedWorkflowStatusCache.delete(key);
+};
+
+const schedulePacedWorkflowStatusCleanup = (key: string) => {
+ cancelPacedWorkflowStatusCleanup(key);
+ pacedWorkflowStatusCleanupTimers.set(
+ key,
+ setTimeout(() => {
+ pacedWorkflowStatusCleanupTimers.delete(key);
+ pacedWorkflowStatusCache.delete(key);
+ }, 1000),
+ );
+};
+
+export const createPacedWorkflowStatus = (
+ getStatuses: () => WorkflowStatus[],
+ live: () => boolean,
+ cacheKey: () => string,
+) => {
+ const [now, setNow] = createSignal(Date.now());
+ let interval: ReturnType<typeof setInterval> | undefined;
+
+ createEffect(() => {
+ const statuses = getStatuses();
+ if (!live()) {
+ if (interval) {
+ clearInterval(interval);
+ interval = undefined;
+ }
+ const key = cacheKey();
+ if (key) deletePacedWorkflowStatusCache(key);
+ return;
+ }
+
+ const key = cacheKey();
+ if (key) {
+ cancelPacedWorkflowStatusCleanup(key);
+ }
+
+ if (statuses.length > 1 && !interval) {
+ interval = setInterval(() => setNow(Date.now()), WORKFLOW_STATUS_RENDER_PACE_MS);
+ } else if (statuses.length <= 1 && interval) {
+ clearInterval(interval);
+ interval = undefined;
+ }
+ });
+
+ onCleanup(() => {
+ if (interval) {
+ clearInterval(interval);
+ }
+ const key = cacheKey();
+ if (key) schedulePacedWorkflowStatusCleanup(key);
+ });
+
+ return createMemo(() => {
+ const statuses = getStatuses();
+ if (statuses.length === 0) return undefined;
+ if (!live()) return statuses[statuses.length - 1];
+ if (statuses.length === 1) return statuses[0];
+
+ const key = cacheKey();
+ const firstKey = workflowStatusRenderKey(statuses[0]);
+ if (!key || !firstKey) return statuses[0];
+
+ const cached = pacedWorkflowStatusCache.get(key);
+ const startedAt = cached?.firstKey === firstKey ? cached.startedAt : Date.now();
+ if (!cached || cached.firstKey !== firstKey) {
+ pacedWorkflowStatusCache.set(key, { firstKey, startedAt });
+ }
+ const currentTime = Math.max(now(), startedAt);
+
+ const index = Math.min(
+ statuses.length - 1,
+ Math.floor(Math.max(0, currentTime - startedAt) / WORKFLOW_STATUS_RENDER_PACE_MS),
+ );
+ return statuses[index] || statuses[statuses.length - 1];
+ });
+};