Add live-streaming tool boxes with per-call state#4
Merged
Conversation
Tool execution is now rendered as a Unicode box that opens on tool_execution_start and streams stdout line-by-line as pi emits tool_execution_update snapshots. The box closes on end with a green ✓ / red ✗ status, elapsed time, and line count. Parallel tool calls (model issues multiple bash calls in one turn) are handled via a per-toolCallId state map and a FIFO queue: only one box streams live at a time; others accumulate output silently and flush in order when their predecessor closes. - event: add ToolCallID field (toolCallId from pi's RPC events) - render: replace single-box state with tools map + activeID/queue - ToolExecStart(id, name, args) opens or queues a box - ToolExecUpdate(id, snapshot) delta-streams complete lines - ToolExecEnd(id, isErr, fullText) closes box, promotes next - full output — no truncation - cli: wire tool_execution_update; drop toolcall_end render (execution box makes it redundant) - ansi: swap BoldBlue/BoldYellow for BoldCyan/DimCyan/BoldGreen/BoldRed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
┌─ ⚡ bash ─ <cmd>on start,│ <line>per streamed line,└─ ✓/✗ bash (1.2s, N lines)on endtool_execution_updatesnapshots (delta-decoded, line-buffered)toolCallIdstate map + FIFO queue — one box streams live, others flush in order when their predecessor closestoolcall_endrendering dropped (execution box covers it)Test Plan
go test -race ./...— 41/41 pass, race-freegolangci-lint run— cleanpi-stream -t bash "run two bash commands: echo hello then echo world"— two clean sequential boxespi-stream -t bash "seq 1 5 with 0.3s sleep"— lines appear progressively inside box