Skip to content

fix: keep a streaming tool call's pill running until it returns - #47882

Open
winnythedev wants to merge 1 commit into
mainfrom
fix/47858-streamed-pill-done
Open

winnythedev wants to merge 1 commit into
mainfrom
fix/47858-streamed-pill-done

Conversation

@winnythedev

Copy link
Copy Markdown
Contributor

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

  • Changing the server, the frames it sends, or the tool-stall watchdog.
  • Changing markEntryReturned or the reconnect settle path.
  • Removing the now-redundant && !output_partial checks in ChatFooter.tsx and hooks/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_result frames with final: false (dashboard/chat_turn/tool_results.py, "final": bool(_tool_terminal)). The sseToolResult reducer (website/src/store/chat/activity.ts) stores the output so far and marks the entry output_partial = true. toolReturned() (website/src/utils/toolReturned.ts) answered "returned" for any entry with output, and the pill's done test (ToolCallLine.tsx isDone, plus the merged edit-run member check) reads it. The footer and the stream hook already add && !output_partial themselves, 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:

  • A call whose output is still streaming keeps the spinner, shimmer and "Running · Ns" line until its final frame, or until its turn ends.
  • A final frame, a result from an older gateway with no final field, and a parallel call that returned still settle as before.
  • A pane showing a background chat behaves the same way.
  • A Stop while a call streams now marks that call stopped (clearPendingPermissions in store/chat/messages.ts reads !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 final field (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 marks final: false reads 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 real ToolCallLine with the real reducers and feeds the frames the server writes:

  • one mid-stream frame keeps the spinner; two mid-stream frames keep it
  • a final frame after streamed frames settles the pill
  • a frame with no final field (older gateway) settles the pill
  • two parallel calls, one returned and one streaming: only the streaming one spins
  • a pane showing a background slot keeps the spinner
  • a Stop mid-stream shows the stopped icon, not the green dot, and the streamed output is still in the card's details
  • the turn ending while the call still streams settles the pill

Proof: 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, clearPendingPermissions or sseToolResult, plus the ToolCallLine, ChatFooter, TurnBlock, editRuns and toolPillAfterReconnect files, and CarriedMockAnswerRatchet with the chatSlice.ownership guard: 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 test suite 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.

  • Found: one Low and two Nits, no security findings; both reviews said ship.
  • Dismissed (Low): a Stop while a call streams leaves it stopped even if its completed frame arrives afterwards. A call with no output already behaves this way, and the Stop normally cancels the call.
  • Dismissed (Nit): the footer's and stream hook's own !output_partial checks are now redundant; kept to hold the change to the helper.
  • Dismissed (Nit): the Stop case counts the status icon's colour classes; they are the same classes the pill's icon logic sets.
  • Two further reviews were not counted: their AGENTS.md line counts did not match the file, so they were not full reads.

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 1 on 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 touches ToolCallLine.tsx (it drops the unused running prop, which this test passes); whichever lands second rebases.

Sibling sweep

Swept: git grep -n -e toolReturned -e output_partial website/src
Sibling: 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

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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
@winnythedev
winnythedev requested review from a team and KiroCrewCaptain as code owners December 5, 2026 19:33
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of bdd7a7991147a37954caaa067d3a9c13da3a7e65 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fix sits in the one shared toolReturned helper. All five readers are accounted for, and an older gateway's frames with no final field still settle.

Notes

  • The && !output_partial checks in ChatFooter.tsx:318 and chatStream.ts:301 now repeat what the helper does. Remove them in a follow-up so the helper is the only place that rule lives.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of bdd7a7991147a37954caaa067d3a9c13da3a7e65 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Stop now leaves a streaming call stopped even if its completed frame arrives afterwards. That card then shows real output under a stopped icon. A follow-up should let a late final frame settle the card.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of bdd7a7991147a37954caaa067d3a9c13da3a7e65 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The fix is in the shared toolReturned predicate, which is where the cause sits. All four production readers pick it up. No pin was deleted, and nothing new is added.

Notes

  • Item 3 — rides along: ChatFooter.tsx:318 and chatStream.ts:301 still carry their own !output_partial checks. With this change those checks repeat what the helper now does. Subtraction: delete both && !…output_partial clauses so the decision lives in one place. The PR's ## Not a goal defers this.

What this change ships

Inventory (3 items) — 2 justified

Intent: a person running a long shell command from chat sees its pill stay "running" until the command actually returns. This is a FIX (#47858).

  1. The pill keeps its spinner, shimmer and "Running · Ns" line while the output streams, and settles on the final frame or when the turn ends — justified
  2. Pressing Stop while a call streams now marks that call stopped instead of done — justified
  3. The footer and stream-hook partial checks are now redundant but kept — rides along, deferred by Not a goal

[FIRST-PRINCIPLES-REVIEWED] bdd7a79

Description read

[DESCRIPTION-READ] 335af3df45fd5db1243e0f5ddcbe4e70f78ffac3d56c9cbed2fa17869cb8b799

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of bdd7a7991147a37954caaa067d3a9c13da3a7e65 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.

[GPT-REVIEWED] bdd7a79

False positive or not applicable? A repository writer can comment:
/ai-review override gpt bdd7a7991147a37954caaa067d3a9c13da3a7e65 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed bdd7a7991147a37954caaa067d3a9c13da3a7e65 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] bdd7a79

Verdict parsed from the review's SHA-scoped output markers for commit bdd7a7991147a37954caaa067d3a9c13da3a7e65.

False positive or not applicable? A repository writer can comment:
/ai-review override fable bdd7a7991147a37954caaa067d3a9c13da3a7e65 false-positive: <reason, 20 to 500 characters>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: checking Automated validation is still running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat: a shell command's tool pill reads finished at its first streamed output while the command still runs

1 participant