Skip to content

fix(tui,agent): the rail yields its keys; a backward history page keeps its exchanges - #1416

Merged
huichen merged 7 commits into
mainfrom
pr/huichen
Oct 29, 2026
Merged

huichen merged 7 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

The workbench rail was swallowing typing, pasting and esc once it had focus, and its tabs answered to plain arrows; this branch routes those keys back to the composer and leaves the tabs to shift+left/right. Alongside it, three agent tests stop depending on a loaded disk: a backward history page keeps the exchanges it asked for, the reset race hook is keyed by session instead of one global slot, and two deadline-shaped waits now have room to finish.

Commits

  • fix(agent): keep the exchanges a backward history page asked for
  • fix(tui): leave the rail's tabs to shift+left/right only
  • fix(tui): typing, pasting and esc take the keys back from the rail
  • test(agent): key the reset race hook by session instead of one slot
  • test(agent): give the ordered-recovery wait room for a loaded disk
  • test(agent): assert the fence lag a negative answer has to survive

Verification

Local pass with rustc/clippy 1.99.1 from ~/.rustup (Homebrew shadows PATH), ulimit -n 8192, in the main checkout at bf96a2eb5 (the first five commits):

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-tui -p future-agent --all-targets -- -D warnings → clean (3m09s)
  • cargo test -p future-tui --lib → 1512 passed, 3 ignored
  • cargo test -p future-agent --lib -- session::persistence session::reset → 47 passed

Delta at the frozen tip 3aa2394b3, after the history-paging commit landed:

  • cargo test -p future-agent --lib -- session::history → 51 passed
  • cargo fmt -p future-agent -- --check → clean

Notes

The two tui commits change key handling in tui/src/workbench/mod.rs and state.rs: plain arrows over a focused rail no longer switch its tabs, and text input plus paste and esc are routed to the composer. docs/guide/tui.md and docs/tui/workbench-spec.zh-CN.md describe the new behaviour.

The fence lane is worth its one open connection only because the cost is
bounded and compensated: a read that does not queue behind the ordered writer
cannot see a write that is still queued, so a session whose placeholder commit
is waiting reads missing. This asserts that lag directly — the fence answers
while the writer is held, the queued create is not visible yet, and the same
question answers present once it commits — so a later change that puts the
fence back on the writer lane, or a caller that trusts missing without
confirming it, has a test to fail.

The desktop half of that contract is covered by
agent_bridge::tests::presence_fence_tests (missing asked twice, deleted and
present once).
recovery_is_ordered_after_already_accepted_appends asserts the order of two
entries, not the latency of the commit between them, but it waited only 5 s for
that commit to land. Every writer commits with `synchronous = FULL`, so a suite
running 32 databases at once can spend longer than that in fsync alone: the full
`cargo test -p future-agent` at 32 threads failed here with `Timeout` on
2026-10-29 while the same suite at 8 threads (CI-like) was green twice.

The wait stays bounded — a real deadlock still fails — but at 60 s it measures
scheduling rather than the disk. No assertion changed.
Four tests register a reset-race hook, and the registry held exactly one. Under
parallel execution the last registration replaced the others, so a reset found no
hook for its own id and succeeded where the test expected `history_changed` — the
id gate was there, the storage was not. Measured 2026-10-29: the full
`cargo test -p future-agent` failed here with 32 test threads and passed with 8.

The registry is now a map keyed by session id, and the hook is removed before it
runs: it writes through the same manager, so holding the registry across that
work would serialize every other test's reset. Test-only (`#[cfg(test)]`); no
production path changes.
A focused rail kept the keys while printable characters, pastes and the
clipboard chord still reached the draft, so the `enter` that followed one
of them opened the rail's selected conversation instead of sending the
prompt. On the launchpad that read as "the first message was never sent —
the screen jumped to somebody else's streaming session".

Editing chords and a second `escape` now blur the rail too, so the keys
land where the typing did. The search line keeps its own `escape`: the
first one clears the filter, the next one leaves the rail.
A focused rail answered the plain left/right arrows by switching between
最近 and 工作区. The rail can hold the keys while the prompt is still on
screen — a click on a tab, a conversation opened from a row, `ctrl+d` —
and a reader standing in the draft reads those two keys as the caret's,
so the rail moved under a caret that never did.

The tabs are now `shift+left`/`shift+right` alone (`Action::PanelPrev` /
`PanelNext`), which already worked from anywhere. Inside a focused rail
the plain arrows are swallowed rather than handed to the editor: that
caret is not the reader's, and moving one they cannot see is the same
surprise one layer down.
`get_session_entries` counts a backward `limit` in user exchanges, but the
canonical branch of `read_display_page` capped the row range at 64 on top of
that window. One busy run is far more than 64 display rows on its own (an
assistant step and a tool entry per call), so a ten-exchange tail page came
back as whatever fitted, the client's missing-user-prefix fetch pulled that
run's question in, and the transcript opened on the newest exchange alone —
everything above it looked like it had been lost, with no page of it loaded
and no sign that any existed.

A backward read now takes the window it named. The row ceiling stays on the
forward branch, where `limit` counts rows and `nextOffset` resumes them. The
canonical page is still bounded: its rows carry no bodies, so the bound moves
to the materializer that reads them — the same eight-megabyte budget every
other page has, which happens to be exactly what the compatibility branch was
already using for its inline bodies.

Measured on a real 784-row session: a `limit: 10` tail read returned 64 rows
(one exchange) before and 783 rows across all ten exchanges after.
@huichen
huichen enabled auto-merge (squash) October 29, 2026 02:44
@huichen
huichen merged commit 5bc7fc8 into main Oct 29, 2026
48 of 50 checks passed
@huichen
huichen deleted the pr/huichen branch October 29, 2026 03:28
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