Skip to content

fix(tui): fold a loaded run like a live one - #806

Merged
huichen merged 2 commits into
mainfrom
fix/tui-history-folds
Sep 23, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/tui-history-folds

Conversation

@huichen

@huichen huichen commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Why

Screenshots of the new compact view (ctrl+d, #804) showed the fold working on a live run but not on a loaded one: a session reopened from history rendered every call as its own row, fold or not.

Cause

The agent stores a tool-using turn as one assistant entry per call — the tool_call step, which carries no text — followed by the call's own tool entry:

assistant { blocks: [tool_call read /a.rs] }
tool      { blocks: [tool_result /a.rs] }
assistant { blocks: [tool_call read /b.rs] }
tool      { blocks: [tool_result /b.rs] }

history_rows_to_messages kept every row that had a tool_call block, so each call produced an empty assistant message. It rendered no row of its own but still took a separator, which had two visible consequences:

  1. a second blank line between call rows that the live view does not have, and
  2. every run of consecutive calls was broken, so a loaded session never folded — ▸ read 4 files came out as four separate read rows.

Fix

A row that would render nothing — no text, no reasoning — is dropped: that is exactly the structural tool-call step (the tool row that follows carries the call, and the name/args index is still built from the dropped row's blocks). A call row is never dropped on that ground: it has a row of its own to render, and the live view shows it too, including when the call returned nothing — which was the second half of the same inconsistency (tool entries with an empty tool_result used to disappear on reload).

Unfolded, a loaded run now has exactly one blank line between calls, matching live.

Also

The page-triggered paging tests (added in #803) waited on pump's wall-clock quiesce window rather than on the page itself, which a loaded host can outrun — one such failure showed up locally while these screenshots were being taken (it did not reproduce in 10 isolated runs or 3 full-suite runs). They now wait for the request to settle, and fail loudly if the request never starts.

Tests

  • a_loaded_run_folds_like_a_live_one — a page in the agent's real shape folds to ▸ thinking + ▸ read 3 files, and unfolded keeps one blank line between calls.
  • a_loaded_call_with_no_output_keeps_its_row.
  • cargo test -p future-tui (2088), cargo fmt --check, cargo clippy --all-targets --no-deps -D warnings, tui/tests/tmux-diff.sh (57 passed).

Screenshots

Captured from the real agent (isolated home, a planted journal) and the real TUI in tmux, before/after in one sheet — .screenshots/tui-compact-view.png (gitignored).

A session loaded through the history pager never folded, even with the
compact view on. The agent stores a tool-using turn as one assistant entry
per call (the `tool_call` step, which carries no text) followed by the
call's own `tool` entry, so `history_rows_to_messages` built an empty
assistant message per call. Those rendered no row of their own while still
taking a separator — a second blank line between calls, which the live
view does not have — and, worse, they broke every run of consecutive
calls: `read` x4 folded to nothing, one call per row.

The mapper now drops a row that would render nothing (no text, no
reasoning), which is exactly the structural tool-call step. A call row is
never dropped on that ground: it has a row of its own to render and the
live view shows it too, including when the call returned nothing.

Also hardens the paging tests: the page-triggered ones waited on `pump`'s
wall-clock quiesce window instead of the page itself, which a loaded host
can outrun; they now wait for the request to settle (and fail loudly if it
never starts).

Tests: a loaded run folds like a live one (and, unfolded, keeps exactly one
blank line between calls), a call with no output keeps its row.
@huichen
huichen enabled auto-merge (squash) September 23, 2026 14:15
@huichen
huichen merged commit ad2521d into main Sep 23, 2026
12 checks passed
@huichen
huichen deleted the fix/tui-history-folds branch September 23, 2026 14:20
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