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.

Fix Assistant completed tool status

rcourtman4974da72673b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 71c80ea76e..807bad0c99 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -532,6 +532,11 @@ runtime cost control, and shared AI transport surfaces.
`session.next.tool.progress`, line 317; `session.next.tool.success`, line
328; `session.next.tool.failed`, line 350), so Pulse's shared browser SSE
consumer must treat opted-in Assistant progress events as paint checkpoints.
+ Pulse's active-turn status ranking must also treat terminal `tool_end`
+ events as fresh visible activity, adapting OpenCode's in-place
+ completed/error tool-part mutation by replacing stale provider-start footer
+ copy with completed or failed tool activity while still preferring any
+ separate unresolved pending tool over a terminal sibling tool.
`frontend-modern/src/api/streaming.ts` must yield through an
animation-frame-backed browser paint checkpoint, with a bounded timer
fallback for inactive tabs, before draining the next opted-in event; a plain
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 fbdd964b10..d7b34ba2bc 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -4971,6 +4971,56 @@ describe('AIChat', () => {
);
});
+ it('shows completed tool activity instead of stale provider wait in the active turn status', () => {
+ mockChat.isLoading.mockReturnValue(true);
+ mockChat.messages.mockReturnValue([
+ {
+ id: 'msg-1',
+ role: 'assistant' as const,
+ content: '',
+ timestamp: new Date(),
+ isStreaming: true,
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ startedAt: 1_000,
+ updatedAt: 1_000,
+ },
+ {
+ type: 'tool',
+ toolId: 'tool-1',
+ tool: {
+ name: 'pulse_read',
+ input:
+ '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',
+ output: '4358',
+ success: true,
+ },
+ startedAt: 1_100,
+ updatedAt: 1_300,
+ },
+ ],
+ },
+ ]);
+ renderChat();
+ expect(screen.getByLabelText('Assistant active turn status')).toHaveTextContent(
+ 'Completed Inspect devices on current resource',
+ );
+ expect(screen.getByLabelText('Assistant active turn status')).not.toHaveTextContent(
+ 'Sent request to OpenRouter; waiting for the first token.',
+ );
+ });
+
it('shows generating status when assistant content is streaming', () => {
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 08740677ef..abc1c876c7 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts
@@ -385,6 +385,112 @@ describe('getAssistantActiveTurnStatus', () => {
});
});
+ it('surfaces completed tool activity over stale provider-start progress', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: true,
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ startedAt: 1_000,
+ updatedAt: 1_000,
+ },
+ {
+ type: 'pending_tool',
+ toolId: 'tool-1',
+ pendingTool: {
+ id: 'tool-1',
+ name: 'pulse_read',
+ input:
+ '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',
+ status: 'running',
+ startedAt: 1_100,
+ updatedAt: 1_100,
+ },
+ startedAt: 1_100,
+ updatedAt: 1_100,
+ },
+ {
+ type: 'tool',
+ toolId: 'tool-1',
+ tool: {
+ name: 'pulse_read',
+ input:
+ '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',
+ output: '4358',
+ success: true,
+ },
+ startedAt: 1_100,
+ updatedAt: 1_300,
+ },
+ ],
+ }),
+ ],
+ true,
+ ),
+ ).toEqual({
+ type: 'tool',
+ text: 'Completed Inspect devices on current resource',
+ });
+ });
+
+ it('surfaces failed completed-tool activity over stale provider-start progress', () => {
+ expect(
+ getAssistantActiveTurnStatus(
+ [
+ assistantMessage({
+ isStreaming: true,
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ streamEvents: [
+ {
+ type: 'workflow_status',
+ workflowStatus: {
+ phase: 'provider_start',
+ message: 'Sent request to OpenRouter; waiting for the first token.',
+ startedAt: 1_000,
+ },
+ startedAt: 1_000,
+ updatedAt: 1_000,
+ },
+ {
+ type: 'tool',
+ toolId: 'tool-1',
+ tool: {
+ name: 'pulse_get_nodes',
+ input: '{}',
+ output: 'permission denied',
+ success: false,
+ },
+ startedAt: 1_100,
+ updatedAt: 1_300,
+ },
+ ],
+ }),
+ ],
+ true,
+ ),
+ ).toEqual({
+ type: 'tool',
+ text: 'Failed get nodes',
+ });
+ });
+
it('surfaces neutral workflow progress while a turn is active', () => {
expect(
getAssistantActiveTurnStatus(
diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
index 16359e1868..f3d3b452c0 100644
--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts
@@ -19,6 +19,7 @@ export interface AssistantActiveTurnStatus {
interface AssistantActiveTurnStatusCandidate extends AssistantActiveTurnStatus {
activityAt?: number;
placeholder?: boolean;
+ terminalTool?: boolean;
order: number;
}
@@ -234,9 +235,7 @@ const latestPendingToolActivity = (tool?: PendingTool): number =>
tool?.updatedAt ?? tool?.startedAt ?? 0;
const isSelectedModelRouteEvent = (event: StreamDisplayEvent): boolean =>
- event.type === 'model_switch' &&
- event.modelEvent === 'selected' &&
- !event.failedModel?.trim();
+ event.type === 'model_switch' && event.modelEvent === 'selected' && !event.failedModel?.trim();
const pendingToolCandidate = (
tool: PendingTool | undefined,
@@ -250,6 +249,7 @@ const pendingToolCandidate = (
text,
startedAt: tool?.startedAt,
activityAt,
+ terminalTool: false,
order,
};
};
@@ -302,6 +302,13 @@ const isFresherStatusCandidate = (
if (candidate.placeholder !== current.placeholder) {
return current.placeholder === true;
}
+ if (
+ candidate.type === 'tool' &&
+ current.type === 'tool' &&
+ candidate.terminalTool !== current.terminalTool
+ ) {
+ return current.terminalTool === true;
+ }
const candidateTime = candidate.activityAt;
const currentTime = current.activityAt;
if (candidateTime !== undefined && currentTime !== undefined && candidateTime !== currentTime) {
@@ -319,6 +326,15 @@ const toolCancelStatusText = (event: StreamDisplayEvent): string => {
return reason ? `Skipped ${label}: ${reason}` : `Skipped ${label}`;
};
+const completedToolStatusText = (event: StreamDisplayEvent): string => {
+ const tool = event.tool;
+ if (!tool) return '';
+ const inputSummary = parseToolInputSummary(toolValueText(tool.input), tool.name, tool.rawInput);
+ const toolActivity = isPlaceholderToolInputSummary(inputSummary) ? '' : inputSummary;
+ const label = toolActivity || formatToolName(tool.name);
+ return tool.success === false ? `Failed ${label}` : `Completed ${label}`;
+};
+
const latestStreamActivityStatus = (
events?: StreamDisplayEvent[],
now?: number,
@@ -336,6 +352,16 @@ const latestStreamActivityStatus = (
for (const key of toolCompletionKeys(event)) {
completedToolKeys.add(key);
}
+ const text = completedToolStatusText(event);
+ if (text) {
+ candidate = {
+ type: 'tool',
+ text,
+ activityAt: eventActivityAt(event),
+ terminalTool: true,
+ order: index,
+ };
+ }
break;
}
case 'tool_cancel': {
@@ -347,6 +373,7 @@ const latestStreamActivityStatus = (
text: toolCancelStatusText(event),
startedAt: event.startedAt,
activityAt: eventActivityAt(event),
+ terminalTool: true,
order: index,
};
break;