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.

Keep Assistant workflow status live

rcourtman1ba987bcda8e
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index a0712e8839..c54ccbac14 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -219,9 +219,9 @@ runtime cost control, and shared AI transport surfaces.
The drawer transcript owns detailed in-flight progress for the active turn:
a new assistant row must start with a neutral local preparation status until
stream progress arrives, must show the current effective model route while
- the turn is still streaming, and must render late workflow progress as typed
- Assistant row evidence while the composer footer keeps a one-line live
- heartbeat of the current active state. Workflow status is live
+ the turn is still streaming, and must keep late workflow progress visible
+ through the composer footer while transcript rows continue to render typed
+ Assistant evidence. Workflow status is live
progress, not answer content or a delayed walkthrough; each new
`workflow_state` replaces the active status immediately instead of waiting
behind a dwell queue. Once visible assistant text, tool progress, approvals,
@@ -235,9 +235,18 @@ runtime cost control, and shared AI transport surfaces.
active assistant message in
`packages/opencode/src/cli/cmd/tui/context/sync-v2.tsx`; Pulse adapts that
precedence by letting typed content, tool, approval, and question evidence
- own the visible row once it exists, so later neutral workflow states such as
- provider reasoning do not repaint a completed tool row as if the turn were
- still waiting on the earlier phase.
+ own the visible row once it exists, while later neutral workflow states such
+ as provider reasoning still replace the live footer heartbeat instead of
+ being hidden behind generic "generating" copy.
+ The referenced OpenCode source at commit
+ `9ed17da55ab1f7360cc0e01075f763e27fa899e9` renders active assistant work
+ as session-owned parts in
+ `packages/opencode/src/cli/cmd/tui/routes/session/index.tsx`
+ (`Session`, `ToolPart`, `InlineToolRow`) and mutates the matching active
+ tool/text state in `packages/opencode/src/cli/cmd/tui/context/sync-v2.tsx`;
+ Pulse's browser drawer adapts that model by keeping the transcript rows
+ typed and stable while the active-turn footer remains a replacing live
+ status slot for provider and workflow progress between visible parts.
OpenCode-parity Assistant UX work must reference OpenCode's actual source
implementation for message parts, tool-state mutation, progress rendering,
and model/session selection before changing Pulse behavior; parity means
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 2c717d8394..a140c7c8b7 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -3205,6 +3205,29 @@ describe('AIChat', () => {
);
});
+ it('keeps late workflow progress visible after assistant content has streamed', () => {
+ mockChat.isLoading.mockReturnValue(true);
+ mockChat.messages.mockReturnValue([
+ {
+ id: 'msg-1',
+ role: 'assistant' as const,
+ content: 'I checked the first source.',
+ timestamp: new Date(),
+ isStreaming: true,
+ streamEvents: [{ type: 'content', content: 'I checked the first source.' }],
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: Date.now() - 5_000,
+ },
+ },
+ ]);
+ renderChat();
+ expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
+ 'Sent request to OpenRouter; waiting for the first token.',
+ );
+ });
+
it('does not fall back to waiting when loading outlives visible assistant content', () => {
mockChat.isLoading.mockReturnValue(true);
mockChat.messages.mockReturnValue([
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 3af0d331c7..2b1935c60e 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -210,11 +210,12 @@ describe('getAssistantActiveTurnStatus', () => {
});
});
- it('prefers generated tool evidence over stale neutral workflow status', () => {
+ it('surfaces fresh workflow progress after completed tool evidence', () => {
expect(
getAssistantActiveTurnStatus(
[
assistantMessage({
+ isStreaming: true,
workflowStatus: {
phase: 'model_thinking',
message: 'Model is reasoning before responding.',
@@ -236,6 +237,29 @@ describe('getAssistantActiveTurnStatus', () => {
],
true,
),
+ ).toEqual({
+ type: 'thinking',
+ text: 'Model is reasoning before responding.',
+ startedAt: 1000,
+ });
+ });
+
+ it('ignores stale workflow status on a completed assistant turn', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: false,
+ content: 'Finished answer',
+ workflowStatus: {
+ phase: 'model_thinking',
+ message: 'Model is reasoning before responding.',
+ startedAt: 1000,
+ },
+ }),
+ ],
+ true,
+ ),
).toEqual({
type: 'generating',
text: 'Generating response',
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
index d390f99869..3246f37ec9 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -1204,7 +1204,7 @@ describe('useChat', () => {
dispose();
});
- it('ignores neutral workflow progress after typed tool evidence is visible', async () => {
+ it('keeps late workflow progress live after typed tool evidence without adding transcript rows', async () => {
const { getFireEvent } = setupWithEventCapture();
const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));
@@ -1238,7 +1238,12 @@ describe('useChat', () => {
});
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
- expect(assistant.workflowStatus).toBeUndefined();
+ expect(assistant.workflowStatus).toEqual(
+ expect.objectContaining({
+ phase: 'model_thinking',
+ message: 'Model is reasoning before responding.',
+ }),
+ );
expect(assistant.streamEvents?.map((event) => event.type)).toEqual(['tool']);
expect(assistant.toolCalls).toHaveLength(1);
dispose();
diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
index 471d273825..831befc4bd 100644
--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
@@ -114,10 +114,10 @@ export const getAssistantActiveTurnStatus = (
return { type: 'tool', text: pendingToolText, startedAt: pendingTool?.startedAt };
}
- const workflowStatusText = formatAssistantWorkflowStatus(assistantMessage.workflowStatus);
- if (hasVisibleAssistantOutput(assistantMessage)) {
- return { type: 'generating', text: 'Generating response' };
- }
+ const workflowStatusText =
+ assistantMessage.isStreaming === false
+ ? ''
+ : formatAssistantWorkflowStatus(assistantMessage.workflowStatus);
if (workflowStatusText) {
return {
@@ -127,5 +127,9 @@ export const getAssistantActiveTurnStatus = (
};
}
+ if (hasVisibleAssistantOutput(assistantMessage)) {
+ return { type: 'generating', text: 'Generating response' };
+ }
+
return { type: 'thinking', text: 'Waiting for assistant' };
};
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index f5679eab70..4b423aa199 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -123,28 +123,6 @@ export function useChat(options: UseChatOptions = {}) {
(a.state || '') === (b.state || '') &&
(a.tool || '') === (b.tool || '');
- const streamEventHasTypedAssistantEvidence = (event: StreamDisplayEvent) => {
- switch (event.type) {
- case 'content':
- return !!event.content?.trim();
- case 'pending_tool':
- return !!event.pendingTool;
- case 'tool':
- return !!event.tool;
- case 'approval':
- return !!event.approval;
- case 'question':
- return !!event.question;
- default:
- return false;
- }
- };
-
- const messageHasTypedAssistantEvidence = (message: ChatMessage) => {
- if ((message.content || '').trim() || message.error) return true;
- return (message.streamEvents || []).some(streamEventHasTypedAssistantEvidence);
- };
-
const setAssistantWorkflowStatus = (
assistantId: string,
requestId: number,
@@ -154,9 +132,7 @@ export function useChat(options: UseChatOptions = {}) {
setMessages((prev) =>
prev.map((msg) => {
if (msg.id !== assistantId) return msg;
- if (messageHasTypedAssistantEvidence(msg)) {
- return msg.workflowStatus ? { ...msg, workflowStatus: undefined } : msg;
- }
+ if (msg.isStreaming === false) return msg;
if (workflowStatusesMatch(msg.workflowStatus, workflowStatus)) return msg;
return { ...msg, workflowStatus };
}),