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 transcript rows

rcourtmand946d76a7343
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 72604138a6..4849db1952 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -541,12 +541,15 @@ runtime cost control, and shared AI transport surfaces.
progress, not answer content or a delayed walkthrough; each new
`workflow_state` replaces the canonical active status immediately. The
browser may retain a bounded in-flight history of those replaced labels for
- state continuity, but the live transcript row and active-turn composer
- footer must render the latest workflow status immediately rather than
- replaying stale preparation/provider labels after backend or network
- coalescing. Older neutral statuses may disappear when replaced by newer
- status, tool, reasoning, or answer evidence; that replacement is the intended
- motion signal.
+ state continuity. When several statuses arrive in one backend/network burst,
+ the live transcript row and active-turn composer footer must use the same
+ paced presentation helper so the operator sees the row move through
+ preparation, context, provider, and tool states instead of jumping to the
+ final burst label. Single fresh status updates still render immediately, and
+ separated transcript workflow rows stay tied to their own streamed event
+ when a durable content/tool/approval/question boundary exists. Older neutral
+ statuses may disappear when replaced by newer status, tool, reasoning, or
+ answer evidence; that replacement is the intended motion signal.
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
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 2d29d38630..189423306d 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -27,6 +27,7 @@ import { getAssistantAnswerText } from './assistantAnswerText';
import { stripAssistantOutputArtifacts } from './assistantOutputHygiene';
import { formatAssistantWorkflowStatus, isInitialRequestStartStatus } from './activeTurnStatus';
import { groupStreamEventsForDisplay } from './streamEventGrouping';
+import { createPacedWorkflowStatus, workflowStatusRenderKey } from './workflowStatusPresentation';
import type {
ChatMessage,
ModelRouteRecoveryOption,
@@ -290,6 +291,27 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
const shouldRenderWorkflowStatusEvent = (evt: StreamDisplayEvent) =>
!!formatAssistantWorkflowStatus(evt.workflowStatus) &&
(!isInitialRequestStartStatus(evt.workflowStatus) || !hasConcreteStreamActivity());
+ const renderableWorkflowStatusEvents = createMemo(() =>
+ groupedEvents().filter(
+ (evt) => evt.type === 'workflow_status' && shouldRenderWorkflowStatusEvent(evt),
+ ),
+ );
+ const latestRenderableWorkflowStatusEventKey = createMemo(() => {
+ const workflowEvents = renderableWorkflowStatusEvents();
+ return workflowStatusRenderKey(workflowEvents[workflowEvents.length - 1]?.workflowStatus);
+ });
+ const pacedWorkflowStatus = createPacedWorkflowStatus(
+ () => [...(props.message.workflowStatusHistory || []), props.message.workflowStatus],
+ { enabled: () => props.message.isStreaming === true },
+ );
+ const shouldPaceWorkflowStatusRow = (evt: StreamDisplayEvent) =>
+ props.message.isStreaming === true &&
+ renderableWorkflowStatusEvents().length === 1 &&
+ workflowStatusRenderKey(evt.workflowStatus) === latestRenderableWorkflowStatusEventKey();
+ const workflowStatusForEvent = (evt: StreamDisplayEvent): WorkflowStatus | undefined => {
+ if (!shouldPaceWorkflowStatusRow(evt)) return evt.workflowStatus;
+ return pacedWorkflowStatus.status() || evt.workflowStatus;
+ };
const isRenderableStreamEvent = (evt: StreamDisplayEvent) => {
switch (evt.type) {
case 'thinking':
@@ -355,7 +377,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
!props.message.error;
const [statusNow, setStatusNow] = createSignal(Date.now());
createEffect(() => {
- const status = props.message.workflowStatus;
+ const status = pacedWorkflowStatus.status();
if (!props.message.isStreaming || !status?.startedAt) return;
setStatusNow(Date.now());
const interval = window.setInterval(() => setStatusNow(Date.now()), 1000);
@@ -377,7 +399,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
return `${message}${elapsedSuffix}`;
};
const workflowStatusText = createMemo(() =>
- formatWorkflowStatus(props.message.workflowStatus, true),
+ formatWorkflowStatus(pacedWorkflowStatus.status(), true),
);
const shouldShowHeaderWorkflowStatus = () =>
props.message.isStreaming &&
@@ -541,6 +563,8 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
{(evt, index) => {
const contentText = () =>
stripAssistantOutputArtifacts(evt?.content || '').text;
+ const visibleWorkflowStatus = () =>
+ evt?.type === 'workflow_status' ? workflowStatusForEvent(evt) : undefined;
return (
<Switch>
@@ -569,7 +593,7 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
role="status"
aria-live="polite"
title={formatWorkflowStatus(
- evt?.workflowStatus,
+ visibleWorkflowStatus(),
props.message.isStreaming,
)}
>
@@ -578,7 +602,10 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
aria-hidden="true"
/>
<span class="min-w-0 truncate">
- {formatWorkflowStatus(evt?.workflowStatus, props.message.isStreaming)}
+ {formatWorkflowStatus(
+ visibleWorkflowStatus(),
+ props.message.isStreaming,
+ )}
</span>
</div>
</Match>
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 c13cf14c06..7044eb9918 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -742,7 +742,10 @@ describe('MessageItem', () => {
).toBeInTheDocument();
});
- it('shows the latest burst workflow activity through one live transcript row', () => {
+ it('paces burst workflow activity through one live transcript row', async () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(1_200);
+
const workflowStatusHistory = [
{
phase: 'request_start',
@@ -782,13 +785,21 @@ describe('MessageItem', () => {
/>
));
- expect(screen.queryByText(/Preparing Pulse context\./)).not.toBeInTheDocument();
+ expect(screen.getByText('Preparing Pulse context.')).toBeInTheDocument();
+ expect(screen.queryByText(/OpenRouter is starting the response\./)).not.toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(650);
+
+ expect(screen.getByText('Reading current Pulse inventory.')).toBeInTheDocument();
expect(
screen.queryByText(/Reading current Pulse inventory with pulse_query\./),
).not.toBeInTheDocument();
- expect(
- screen.getByText(/OpenRouter is starting the response\./),
- ).toBeInTheDocument();
+ expect(screen.queryByText(/OpenRouter is starting the response\./)).not.toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(650);
+
+ expect(screen.getByText('OpenRouter is starting the response.')).toBeInTheDocument();
+ expect(screen.queryByText(/Preparing Pulse context\./)).not.toBeInTheDocument();
});
it('keeps separated transcript workflow rows tied to their own streamed status', () => {
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index bf6a5e451c..e5877e78ec 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -7,7 +7,6 @@ import {
For,
createMemo,
createEffect,
- untrack,
} from 'solid-js';
import { useNavigate } from '@solidjs/router';
import { unwrap } from 'solid-js/store';
@@ -173,17 +172,12 @@ import {
formatAssistantTranscript,
hasAssistantTranscriptContent,
} from './transcriptExport';
-import {
- latestWorkflowStatus,
- normalizeWorkflowStatusSequence,
- workflowStatusRenderKey,
-} from './workflowStatusPresentation';
+import { createPacedWorkflowStatus } from './workflowStatusPresentation';
import type {
ChatMessage,
ModelRouteRecoveryOption,
PendingApproval,
PendingQuestion,
- WorkflowStatus,
} from './types';
import { formatIdentifierLabel } from '@/utils/textPresentation';
@@ -199,7 +193,6 @@ const AI_CHAT_PINNED_SESSION_LIMIT = 30;
const AI_CHAT_SESSION_TITLE_MAX_LENGTH = 120;
const AI_CHAT_SESSION_SEARCH_DEBOUNCE_MS = 150;
const AI_CHAT_SESSION_SEARCH_LIMIT = 30;
-const AI_CHAT_WORKFLOW_STATUS_BURST_VISIBLE_MS = 650;
const STRUCTURED_PATROL_CONTEXT_TARGETS = new Set(['patrol-configuration', 'patrol-run']);
const STRUCTURED_RESOURCE_CONTEXT_HANDOFF_KINDS = new Set(['resource_context']);
const AI_CHAT_CYCLE_RECENT_MODEL_LABEL = 'Cycle recent Assistant model';
@@ -2385,104 +2378,14 @@ export const AIChat: Component<AIChatProps> = (props) => {
}
return undefined;
});
- const activeWorkflowStatusSequence = createMemo(() => {
- const message = activeAssistantMessage();
- if (!message) return [];
- return normalizeWorkflowStatusSequence([
- ...(message.workflowStatusHistory || []),
- message.workflowStatus,
- ]);
- });
- const [displayedActiveWorkflowStatusKey, setDisplayedActiveWorkflowStatusKey] =
- createSignal('');
- const [pacingWorkflowStatusBurst, setPacingWorkflowStatusBurst] = createSignal(false);
- let lastWorkflowStatusSequenceFingerprint = '';
- let lastWorkflowStatusSequenceLength = 0;
- let workflowStatusAdvanceTimer: number | undefined;
-
- const clearWorkflowStatusAdvanceTimer = () => {
- if (workflowStatusAdvanceTimer) {
- window.clearTimeout(workflowStatusAdvanceTimer);
- workflowStatusAdvanceTimer = undefined;
- }
- };
-
- const scheduleWorkflowStatusAdvance = (keys: string[], currentIndex: number) => {
- clearWorkflowStatusAdvanceTimer();
- if (currentIndex >= keys.length - 1) {
- setPacingWorkflowStatusBurst(false);
- return;
- }
-
- setPacingWorkflowStatusBurst(true);
- workflowStatusAdvanceTimer = window.setTimeout(() => {
- const nextIndex = Math.min(currentIndex + 1, keys.length - 1);
- setDisplayedActiveWorkflowStatusKey(keys[nextIndex] || '');
- scheduleWorkflowStatusAdvance(keys, nextIndex);
- }, AI_CHAT_WORKFLOW_STATUS_BURST_VISIBLE_MS);
- };
-
- // Burst status histories can arrive in one render after cold starts. Pace
- // only those bursts so the dock shows visible progress instead of jumping.
- createEffect(() => {
- const sequence = activeWorkflowStatusSequence();
- const keys = sequence.map(workflowStatusRenderKey);
- const fingerprint = keys.join('\u001e');
- const previousFingerprint = lastWorkflowStatusSequenceFingerprint;
- const previousLength = lastWorkflowStatusSequenceLength;
- const sequenceChanged = fingerprint !== previousFingerprint;
- const addedCount = sequenceChanged ? Math.max(0, sequence.length - previousLength) : 0;
-
- lastWorkflowStatusSequenceFingerprint = fingerprint;
- lastWorkflowStatusSequenceLength = sequence.length;
- clearWorkflowStatusAdvanceTimer();
-
- if (sequence.length === 0) {
- setDisplayedActiveWorkflowStatusKey('');
- setPacingWorkflowStatusBurst(false);
- return;
- }
-
- const currentKey = untrack(displayedActiveWorkflowStatusKey);
- const currentIndex = keys.indexOf(currentKey);
- if (currentIndex === -1) {
- const initialIndex = sequence.length > 1 ? 0 : sequence.length - 1;
- setDisplayedActiveWorkflowStatusKey(keys[initialIndex] || '');
- if (initialIndex < sequence.length - 1) {
- scheduleWorkflowStatusAdvance(keys, initialIndex);
- } else {
- setPacingWorkflowStatusBurst(false);
- }
- return;
- }
-
- if (currentIndex >= sequence.length - 1) {
- setPacingWorkflowStatusBurst(false);
- return;
- }
-
- const pendingCount = sequence.length - currentIndex - 1;
- const shouldPace = untrack(pacingWorkflowStatusBurst) || addedCount > 1 || pendingCount > 1;
- if (shouldPace) {
- scheduleWorkflowStatusAdvance(keys, currentIndex);
- return;
- }
-
- setDisplayedActiveWorkflowStatusKey(keys[sequence.length - 1] || '');
- setPacingWorkflowStatusBurst(false);
- });
-
- onCleanup(clearWorkflowStatusAdvanceTimer);
-
- const displayedActiveWorkflowStatus = createMemo<WorkflowStatus | undefined>(() => {
- const sequence = activeWorkflowStatusSequence();
- const key = displayedActiveWorkflowStatusKey();
- if (key) {
- const matched = sequence.find((status) => workflowStatusRenderKey(status) === key);
- if (matched) return matched;
- }
- return latestWorkflowStatus(sequence);
- });
+ const displayedActiveWorkflowStatus = createPacedWorkflowStatus(
+ () => {
+ const message = activeAssistantMessage();
+ if (!message) return [];
+ return [...(message.workflowStatusHistory || []), message.workflowStatus];
+ },
+ { enabled: () => chat.isLoading() },
+ ).status;
const [currentStatusNow, setCurrentStatusNow] = createSignal(Date.now());
const currentStatus = createMemo(() => {
const status = getAssistantActiveTurnStatus(
diff --git a/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts b/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts
index d0170d3f93..9a50e04676 100644
--- a/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts
+++ b/frontend-modern/src/components/AI/Chat/workflowStatusPresentation.ts
@@ -1,6 +1,16 @@
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ onCleanup,
+ untrack,
+ type Accessor,
+} from 'solid-js';
import { formatAssistantWorkflowStatus } from './activeTurnStatus';
import type { WorkflowStatus } from './types';
+export const ASSISTANT_WORKFLOW_STATUS_BURST_VISIBLE_MS = 650;
+
export const workflowStatusRenderKey = (status?: WorkflowStatus) =>
status
? [
@@ -28,3 +38,128 @@ export const normalizeWorkflowStatusSequence = (statuses: Array<WorkflowStatus |
export const latestWorkflowStatus = (statuses: WorkflowStatus[]) =>
statuses.length > 0 ? statuses[statuses.length - 1] : undefined;
+
+interface PacedWorkflowStatusOptions {
+ enabled?: Accessor<boolean>;
+ visibleMs?: number;
+}
+
+interface PacedWorkflowStatus {
+ sequence: Accessor<WorkflowStatus[]>;
+ status: Accessor<WorkflowStatus | undefined>;
+ pacing: Accessor<boolean>;
+}
+
+export const createPacedWorkflowStatus = (
+ getStatuses: Accessor<Array<WorkflowStatus | undefined>>,
+ options: PacedWorkflowStatusOptions = {},
+): PacedWorkflowStatus => {
+ const sequence = createMemo(() => normalizeWorkflowStatusSequence(getStatuses()));
+ const [displayedStatusKey, setDisplayedStatusKey] = createSignal('');
+ const [pacing, setPacing] = createSignal(false);
+ const visibleMs = options.visibleMs ?? ASSISTANT_WORKFLOW_STATUS_BURST_VISIBLE_MS;
+ let lastSequenceFingerprint = '';
+ let lastSequenceLength = 0;
+ let advanceTimer: number | undefined;
+
+ const clearAdvanceTimer = () => {
+ if (advanceTimer !== undefined) {
+ window.clearTimeout(advanceTimer);
+ advanceTimer = undefined;
+ }
+ };
+
+ const showLatest = (keys: string[]) => {
+ clearAdvanceTimer();
+ setDisplayedStatusKey(keys[keys.length - 1] || '');
+ setPacing(false);
+ };
+
+ const scheduleAdvance = (keys: string[], currentIndex: number) => {
+ clearAdvanceTimer();
+ if (currentIndex >= keys.length - 1) {
+ setPacing(false);
+ return;
+ }
+
+ setPacing(true);
+ advanceTimer = window.setTimeout(() => {
+ const nextIndex = Math.min(currentIndex + 1, keys.length - 1);
+ setDisplayedStatusKey(keys[nextIndex] || '');
+ scheduleAdvance(keys, nextIndex);
+ }, visibleMs);
+ };
+
+ createEffect(() => {
+ const statuses = sequence();
+ const keys = statuses.map(workflowStatusRenderKey);
+ const fingerprint = keys.join('\u001e');
+ const previousFingerprint = lastSequenceFingerprint;
+ const previousLength = lastSequenceLength;
+ const sequenceChanged = fingerprint !== previousFingerprint;
+ const addedCount = sequenceChanged ? Math.max(0, statuses.length - previousLength) : 0;
+ const enabled = options.enabled?.() ?? true;
+
+ lastSequenceFingerprint = fingerprint;
+ lastSequenceLength = statuses.length;
+
+ if (statuses.length === 0) {
+ clearAdvanceTimer();
+ setDisplayedStatusKey('');
+ setPacing(false);
+ return;
+ }
+
+ if (!enabled) {
+ showLatest(keys);
+ return;
+ }
+
+ const currentKey = untrack(displayedStatusKey);
+ const currentIndex = keys.indexOf(currentKey);
+ if (currentIndex === -1) {
+ const initialIndex = statuses.length > 1 ? 0 : statuses.length - 1;
+ setDisplayedStatusKey(keys[initialIndex] || '');
+ if (initialIndex < statuses.length - 1) {
+ scheduleAdvance(keys, initialIndex);
+ } else {
+ clearAdvanceTimer();
+ setPacing(false);
+ }
+ return;
+ }
+
+ if (currentIndex >= statuses.length - 1) {
+ clearAdvanceTimer();
+ setPacing(false);
+ return;
+ }
+
+ const pendingCount = statuses.length - currentIndex - 1;
+ const shouldPace = untrack(pacing) || addedCount > 1 || pendingCount > 1;
+ if (shouldPace) {
+ scheduleAdvance(keys, currentIndex);
+ return;
+ }
+
+ showLatest(keys);
+ });
+
+ onCleanup(clearAdvanceTimer);
+
+ const status = createMemo<WorkflowStatus | undefined>(() => {
+ const statuses = sequence();
+ const key = displayedStatusKey();
+ if (key) {
+ const matched = statuses.find((candidate) => workflowStatusRenderKey(candidate) === key);
+ if (matched) return matched;
+ }
+ return latestWorkflowStatus(statuses);
+ });
+
+ return {
+ sequence,
+ status,
+ pacing,
+ };
+};