Skip to content

fix(cli): abbreviate run_command titles in Step tool rows - #275

Merged
ZouR-Ma merged 2 commits into
mainfrom
fix/run-command-title-preview
Oct 21, 2026
Merged

ZouR-Ma merged 2 commits into
mainfrom
fix/run-command-title-preview

Conversation

@ZouR-Ma

@ZouR-Ma ZouR-Ma commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

In the Step presentation, a run_command call with a long or multi-line command (inline node -e / playwriter -e scripts, heredocs) prints the entire command in the transcript, often dozens of rows before any output. This pushes the actual result off screen.

Root cause: run_command reuses the native bash renderCall, which renders $ <command> (timeout Ns) as a multi-line Text. ToolExecutionComponent.buildStepDefaultLines replaces the first row with the run_command(...) title but moves the remaining rows into the result body under the └ connector, as it does for write's preview rows. The title itself was also not shortened, only clipped to the terminal width.

Changes

apps/cli/src/ui/view/transcript/tool-execution.ts:

  • The run_command(...) title now shows a command preview: line breaks and their surrounding indentation fold into one space, and the text is cut to the first 50 code points with a trailing ….
  • For run_command, the native call-renderer rows are no longer moved into the body while collapsed. The body shows only command output and the existing expand hint.
  • On expand, the full native $ <command> (timeout …) rows are placed above the output, but only when the title preview differs from the raw command (it was shortened or reflowed). They are rendered at body width so the connector does not clip them. Short single-line commands do not get a duplicate echo row.
  • Other tools keep the existing "extra call rows become payload" behavior (for example, the write_file preview).

Behavior and compatibility

  • Presentation-only change in the Step transcript (presentation: "step"). The native Pi presentation, tool arguments, execution, persisted transcripts, and model-visible output are unchanged.
  • The approval dialog is unchanged and still shows the full command.
  • Escape path for the full command: the existing expand action (app.tools.expand, Ctrl+O by default).
  • In the collapsed Step view, the (timeout Ns) suffix is no longer shown for multi-line or long commands. Single-line commands already did not show it in the Step title. The suffix remains visible on expand.

Validation

  • pnpm exec vitest --run test/step-tool-row-contract.test.ts test/tool-execution-component.test.ts (from apps/cli): 2 files, 48 tests passed. Adds regression tests covering:
    • A long multi-line command: the collapsed title equals the 50-character preview plus …, the command tail and timeout are absent, and the first body row is the output. On expand, the full command and output are visible.
    • A short command (pnpm test): the title is verbatim and there is no $ pnpm test echo row on expand.
  • pnpm exec vitest --run test/tui-acceptance-snapshot.test.ts test/tui-acceptance-interactions.test.ts (from apps/cli): 2 files, 42 tests passed. No snapshot updates.
  • pnpm run check: exit 0.
  • ./test.sh on this branch (based on origin/main): all workspaces passed. For example, coding-agent passed 4860 tests with 59 skipped, and apps/cli passed 735 tests. Local notes:
    • Run with TMPDIR=/tmp because the default macOS TMPDIR made subagent-invocation.test.ts fail with listen EINVAL: tsx's IPC socket path exceeded the Unix socket length limit. This is an environment issue unrelated to this change.
    • Run with the locally cached pnpm 9.15.9, because Corepack could not reach the registry.

Platform: macOS (darwin), Node.js 24.3.0.

Limitations

None. CI (Check commit attribution, build-check-test) passed.

Manual check in a live terminal (./step-test.sh in tmux, 160x45, real model):

  • A multi-line node -e "..." command: the collapsed row reads ● run_command(node -e " const marker = 'FULL_COMMAND_TAIL'; for …) followed directly by output. Ctrl+O shows the full $ node -e "..." (timeout 120s) above the output.
  • echo short-ok (with tool output expanded): ● run_command(echo short-ok), └ short-ok, and no duplicate $ echo short-ok row.

The Step presentation reused the native bash call renderer, whose multi-line
`$ <command> (timeout ...)` echo was moved into the result body. Long inline
scripts and heredocs therefore filled the transcript with the full command.

Preview the command in the run_command title (line breaks folded, first 50
characters plus an ellipsis) and drop the echo rows while collapsed. The full
command is still shown in the body on expand when the title shortened it.
@ZouR-Ma
ZouR-Ma merged commit 7ae808a into main Oct 21, 2026
2 checks passed
@ZouR-Ma
ZouR-Ma deleted the fix/run-command-title-preview branch October 21, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant