feat: make AI chat tool use blocks expandable with input/output details

Tool call blocks in AI Chat are now clickable and expandable to show
tool name, input parameters (pretty-printed JSON), and output/result.
Collapsed by default, keyboard accessible (Tab/Enter/Space/Esc).

Backend: Rust stream events now carry tool input (accumulated from
input_json_delta chunks) and tool output (from tool_result events).
Frontend: AiActionCard is a disclosure widget with aria-expanded,
error output shown in red, long content truncated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Test
2026-03-03 21:08:48 +01:00
parent ba7d2f1acc
commit ceee8b04ea
7 changed files with 597 additions and 89 deletions

View File

@@ -24,15 +24,16 @@ export function buildAgentSystemPrompt(vaultContext?: string): string {
type ClaudeAgentStreamEvent =
| { kind: 'Init'; session_id: string }
| { kind: 'TextDelta'; text: string }
| { kind: 'ToolStart'; tool_name: string; tool_id: string }
| { kind: 'ToolDone'; tool_id: string }
| { kind: 'ToolStart'; tool_name: string; tool_id: string; input?: string }
| { kind: 'ToolDone'; tool_id: string; output?: string }
| { kind: 'Result'; text: string; session_id: string }
| { kind: 'Error'; message: string }
| { kind: 'Done' }
export interface AgentStreamCallbacks {
onText: (text: string) => void
onToolStart: (toolName: string, toolId: string) => void
onToolStart: (toolName: string, toolId: string, input?: string) => void
onToolDone: (toolId: string, output?: string) => void
onError: (message: string) => void
onDone: () => void
}
@@ -65,7 +66,10 @@ export async function streamClaudeAgent(
callbacks.onText(data.text)
break
case 'ToolStart':
callbacks.onToolStart(data.tool_name, data.tool_id)
callbacks.onToolStart(data.tool_name, data.tool_id, data.input)
break
case 'ToolDone':
callbacks.onToolDone(data.tool_id, data.output)
break
case 'Error':
callbacks.onError(data.message)