Skip to content

fix(tui): replace streaming chunk append with canonical body_display on ToolOutput (#2126)#2129

Merged
bug-ops merged 1 commit intomainfrom
fix/2126-tui-output-duplicate
Mar 22, 2026
Merged

fix(tui): replace streaming chunk append with canonical body_display on ToolOutput (#2126)#2129
bug-ops merged 1 commit intomainfrom
fix/2126-tui-output-duplicate

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 22, 2026

Summary

Root Cause

Three paths wrote into the same streaming message:

  • ToolStart: created message with "$ cmd\n"
  • ToolOutputChunk: appended raw output chunks as they streamed
  • ToolOutput: appended body_display (raw output) again, doubling the content

Fix

handle_tool_output_event now:

  1. Finds the end of the header line (find('\n').map_or(0, |i| i+1))
  2. Truncates to keep only "$ cmd\n"
  3. Pushes body_display — exactly one copy of the output

Works correctly for both cases: chunks streamed (discards them, writes canonical) and no chunks (no-op truncate, then writes).

Test Plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 6377 passed (+2 vs baseline)

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 22, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 22, 2026 14:05
…on ToolOutput (#2126)

After #2116 fixed duplicate tool entries, the content within each entry
was still duplicated: ToolStart wrote "$ cmd\n", OutputChunks appended
raw output, then ToolOutput appended the full body_display again.

handle_tool_output_event now truncates the message to the header line
("$ cmd\n") before writing body_display, discarding accumulated chunks.
Streaming chunks remain a live preview; ToolOutput is the ground truth.
@bug-ops bug-ops force-pushed the fix/2126-tui-output-duplicate branch from b9815ef to 4ef7e2e Compare March 22, 2026 14:18
@bug-ops bug-ops merged commit 4c4db6b into main Mar 22, 2026
25 checks passed
@bug-ops bug-ops deleted the fix/2126-tui-output-duplicate branch March 22, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tui: shell tool output content duplicated within single entry after #2116 fix

1 participant