Repository navigation
fix: keep a streaming tool call's pill running until it returns - #47882
winnythedev wants to merge 1 commit into
Conversation
A shell command's streamed stdout reaches the dashboard as tool_result frames with final: false. The reducer stores the output so far and marks the entry output_partial, but toolReturned() counted any entry with output as returned. The pill's done test reads it, so the spinner, shimmer and "Running" line went away at the first streamed line while the command still ran. toolReturned() now treats output marked partial as not returned. A final frame, a frame from an older gateway with no final field, and a call that returned while unwatched still count as returned. A Stop while a call streams now marks that call stopped, the same as a call with no output, and its streamed output stays on the card. Fixes #47858
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix sits in the one shared Notes
[DESIGN-REVIEWED] bdd7a79 Description read[DESCRIPTION-READ] 48cd9bb92ec7822a1f035cb38265edaf37b039b8756a72e646f6561a2cb06522 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS No control, label or visual state is added or changed. The fix only holds an existing pill in its existing running state until the final frame arrives, so a missing screenshot leaves no gap. Notes
[UX-REVIEWED] bdd7a79 Description read[DESCRIPTION-READ] 2408d99b58453a232f5965efdc6ca40027e27ec6e1c7d54c9fcc250c66a525f9 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is in the shared Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: a person running a long shell command from chat sees its pill stay "running" until the command actually returns. This is a FIX (#47858).
[FIRST-PRINCIPLES-REVIEWED] bdd7a79 Description read[DESCRIPTION-READ] 335af3df45fd5db1243e0f5ddcbe4e70f78ffac3d56c9cbed2fa17869cb8b799 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Problem / Motivation
Goal: A shell command's tool pill keeps its running state until the command returns, instead of reading done at its first streamed output.
In an open chat, a shell command's tool pill turns from the running spinner to the green done dot as soon as the command prints its first line. The shimmer and the shell's "Running · Ns" line go away too, so a long build or test run reads as finished seconds after it started. The kiro and claude adapters both stream a running command's output this way (the recorded frames under
test/fixtures/acp_frames/show it).Why it matters
Anyone who runs a long command from chat (a build, a test suite, an install) is told it is done while it still runs. They read a partial result as the final one, or start the next step too early. The footer and the status line already know the call is still running, so the pill contradicts them on the same screen.
Not a goal
markEntryReturnedor the reconnect settle path.&& !output_partialchecks inChatFooter.tsxandhooks/websocket/chatStream.ts.What changed (motivation → approach → change)
Symptom: the pill reads done at the first streamed line. Root cause: the gateway sends a running command's stdout as
tool_resultframes withfinal: false(dashboard/chat_turn/tool_results.py,"final": bool(_tool_terminal)). ThesseToolResultreducer (website/src/store/chat/activity.ts) stores the output so far and marks the entryoutput_partial = true.toolReturned()(website/src/utils/toolReturned.ts) answered "returned" for any entry with output, and the pill's done test (ToolCallLine.tsxisDone, plus the merged edit-run member check) reads it. The footer and the stream hook already add&& !output_partialthemselves, which shows the shared helper was meant to treat partial output as not returned.Change:
toolReturned()now treats output marked partial as not returned:e.output_partial === false || (e.output != null && e.output_partial !== true). Its doc comment says so. One shared helper fixes every reader at once, so no caller gets a second partial-output check.What a person sees now:
finalfield, and a parallel call that returned still settle as before.clearPendingPermissionsinstore/chat/messages.tsreads!toolReturned). A call with no output yet already gets this today. Its streamed output still shows on the stopped card; the new test checks that.Backwards compatibility
Compatible: a result frame without a
finalfield (an older gateway) still counts as returned, and a call marked returned while unwatched (output_partial === false, no output) still counts as returned. Only a frame the server marksfinal: falsereads differently.Removes nothing: the diff narrows when one predicate answers true for a still-running call; no path, record, key or function is removed.
Tests
website/src/test/ToolCallLine.streamedOutputRunning.test.tsx(new, 8 cases) renders the realToolCallLinewith the real reducers and feeds the frames the server writes:finalfield (older gateway) settles the pillProof: not provable -- frontend test (prove.py runs Python only). By hand, same command on both trees: base 6 failed, 2 passed (8); head 8 passed (8).
Related inputs run on the head: every test file naming
toolReturned,output_partial,clearPendingPermissionsorsseToolResult, plus theToolCallLine,ChatFooter,TurnBlock,editRunsandtoolPillAfterReconnectfiles, andCarriedMockAnswerRatchetwith thechatSlice.ownershipguard: 44 files, 1,259 tests passed.test/test_flake_pattern_ratchet.py: 81 passed. eslint on both files: clean.npm run build: passed. semgrep 1.78.0 with--baseline-commit: clean.The full
npm run testsuite was started locally but did not finish in time (4,953 files on this host); CI runs it.Review (multi-model interrogate)
Two independent reviewers read the full diff against the CI lane contracts, and one more re-checked the final rebased diff.
!output_partialchecks are now redundant; kept to hold the change to the helper.Manual verification
No live dashboard run and no gateway were started; the vitest cases drive the real pill and reducers with the frames the server writes.
Real-machine verification
Machine: own computer, Linux x86_64.
Before (main a3b6d94):
cd website && npx vitest run src/test/ToolCallLine.streamedOutputRunning.test.tsx --coverage.enabled=false->Tests 6 failed | 2 passed (8)(expected +0 to be 1on the spinner count).After (head, same command):
Tests 8 passed (8).Cleanup: own computer; no browser run, no gateway and no dashboard token.
Screenshots / video
Why no screenshot: No layout, colour or component changes; the pill shows its existing running state for longer, which the eight vitest cases above pin state by state.
Related Issues
Fixes #47858
Interplay: #47861 (a cancelled call's pill revived by a later recovery turn) is queued separately and will add a turn-end settle that calls
toolReturned; it has no PR yet. Open PR #47300 also touchesToolCallLine.tsx(it drops the unusedrunningprop, which this test passes); whichever lands second rebases.Sibling sweep
Swept:
git grep -n -e toolReturned -e output_partial website/srcSibling: website/src/pages/chat/ChatFooter.tsx -- not affected -- already adds its own partial check, result unchanged
Sibling: website/src/hooks/websocket/chatStream.ts -- not affected -- already adds its own partial check, result unchanged
Sibling: website/src/store/chat/messages.ts -- changed here -- a Stop mid-stream now marks the call stopped, through the helper
Sibling: website/src/pages/chat/ToolCallLine.tsx -- changed here -- both done tests read the fixed helper
Pattern harvest
Not generalizable: one shared predicate ignored a flag its own writer sets; it is fixed in that one helper, and no other reader decides return on its own.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.