Skip to content

feat(tui): ctrl-e folds a whole reply; the rail becomes a task panel - #1370

Merged
huichen merged 16 commits into
mainfrom
pr/huichen
Oct 26, 2026
Merged

huichen merged 16 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

What this carries

14 non-merge commits, origin/dev-huichen over main (4d10fd70). Four separate pieces of work, all reviewed by the supervisor as they landed:

1. ctrl-e folds a whole settled reply — the reported bug

The report was "ctrl-e only collapses part of the output; scrolling up I find the historical messages are not collapsed". The reading level folded only the process before the answer's final text segment; anything the turn did after that text stayed outside the summary row. In an interrupted turn that is dozens of tool rows — on a real transcript 296 lines folded while 89 stayed out, which reads exactly like "history was not folded".

  • c80f5190 — one settled turn is now one unit: calls that follow the answer count into the summary row.
  • f6f3c626 — ctrl-e writes its level into settings (previously only /reply-detail did), so the level survives.
  • 0a9cd08c, 462f8abe — regression cover: a page of history prepended from the session store folds with the live turns; the incremental paths (sync_compact_layout / fold_layout_extends / rerender_message), a toggle round-trip from an unfolded render, a later prepend while already folded, and a resize under the folded level.

A turn that never produced prose at all still stays whole — that rule is documented in two places and is pinned by an_interrupted_turn_keeps_its_slices_by_design so a future change cannot quietly start folding it.

2. The rail becomes a task panel — 最近 and 工作区

  • 15f0ba6c, 217ef208, aca5f40e, 92ba326b — two tabs: 最近 (each conversation as two rows: title, then workspace and refresh time) and 工作区 (the same archive the desktop uses, ordered pinned → workspace → conversation), conversations grouped by the directory they actually ran in (case and trailing-slash variants are one), pins in ~/.future/tui/settings.json. The todo / usage / skills panels are gone — usage lives in the status bar, skills in the / palette.
  • tab hands focus to the rail on the current conversation, ↑↓ moves between conversations (skipping title rows), shift+←/→ switches conversations from anywhere. The rail's cursor follows a switch it did not make.

3. The desktop shows a host's empty workspace

d4c070a9 — a workspace created on machine B had no heading on this side at all: groupMergedRows derived workspace groups only from session rows, and the desktop never stored the peer's workspace list. Now RemoteCatalog carries workspaces, a peer workspace with no session rows gets its own heading (existing rows are not duplicated, temporary stays unscoped), and a failed read keeps the previous copy rather than blanking every heading.

4. Two smaller fixes

  • 4308c785 — the host log folded nothing: every retry attempt printed unconditionally, 18 lines per window, forever while a pairing is down. Identical failures within a window now print once and count; changed error text prints immediately; the window reports its tally when it ends.
  • 044542e2 — the first-screen Enter sent the wrong prompt: the surface read one value and submitted another.

Verification

Per commit, as landed: cargo test -p future-tui (1222 lib tests plus the integration and example suites), cargo fmt --check, cargo clippy -p future-tui --all-targets -- -D warnings; on the desktop side tsc --noEmit, eslint, and 1728 cases across src/features/remote-peer and src/components/layout. make check-docs passes after the docs/guide/tui*.md and docs/tui/workbench-spec*.md updates.

The four workbench examples were run and pass: workbench_interaction (563 click targets), workbench_perceptual (1202 assertions), workbench_semantics (24 cases), and the demo self-test.

Not in this PR

  • The agent/ Windows clippy lint on sandbox/{mod,windows/token}.rs (chunks_exact_to_as_chunks) is pre-existing and untouched here; Linux CI does not compile that file.
  • Re-freezing this branch is not automatic on this machine — the dev 分支 PR 合并 task does not exist here, so this PR was opened by the supervisor.

A remote peer that is switched off made the desktop log noisy on two layers,
both at once:

- `async_nats` logs `connected successfully ...`, `event: connected` and
  `event: closed` at INFO, and a dead peer makes the client connect and drop
  once per attempt. The embedded tracing filter already pins h2/rustls/tonic/
  tower to WARN for the same reason; `async_nats` now sits with them, so its
  WARNs (the ones that matter) still print and the churn does not.
- The reconnect supervisor printed one `remote_peer: reconnect attempt ...
  failed` line per backoff step: eighteen identical lines per retry window, a
  window every few minutes, for as long as the pairing exists. It now says the
  first failure of a window in full, counts identical repeats, and reports the
  count once when the message changes or the window closes. A different error
  still prints immediately, carrying the count of the run it interrupted.
The task was to make `ctrl-e` fold every settled reply, with a regression test
that first fails. The test that the cancelled worker wrote for exactly that
expectation **passes on this code**, so there is no red to show: the reading
level has applied to the whole transcript, not just the newest reply, since the
feature landed (`1d8a972c`), and `git log -p 1d8a972..HEAD -- chat_area.rs`
shows no change to the fold since.

Evidence that this is not a shallow pass:

* `reply_fold_layout` walks the whole message list and cuts a segment at every
  user/system boundary, so every settled reply is a candidate — the fold was
  never limited to the newest one;
* `prepend_messages` (how an older page arrives) calls the full `rerender()`,
  so history that lands after the toggle is folded with everything else;
* 8 further sequences were driven by hand and a 24-seed x 40-step fuzz over
  {stream a turn, prepend a stored page, toggle, render} checked after every
  step that no folded row is painted at the folded level. All green.

Three *deliberate* rules can still leave a turn expanded, and they are where the
report most likely comes from. They are documented behaviour, not this bug:

1. a reply with no prose stays whole (`fold_reply_segment` needs an answer);
2. an unsettled reply stays whole — and `Live::abort` only calls the agent, so a
   run that ends without `agent_end` leaves its turn `pending` for the session;
3. linear reading mode replays the transcript only when the session changes
   (`LinearReader::sync_session`), so a toggle after entering it cannot rewrite
   the scrollback already emitted.

So the test is kept as a pin rather than presented as a fix, and the next step
is the user's actual repro (linear mode? a cancelled run? a turn with no prose?),
not a speculative change to the fold.
…id in it

The workspace section's '+' on a paired machine's list registers a folder on that machine, and the folder then existed there with no conversation in it — so the merged list, which builds a workspace group from the rows under it, had nothing to build one from. The create succeeded, the host could list the workspace, and the list went on showing nothing; this machine's own empty folders were always drawn, from its own workspace store, which is what made the two lists disagree about a place that plainly exists.

The host's workspaces now travel with its sessions: read beside them on the same cadence in useRemotePeers (a failed read keeps the last list instead of emptying every heading), applied from the pushed state.workspaces snapshot the hook used to gate and discard, and carried through RemoteCatalog. groupMergedRows seeds a group for a host workspace with no rows — once, never beside the group its rows already built, and not for a temporary workspace, which holds chats rather than folders.
Typing on the home screen and pressing enter produced nothing: no session was
created and no prompt reached the agent. The same was true of every message sent
from the workbench, launchpad or not.

The driver cleared the surface's draft before handing `WbAction::Submit` to the
adapter, and `Live::submit` ignored the action's own text, re-reading the prompt
out of that draft. It therefore found an empty string, hit its `typed.is_empty()`
guard, and returned without touching the client — silently, because a submit with
nothing in it is a legitimate no-op. Clearing the draft first also threw away the
folded pastes and image attachments the draft was carrying.

Two changes, both about who owns the text:

* `submit` takes the action's text as the authority and uses the draft only while
  it still holds something, because the draft is what carries the folded pastes
  that `pending()` expands into the prompt;
* the driver no longer clears the draft at all. `submit` clears it itself once
  the prompt is on its way, which also means the reader's text survives a session
  that could not be started, so it can be sent again.

The regression test drives the real `Live` against the crate's agent test double
in the driver's exact order and asserts `new_session` then `prompt` are sent and
the user row is painted. Two companion tests pin the repaired paths: the ordinary
one with the draft intact, and the failed-session one where the draft must stay.

Red before the fix, from the same test:

    the first message must create a session,
    saw ["get_state", "list_sessions", "list_models", "get_session_entries"]

Green after: 1214 library tests pass, plus 6 CLI, 8 i18n and the perf probe;
`cargo fmt --check` and `clippy -D warnings --all-targets` clean.

`grpc_client.rs` changes are test-only: the agent test double and its constructor
are `pub(crate)` so a test outside that module can use them.
The workspace-level test only ever reached `render()` + `prepend_messages` +
toggle, so four paths the fold actually uses had no coverage. They do now, and
all four are green — no defect found in any of them:

* `incremental_streaming_keeps_every_turn_folded` — establish the width once,
  then drive turns through `add_message` / `append_to_thinking` / `add_tool_start`
  / `finish_tool` / `append_to_last_message`, re-reading after every step. Asking
  for a new width or leaving `dirty` set would rerender everything and hide the
  splice path, so neither happens.
* `toggling_after_incremental_streaming_folds_everything` — the level flipped
  *after* the incremental stream, which is the order that exercises
  `sync_compact_layout` deciding to rebuild.
* `resizing_while_folded_keeps_every_turn_folded` — 120/64/40/100 columns, each
  compared against a fresh layout at that same width.
* `a_stored_tool_row_is_never_running` — the premise behind the "unsettled tool"
  suspicion: `session_rows::rows_to_messages` gives every tool row `Complete` or
  `Error`, never `Running`, and never leaves one `pending`. A stored page cannot
  block its own fold that way.

Three mutations prove the coverage is real: making `sync_compact_layout` return
early, making the splice path ignore a grown layout, and making a width change
keep the previous wrap each turn exactly the test that claims that path red.

`an_interrupted_turn_keeps_its_slices_by_design` and its stored-page twin are
pins, not fixes. A turn that never produced an answer — an interrupted or
cancelled run, whose `agent_end` settles the messages without carrying text —
does not fold, because the fold isolates work *above an answer*. That is the
documented rule on `ReplyDetail::Default` and on `reply_fold_layout`, and it is
also the closest thing found to the report ("ctrl+e only collapses part of the
output; scrolling up I find the historical messages not collapsed"): one
interrupted turn in the history is exactly one stretch that stays expanded.
Folding it would leave a summary row with nothing under it, which is a product
decision. The tests say so in their names and comments so flipping the rule is a
deliberate act with an obvious place to edit.

No change to `abort()`; no change to the no-prose rule; no change outside
`chat_area.rs`.
@huichen
huichen enabled auto-merge (squash) October 26, 2026 09:39
@huichen
huichen merged commit e224290 into main Oct 26, 2026
29 checks passed
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