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 bursts

rcourtman0a6531e1e462
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 78fa8c703a..393bbcbc79 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -27,7 +27,10 @@ import { getAssistantAnswerText } from './assistantAnswerText';
import { stripAssistantOutputArtifacts } from './assistantOutputHygiene';
import { formatAssistantWorkflowStatus } from './activeTurnStatus';
import { groupStreamEventsForDisplay } from './streamEventGrouping';
-import { WORKFLOW_STATUS_REFRESH_MS } from './workflowStatusDisplay';
+import {
+ createPacedWorkflowStatus,
+ WORKFLOW_STATUS_REFRESH_MS,
+} from './workflowStatusDisplay';
import type {
ChatMessage,
ModelRouteRecoveryOption,
@@ -315,6 +318,50 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
groupedEvents()
.slice(eventIndex + 1)
.some((evt) => evt.type !== 'model_switch' && isConcreteStreamActivity(evt));
+ const isDurableWorkflowBoundary = (evt: StreamDisplayEvent) => {
+ switch (evt.type) {
+ case 'content':
+ return !!stripAssistantOutputArtifacts(evt.content || '').text;
+ case 'tool':
+ return !!evt.tool;
+ case 'pending_tool':
+ return !!evt.pendingTool;
+ case 'tool_cancel':
+ return !!evt.toolCancel;
+ case 'approval':
+ return !!evt.approval;
+ case 'question':
+ return !!evt.question;
+ default:
+ return false;
+ }
+ };
+ const hasDurableWorkflowBoundaryAround = (eventIndex: number) =>
+ groupedEvents().some((evt, index) => index !== eventIndex && isDurableWorkflowBoundary(evt));
+ const liveWorkflowStatusHistory = createMemo(() =>
+ props.message.isStreaming === true ? props.message.workflowStatusHistory || [] : [],
+ );
+ const workflowStatusPaceSequenceKey = createMemo(() => {
+ const first = liveWorkflowStatusHistory()[0];
+ return [
+ props.message.id,
+ first?.phase,
+ first?.message,
+ first?.startedAt,
+ ]
+ .map((value) => String(value ?? ''))
+ .join(':');
+ });
+ const pacedWorkflowStatus = createPacedWorkflowStatus(
+ liveWorkflowStatusHistory,
+ () => props.message.isStreaming === true && liveWorkflowStatusHistory().length > 1,
+ workflowStatusPaceSequenceKey,
+ );
+ const shouldPaceWorkflowStatusEvent = (evt: StreamDisplayEvent, eventIndex: number) =>
+ props.message.isStreaming === true &&
+ evt.type === 'workflow_status' &&
+ liveWorkflowStatusHistory().length > 1 &&
+ !hasDurableWorkflowBoundaryAround(eventIndex);
const shouldCompactCompletedToolEvent = (evt: StreamDisplayEvent, eventIndex: number) =>
evt.type === 'tool' &&
props.message.isStreaming === true &&
@@ -581,7 +628,11 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
const contentText = () =>
stripAssistantOutputArtifacts(evt?.content || '').text;
const visibleWorkflowStatus = () =>
- evt?.type === 'workflow_status' ? evt.workflowStatus : undefined;
+ evt?.type === 'workflow_status'
+ ? shouldPaceWorkflowStatusEvent(evt, index())
+ ? pacedWorkflowStatus() || evt.workflowStatus
+ : evt.workflowStatus
+ : undefined;
return (
<Switch>
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 82b548ed2b..650c8854f7 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_PACE_MS } from '../workflowStatusDisplay';
// ── Hoisted mocks (vi.mock factories reference these) ──────────────────────
@@ -5478,7 +5479,7 @@ describe('AIChat', () => {
expect(status).not.toHaveTextContent('Using Qwen: Qwen3.7 Plus via OpenRouter');
});
- it('uses the latest replacing workflow progress in the active turn status footer', async () => {
+ it('paces replacing workflow progress in the active turn status footer', async () => {
vi.useFakeTimers();
vi.setSystemTime(1_200);
const [isLoading, setIsLoading] = createSignal(false);
@@ -5527,12 +5528,19 @@ describe('AIChat', () => {
]);
const status = screen.getByLabelText('Assistant active turn status');
- await waitFor(() => expect(status).toHaveTextContent('OpenRouter is starting the response.'));
+ await waitFor(() => expect(status).toHaveTextContent('Preparing Pulse context.'));
+ expect(status).not.toHaveTextContent('OpenRouter is starting the response.');
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(status).toHaveTextContent('Reading current Pulse inventory.');
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(status).toHaveTextContent('OpenRouter is starting the response.');
expect(status).not.toHaveTextContent('Preparing Pulse context.');
expect(status).not.toHaveTextContent('Reading current Pulse inventory.');
});
- it('uses the latest replacing workflow progress without dropping queued follow-up pressure', async () => {
+ it('paces replacing workflow progress without dropping queued follow-up pressure', async () => {
vi.useFakeTimers();
vi.setSystemTime(1_200);
const [isLoading, setIsLoading] = createSignal(false);
@@ -5590,8 +5598,17 @@ describe('AIChat', () => {
const status = screen.getByLabelText('Assistant active turn status');
await waitFor(() =>
- expect(status).toHaveTextContent('OpenRouter is starting the response. · 1 follow-up queued'),
+ expect(status).toHaveTextContent('Preparing Pulse context. · 1 follow-up queued'),
);
+ expect(status).not.toHaveTextContent('OpenRouter is starting the response.');
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(status).toHaveTextContent(
+ 'Reading current Pulse inventory. · 1 follow-up queued',
+ );
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(status).toHaveTextContent('OpenRouter is starting the response. · 1 follow-up queued');
expect(status).not.toHaveTextContent('Preparing Pulse context.');
expect(status).not.toHaveTextContent('Reading current Pulse inventory.');
});
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 1dc38058e2..986130d29f 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -2,6 +2,7 @@ import { describe, expect, it, vi, afterEach } from 'vitest';
import { cleanup, render, screen, fireEvent, waitFor } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { MessageItem } from '../MessageItem';
+import { WORKFLOW_STATUS_PACE_MS } from '../workflowStatusDisplay';
import type { ChatMessage, PendingApproval, PendingQuestion, StreamDisplayEvent } from '../types';
// Mock child components to isolate MessageItem logic
@@ -801,7 +802,7 @@ describe('MessageItem', () => {
).toBeInTheDocument();
});
- it('renders the latest replacing workflow activity through one live transcript row', () => {
+ it('paces replacing workflow activity through one live transcript row', async () => {
vi.useFakeTimers();
vi.setSystemTime(1_200);
@@ -844,6 +845,13 @@ describe('MessageItem', () => {
/>
));
+ expect(screen.getByText(/Preparing Pulse context\./)).toBeInTheDocument();
+ expect(screen.queryByText(/OpenRouter is starting the response\./)).not.toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(screen.getByText(/Reading current Pulse inventory\./)).toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
expect(screen.getByText(/OpenRouter is starting the response\./)).toBeInTheDocument();
expect(screen.queryByText(/Preparing Pulse context\./)).not.toBeInTheDocument();
expect(
@@ -851,7 +859,7 @@ describe('MessageItem', () => {
).not.toBeInTheDocument();
});
- it('uses provider retry workflow activity as the latest live transcript status', () => {
+ it('paces provider retry workflow activity into the live transcript status', async () => {
vi.useFakeTimers();
vi.setSystemTime(1_200);
@@ -896,10 +904,14 @@ describe('MessageItem', () => {
/>
));
+ expect(screen.getByText('Preparing Pulse context.')).toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
+ expect(screen.getByText('OpenRouter is starting the response.')).toBeInTheDocument();
+
+ await vi.advanceTimersByTimeAsync(WORKFLOW_STATUS_PACE_MS);
expect(
- screen.getByText(
- 'Provider connection failed before any output; retrying. · attempt 2/3 · retrying in 3.2s',
- ),
+ screen.getByText(/Provider connection failed before any output; retrying\. · attempt 2\/3/),
).toBeInTheDocument();
expect(screen.queryByText('Preparing Pulse context.')).not.toBeInTheDocument();
expect(screen.queryByText('OpenRouter is starting the response.')).not.toBeInTheDocument();
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 197284684f..5a793c4cc9 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -154,7 +154,11 @@ import { SlashCommandAutocomplete } from './SlashCommandAutocomplete';
import {
getAssistantActiveTurnStatus,
} from './activeTurnStatus';
-import { WORKFLOW_STATUS_REFRESH_MS } from './workflowStatusDisplay';
+import {
+ createPacedWorkflowStatus,
+ replaceLatestWorkflowStatusEventForDisplay,
+ WORKFLOW_STATUS_REFRESH_MS,
+} from './workflowStatusDisplay';
import { getLastAssistantAnswerText } from './assistantAnswerText';
import {
getNextAssistantRecentModelRoute,
@@ -2357,9 +2361,53 @@ export const AIChat: Component<AIChatProps> = (props) => {
}
return undefined;
});
+ const activeWorkflowStatusHistory = createMemo(() => {
+ const message = activeAssistantMessage();
+ if (!message || message.isStreaming === false) return [];
+ return message.workflowStatusHistory || (message.workflowStatus ? [message.workflowStatus] : []);
+ });
+ const activeWorkflowStatusPaceSequenceKey = createMemo(() => {
+ const message = activeAssistantMessage();
+ const first = activeWorkflowStatusHistory()[0];
+ return [
+ message?.id,
+ first?.phase,
+ first?.message,
+ first?.startedAt,
+ ]
+ .map((value) => String(value ?? ''))
+ .join(':');
+ });
+ const pacedActiveWorkflowStatus = createPacedWorkflowStatus(
+ activeWorkflowStatusHistory,
+ () => chat.isLoading() && activeWorkflowStatusHistory().length > 1,
+ activeWorkflowStatusPaceSequenceKey,
+ );
+ const messagesWithPacedActiveWorkflowStatus = createMemo(() => {
+ const activeMessage = activeAssistantMessage();
+ const workflowStatus = pacedActiveWorkflowStatus();
+ const messages = chat.messages();
+ if (!activeMessage || !workflowStatus) return messages;
+
+ return messages.map((message) => {
+ if (message.id !== activeMessage.id) return message;
+ return {
+ ...message,
+ workflowStatus,
+ streamEvents: replaceLatestWorkflowStatusEventForDisplay(
+ message.streamEvents,
+ workflowStatus,
+ ),
+ };
+ });
+ });
const [currentStatusNow, setCurrentStatusNow] = createSignal(Date.now());
const currentStatus = createMemo(() => {
- return getAssistantActiveTurnStatus(chat.messages(), chat.isLoading(), currentStatusNow());
+ return getAssistantActiveTurnStatus(
+ messagesWithPacedActiveWorkflowStatus(),
+ chat.isLoading(),
+ currentStatusNow(),
+ );
});
createEffect(() => {
const status = currentStatus();
diff --git a/frontend-modern/src/components/AI/Chat/workflowStatusDisplay.ts b/frontend-modern/src/components/AI/Chat/workflowStatusDisplay.ts
index edf8da6d8d..23682aafb0 100644
--- a/frontend-modern/src/components/AI/Chat/workflowStatusDisplay.ts
+++ b/frontend-modern/src/components/AI/Chat/workflowStatusDisplay.ts
@@ -1 +1,110 @@
+import { createEffect, createMemo, createSignal, onCleanup, type Accessor } from 'solid-js';
+import type { StreamDisplayEvent, WorkflowStatus } from './types';
+
export const WORKFLOW_STATUS_REFRESH_MS = 300;
+export const WORKFLOW_STATUS_PACE_MS = 380;
+
+const workflowStatusDisplayKey = (status?: WorkflowStatus): string =>
+ [
+ status?.phase,
+ status?.message,
+ status?.state,
+ status?.tool,
+ status?.provider,
+ status?.model,
+ status?.attempt,
+ status?.maxAttempts,
+ status?.retryAfterMs,
+ status?.startedAt,
+ ]
+ .map((value) => String(value ?? ''))
+ .join('\u001f');
+
+const normalizeWorkflowStatusHistory = (statuses?: WorkflowStatus[]): WorkflowStatus[] => {
+ const normalized: WorkflowStatus[] = [];
+ for (const status of statuses || []) {
+ if (!status?.message?.trim()) continue;
+ const previous = normalized[normalized.length - 1];
+ if (workflowStatusDisplayKey(previous) === workflowStatusDisplayKey(status)) continue;
+ normalized.push(status);
+ }
+ return normalized;
+};
+
+export const createPacedWorkflowStatus = (
+ statuses: Accessor<WorkflowStatus[] | undefined>,
+ live: Accessor<boolean>,
+ sequenceKey: Accessor<string> = () => '',
+): Accessor<WorkflowStatus | undefined> => {
+ const history = createMemo(() => normalizeWorkflowStatusHistory(statuses()));
+ const [displayIndex, setDisplayIndex] = createSignal(0);
+ let previousSequenceKey = '';
+
+ createEffect(() => {
+ const currentHistory = history();
+ const currentSequenceKey = sequenceKey();
+ const isLive = live();
+
+ if (currentHistory.length === 0) {
+ previousSequenceKey = currentSequenceKey;
+ setDisplayIndex(0);
+ return;
+ }
+
+ if (!isLive || currentHistory.length === 1) {
+ previousSequenceKey = currentSequenceKey;
+ setDisplayIndex(currentHistory.length - 1);
+ return;
+ }
+
+ if (currentSequenceKey !== previousSequenceKey) {
+ previousSequenceKey = currentSequenceKey;
+ setDisplayIndex(0);
+ return;
+ }
+
+ setDisplayIndex((index) => Math.min(Math.max(index, 0), currentHistory.length - 1));
+ });
+
+ createEffect(() => {
+ const currentHistory = history();
+ const index = displayIndex();
+ if (!live() || currentHistory.length <= 1 || index >= currentHistory.length - 1) return;
+
+ const timer = window.setTimeout(() => {
+ setDisplayIndex((current) => Math.min(current + 1, history().length - 1));
+ }, WORKFLOW_STATUS_PACE_MS);
+ onCleanup(() => window.clearTimeout(timer));
+ });
+
+ return () => {
+ const currentHistory = history();
+ if (currentHistory.length === 0) return undefined;
+ const index = Math.min(Math.max(displayIndex(), 0), currentHistory.length - 1);
+ return currentHistory[index];
+ };
+};
+
+export const replaceLatestWorkflowStatusEventForDisplay = (
+ events: StreamDisplayEvent[] | undefined,
+ workflowStatus: WorkflowStatus | undefined,
+): StreamDisplayEvent[] | undefined => {
+ if (!events || !workflowStatus) return events;
+
+ for (let index = events.length - 1; index >= 0; index -= 1) {
+ const event = events[index];
+ if (event.type !== 'workflow_status') continue;
+ return [
+ ...events.slice(0, index),
+ {
+ ...event,
+ workflowStatus,
+ startedAt: workflowStatus.startedAt ?? event.startedAt,
+ updatedAt: workflowStatus.startedAt ?? event.updatedAt,
+ },
+ ...events.slice(index + 1),
+ ];
+ }
+
+ return events;
+};