Skip to content

feat(tui,host,rpc,cli)!: the workbench becomes future tui; a steadier attach and shadow review - #1346

Merged
huichen merged 30 commits into
mainfrom
pr/huichen
Oct 25, 2026
Merged

huichen merged 30 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

The terminal client changes shape. future tui now opens the workbench — a full-screen interface with its own entry point and its own design spec — and the previous inline UI is deleted rather than kept behind a flag, which is why this branch is marked breaking. Alongside it: the TUI attaches to an Agent that is already running instead of starting or restarting one, a readiness handshake that has not been answered yet is retried within a bounded budget before the client refuses the endpoint, shadow review keeps working after a workspace is moved and logs the failures it used to swallow, a shutdown-cancelled terminal commit is reported as an interruption instead of a failure, and future remote says what a signed-out remote desktop needs instead of failing without an explanation. Two mobile fixes ride along: a paired desktop's name and icon are editable on its row, and a machine's settings are offered only while it can actually be configured.

Commits

  • fix(tui): drop the console-harness hooks the inline-TUI deletion left behind
  • docs: point the agent guide at the terminal UI that exists
  • refactor(tui)!: delete the inline TUI; future tui is the workbench
  • test(host): compare shadow-repo alternates as paths, not as text
  • feat(tui): future tui is the workbench; the inline UI becomes --legacy
  • fix(cli): say what a signed-out remote desktop needs
  • fix(tui): attach to the Agent instead of starting or restarting it
  • fix(rpc): retry the startup readiness handshake instead of refusing
  • fix(host): repair shadow review after a workspace move and log its failures
  • feat(workbench): a second, full-screen TUI with its own entry point
  • test(tui): prove a refused workspace path fails on every platform
  • fix(agent): report a shutdown-cancelled terminal commit as an interruption
  • docs(tui): add the workbench design spec
  • fix(tui): route terminal paste and raw ctrl+c to the new-session screen
  • fix(mobile): offer a machine's settings only while it can be configured
  • feat(tui): new-session screen, final-answer view and workspace-aware session list
  • feat(mobile): edit a paired desktop's name and icon on its row

Verification

Local checks on Rust 1.97.0, the toolchain rust-toolchain.toml pins, at the current head a26a1d5c9:

  • cargo metadata --no-deps -> resolves every target (this is what proves the deleted inline TUI left no dangling [[bin]] behind)
  • cargo fmt -p future-tui -p future-cli -- --check -> clean
  • cargo clippy -p future-tui -p future-cli --all-targets -- -D warnings -> clean
  • cargo test -p future-tui --lib -> 968 passed
  • cargo check --target x86_64-pc-windows-msvc -p future-tui --all-targets -> clean, which is the target that failed CI; reverting only the fix(tui) commit reproduces the same four E0433: cannot find console_harness errors, so the check is falsifiable
  • cargo check --target x86_64-pc-windows-msvc -p future-cli --all-targets -> clean

Earlier in this branch's life, at edc6edc58: cargo fmt --all -- --check clean; cargo clippy -p future-rpc -p future-tui -p future-cli -p future-host --all-targets -- -D warnings clean; cargo test -p future-rpc --lib 230 passed; cargo test -p future-host --lib shadow_review 44 passed; cargo test -p future-cli --lib 1393 passed with 2 failures in commands::mcp_client::tests::process that reproduce identically at origin/main in a clean worktree (the child shell there reports sed: command not found), so they predate this branch.

The commits from other sessions that merged into dev-huichen while this PR was open carry their own local checks; CI on this head is the shared gate. Two of the commits above exist because of CI on this branch: test(tui) removed a POSIX-only assumption that let a refused-workspace test pass for the wrong reason on Windows, and test(host) compares the shadow-repo alternates by path instead of by separators, which is what made alternates_are_repointed_after_the_workspace_moves fail only on Windows.

Notes

  • Breaking: the inline terminal UI is gone and --legacy is no longer a supported surface. future tui keeps its name and is now the workbench.
  • No migration or data-format change.
  • The Windows console test harness is gone with the inline TUI it existed to exercise; the two Windows-only test helpers now skip on a redirected runner instead of spawning a console child. No assertion was changed.
  • An earlier freeze of this branch (through 54ae4c69a) could not build: tui/Cargo.toml still declared a future-workbench binary at tui/src/bin/workbench.rs, a path the repository's bin/ ignore rule had kept out of every commit. The refactor that deleted the inline UI also removed that declaration, so the current head resolves all targets — verified with cargo metadata --no-deps above.

huichen and others added 20 commits October 25, 2026 15:39
The phone's own label for a machine (its name and icon) is stored in the local
credential book and never sent to the desktop, but the only way to change it was
a device page whose every other row is read from or written to that machine.
That mixed a local label into remote settings, and it meant the one thing a user
wants with the machine switched off — call it something recognisable — was
behind a gear that works on a machine that answers.

The label now has its own affording where it is drawn: a pencil beside the name
on the paired list's row opens a dialog with the name field and the icon grid,
and one Save writes one patch carrying only what changed. A blank name still
clears the label, and the icon grid needs no "none" entry because the default
mark is drawn by the default id. A refused write keeps the dialog open with what
the user typed instead of closing on a write that did not happen.

The device settings page drops its identity section, so it is now one subject:
what the machine answers. The label is reachable with the machine offline, which
that page could not offer.

Tests move with the field: the identity cases leave `SettingsScreen`'s suite and
`DesktopLabelDialog` gets its own (opens on the stored label, one patch per save,
a blank name clears, a refusal is reported and retried), and the list's suite
covers the pencil opening the editor for the right machine and the startup
picker's rows carrying no inner control. The screenshot scenarios follow: the
`desktops` rows now expect three controls, `desktop-settings` no longer expects
the identity fields, and `desktop-label-edit` drives the new editor end to end.
…session list

The TUI was the only client without the two things the conversation screen
needs once a session gets long: a way to start a new one with its workspace,
model and thinking level chosen up front, and the same "final answer only"
reading level the desktop and the phone have.

- `ctrl+n` opens a whole-surface new-session screen: one prompt box plus the
  workspace, model and thinking rows, with `@`/`#`/`/` hints. Enter creates
  the session with those choices, sends the draft as its first message and
  switches onto it; the conversation's own draft is untouched. The workspace
  row can name a new folder (`n`, then a path), and the model/workspace lists
  come from the agent (`list_models`, `list_sessions`).
- `ctrl+e` (and `/reply-detail [default|detailed]`) sets the reading level of
  a settled reply. The default keeps the answer a reply ends on and folds the
  reasoning and calls that produced it into one `▸ N tool calls · M thoughts`
  row; `detailed` shows every slice. Neither level inlines tool bodies — those
  still wait for `ctrl+g`. A reply that is streaming, or one with no prose of
  its own, is never folded. The level persists as `replyDetail`, the same key
  the GUI clients store.
- `/workspace`, `/workspace new <path>` and the `ctrl+r` list: the picker now
  orders sessions by last activity and names the workspace each one belongs
  to, and workspaces can be listed, created and switched into.

Two supporting fixes fell out of the fold: a message that had stopped growing
kept `pending` set (nothing ever finished a reasoning-only message), which
also left `thinking…` beside finished work; it is now settled when the run
moves past it. `/transcript` renders at the detailed level, since it is a
record rather than the reading view.
The gear on a paired desktop's row opened a page whose every row is read from
or written to that machine — and it did so whether or not the machine was
answering, and whether or not this phone was the one driving it. Off, still
connecting, or held by another device, that page could only say so: a tap that
lands on a notice, which reads as a broken app.

The action is now offered only when the machine is `connected` and not in
standby, and the row says why in place of the desktop id it would otherwise
file the machine under: "未连接" / "连接中" / "准备中", or who has taken it over.
The gear is dimmed by opacity rather than recoloured — `inkSoft` and `inkMuted`
are two greys that differ in the dark theme but are nearly the same in the light
one, so a token swap would have read as no change exactly where the phone is
easiest to read.

Naming and unpairing stay available in every state: they act on this phone's own
records, and a machine that is off is precisely when a label wants changing.
Taking a held machine back is offered where a machine is picked and on the
connection sheet, so nothing is reachable only through the greyed control.

`pairedMachines` is the list the popover, the picker and this page now share —
the open machine judged from the connection the app renders from, the rest from
their own runtimes — so no surface calls a machine by a state another one
contradicts. `machineConfigurable` owns the two-part rule and treats a machine
no runtime has reported on as configurable, because missing data is not
evidence of a fault.

Covered by unit tests for both helpers, list tests for each state (off,
connecting, held with and without a holder name, per-row independence, and the
no-report case), and two screenshot scenarios that show the greyed action beside
one that still works — including pressing it and proving no page opens.
The screen is modal for keys, but two input paths bypassed it: a bracketed
paste wrote straight into the conversation's composer, and the raw `\x03`
byte interrupted the run instead of leaving the screen. A paste now lands in
the screen's own prompt (the conversation draft stays untouched), and ctrl+c
closes the screen — the rawer form of the same "get me out" as ctrl+n.

refs feat/tui-sessions-reply
The spec for the planned full-screen workbench existed only as an untracked
file in a working tree: no commit, so no other worker could read it, and the
next cleanup would have taken it with it. It is a contract between workers
(type names, file layout, layout constants, key bindings, acceptance
commands), so the one place it has to live is the repository.

The Chinese text is the frozen contract, moved here byte for byte as
`workbench-spec.zh-CN.md`. `workbench-spec.md` is its translation, which the
docs policy requires for every document under `docs/`; only the prose was
translated — the code blocks, type names, constants, colour table, key
bindings and acceptance commands are identical between the two, and the
layout diagram was re-padded so its borders line up with English text.

This is a design proposal for work that has **not** been built: the TUI today
ships the `ctrl+n` composer, `ctrl+e` / `/reply-detail` reply fold and
`/workspace`, which is what `guide/tui.md` documents. `docs/README.md` indexes
the spec as planned work so the two are not mistaken for each other.
…ption

A run's terminal commit is a spawn_blocking task, so a join that reports
cancellation means the runtime shut down under it: the process is exiting,
not the store failing. When that same shutdown also interrupted the run, the
old code marked the session persistence_degraded and logged "restart or
operator intervention required", which sends an operator looking for a
storage fault that does not exist and keeps the session fail-closed.

Such a commit is now read as the interruption it is: one warn line plus an
agent_end carrying the state the journal will be settled to on the next
start (interrupted_by_restart). A real failure - a refused commit, a panicked
task, or a cancelled join without a shutdown interruption - keeps the
fail-closed path and its wording unchanged.
The refused-path case used `/proc/nope/cannot` as a folder that cannot be
created, which is a POSIX assumption: on Windows the path resolves under the
current drive root, and an elevated GitHub Actions runner can create
`<drive>:\proc\nope\cannot`, so `accept_workspace` returned true and the
assertion failed (CI run Rust Windows test / tui-cli).

Build the uncreatable path from a regular file inside a tempdir instead:
`create_dir_all` fails on such a parent on every platform (ENOTDIR on POSIX,
ERROR_PATH_NOT_FOUND/ERROR_ALREADY_EXISTS on Windows), so "cannot create the
folder keeps the editor open and says why" is now really exercised
everywhere. Product behaviour is unchanged.
The workbench was specified as a layout mode of the inline TUI
(`--layout workbench|inline`) wired through `app.rs`. It is not one, and this
commit makes that structural: `future-workbench` is its own program with its own
raw mode, alternate screen, render loop and mouse handling, and nothing in it
goes through `app.rs` or `index.rs`.

Why a second TUI rather than a mode: `future-tui` appends rows into the
terminal's scrollback and diffs the tail; a full-screen surface has to own the
screen, repaint absolute rows and resolve clicks against what it painted. One
binary with two renderers behind a `--layout` switch would have both drawing
into the same output stream. The reuse happens at the leaves instead — the gRPC
client, key parsing, width helpers and the conversation renderer are shared;
none of their behaviour changes.

What the surface does today (demo data, `workbench::demo`; the header says
"demo"):

- The frame: header (pixel whale, block wordmark at width >= 96, session /
  workspace / model, backend dot), conversation, five-panel sidebar with a
  draggable divider, input box, activity row, status bar with a context gauge,
  hint row. Every frame is exactly h rows of exactly w display columns — at
  1x1 too — and the two contract breakpoints (width < 88 drops the sidebar,
  height < 24 squeezes the header and input) are implemented and tested.
- The launchpad as the *body*, not a dialog: logo, wordmark, prompt box, the
  four parameter chips, shortcuts and recent sessions, with no second input
  band under it.
- Mouse (SGR 1006, enabled only by this program): sidebar tabs and rows, the
  divider drag, input focus, wheel scrolling, and "reached the top -> load
  older". Hits are recorded while drawing, so a click cannot drift from what is
  on screen.
- Keys: tab/shift+tab focus, arrows, ctrl+b (show+focus -> unfocus -> hide, or
  full-screen panel on a narrow terminal), `/` command palette with filtering,
  `?` help overlay, ctrl+c quit.
- `/self-test` acceptance from the contract: `cargo run --example
  workbench_demo -- --self-test` checks the four hit regions at 120x38 and
  90x24.

Also: the spec said the workbench coexists with the inline mode behind a
`--layout` switch and that live integration goes through `app.rs`; that is
exactly the framing the workbench should not have, so §1.8 and §2 of both
language versions now say the workbench is an independent TUI with its own
entry point, and that `app.rs` / `index.rs` must not change.

Not wired yet, and documented as such (`docs/guide/workbench.md`): the agent
adapter that fills `WorkbenchData` from `get_state` / `list_sessions` / the event
stream, `future wb` in the unified CLI, and the contract's P1 items.
…ilures

The shadow repo borrows the real repo's object database through
`objects/info/alternates`, written once at init from wherever the store was
then. A renamed, moved or re-cloned Workspace stranded that path: git reported
"unable to normalize alternate object path" on every read, and because the
index had been seeded from the real repo's index it still named objects only
the lost store had, so `write-tree` died with "invalid object … for <path>".
Every Run then recorded a failed snapshot, i.e. that workspace's diff/review
read as unavailable forever, with no way back short of deleting the shadow
state by hand.

`ensure_initialized` now checks the recorded entries on every open (one file
read) and re-points them at the current store when one no longer resolves. A
moved store keeps its seeded index — same objects, so re-hashing a large
checkout is unnecessary — while an index the new store cannot serve (a
re-clone) is dropped, which makes the next snapshot hash the checkout instead
of failing on entries nothing can read. Verified falsifiable: with the repair
stubbed out, both new tests fail.

The same messages also only ever reached the terminal: `eprintln!` bypasses
the log mirror, so a host under a service manager lost the only evidence and
nothing on the line said which subsystem emitted it. They now go through
`tracing` (target `future_host::shadow_review`), which stamps them with a
level and a time and writes them into `~/.future/app/logs/desktop.log`
alongside everything else.
AgentHost::select() called select_agent() once with a 2 s handshake
deadline. On a loaded host the owner Agent can miss that deadline (it was
descheduled, or its socket stalled behind a storage write) while answering
moments later, and a single attempt turned that transient answer into a
permanent refusal - "Agent readiness could not be verified; local startup
is forbidden" - so `future host` exited even though the Agent it has to
attach to was healthy. probe_local_agent() already retried these attempts;
the entry's own startup selection did not.

Route that selection through a shared select_agent_with_retries(), so the
decision to attach-or-refuse is retried like every other readiness probe,
and add coverage: a transiently unavailable readiness still attaches, and
a permanently unavailable one ends in the same Unverified refusal after a
bounded number of attempts.
The TUI used to host a complete Agent in-process when none answered, and every
running terminal supervised it, so several terminals raced to bring a dead
Agent back and any of them could become the owner whose exit interrupted the
other clients' runs. The Agent now belongs to its host only (uture host, the
desktop app, or an explicit uture agent): with no Agent serving, the TUI
exits naming the command to run, and an Agent that disappears later leaves the
client on its reconnect banner.

agent_attach.rs replaces agent_host.rs/agent_supervisor.rs; the exit-path stop,
the supervision loop and the TUI's Agent-hosting dependency go with them
(future-host stays for the update check's rustls provider). Docs, READMEs and
the host/agent-guide claims about a TUI-started Agent are corrected, and the
supervision design records the reversal as D11.
`future remote devices` is mostly local: list and use read and edit the pairing
book, so they succeed with no account - and that is exactly what makes a table
of paired devices (or "X now drives this machine") read as working when nothing
can connect. Both now add the missing fact, naming `future auth login` and the
self-hosted relay alternative, and an empty book says it before `add` would.

remove already queued an undeliverable platform revoke; when the cause is being
signed out it now names the login that drains the queue instead of reporting a
missing auth.json. Pairing a peer against a platform invitation surfaced the
host's bare "Not signed in to FutureOS."; it now explains that such an
invitation needs an account and how to get one.

The group help states which commands need an account and which do not, and the
host guide says the same next to the device commands.
The workbench is the terminal UI now. `future tui` starts it; the previous
inline UI is reachable as `future tui --legacy` and is documented as the
surface it replaced. Both `future tui` and the `future-workbench` binary reach
one driver, so there is exactly one event loop.

Wiring (`workbench/live.rs`, `workbench/run.rs`), reusing the inline TUI's
leaves rather than reimplementing them:

- Conversation: `ChatArea` — markdown, tool rows, thinking and the
  final-answer fold are the same code, so a reply looks the same in both
  surfaces. History paging reads `get_session_entries` with the same backward
  cursor, and older pages prepend without moving the reader.
- Streaming: `prompt` with the coalescing policy; `text_chunk`, `thinking_*`,
  `tool_*`, `agent_end` and `error` drive the transcript and the activity row.
- Approvals: a parked request shows on the activity row and `y` / `n` answer
  it; `get_state.pendingApprovals` brings it back after a restart, and
  `approval_decision` clears it whichever client answered — the desktop or the
  phone may decide first.
- Sessions panel lists `list_sessions` newest first and click switches; usage,
  context and cost come from `get_state`, refreshed on the same events.
- `ctrl+n` / `/new`, `ctrl+x` stop, `ctrl+k` refresh, and the launchpad's
  parameter chips cycle model / effort / permission / approval mode on the
  agent. A first message from the launchpad creates the session, then sends.
- Theme and reading level persist to the same `~/.future/tui/settings.json`
  keys the inline TUI writes, so the two surfaces agree.

`--session`, `--continue` and an initial message all work; `--version`,
`--help`, `--list-models` and print mode are untouched (`--help` gains the one
`--legacy` line).

History mapping moved to `tui/src/session_rows.rs` so both surfaces render the
same journal rows the same way, including its structural rules (an empty
`tool_call` step is not a message, a compaction entry is a divider).

Verified against an isolated agent on a fresh port: `future tui` attaches,
draws a real session, creates one on first submit, streams, and exits cleanly on
ctrl+c with the terminal restored; `future tui --legacy` still starts the old
UI. Not yet wired, and stated as such in `docs/guide/workbench.md`: the todo and
job panels (goal is a local CLI read), the skills browser, image attachments and
`@` file mentions, and the inline UI's `/providers`, `/tools`, `/sandbox`,
`/skills`, `/worktree` panels — those still need `--legacy`.
@huichen
huichen enabled auto-merge (squash) October 25, 2026 09:28
…-tui

# Conflicts:
#	docs/README.md
#	docs/README.zh-CN.md
#	docs/tui/workbench-spec.md
#	docs/tui/workbench-spec.zh-CN.md
The move test asserted the alternates file *contains* the object path
spelled by `PathBuf::join`, which only ever matched by accident: git
reports the common dir canonicalised and with forward slashes, so on
unix the raw temp path survived as a substring of `/private/var/...`
and the assertion passed, while on Windows the written
`C:/.../.git\objects` matched neither form, failing `Rust Windows test
/ host-core` (CI run 40180790222).

Assert the behaviour instead: every line resolves to a live object
store (so the stale pre-move entry is gone) and one of them resolves
to the moved store. Both are compared after canonicalisation, so
neither separator style nor `/private`-style canonicalisation can
decide the result.
@huichen huichen changed the title fix(tui,rpc,host,cli): attach to a running Agent; retry readiness; repair shadow review feat(tui,host,rpc,cli): the workbench becomes future tui; a steadier attach and shadow review Oct 25, 2026
`--legacy` was the wrong shape: keeping a second, complete terminal UI behind a
flag means two renderers, two command sets and two sets of tests to keep alive,
for a surface nobody should reach for. It is gone, along with its page and its
code — not deprecated, deleted (about 70k lines).

Removed:

- `tui/src/app.rs` — the inline app: session orchestration, slash commands,
  overlays, the differential scrollback renderer.
- The components only it drew: menus, footer, pager, provider dialogs, sandbox
  panel, skills browser, usage panel, worktree browser, keymap editor,
  autocomplete, select list, scoped-model selector, approval card, and the
  `ctrl+n` new-session screen (the workbench launchpad replaced it).
- The services that existed for those: keybinding overrides, notifications,
  skill recommendation, the `future skills` CLI plumbing, external editor,
  clipboard integration, worktree git plumbing, insert-into-scrollback, the
  Windows console test harness, and the inline app's agent supervisor.
- The render-parity harness and its goldens (`tui/tests/golden*`,
  `tmux-diff.sh`, `parity-corpus.json`, `mock_agent.rs`, `render_parity.rs`,
  `gen_parity_corpus.py`) and the internals page describing it.
- `--legacy` / `--classic` and `--resume`: unknown options now, which is the
  point — a script that still asks for the old surface fails loudly instead of
  silently getting something else. `--resume`'s session picker has no
  equivalent; `--session` and `--continue` are what replace it.

Kept, because the workbench draws with it: `components/{chat_area,diff,input,
markdown}`, `keys`, `utils`, `theme`, `themes`, `tui` (trimmed to the `Component`
trait and ANSI helpers — the overlay layout maths went with the compositor),
`terminal*`, `paste*`, `rpc`, `agent_attach`, `crash`, `stderr_log`, `home`,
`update`, and `session_rows`.

Split out of files whose owners were deleted, so nothing is duplicated:

- `tui/src/settings.rs` — `TuiSettings`, minus the notification, bell and
  skill-recommendation keys those features took with them. A file that still
  carries them loads; writing it back does not resurrect them.
- `tui/src/approval_mode.rs` — `ApprovalMode`, the part of the sandbox panel the
  launchpad chip and the status bar need.
- `tui/src/subprocess.rs` — the capped spawner (drain-while-waiting, kill and
  reap, no inherited stdin) that the clipboard path shared with the skills CLI.
  It keeps its tests, which are the record of the deadlock it fixes.

`--help` is rewritten rather than patched: the old text was a verbatim port of
the TypeScript CLI's help, complete with `node dist/index.js` in every example,
and no longer described anything that runs.

Docs: `docs/guide/tui.md` now documents the terminal UI that exists (the former
workbench page, moved to the TUI path); the old inline page, the deleted
harness's internals page and the `--legacy` escape hatch are gone. The
`future-tui` coverage record keeps its place with a banner saying what it
measured no longer exists.

Verified against an isolated agent on a fresh port: `future tui` attaches,
draws, creates a session on the first message, streams, and quits cleanly on
ctrl+c; `future tui --legacy` is refused as an unknown option; no
`future-workbench` binary is produced. `cargo test -p future-tui` 968 pass,
clippy `-D warnings` clean, `make check-docs` clean.
AGENTS.md said the TUI can start an agent sidecar; it attaches only and names
what to start instead. The `tui/` entry now says it is the full-screen
workbench and links the page that documents it.
@huichen huichen changed the title feat(tui,host,rpc,cli): the workbench becomes future tui; a steadier attach and shadow review feat(tui,host,rpc,cli)!: the workbench becomes future tui; a steadier attach and shadow review Oct 25, 2026
… behind

`d701765ca` deleted `tui/src/console_harness.rs` and its `pub mod`, but the
two Windows-only test helpers kept calling into it, so the lib-test target no
longer compiled on Windows (`E0433: cannot find console_harness in crate`, four
call sites) while POSIX stayed green because the block is `cfg(all(test,
windows))`.

The harness was removed on purpose (it existed to make the inline TUI's
console tests run under a redirected runner), so the hooks go with it:
`terminal_or_skip` and `backend_or_skip` are back to the plain build-or-skip
pair, and the doc comments no longer describe a console child.
@huichen
huichen merged commit d04d2c7 into main Oct 25, 2026
33 checks passed
@huichen
huichen deleted the pr/huichen branch October 25, 2026 10:43
huichen added a commit that referenced this pull request Oct 27, 2026
`… 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.
huichen added a commit that referenced this pull request Oct 27, 2026
…canvas at AA (#1389)

* feat(tui): let the workspace picker choose no workspace — a plain chat

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.

* fix(tui): make a conversation switch one round trip, and hold the ones 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.

* fix(tui): pageUp/pageDown scroll the transcript, never the rail

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.

* feat(tui): a fresh launchpad opens on 对话会话, the agent's defaults and 完全访问

`/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.

* fix(tui): esc from a preview goes back one level, and the key tables 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).

* feat(tui): put language, palette and rail visibility in the preferences 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.

* feat(tui): a lane graph, a selection band and pageable details in `/git`

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.

* fix(tui): the workbench paints its own black canvas, and every theme'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).

* feat(tui): tab walks the conversation's links and pictures

`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.

* fix(tui): the tool-output footer names a door that exists

`… 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.

* fix(tui): the key table counts the door the tool footer names

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.

* fix(tui): exempt git's diff-header tokens, which the guard read as chrome

`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.
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