Skip to content

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

@bug-ops

Description

@bug-ops

Description

After the fix for #2116 (which correctly eliminated the duplicate tool entry), a new issue remains: the content within a single tool entry is duplicated — the command and output appear twice inside one entry.

Root Cause

Two code paths contribute content to the same streaming message:

Path A — ToolStart (app.rs handle_tool_start_event):

  • Creates a new streaming message with initial content: "$ {command}\n"

Path B — OutputChunk (app.rs handle_tool_output_chunk):

  • Appends raw output chunks as they stream in

Path C — ToolOutput (app.rs handle_tool_output_event line 570):

  • Receives body_display from TuiChannel::send_tool_output which contains "$ {cmd}\n{output}" (the full formatted result)
  • Calls content.push_str(&output) — appends the full formatted string onto the streaming message that already has "$ {cmd}\n" + raw chunks

Result: The streaming message ends up with:

$ echo 'hello'
hello                  ← from OutputChunks (Path B)
$ echo 'hello'
hello                  ← from body_display append (Path C)

Steps to Reproduce

  1. Run with TUI: cargo run --features full -- --tui --config .local/config/testing.toml
  2. Send: Run the shell command: echo 'test'
  3. Observe the tool result entry in the chat panel — command+output appears twice within one entry

Expected Behavior

Command and output appear exactly once per tool call.

Affected Code

  • crates/zeph-tui/src/app.rshandle_tool_output_event (the content.push_str(&output) call)
  • crates/zeph-tui/src/channel.rsTuiChannel::send_tool_output (sends body_display with full cmd+output)

Fix Options

  1. In handle_tool_output_event: skip push_str when streaming chunks have already been accumulated (check if streaming message has chunks > 0)
  2. In TuiChannel::send_tool_output: send only the final output without the command prefix (command is already in the streaming message from ToolStart)
  3. Replace the streaming message entirely with the body_display on ToolOutput (discard incremental chunks)

Severity

MEDIUM — cosmetic but confusing: tool results appear doubled in TUI

Discovered

CI-79 (2026-03-22), post-fix verification of #2116.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions