Skip to content

fix(chat): clear accumulated shell output on !command re-run (+ regression test)#4025

Merged
esengine merged 2 commits into
main-v2from
fix/shell-output-cumulative-regression-test
Jun 11, 2026
Merged

fix(chat): clear accumulated shell output on !command re-run (+ regression test)#4025
esengine merged 2 commits into
main-v2from
fix/shell-output-cumulative-regression-test

Conversation

@esengine

Copy link
Copy Markdown
Owner

Lands @CnsMaple's fix from #4020 with an added regression test.

Closes #4020

Problem

Repeated !pwd (or any ! command) accumulated output across runs. RunShell
derives a stable tool id from the command text (shell-pwd), and
streamToolOutput does m.shellOutputs[id] += chunkbeginToolRunning never
cleared the entry, so each re-run appended to the prior run's output and
collapseShellSlot rendered all of it.

Fix (@CnsMaple, #4020)

Clear m.shellOutputs[id] in beginToolRunning, which runs on each ToolDispatch
— before the new run accumulates and after the previous run already collapsed
into the transcript. One delete, both render modes.

Added here

TestRepeatedShellCommandDoesNotAccumulateOutput: three identical shell-pwd
runs must leave one run's output in shellOutputs, not three. Verified it fails
without the fix ("…\n…\n…\n") and passes with it.

Test

  • go test ./internal/cli/ — pass

CnsMaple and others added 2 commits June 11, 2026 04:05
When a !command (e.g. !pwd) is run multiple times, the tool ID is
fixed (e.g. "shell-pwd") so streamToolOutput appends each run's
output to the same shellOutputs key. Without clearing, collapseShellSlot
renders all accumulated lines from every run.

Fix by deleting shellOutputs[id] in beginToolRunning, so each run
starts with a clean slate.

Before (3x !pwd):
  ⎿  /d/about_fish/ProgramProtable/DeepSeek-Reasonix
     /d/about_fish/ProgramProtable/DeepSeek-Reasonix
     /d/about_fish/ProgramProtable/DeepSeek-Reasonix

After (3x !pwd):
  ⎿  /d/about_fish/ProgramProtable/DeepSeek-Reasonix
  ⎿  /d/about_fish/ProgramProtable/DeepSeek-Reasonix
  ⎿  /d/about_fish/ProgramProtable/DeepSeek-Reasonix
A re-run of the same "!" command reuses its command-derived id, so without
the clearing fix streamToolOutput appended each run's output to the last.
Pin the regression: three identical runs must leave one run's output, not three.
@esengine esengine requested a review from SivanCola as a code owner June 11, 2026 11:07
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Jun 11, 2026
@esengine esengine merged commit 6f338e2 into main-v2 Jun 11, 2026
14 checks passed
@esengine esengine deleted the fix/shell-output-cumulative-regression-test branch June 11, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants