Repository navigation
feat(tui): bring the terminal UI up to the desktop feature surface - #776
Merged
Merged
Conversation
The TUI had fallen behind the desktop app: no provider or model editing, no skills browser or install path, no sandbox or permission controls, and menus that could only list a flat set of choices. This lands the interaction surface the desktop already had, plus the defects that surfaced while verifying it. Interaction surfaces - A popup-menu framework (incremental search, groups, multi-select, reload) now backs /providers, /models, /tools, /sessions, /tree and the scoped-model picker, replacing the flat lists. - Provider and model configuration: add and edit providers, keys, endpoints and models from the panel. /provider-key captures a key and does what its prompt promises — empty input clears the stored key. - Skills: a browser that merges the agent's own skills with the installable catalogue, with search, groups, a detail preview and use. Install, uninstall (a two-press confirmation that any other key disarms) and upgrade run through the `future` binary, then refresh the panel so it shows the new state. - Sandbox and permission: /sandbox shows the tier, its reason and how platforms differ, and surfaces the agent's silent sandbox-to-manual fallback instead of hiding it; /permission persists the level. - Diff rendering for edit, write and patch output, with per-file stats, collapsing and syntax colouring. - A full-screen pager (/transcript) with search, copy and a status row, whose live search claims the first escape. - Clipboard (/copy) with a tmux, native, OSC 52 ladder and an honest notice when a write cannot be confirmed. - Desktop notifications and the terminal title (OSC 9 and OSC 0), respecting the terminal's own settings. - External editor drafts for /editor, and a theme catalog behind /theme that repaints every chrome widget. - /worktree picks or creates a git worktree and moves the session into it, reusing the existing set_cwd RPC; destructive git subcommands are refused. - /keymap lists every binding by group and rebinds one, with conflict detection and persistence to `~/.future/tui/keybindings.json`. - Finished transcript rows are inserted into the terminal's own scrollback, so a conversation can be scrolled back to and selected with the terminal's copy mode after the TUI exits. Rows are handed over once (a watermark), re-wrapped at the terminal width, and sanitised so a tool result cannot replay an escape into the terminal a second time. - /history results now show why each hit matched and when it was said: the query is highlighted inside the snippet (display-width aware, so CJK and emoji are not cut), the timestamp is printed, and the opaque entry id is demoted. - Long pastes fold. A paste longer than 200 characters never enters the box as text: it is kept aside and replaced by a `[Pasted Content N chars]` marker (numbered `#2`, `#3` … for repeats, reusing a number a deleted marker frees), and expanded back to the pasted bytes on submit. The threshold is the box's own height in characters — three lines at 80 columns, so roughly 240 characters are visible — because a paste that overflows the box while still being shown as text is what the marker exists to prevent. The count is characters, not bytes, so CJK is not three times as long as it looks. - Pasting an image *path* attaches the file instead of inserting the text: an `[Image #N]` marker in the box, the number of waiting images beside it, and the path on the wire as an attachment. Dragging a file into the terminal pastes its path, so this is how that gesture becomes an attachment. The path is normalised (quotes, `file://`, backslash-escaped spaces) and the file is checked by its magic bytes — a text file named `notes.png` is not an image, so it stays text. - Ctrl+V takes an image off the system clipboard (a screenshot), or its text when it holds no image. `super+v` is bound to the same path: upstream of a Kitty-protocol terminal a Command press is reported that way, and where the terminal keeps Command for its own Paste menu the key never arrives at all — which is why Ctrl+V remains what that case sends. Deleting a marker drops its attachment and the survivors are renumbered, so what is shown is what is sent. - A paste burst is detected when the terminal does not send bracketed paste (some Windows hosts): characters that arrive faster than typing are buffered as one paste, so an `Enter` inside it is a newline rather than a submit and a `?` in it does not toggle anything. Only the bracketed-paste-less path uses it, so the recorded screens are unchanged. Slash commands added to the dispatch surface /shell /delete /title /metrics /snapshot /context /export (now a real implementation rather than a stub) /agent /history /tool-output /autocompact /autoretry /scoped-models /fork /keymap /worktree and /theme <id>. Shortcuts ctrl+v pastes the clipboard (image or text) and is listed in `/help` with the other keys — pasting an image has no slash command to be discovered through. ctrl+x copies the last answer, as before. Commands removed - /append-prompt and /system-prompt were silent no-ops: the agent composes a run's system prompt from project context, skills, workspace memory and the tool list and never reads the list field those commands wrote, so the value was overwritten at every run boundary. Their RPCs stay (the CLI builds them directly for its own flags) but nothing here sends them any more. - /ephemeral, /rule, /quit-agent and /stats were removed by choice. /stats was not dropped: its counters are now the tail of /status, so the session report and the usage ledger have one home instead of two panels printing the same numbers. - Unknown slash commands still fall through to a prompt, so one typed from muscle memory is sent as text rather than rejected. That is the existing, test-pinned behaviour that also lets `/usr/bin/foo` be sent as a message. Fixes - The skills child's pipes are drained while it waits, so a catalogue larger than the 64 KiB pipe buffer no longer deadlocks into a timeout. - An overlay owns its whole row instead of splicing over the rows beneath it, so chat text can no longer bleed into a panel's leading columns. - /help scrolls (the commands above were unreachable at 80x36), /permission opens focused on the permission half of its shared card, and truncated hints end in an ellipsis. - A panel's live search claims escape before the overlay closes, matching what the components already did when tested in isolation. - The pager accepts the key ids a real terminal sends (pageDown, not pagedown). - The mock agent carries `state` on agent_end, without which the completion notification path was unreachable in the harness. - A test restores the panic hook it installed instead of removing it, so a leaked hook can no longer swallow another test's panic or append to the developer's real crash log. - Cumulative token totals are labelled as resent-per-call and joined by an average per query, so they cannot be read as the current context size. - markdown follows the active palette: under the light theme, headings, links and code were painted with the dark constants' xterm indices (1.4-2.3:1 on white) while the palette's own md_* roles went unread. - /history snippets were byte slices of concatenated UTF-8, so a window edge could land inside a multi-byte character and lossy decoding rendered the half as U+FFFD — the box users saw with CJK text. The partial character is dropped on each edge instead of substituted for; the SQL and `byteOffset` are unchanged. Verification - 2020 TUI unit tests, 8 CLI smoke tests and 5 bug-hunt regressions pass, plus 1822 agent tests; rustfmt and clippy are clean at the pinned 1.97.0 toolchain. - A tmux harness drives the real TUI against a deterministic mock agent and compares recorded screens byte for byte, waiting on content instead of fixed sleeps. It covers every panel listed above plus the applied state (tier set, permission applied, theme switched, tool expanded, search, paging) and the paste surfaces (folding, an image path, attachment numbering, renumbering after a delete): 51 checks pass, 0 warnings. - Pasting was checked end to end on a real pane, not through doubles. A 250 character paste folds, and the whole text still reaches the agent while the marker never does (the mock echoes the prompt, so the pane is the wire). A pasted image path and a Ctrl+V from the clipboard both attach, and the attachment's path, kind and name arrive on the prompt. - The clipboard probe was run on macOS both ways: with a real PNG on the clipboard it writes the file, and with text on it the tool fails without leaving a partial file behind — which is the fallback to a text paste. - The scrollback path was checked against a real pane, not a double: the exit status and the conversation are readable through `capture-pane -S` after the TUI leaves, the oldest rows sit above the viewport (so scrolling is required to reach them), and one exchange produces exactly one copy of each row. - New-on-branch coverage is complete: three independent oracles (two blame-based, one difflib) agree on zero uncovered lines, sanity-checked against a report with 57059 records of which 96.9% are covered. Not verified here - Windows and Linux are covered by CI only; this machine cannot cross-compile the agent's `ring` dependency. The clipboard probe's PowerShell and Wayland / X11 command lines are held by unit tests, not by a real clipboard on a host that has them. - Command+V cannot be shown to work on a terminal that does not speak the Kitty keyboard protocol (Terminal.app, for one): the key never arrives there. That is a property of the terminal, not something the TUI can fix — Ctrl+V is what that case sends, and both spellings are bound. - The keymap panel's capture/rebind flow was driven by unit tests and the keybindings.json round trip, not end to end in a real pane. - ctrl+p (cycle model) cannot be exercised in the harness: the real agent implements `cycle_model`, the mock does not.
huichen
enabled auto-merge (squash)
September 22, 2026 08:53
Twelve tests passed on macOS and failed on Linux CI, each for the same shape of reason: a test asserted one host's behaviour while the code under test read the host it happened to be running on. - Clipboard paste: four tests drove `ctrl+v`/`super+v` and asserted the macOS probe names (`osascript`/`pbpaste`), while `paste_clipboard` read `std::env::consts::OS` — on Linux the probes are `wl-paste`/`xclip`. The OS is now a parameter (`paste_clipboard_for_os`), as the sandbox panel already does for its platform, and the tests pin macOS. - Sandbox/permission panels: three tests asserted `current: Sandboxed` and the marked tier row, which is the macOS platform default; on Linux the default is `Manual` and Bubblewrap adds its own caveat. The app now reads one `host_sandbox_platform()`, pinned to macOS in the test build, so the whole panel lifecycle (open, probe, policy answer) agrees. - Copy: `recording_clipboard` inherited the host's resolved candidate list. On macOS `pbcopy` was found and the recording runner was reached; a Linux runner without X11/Wayland resolved to no candidates, so `copy()` took the OSC 52 fallback and recorded nothing. The helper now carries one synthetic candidate, the same on every host — `copy()` keeps using the clipboard's own list, so only the fixture changes, and the real OSC 52 fallback keeps its own test. - Skills: `skills_cli_for_host` returned `None` when no `future` binary was resolvable, so on a CI runner (none next to the test executable, none on `PATH`) the panel showed the no-binary notice and two tests waited for behaviour that needs an installer. The test build now always offers the refusing installer; a test that wants the missing-binary state sets `skills_cli = None`, as one already did. Verified: 2020 tui unit tests pass, rustfmt clean, clippy clean at the pinned 1.97.0 toolchain. Each of the twelve is host-independent by construction rather than by a host check — the test build cannot read the host for the platform, the OS arrives as an argument, and the candidate list is synthetic — so the run on this Mac is the run CI will do, not a second behaviour to be reconciled later.
huichen
force-pushed
the
feat/tui-parity
branch
from
September 22, 2026 09:23
8268e07 to
51a35a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(tui): bring the terminal UI up to the desktop feature surface
The TUI had fallen behind the desktop app: no provider or model editing, no
skills browser or install path, no sandbox or permission controls, and menus
that could only list a flat set of choices. This lands the interaction surface
the desktop already had, plus the defects that surfaced while verifying it.
Interaction surfaces
backs /providers, /models, /tools, /sessions, /tree and the scoped-model
picker, replacing the flat lists.
models from the panel. /provider-key captures a key and does what its prompt
promises — empty input clears the stored key.
catalogue, with search, groups, a detail preview and use. Install, uninstall
(a two-press confirmation that any other key disarms) and upgrade run through
the
futurebinary, then refresh the panel so it shows the new state.differ, and surfaces the agent's silent sandbox-to-manual fallback instead of
hiding it; /permission persists the level.
collapsing and syntax colouring.
live search claims the first escape.
a write cannot be confirmed.
terminal's own settings.
repaints every chrome widget.
reusing the existing set_cwd RPC; destructive git subcommands are refused.
and persistence to
~/.future/tui/keybindings.json.conversation can be scrolled back to and selected with the terminal's copy
mode after the TUI exits. Rows are handed over once (a watermark), re-wrapped
at the terminal width, and sanitised so a tool result cannot replay an escape
into the terminal a second time.
is highlighted inside the snippet (display-width aware, so CJK and emoji are
not cut), the timestamp is printed, and the opaque entry id is demoted.
text: it is kept aside and replaced by a
[Pasted Content N chars]marker(numbered
#2,#3… for repeats, reusing a number a deleted marker frees),and expanded back to the pasted bytes on submit. The threshold is the box's own
height in characters — three lines at 80 columns, so roughly 240 characters are
visible — because a paste that overflows the box while still being shown as
text is what the marker exists to prevent. The count is characters, not bytes,
so CJK is not three times as long as it looks.
[Image #N]marker in the box, the number of waiting images beside it, and thepath on the wire as an attachment. Dragging a file into the terminal pastes its
path, so this is how that gesture becomes an attachment. The path is normalised
(quotes,
file://, backslash-escaped spaces) and the file is checked by itsmagic bytes — a text file named
notes.pngis not an image, so it stays text.it holds no image.
super+vis bound to the same path: upstream of aKitty-protocol terminal a Command press is reported that way, and where the
terminal keeps Command for its own Paste menu the key never arrives at all —
which is why Ctrl+V remains what that case sends. Deleting a marker drops its
attachment and the survivors are renumbered, so what is shown is what is sent.
Windows hosts): characters that arrive faster than typing are buffered as one
paste, so an
Enterinside it is a newline rather than a submit and a?in itdoes not toggle anything. Only the bracketed-paste-less path uses it, so the
recorded screens are unchanged.
Slash commands added to the dispatch surface
/shell /delete /title /metrics /snapshot /context /export (now a real
implementation rather than a stub) /agent /history /tool-output /autocompact
/autoretry /scoped-models /fork /keymap /worktree and /theme .
Shortcuts
ctrl+v pastes the clipboard (image or text) and is listed in
/helpwith theother keys — pasting an image has no slash command to be discovered through.
ctrl+x copies the last answer, as before.
Commands removed
run's system prompt from project context, skills, workspace memory and the
tool list and never reads the list field those commands wrote, so the value was
overwritten at every run boundary. Their RPCs stay (the CLI builds them
directly for its own flags) but nothing here sends them any more.
not dropped: its counters are now the tail of /status, so the session report
and the usage ledger have one home instead of two panels printing the same
numbers.
muscle memory is sent as text rather than rejected. That is the existing,
test-pinned behaviour that also lets
/usr/bin/foobe sent as a message.Fixes
than the 64 KiB pipe buffer no longer deadlocks into a timeout.
chat text can no longer bleed into a panel's leading columns.
opens focused on the permission half of its shared card, and truncated hints
end in an ellipsis.
the components already did when tested in isolation.
stateon agent_end, without which the completionnotification path was unreachable in the harness.
leaked hook can no longer swallow another test's panic or append to the
developer's real crash log.
average per query, so they cannot be read as the current context size.
and code were painted with the dark constants' xterm indices (1.4-2.3:1 on
white) while the palette's own md_* roles went unread.
could land inside a multi-byte character and lossy decoding rendered the half
as U+FFFD — the box users saw with CJK text. The partial character is dropped
on each edge instead of substituted for; the SQL and
byteOffsetareunchanged.
Verification
1822 agent tests; rustfmt and clippy are clean at the pinned 1.97.0 toolchain.
compares recorded screens byte for byte, waiting on content instead of fixed
sleeps. It covers every panel listed above plus the applied state (tier set,
permission applied, theme switched, tool expanded, search, paging) and the
paste surfaces (folding, an image path, attachment numbering, renumbering
after a delete): 51 checks pass, 0 warnings.
character paste folds, and the whole text still reaches the agent while the
marker never does (the mock echoes the prompt, so the pane is the wire). A
pasted image path and a Ctrl+V from the clipboard both attach, and the
attachment's path, kind and name arrive on the prompt.
clipboard it writes the file, and with text on it the tool fails without
leaving a partial file behind — which is the fallback to a text paste.
status and the conversation are readable through
capture-pane -Safter theTUI leaves, the oldest rows sit above the viewport (so scrolling is required to
reach them), and one exchange produces exactly one copy of each row.
one difflib) agree on zero uncovered lines, sanity-checked against a report
with 57059 records of which 96.9% are covered.
Not verified here
the agent's
ringdependency. The clipboard probe's PowerShell and Wayland /X11 command lines are held by unit tests, not by a real clipboard on a host
that has them.
keyboard protocol (Terminal.app, for one): the key never arrives there. That is
a property of the terminal, not something the TUI can fix — Ctrl+V is what that
case sends, and both spellings are bound.
keybindings.json round trip, not end to end in a real pane.
implements
cycle_model, the mock does not.