fix: show streaming progress for large tool inputs instead of stuck Preparing write#16024
fix: show streaming progress for large tool inputs instead of stuck Preparing write#16024guazi04 wants to merge 3 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR: This PR appears related because it also deals with streaming tool arguments, which is the core mechanism being enhanced in PR #16024 to provide real-time progress feedback during large tool input transmission. No duplicate PRs were found that address the same issue of showing streaming progress for large tool inputs. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Thanks for flagging #10925! The two PRs touch the same
They could potentially be combined, but this PR is specifically focused on the UX side of #11112 (showing progress instead of a stuck "Preparing write..." message). |
d1696f5 to
a319cc6
Compare
…reparing write... Process tool-input-delta events in the session processor to provide real-time progress feedback when AI writes large files. Previously, the TUI showed a static "Preparing write..." message for minutes while waiting for the full JSON argument to arrive (affected by proxy buffering). Changes: - Reorder write tool schema to emit filePath before content - Handle tool-input-delta events with throttled progress updates - Extract filePath early via regex scanning of partial JSON - Track received bytes and display progress in TUI (Write/Edit/Patch) - Add received field to ToolStatePending type - Clean up accumulators on tool-call and tool-input-end events Closes anomalyco#11112
a319cc6 to
8d34fea
Compare
…e test The test was checking if #review-panel was removed from the DOM when closed, but this element is a shared container that stays in the DOM as long as either the review panel OR file tree is open (per session-side-panel.tsx line 49). The aria-expanded attribute already correctly verifies the toggle state, so the redundant DOM count checks are unnecessary and cause false failures. Fixes blocking issue on CI for all PRs.
Issue for this PR
Closes #11112
Type of change
What does this PR do?
When AI writes large files (100KB+), the TUI shows a static "Preparing write..." message for minutes while waiting for the complete JSON argument to arrive. This is caused by HTTP proxies buffering the SSE stream (the JSON-escaped tool content has no real newlines to trigger proxy flushes). The
tool-input-deltaevents were completely ignored inprocessor.ts(no-opbreak), so the UI had no way to show progress.This PR processes
tool-input-deltaevents to provide streaming progress:processor.ts: Accumulates delta bytes per tool call, extracts
filePathearly via regex on partial JSON (capped at 8KB scan buffer), and throttle-updates the part state (every 500ms or 16KB). JSON-escaped paths are properly decoded. Accumulators are cleaned up on bothtool-input-endandtool-callevents to prevent leaks on abnormal termination.write.ts: Reordered schema to put
filePathbeforecontent, nudging models to emit it first for earlier extraction.TUI: Write/Edit/ApplyPatch components now show dynamic progress — e.g. "Preparing write… (64KB)" or "Write src/foo.ts (receiving… 128KB)" instead of a static message.
message-v2.ts: Added optional
receivedfield toToolStatePendingfor byte count tracking.The fix is best-effort: if regex extraction fails, it degrades to showing byte count only; if no deltas arrive at all, it falls back to the original static message. Tool execution is unchanged — still waits for complete JSON via
tool-callevent.Note: PR #10925 also handles
tool-input-deltaby populatingstate.rawwith full accumulated args. Our approach differs — we avoid storing the large raw string and instead extract only small metadata (filePath + byte count) for UI progress. These could potentially be combined.How did you verify your code works?
tsc --noEmitand CI typecheck pass)Screenshots / recordings
N/A — this is a streaming progress indicator that only manifests with real LLM tool calls behind proxied connections. The TUI change is purely text-based (no layout changes).
Checklist