Skip to content

feat(tui): /git lane graph, preferences box, link walking; one black canvas at AA - #1389

Merged
huichen merged 22 commits into
mainfrom
pr/huichen
Oct 27, 2026
Merged

huichen merged 22 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

This PR brings the TUI workbench's panels and keyboard surface into one coherent shape: /git gains a lane graph with pageable details, the preferences box now owns language, palette and rail visibility, tab walks links and pictures in a conversation, the whole surface paints its own black canvas so every theme clears AA contrast, and the small interactions around previews, paging and switching conversations stop getting in each other's way.

Commits

  • feat(tui): put language, palette and rail visibility in the preferences box
  • feat(tui): a lane graph, a selection band and pageable details in /git
  • fix(tui): the workbench paints its own black canvas, and every theme's text clears AA
  • feat(tui): tab walks the conversation's links and pictures
  • fix(tui): the tool-output footer names a door that exists
  • fix(tui): the key table counts the door the tool footer names
  • fix(tui): exempt git's diff-header tokens, which the i18n guard read as chrome
  • fix(tui): escape from a picture preview goes back one level, and the key tables name the keys they list
  • feat(tui): a fresh launchpad opens on the conversation list, the agent's defaults and full access
  • fix(tui): pageUp/pageDown scroll the transcript and never the rail
  • fix(tui): switch conversations in one round trip, and keep the ones you pass through
  • feat(tui): let the workspace picker choose no workspace, i.e. a plain chat

Verification

Run locally at the tip, rustc/clippy 1.99.1, ulimit -n 8192:

  • cargo fmt --all -- --check — clean
  • cargo clippy -p future-tui --all-targets -- -D warnings — clean
  • cargo test -p future-tui — lib 1438 passed, i18n_guard 8 passed, other integration targets 6/1/6 passed, 0 failed
  • make check-docs — 358 docs OK, provider matrix 13 rows

The first CI attempt caught a real regression the lib-only suite cannot see: cargo test -p future-tui --test i18n_guard failed on seven literals in tui/src/workbench/screen.rs that are git's own diff-header tokens (diff --git, new file mode, …) used as prefix comparisons, not chrome the surface writes. They are now exempt in tui/tests/i18n_guard/allowlist.rs with a reason each, and the guard's own matching rules were left untouched.

Notes

  • The preferences box writes language, theme palette and rail visibility; a dragged rail width survives a restart.
  • /git draws one colour per lane, marks the selected row with a band, and pageUp/pageDown page its detail pane.
  • Tab cycles the links and pictures of the open conversation.
  • A fresh launchpad pre-selects the conversation list, the agent's own defaults and full access; previously it opened without a selection.
  • pageUp/pageDown belong to whichever pane has focus, so a focused rail no longer scrolls the transcript or the other way round.
  • Switching conversations reloads only the conversation being opened, and conversations passed over keep their state.

The `ctrl+l` chooser listed every directory this client has a conversation in
plus a row that creates one from the path typed into its search line, so a reader
who wanted a conversation with no workspace had no row to press: "I did not pick
a workspace" was the one choice the menu could not express.

That choice is now a row of its own — 对话会话 / "Chat", with 不绑工作区 / "no
workspace" where the workspaces print their paths. `enter` there stages the
agent's own `agent/workspace` for the session the next message creates, or moves
an attached one with `set_cwd`; it is the directory the rail's 对话会话 section
already files such a conversation under, and the surface creates it on the way
because nobody else owns that path. An already-chat session is left where it is,
like `esc`.

The row sits after a typed path and never before it: `enter` straight after
typing a directory must still create the directory the reader named. It is keyed
by a NUL sentinel no real path can carry (`picker::CHAT_WORKSPACE_KEY`) and maps
to its own `WbAction::SelectChatWorkspace`, since the directory it moves to is
the app's rather than one the reader chose.

`SessionMeta` gains `chat` (the adapter sets it from `is_chat_directory`), which
is what ticks that row, and the launchpad's 工作区 chip now names a chat by the
same word instead of printing the scratch folder's last segment as if it were a
project.
…s you pass

`shift+↑`/`shift+↓` walked the rail by opening every conversation it landed
on. Each open cost three sequential RPCs (`switch_session`, `get_state`, then
the transcript page), a rebuild of the transcript from that page and a full
frame — and a held key repeats every 30–40 ms, so the conversations in between
were loaded only to be thrown away 30 ms later. Measured on a 180×50 terminal
against the release build: one press took 70–75 ms to settle, and eight repeats
took 412 ms in six frames (178 KB written) with the transcript trailing the
reader's fingers the whole way.

Three changes, each one thing a switch no longer does:

* **The rail's cursor moves; the conversation opens once the keys are quiet.**
  A step still resolves immediately (`Workbench::step_session`), so the cursor
  follows the reader's fingers, but the open is deferred by `OPEN_SETTLE`
  (80 ms) and every repeat pushes it out. A key that is released opens what it
  stopped on; the ones passed through are never loaded.
* **Conversations already read come back from memory.** `Live` keeps the last
  eight conversations it showed — rendered rows and all — and a switch that
  hits one paints them *before* it asks the agent anything. The reconcile that
  follows is one `get_state` + `get_session_entries` pair, both addressed by
  name so they go out together; a page that comes back unchanged keeps the rows
  it is compared against (`ChatArea::full_renders` does not move), one that
  changed rebuilds the transcript instead of appending to it.
* **`switch_session` is gone from the switch.** `get_state` resolves the very
  same `try_get_session`, so addressing it by name hydrates the session the
  switch was going to hydrate anyway: three sequential round trips become one
  concurrent pair. A click on the row already on screen now reads nothing at
  all (it used to re-fetch and rebuild, dropping the reader's scroll position
  and any older pages they had loaded).

`/new` keeps the conversation it leaves for the same reason, and
`ChatArea::empty_like` carries the presentation settings (`ctrl+e` level,
`ctrl+d` folding, `ctrl+g` bodies, theme) into the empty side of a swap, so a
cache hit does not silently reset how the reader reads.

Not included: `get_state` still reads the whole `history_shapes` projection once
per call for `queryCount`/parent lineage/unterminated-run recovery — it looked
like a pure waste, but all three readers are real, so making it lazy needs a
memoised projection with its own invalidation. That is a separate change, and
this one does not depend on it.

Tests: a cached conversation comes back without re-fetching or re-rendering its
rows, one that moved on is rebuilt rather than appended, `/new` keeps what it
left, clicking the row on screen reads nothing, and the settle window collapses
a 30/s repeat into one open (with its two bounds pinned so a later tweak cannot
break the property). Spec and both guides say what a held key now does.
With the rail focused, `scroll()` handed the page keys (and `ctrl+↑`/`ctrl+↓`)
to the rail's list, so the same key meant two different things depending on
where `tab` had left the cursor — and the transcript was unreachable from the
rail without leaving it first.

The transcript is the one thing those keys mean now. The rail scrolls where a
list should: its cursor walks with `↑`/`↓` (the window follows it), a wheel over
the rail moves it, and the full-screen panel keeps its own keys. `end` — the
same verb — follows the same rule.
…完全访问

`/new` (and a TUI started against an agent with no session) carried the
conversation it had just left into the next one: the workspace chip named that
session's directory, the model chip its model, the effort chip its level, and the
approval chip its mode. A fresh screen was therefore a copy of what came before,
and the only way to get "just a chat" was to notice the workspace chooser's own
row and press it.

The four chips now name the product defaults when nothing is staged:

* 工作区 — the plain chat. The session is created in the agent's own
  `agent/workspace` (the directory the rail's 对话会话 section already files),
  which the surface creates on the way: a session parked in a directory that is
  not there has no tool that works.
* 模型 / 强度 — the agent's default model and the level that model starts at,
  read from `list_models` (`isDefault`, `defaultThinkingLevel` — the same
  resolution `new_session` performs), so the chip and the created session agree.
* 审批 — 完全访问 (`off`), and it is *applied* to the created session rather
  than only named: a chip that named a mode the session did not run under would
  be a lie.

Choices the reader makes still win, and staging is spent exactly as before.

Two consequences fixed with it, because they would have described the old
directory while the session ran in the new one: `@` (and `@file` expansion, the
files panel, the branch in the header) now follows the staged directory instead
of the one `/new` left behind, and the chip's cycle became a stable ring that
starts at the chat — it used to reorder itself around whatever was in force, so
two presses bounced between the same pair and the chat became unreachable once
stepped off.

The header, the box title and the chip all name such a conversation 对话会话
rather than printing `~/.future/agent/workspace` as if it were a checkout.
…list keys

Three things the help box and the footer were saying that the surface no
longer does:

- `esc` in the preview box closed it *and* the panel under it, so a file
  opened from the files tree landed back in the chat. The box is now a
  level: `open_preview` remembers the surface it opened over (the files
  tree, the `/git` browser), `esc` returns to it, and only the last `esc`
  reaches the chat. A picture opened from the draft had nothing under it
  and still closes onto the chat.
- `?` opens the help; the full-width `?` a Chinese IME types for the same
  key did not, which is exactly the reader who wants the Chinese copy.
  Both do now, and the footer names the key (`? 帮助`), where it used to
  spell `esc 回到聊天` — the key that leaves *whatever the reader is in*,
  which is not one of its five destinations and is printed by the boxes
  that answer it.
- the help table listed every action and printed `—` in the key column
  for the ten with no chord. A key table lists keys; those verbs keep
  their typed door in the command list at the end of the same box, and
  the shortcut editor still lists all of them (that screen exists to give
  a chordless action a chord).
…es box

The preferences box is the one screen a reader visits to see what this
terminal client remembers, so it now lists the choices that had only a
slash command or nothing at all:

* Interface language and Color theme — the two rows that are menus: Enter
  opens the same picker `/lang` and `/theme` open, and committing or
  dismissing it lands back on the box, on the row that opened it (the way
  `Customize shortcuts` already returns there).
* Show sidebar — the rail's visibility had a chord (`ctrl+d`) and an edge
  button but no row, so a reader who had hidden the rail had to know the
  chord to get it back. Toggling it here leaves the keys with the box.

`Restore defaults` was a half-truth once the box showed language and
palette: it now hands the language back to the system and the palette back
to the terminal's light/dark hint (the stored `themeId` is cleared rather
than pinned to today's hint), and drops a stale rail focus.

The rail's width was not remembered above 48 columns: `settings.json`
clamped `sidebarWidth` to 30..48 while the divider drag ran to 60, so the
widest third of the drag was narrowed again on the next start. The file
now clamps to the drag's own `SIDEBAR_MIN..=SIDEBAR_MAX`, and a test walks
every width in that range through the write/read round trip.

The docs gain the new rows (and lose a stale `Ctrl+O`/`ctrl+o` for the
panel, which has been `ctrl+q`), and the 30–48 column range the drag
outgrew.
…d rail visibility; the rail width survives a restart
The git browser drew git's own ASCII graph in one colour, so a merge read as
punctuation rather than as a line of work; the selected row was an arrow; the
patch beside it was plain text; and the page keys moved the cursor, which left
a long patch to be walked one line at a time.

* The log is read across every branch, remote-tracking branch and tag, so the
  graph has more than one lane to draw (`--branches --remotes --tags
  --date-order`; not `--all`, which would put `refs/stash` in the log as if it
  were a branch, and not `HEAD` as well, which is fatal on an unborn branch and
  takes the other branches' commits down with it).
* Each lane keeps a colour of its own, so two branches running side by side
  stay apart, and the glyphs are the box-drawing twins (`●`, `│`, `╱`, `╲`)
  that let a vertical run read as one line instead of a dotted column of `|`.
* Every field of a row now travels with what it is (`GitKind`), so the painter
  colours a sha, a decoration, a ref's name and a date by meaning rather than
  by position (an empty field is dropped, so positions shift). The selected row
  is a band across the whole list, in a colour stepped off the palette's panel
  onto the grey ramp — the 256-colour table is not a number line, and the
  high-contrast palette's near-white *border* painted white text on white.
* The detail pane paints what it shows — hunk headers, `+++`/`---`, added and
  removed lines, a diffstat's bars, the commit's own header — classified by the
  *source* line, so a wrapped tail keeps the colour of the line it belongs to.
* `PgUp`/`PgDn` page the detail rather than moving the cursor while the detail
  is on screen; the panel splits from 108 columns so a patch is never wrapped
  under about fifty cells, and below that `tab` gives it the full width. The
  detail's offset stops at the last screenful instead of scrolling into blank,
  its title says which rows are on show (`1–35/1017`), and the offset starts
  over when the cursor lands on another row.

`shot.sh git` captures the panel from a checkout: the scripted session's
directory is overridable with `FUTURE_DEMO_CWD`, and the fictional default
keeps every other frame byte-identical across machines.
…s text clears AA

The frame painted only the panels; the canvas was whatever the terminal
profile drew. Ghostty ships `#282c34`, a mid slate, so every dark theme read
washed out no matter which palette was in force, and secondary text sat under
4.5:1. Measured at 120x38 on that profile: 98.6% of the cells carried no
background of ours, `muted` landed at 4.06:1 (2.9:1 for one-dark/dracula on
their own panel) and the rail divider at 1.44:1.

- `workbench::run::canvas_rows` paints every row to the last column with the
  palette's `bg`, re-applying it after each span reset (that is what a
  `styled()` reset would otherwise clear). A row that paints a surface of its
  own — the user bubble, a tool block — keeps its colours and only gets the
  canvas as a fallback; a row on the canvas also gets the palette's `fg`, so
  neither a light palette on a dark profile nor a dark one on a light profile
  is left to the reader's default pair.
- Every dark palette uses the same near-black canvas (`232`, `#080808`) with
  `panel` one step above (`234`); `high-contrast` keeps true black. A theme's
  identity is its hues, not a lighter canvas.
- Every text role now clears WCAG AA (4.5:1) on both the canvas and the panel,
  `fg` 7:1 on the canvas: `muted` is lifted where it was 2.9-4.4:1, and three
  dark palettes' accents (`gruvbox` iris, `nord` red, `solarized` purple).
  The light palettes keep the desktop's shared hues; only their `fg`/`muted`
  moved, and their remaining sub-AA accents are reported in the spec.
- Pinned by `text_roles_clear_aa_on_their_own_canvas`,
  `every_dark_canvas_is_the_same_near_black` and
  `canvas_rows_fill_every_column_and_survive_resets`; the visual spec's table
  and its light-palette shortfall list follow.

The 19 frames in `docs/tui/assets/` predate the painted canvas and are marked
for a re-shoot with the live recipe (verification.md §7).
@huichen
huichen enabled auto-merge (squash) October 27, 2026 08:24
`tab` used to move the keys into the rail, which is the one thing a reader
stepping towards a link never meant. It now walks the openable spans of the
transcript — a markdown link, a `futureos://session/…` conversation link, a
local file, a picture path written in prose — and `enter` opens the one under
the cursor: a URL in the browser, a conversation by switching to it, a file in
the preview box (a picture as a picture). `esc` hands the keys back to the
draft, and the rail keeps its own chord (`ctrl+d`, which now also lands its
cursor on the conversation on screen).

The spans are read back from what the renderer actually emitted (the OSC 8
hyperlinks around every markdown link) rather than parsed a second time, so a
row's targets cannot drift from what it draws; a bare path is accepted only
when it names an existing picture, because every candidate costs a `stat`.

Pictures became reachable by the same route: `![caption](path)` used to render
nothing at all, and now renders its caption (its path, with no caption) linked
to the file; a user message's attached images render the same way from the
path the entry kept. Clicking any visible span does what `enter` does — the
terminal's own ctrl/cmd+click cannot, since it hands the destination to the
browser.
`… N more lines · ctrl+g to expand` has been lying twice over. `ctrl+g` is
the git browser since #1384, and the view toggle it used to answer was
dropped in the Rust port (#1346): pressing the advertised key opened the
repository panel, and nothing expanded a tool body at all.

The footer names `/tool-output` now — the verb the original design already
carried (`/tool-output <call-id>` in #796, still named in a comment the port
left behind) — implemented as a palette entry that flips the same
`ChatArea` toggle: every call's body under its row, up to 200 rows each,
and back again. No chord: the map has no ctrl+letter left (`ctrl+a`/`ctrl+b`
are tmux's, the composer keeps the readline set), which is the same reason
the port left it behind.

The guard stops reading the hint as a sentence to translate once it names a
command, so its allowlist row and the budget go down by one; the docs' own
inventory loses the row and the key table gains the verb.
# Conflicts:
#	tui/src/workbench/i18n.rs
The merge of feat/tui-transcript-links and fix/tui-tool-output added one key
on each side; the exhaustive table's length caught it.
…rome

`git_detail_line` colours a patch line by the prefix it starts with: `diff
--git`, `new file mode`, `similarity index`, `rename from `, `old mode `,
`new mode `. Those strings are git's own diff format compared against the
line, never text this tree writes — the row on screen is the line git
printed, so translating them would be inventing words git never emitted.

Seven `NotChrome` rows in the i18n guard's allowlist, and `BUDGET` 43 → 50
with the reason written next to it.
@huichen huichen changed the title feat(tui): a /git lane graph and a preferences box; preview, pager and switch fixes feat(tui): /git lane graph, preferences box, link walking; one black canvas at AA Oct 27, 2026
@huichen
huichen merged commit 4c888c9 into main Oct 27, 2026
10 checks passed
@huichen
huichen deleted the pr/huichen branch October 27, 2026 09:21
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