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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Show skipped Assistant tools in transcript
rcourtmanb04a7f593891
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 3461ab9071..1a775919af 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -475,8 +475,9 @@ runtime cost control, and shared AI transport surfaces.may short-circuit an explicit local fixture prompt only when`import.meta.env.DEV` or test mode is active, and the fixture must emit thesame typed `StreamEvent` objects (`session`, `workflow_state`, `thinking`,- `tool_start`, `tool_progress`, `tool_end`, `content`, `done`) through the- normal `useChat` reducer rather than rendering a separate mock transcript.+ `tool_start`, `tool_progress`, `tool_cancel`, `tool_end`, `content`,+ `done`) through the normal `useChat` reducer rather than rendering a+ separate mock transcript.This fixture is a local development primitive, not a product mode: it mustnot bypass backend governance in production, persist as a server session, orintroduce any UI-only event shape that real providers cannot emit.@@ -696,10 +697,19 @@ runtime cost control, and shared AI transport surfaces.replaces that row rather than appending a delayed batch of steps. Waitinguntil `[DONE]`, `message_stop`, or execution completion recreates thedelayed 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. 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.+ placeholder attempts remain governed by the runtime and may resolve the+ pending row into a durable skipped `tool_cancel` row instead of either+ persisting a failed tool card or hiding the activity. If a terminal+ `tool_end` or `tool_cancel` reaches the browser without a matching pending+ row, the frontend must still append terminal tool evidence instead of+ dropping the only visible activity. The 2026-06-07 Pulse slice rechecked+ OpenCode `origin/dev` commit+ `1025540fcc2a69609a0131a7168300205656d728`, where+ `packages/core/src/session/event.ts` and+ `packages/core/src/session/message-updater.ts` keep tool lifecycle events as+ typed message parts through terminal success/failed states; Pulse adapts+ that lifecycle shape by making skipped policy/runtime tool calls visible as+ terminal transcript rows.While streamed arguments are still invalid, incomplete JSON, or incompleteprovider-style function-call input, the frontend must use the `raw_input`fragment to show a safe partial command/path/query summary instead of adiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 2a41e91cb1..ea23f1df83 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -555,13 +555,16 @@ payload shape change when the portal presents compact client rows.mode, only for reserved `/fixture ...` prompts, and only by calling thenormal `AIChatAPI.chat` event callback with the generated`AIChatStreamEvent` union (`session`, `workflow_state`, `thinking`,- `tool_start`, `tool_progress`, `tool_end`, `content`, `done`). It must not- open a backend session, mutate persisted chat history, add browser-only- stream event shapes, or become a production fallback for provider or VPN- failures. At least one fixture-backed Assistant tool sequence must exercise- the OpenCode-parity raw tool-input path by starting with incomplete- provider-style `raw_input`, then mutating the same tool row with completed- arguments through the normal `tool_progress` event.+ `tool_start`, `tool_progress`, `tool_cancel`, `tool_end`, `content`,+ `done`). It must not open a backend session, mutate persisted chat history,+ add browser-only stream event shapes, or become a production fallback for+ provider or VPN failures. At least one fixture-backed Assistant tool+ sequence must exercise the OpenCode-parity raw tool-input path by starting+ with incomplete provider-style `raw_input`, then mutating the same tool row+ with completed arguments through the normal `tool_progress` event.+ At least one fixture-backed Assistant tool sequence must exercise the+ skipped-tool lifecycle by resolving a visible `tool_start` row through+ `tool_cancel` instead of hiding the activity.34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.Legacy Assistant SSE routes in this handler that still use the olderexecute envelope, including `/api/ai/execute/stream` anddiff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex 1da6917ac9..9b9c6c7701 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -149,6 +149,51 @@ describe('AIChatAPI', () => {});});+ it('runs the skipped-tool dev stream fixture without opening a provider request', async () => {+ const onEvent = vi.fn();++ await AIChatAPI.chat(+ '/fixture skipped-tool',+ undefined,+ 'openrouter:deepseek/deepseek-chat',+ onEvent,+ );++ expect(apiFetchMock).not.toHaveBeenCalled();+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual([+ 'session',+ 'workflow_state',+ 'tool_start',+ 'tool_cancel',+ 'content',+ 'done',+ ]);+ expect(onEvent.mock.calls[2][0]).toMatchObject({+ type: 'tool_start',+ data: {+ id: 'fixture-tool-skipped',+ name: 'pulse_read',+ input: expect.stringContaining('current_resource'),+ raw_input: expect.stringContaining('ls /dev | wc -l'),+ },+ });+ expect(onEvent.mock.calls[3][0]).toMatchObject({+ type: 'tool_cancel',+ data: {+ id: 'fixture-tool-skipped',+ name: 'pulse_read',+ reason: 'current_resource unavailable',+ },+ });+ expect(onEvent.mock.calls[5][0]).toMatchObject({+ type: 'done',+ data: {+ session_id: 'dev-fixture-skipped-tool',+ model: 'openrouter:deepseek/deepseek-chat',+ },+ });+ });+it('lets the browser paint the first visible text delta before draining a coalesced chat chunk', async () => {vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });const requestAnimationFrame = installAnimationFrame();diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.tsindex 38bce69212..d32c1d56df 100644--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts@@ -3,6 +3,7 @@ import type { AIChatStreamEvent } from './generated/aiChatEvents';export const AI_CHAT_DEV_STREAM_FIXTURE_PROMPTS = ['/fixture devices','/fixture assistant-stream',+ '/fixture skipped-tool',] as const;const DEFAULT_DEV_FIXTURE_STEP_DELAY_MS = 140;@@ -141,6 +142,62 @@ const buildDeviceCountFixtureEvents = (model?: string): AIChatStreamEvent[] => [},];+const buildSkippedToolFixtureEvents = (model?: string): AIChatStreamEvent[] => [+ {+ type: 'session',+ data: { id: 'dev-fixture-skipped-tool' },+ },+ {+ type: 'workflow_state',+ data: {+ phase: 'request_start',+ message: 'Preparing Pulse context.',+ },+ },+ {+ type: 'tool_start',+ data: {+ id: 'fixture-tool-skipped',+ name: 'pulse_read',+ input:+ '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ raw_input:+ 'pulse_read(target_host="current_resource", command="ls /dev | wc -l")',+ },+ },+ {+ type: 'tool_cancel',+ data: {+ id: 'fixture-tool-skipped',+ name: 'pulse_read',+ reason: 'current_resource unavailable',+ },+ },+ {+ type: 'content',+ data: {+ text: 'I could not inspect the current resource because no resource context was attached to this chat turn.',+ },+ },+ {+ type: 'done',+ data: {+ session_id: 'dev-fixture-skipped-tool',+ model: assistantFixtureModel(model),+ input_tokens: 41,+ output_tokens: 27,+ },+ },+];++const buildFixtureEvents = (prompt: string, model?: string): AIChatStreamEvent[] => {+ const normalized = normalizeFixturePrompt(prompt);+ if (normalized === '/fixture skipped-tool') {+ return buildSkippedToolFixtureEvents(model);+ }+ return buildDeviceCountFixtureEvents(model);+};+export const maybeRunAIChatDevStreamFixture = async (options: AIChatDevStreamFixtureOptions,): Promise<boolean> => {@@ -153,7 +210,7 @@ export const maybeRunAIChatDevStreamFixture = async ((import.meta.env.MODE === 'test'? TEST_FIXTURE_STEP_DELAY_MS: DEFAULT_DEV_FIXTURE_STEP_DELAY_MS);- const events = buildDeviceCountFixtureEvents(options.model);+ const events = buildFixtureEvents(options.prompt, options.model);for (let index = 0; index < events.length; index += 1) {const event = events[index];diff --git a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsxindex e036d92041..694a6acbe2 100644--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx@@ -97,6 +97,15 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {textActivityFingerprint(event.tool?.rawInput),textActivityFingerprint(event.tool?.output),].join(':');+ case 'tool_cancel':+ return [+ ...base,+ event.toolCancel?.id,+ event.toolCancel?.name,+ textActivityFingerprint(event.toolCancel?.input),+ textActivityFingerprint(event.toolCancel?.rawInput),+ textActivityFingerprint(event.toolCancel?.reason),+ ].join(':');case 'content':return [...base, textActivityFingerprint(event.content)].join(':');case 'thinking':diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsxindex bd2c85af9f..8a89308780 100644--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx@@ -19,7 +19,7 @@ import RotateCcwIcon from 'lucide-solid/icons/rotate-ccw';import SparklesIcon from 'lucide-solid/icons/sparkles';import XIcon from 'lucide-solid/icons/x';import { renderMarkdown } from '../aiChatUtils';-import { PendingToolBlock, ToolExecutionBlock } from './ToolExecutionBlock';+import { PendingToolBlock, ToolCancellationBlock, ToolExecutionBlock } from './ToolExecutionBlock';import { ApprovalCard } from './ApprovalCard';import { QuestionCard } from './QuestionCard';import { ThinkingBlock } from './ThinkingBlock';@@ -276,6 +276,8 @@ export const MessageItem: Component<MessageItemProps> = (props) => {return !!evt.tool;case 'pending_tool':return !!evt.pendingTool;+ case 'tool_cancel':+ return !!evt.toolCancel;case 'model_switch':return !!evt.model?.trim();case 'approval':@@ -304,6 +306,8 @@ export const MessageItem: Component<MessageItemProps> = (props) => {return !!evt.tool;case 'pending_tool':return !!evt.pendingTool;+ case 'tool_cancel':+ return !!evt.toolCancel;case 'model_switch':return !!evt.model?.trim();case 'approval':@@ -613,6 +617,10 @@ export const MessageItem: Component<MessageItemProps> = (props) => {<PendingToolBlock tool={evt.pendingTool!} /></Match>+ <Match when={evt.type === 'tool_cancel' && evt.toolCancel}>+ <ToolCancellationBlock tool={evt.toolCancel!} />+ </Match>+<Match when={evt.type === 'tool' && evt.tool}><ToolExecutionBlockstartedAt={evt.startedAt}diff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsxindex 6ca9e337f0..5534c731dc 100644--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx@@ -15,7 +15,7 @@ import ClockIcon from 'lucide-solid/icons/clock';import CopyIcon from 'lucide-solid/icons/copy';import LoaderCircleIcon from 'lucide-solid/icons/loader-circle';import XCircleIcon from 'lucide-solid/icons/x-circle';-import type { ToolExecution, PendingTool } from './types';+import type { ToolExecution, PendingTool, ToolCancellation } from './types';import { copyToClipboard } from '@/utils/clipboard';import { getToolCallResultTextClass } from '@/utils/patrolRunPresentation';import {@@ -42,6 +42,10 @@ interface ToolCommandPreviewProps {preview: string;}+interface ToolCancellationBlockProps {+ tool: ToolCancellation;+}+const hasReadableToolOutput = (output: string) => {const trimmed = output.trim();return trimmed.length > 0 && !trimmed.toLowerCase().includes('not available');@@ -458,6 +462,64 @@ export const PendingToolBlock: Component<PendingToolBlockProps> = (props) => {);};+/**+ * ToolCancellationBlock - Durable row for tool calls skipped by policy/runtime boundaries.+ */+export const ToolCancellationBlock: Component<ToolCancellationBlockProps> = (props) => {+ const toolLabel = createMemo(() => getToolLabel(props.tool.name));+ const inputText = createMemo(() => toolValueText(props.tool.input));+ const parsedInputSummary = createMemo(() =>+ parseToolInputSummary(inputText(), props.tool.name, props.tool.rawInput),+ );+ const inputSummary = createMemo(() => {+ const summary = parsedInputSummary();+ return isPlaceholderToolInputSummary(summary) ? pendingToolActionLabel(props.tool.name) : summary;+ });+ const commandPreview = createMemo(() => {+ const preview = parseToolCommandPreview(inputText(), props.tool.name, props.tool.rawInput);+ const summary = inputSummary().trim();+ if (!preview || summary.startsWith('$ ') || preview === summary) return '';+ return preview;+ });+ const reason = createMemo(() => props.tool.reason?.trim() || 'Skipped before execution');++ return (+ <div+ class="my-1 rounded-md border border-amber-200 bg-amber-50/70 px-2.5 py-2 text-[11px] dark:border-amber-900/60 dark:bg-amber-950/20"+ role="status"+ aria-label="Assistant tool canceled"+ title={reason()}+ >+ <div class="flex min-w-0 items-start gap-2">+ <div class="pt-0.5">+ <XCircleIcon+ class="h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-300"+ aria-label="skipped"+ />+ </div>++ <div class="min-w-0 flex-1">+ <div class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">+ <span class="shrink-0 font-mono text-[9px] font-semibold uppercase tracking-wider text-muted">+ {toolLabel()}+ </span>+ <span class="shrink-0 rounded border border-amber-200 bg-amber-100 px-1.5 py-0.5 text-[9px] font-medium text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200">+ skipped+ </span>+ </div>+ <ToolInputSummary summary={inputSummary()} />+ <Show when={commandPreview()}>+ <ToolCommandPreview preview={commandPreview()} />+ </Show>+ <div class="mt-1 min-w-0 text-[10px] leading-snug text-muted">+ <span class="block whitespace-pre-wrap break-words">{reason()}</span>+ </div>+ </div>+ </div>+ </div>+ );+};+/*** PendingToolsList - Groups multiple pending tools into a compact list*/diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsxindex b7f99db69c..7b79606386 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx@@ -29,6 +29,16 @@ vi.mock('../ToolExecutionBlock', () => ({{props.tool.input}</div>),+ ToolCancellationBlock: (props: {+ tool: { name: string; input: string; reason?: string };+ }) => (+ <div role="status" aria-label="Assistant tool canceled">+ <span>{props.tool.name.replace(/^pulse_/, '')}</span>+ <span>skipped</span>+ <span>Inspect devices on current resource</span>+ <span>{props.tool.reason}</span>+ </div>+ ),ToolExecutionBlock: (props: {tool: { name: string; input: string; output: string; success: boolean };startedAt?: number;@@ -974,6 +984,35 @@ describe('MessageItem', () => {expect(block).toHaveAttribute('data-completed-at', '4200');});+ it('renders canceled tool activity as a skipped transcript row', () => {+ const events: StreamDisplayEvent[] = [+ {+ type: 'tool_cancel',+ toolId: 'tool-1',+ toolCancel: {+ id: 'tool-1',+ name: 'pulse_read',+ input:+ '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ reason: 'current_resource unavailable',+ },+ },+ ];++ render(() => (+ <MessageItem+ message={makeMessage({ role: 'assistant', content: '', streamEvents: events })}+ {...makeHandlers()}+ />+ ));++ const row = screen.getByRole('status', { name: 'Assistant tool canceled' });+ expect(row).toHaveTextContent('read');+ expect(row).toHaveTextContent('skipped');+ expect(row).toHaveTextContent('Inspect devices on current resource');+ expect(row).toHaveTextContent('current_resource unavailable');+ });+it('does not render tool block when tool property is undefined', () => {render(() => (<MessageItemdiff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsxindex de9021f8b2..2b1b7dadc9 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx@@ -4,6 +4,7 @@ import { afterEach } from 'vitest';import {ToolExecutionBlock,PendingToolBlock,+ ToolCancellationBlock,PendingToolsList,ToolExecutionsList,} from '../ToolExecutionBlock';@@ -834,6 +835,28 @@ describe('PendingToolBlock', () => {});});+describe('ToolCancellationBlock', () => {+ it('renders skipped tool activity with the cancellation reason', () => {+ render(() => (+ <ToolCancellationBlock+ tool={{+ id: 'tool-1',+ name: 'pulse_read',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ reason: 'current_resource unavailable',+ }}+ />+ ));++ expect(screen.getByRole('status', { name: 'Assistant tool canceled' })).toHaveTextContent(+ 'skipped',+ );+ expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc -l');+ expect(screen.getByText('current_resource unavailable')).toBeInTheDocument();+ });+});+// ============================================================// PendingToolsList// ============================================================diff --git a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.tsindex 77fcbe4503..4e2810b0d4 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/activeTurnStatus.test.ts@@ -428,6 +428,49 @@ describe('getAssistantActiveTurnStatus', () => {});});+ it('surfaces skipped tool activity in the active turn status', () => {+ expect(+ getAssistantActiveTurnStatus(+ [+ assistantMessage({+ streamEvents: [+ {+ type: 'pending_tool',+ toolId: 'tool-1',+ pendingTool: {+ id: 'tool-1',+ name: 'pulse_read',+ input: '{}',+ status: 'pending',+ startedAt: 1_000,+ },+ startedAt: 1_000,+ updatedAt: 1_000,+ },+ {+ type: 'tool_cancel',+ toolId: 'tool-1',+ toolCancel: {+ id: 'tool-1',+ name: 'pulse_read',+ input: '{}',+ reason: 'current_resource unavailable',+ },+ startedAt: 1_000,+ updatedAt: 1_500,+ },+ ],+ }),+ ],+ true,+ ),+ ).toEqual({+ type: 'tool',+ text: 'Skipped read: current_resource unavailable',+ startedAt: 1_000,+ });+ });+it('carries question event timing into the active waiting status', () => {expect(getAssistantActiveTurnStatus(diff --git a/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.tsindex b5840d8159..22fcf2b472 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/transcriptExport.test.ts@@ -175,6 +175,41 @@ describe('Assistant transcript export', () => {expect(transcript).toContain('[model] using Qwen 3.7 Plus via OpenRouter');});+ it('includes canceled tool activity as skipped transcript evidence', () => {+ const transcript = formatAssistantTranscript({+ messages: [+ {+ id: 'assistant-1',+ role: 'assistant',+ content: '',+ timestamp,+ streamEvents: [+ {+ type: 'tool_cancel',+ toolId: 'tool-1',+ toolCancel: {+ id: 'tool-1',+ name: 'pulse_read',+ input: JSON.stringify({+ action: 'exec',+ target_host: 'current_resource',+ command: 'ls /dev | wc -l',+ }),+ reason: 'current_resource unavailable',+ },+ },+ ],+ },+ ],+ generatedAt: timestamp,+ });++ expect(transcript).toContain('[tool:read] Inspect devices on current resource');+ expect(transcript).toContain('skipped');+ expect(transcript).toContain('reason: current_resource unavailable');+ expect(transcript).not.toContain('ls /dev | wc -l');+ });+it('reports whether a transcript has content', () => {expect(hasAssistantTranscriptContent([])).toBe(false);expect(diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.tsindex a3824eb018..e6de394939 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts@@ -3307,7 +3307,7 @@ describe('useChat', () => {dispose();});- it('removes a canceled pending tool without adding a completed tool call', async () => {+ it('replaces a canceled pending tool with durable skipped activity', async () => {const { getFireEvent } = setupWithEventCapture();const { value: chat, dispose } = withRoot(() => useChat({ sessionId: 's' }));@@ -3333,6 +3333,19 @@ describe('useChat', () => {expect(assistant.streamEvents?.filter((event) => event.type === 'pending_tool')).toHaveLength(0,);+ expect(assistant.streamEvents?.filter((event) => event.type === 'tool_cancel')).toEqual([+ expect.objectContaining({+ type: 'tool_cancel',+ toolId: 'a',+ toolCancel: {+ id: 'a',+ name: 'pulse_read',+ input: '{}',+ rawInput: undefined,+ reason: 'current_resource unavailable',+ },+ }),+ ]);dispose();});});diff --git a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts b/frontend-modern/src/components/AI/Chat/activeTurnStatus.tsindex 7f12f8aa3e..8329e973a9 100644--- a/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts+++ b/frontend-modern/src/components/AI/Chat/activeTurnStatus.ts@@ -107,13 +107,21 @@ const activePendingToolFromEvents = (events?: StreamDisplayEvent[]): PendingToolreturn event.pendingTool;}}- if (event.type === 'tool') {+ if (event.type === 'tool' || event.type === 'tool_cancel') {for (const key of [event.toolId, event.tool?.name]) {const normalized = key?.trim();if (normalized) {completedToolKeys.add(normalized);}}+ if (event.type === 'tool_cancel') {+ for (const key of [event.toolCancel?.id, event.toolCancel?.name]) {+ const normalized = key?.trim();+ if (normalized) {+ completedToolKeys.add(normalized);+ }+ }+ }}}@@ -170,7 +178,7 @@ const eventActivityAt = (event: StreamDisplayEvent): number | undefined => {};const toolCompletionKeys = (event: StreamDisplayEvent): string[] =>- [event.toolId, event.tool?.name]+ [event.toolId, event.tool?.name, event.toolCancel?.id, event.toolCancel?.name].map((value) => value?.trim()).filter((value): value is string => !!value);@@ -197,6 +205,13 @@ const isFresherStatusCandidate = (return candidate.order >= current.order;};+const toolCancelStatusText = (event: StreamDisplayEvent): string => {+ const name = event.toolCancel?.name || event.pendingTool?.name;+ const label = formatToolName(name);+ const reason = event.toolCancel?.reason?.trim();+ return reason ? `Skipped ${label}: ${reason}` : `Skipped ${label}`;+};+const latestStreamActivityStatus = (events?: StreamDisplayEvent[],): AssistantActiveTurnStatusCandidate | null => {@@ -215,6 +230,19 @@ const latestStreamActivityStatus = (}break;}+ case 'tool_cancel': {+ for (const key of toolCompletionKeys(event)) {+ completedToolKeys.add(key);+ }+ candidate = {+ type: 'tool',+ text: toolCancelStatusText(event),+ startedAt: event.startedAt,+ activityAt: eventActivityAt(event),+ order: index,+ };+ break;+ }case 'pending_tool': {const keys = pendingToolKeys(event);if (!keys.some((key) => completedToolKeys.has(key))) {@@ -341,6 +369,7 @@ const hasVisibleAssistantOutput = (message: ChatMessage): boolean => {return (message.streamEvents || []).some((event) => {if (event.type === 'content') return !!event.content?.trim();if (event.type === 'tool') return !!event.tool;+ if (event.type === 'tool_cancel') return !!event.toolCancel;if (event.type === 'approval') return !!event.approval;if (event.type === 'question') return !!event.question;return false;diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.tsindex a86e3eaba0..3f44e536b0 100644--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts@@ -508,6 +508,52 @@ export function useChat(options: UseChatOptions = {}) {return updatedEvents;};+ const replacePendingToolWithCancelEvent = (+ events: StreamDisplayEvent[],+ canceledTool: PendingTool,+ reason: string | undefined,+ matchesTool: (tool?: PendingTool, toolId?: string) => boolean,+ now: number,+ ): StreamDisplayEvent[] => {+ let replacedEvent = false;+ const updatedEvents: StreamDisplayEvent[] = [];+ const cancelEvent = () =>+ withStreamEventTiming(+ {+ type: 'tool_cancel',+ toolId: canceledTool.id,+ toolCancel: {+ id: canceledTool.id,+ name: canceledTool.name,+ input: canceledTool.input,+ rawInput: canceledTool.rawInput,+ reason,+ },+ startedAt: canceledTool.startedAt,+ updatedAt: now,+ },+ now,+ );++ for (const event of events) {+ if (event.type !== 'pending_tool' || !matchesTool(event.pendingTool, event.toolId)) {+ updatedEvents.push(event);+ continue;+ }+ if (replacedEvent) {+ continue;+ }+ replacedEvent = true;+ updatedEvents.push(cancelEvent());+ }++ if (!replacedEvent) {+ updatedEvents.push(cancelEvent());+ }++ return updatedEvents;+ };+const upsertPendingToolStart = (msg: ChatMessage,data: {@@ -1171,6 +1217,7 @@ export function useChat(options: UseChatOptions = {}) {const data = event.data as {id?: string;name?: string;+ reason?: string;};const normalizedName = normalizeChatToolName(data.name || '');const matchesTool = (tool?: PendingTool, toolId?: string) => {@@ -1179,20 +1226,32 @@ export function useChat(options: UseChatOptions = {}) {if (data.id && tool.id === data.id) return true;return normalizedName !== '' && normalizeChatToolName(tool.name) === normalizedName;};+ const pendingTools = msg.pendingTools || [];+ const resolvedTool =+ pendingTools.find((tool) => matchesTool(tool, tool.id)) ||+ ({+ id: data.id || generateId(),+ name: data.name || 'unknown',+ input: '{}',+ startedAt: Date.now(),+ updatedAt: Date.now(),+ } satisfies PendingTool);+ const now = Date.now();return {...msg,workflowStatus: undefined,workflowStatusHistory: undefined,- pendingTools: (msg.pendingTools || []).filter(- (tool) => !matchesTool(tool, tool.id),- ),- streamEvents: (- streamEventsWithoutWorkflowStatusRows(msg.streamEvents || []) || []- ).filter(- (streamEvent) =>- streamEvent.type !== 'pending_tool' ||- !matchesTool(streamEvent.pendingTool, streamEvent.toolId),+ pendingTools: pendingTools.filter((tool) => !matchesTool(tool, tool.id)),+ streamEvents: replacePendingToolWithCancelEvent(+ streamEventsWithoutWorkflowStatusRows(msg.streamEvents || []) || [],+ {+ ...resolvedTool,+ updatedAt: now,+ },+ data.reason?.trim() || undefined,+ matchesTool,+ now,),};}diff --git a/frontend-modern/src/components/AI/Chat/transcriptExport.ts b/frontend-modern/src/components/AI/Chat/transcriptExport.tsindex feaee22f55..e47e55922d 100644--- a/frontend-modern/src/components/AI/Chat/transcriptExport.ts+++ b/frontend-modern/src/components/AI/Chat/transcriptExport.ts@@ -4,6 +4,7 @@ import type {PendingQuestion,PendingTool,StreamDisplayEvent,+ ToolCancellation,ToolExecution,WorkflowStatus,} from './types';@@ -117,6 +118,17 @@ const formatPendingTool = (tool: PendingTool): string => {]);};+const formatCanceledTool = (tool: ToolCancellation): string => {+ const label = getToolLabel(tool.name);+ const parsedSummary = formatToolInputSummary(tool.name, tool.input, tool.rawInput);+ const summary = parsedSummary || pendingToolActionLabel(tool.name);+ return compactText([+ `[tool:${label}] ${summary}`,+ 'skipped',+ tool.reason?.trim() ? `reason: ${tool.reason.trim()}` : undefined,+ ]);+};+const formatWorkflowStatus = (status?: WorkflowStatus): string => {const message = formatAssistantWorkflowStatus(status).trim();return message ? `[status] ${message}` : '';@@ -162,6 +174,8 @@ const hasRenderableEvent = (event: StreamDisplayEvent, includeThinking = false):return Boolean(event.tool);case 'pending_tool':return Boolean(event.pendingTool);+ case 'tool_cancel':+ return Boolean(event.toolCancel);case 'content':return Boolean(visibleContentEvent(event));case 'model_switch':@@ -248,6 +262,11 @@ const appendAssistantStreamEvents = (pendingToolAppended = true;}break;+ case 'tool_cancel':+ if (event.toolCancel) {+ appendBlock(lines, formatCanceledTool(event.toolCancel));+ }+ break;case 'model_switch':appendBlock(lines, formatModelSwitch(event, options.getModelRouteLabel));break;diff --git a/frontend-modern/src/components/AI/Chat/types.ts b/frontend-modern/src/components/AI/Chat/types.tsindex 351b7d4379..841e756369 100644--- a/frontend-modern/src/components/AI/Chat/types.ts+++ b/frontend-modern/src/components/AI/Chat/types.ts@@ -25,6 +25,14 @@ export interface PendingTool {updatedAt?: number;}+export interface ToolCancellation {+ id: string;+ name: string;+ input: string;+ rawInput?: string;+ reason?: string;+}+export interface PendingApproval {command: string;toolId: string;@@ -100,6 +108,7 @@ export type StreamEventType =| 'tool'| 'content'| 'pending_tool'+ | 'tool_cancel'| 'model_switch'| 'approval'| 'question';@@ -112,6 +121,7 @@ export interface StreamDisplayEvent {updatedAt?: number;tool?: ToolExecution;pendingTool?: PendingTool;+ toolCancel?: ToolCancellation;content?: string;model?: string;failedModel?: string;diff --git a/frontend-modern/src/types/ai.ts b/frontend-modern/src/types/ai.tsindex 25b93d6221..2840c32259 100644--- a/frontend-modern/src/types/ai.ts+++ b/frontend-modern/src/types/ai.ts@@ -215,6 +215,7 @@ export interface AIExecuteResponse {export type AIStreamEventType =| 'tool_start'| 'tool_progress'+ | 'tool_cancel'| 'tool_end'| 'content'| 'thinking'@@ -237,6 +238,12 @@ export interface AIStreamToolProgressData {message?: string;}+export interface AIStreamToolCancelData {+ id: string;+ name: string;+ reason?: string;+}+export interface AIStreamToolEndData {name: string;input: string;@@ -296,6 +303,7 @@ export interface AIStreamEvent {| string| AIStreamToolStartData| AIStreamToolProgressData+ | AIStreamToolCancelData| AIStreamToolEndData| AIStreamCompleteData| AIStreamApprovalNeededDatadiff --git a/internal/ai/chat/types.go b/internal/ai/chat/types.goindex 8024328dec..d54bf602ea 100644--- a/internal/ai/chat/types.go+++ b/internal/ai/chat/types.go@@ -313,8 +313,8 @@ type ToolProgressData struct {}// ToolCancelData is the data for "tool_cancel" events.-// It removes a pending tool row when a model-selected call is consumed by an-// internal policy boundary instead of becoming user-visible tool execution.+// It marks a pending tool row as skipped when a model-selected call is consumed+// by an internal policy boundary instead of becoming user-visible execution.type ToolCancelData struct {ID string `json:"id"`Name string `json:"name"`