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.

Preserve Assistant tool completion evidence

rcourtman5b8561151670
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 1d4284997a..5ed5a57328 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -317,12 +317,22 @@ runtime cost control, and shared AI transport surfaces.
until `[DONE]`, `message_stop`, or execution completion recreates the
delayed batch feeling this contract is meant to prevent. Policy-hidden
placeholder attempts remain governed by the runtime and may cancel a pending
- row instead of persisting a failed tool card. While streamed arguments are
- still invalid or incomplete JSON, the frontend must use the `raw_input`
+ row instead of persisting a failed tool card. If a terminal `tool_end`
+ reaches the browser without a matching pending row, the frontend must still
+ append the completed row instead of dropping the only visible tool evidence.
+ While streamed arguments are still invalid or incomplete JSON, the frontend
+ must use the `raw_input`
fragment to show a safe partial command/path/query summary instead of a
blank `{}` request row, then replace it with the structured summary once
parsing succeeds.
The referenced OpenCode source at fetched `origin/dev` commit
+ `1399323b78a04229d9bfe00c7436d7f41770fda8` keeps tool invocations as durable
+ message parts in `packages/opencode/src/session/processor.ts`
+ (`ensureToolCall`, `updateToolCall`, `completeToolCall`) and renders the
+ typed part immediately in
+ `packages/opencode/src/cli/cmd/tui/feature-plugins/system/session-v2.tsx`
+ (`AssistantTool`, `pendingInput`, `toolComplete`).
+ The referenced OpenCode source at fetched `origin/dev` commit
`09d9cf01f93798939c1284fbe974b6e1f4d2759d` renders tool-specific inline
labels such as `Read <path>`, `Grep "<pattern>"`, `WebFetch <url>`, and bash
commands in
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 cb71f79b07..e9f8a420c1 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -2370,6 +2370,18 @@ describe('useChat', () => {
const assistant = chat.messages().find((m) => m.role === 'assistant')!;
expect(assistant.toolCalls).toHaveLength(1);
expect(assistant.toolCalls![0].name).toBe('mystery_tool');
+ const toolEvents = assistant.streamEvents?.filter((event) => event.type === 'tool');
+ expect(toolEvents).toHaveLength(1);
+ expect(toolEvents![0]).toEqual({
+ type: 'tool',
+ tool: {
+ name: 'mystery_tool',
+ input: '{}',
+ output: 'ok',
+ success: true,
+ },
+ toolId: 'orphan',
+ });
// pendingTools should remain empty (nothing to remove)
expect(assistant.pendingTools).toHaveLength(0);
dispose();
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index 5da192c883..8157132817 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -867,8 +867,10 @@ export function useChat(options: UseChatOptions = {}) {
});
updatedEvents.push({ type: 'tool', tool: newToolCall, toolId: data.id });
} else {
- // No approval - just replace pending_tool in place
+ // No approval - replace the pending_tool in place. If the terminal
+ // event is the first visible evidence, keep the completed row.
updatedEvents = [...events];
+ let replacedPendingTool = false;
for (let i = events.length - 1; i >= 0; i--) {
const evt = events[i];
if (
@@ -878,9 +880,13 @@ export function useChat(options: UseChatOptions = {}) {
: normalizeChatToolName(evt.pendingTool?.name || '') === normalizedEndName)
) {
updatedEvents[i] = { type: 'tool', tool: newToolCall, toolId: data.id };
+ replacedPendingTool = true;
break;
}
}
+ if (!replacedPendingTool) {
+ updatedEvents.push({ type: 'tool', tool: newToolCall, toolId: data.id });
+ }
}
// Also remove from pendingApprovals if present