Repository navigation
feat(tui,screenshots): one picker overlay; the terminal UI captured as a real screenshot - #1348
Merged
Merged
Conversation
…h a line feed A frame written with `\r\n` between rows is only safe while the program's idea of the height equals the terminal's. It need not: the pty reports its size through SIGWINCH, so between a resize and the next frame a taller frame runs past the last row and the alternate screen scrolls. The frame is then not clipped but *shifted* — the header leaves the screen, every band sits above the row the layout assigned it, and an SGR mouse report (a fixed cell) lands on the wrong thing. Measured while building the screenshot harness: in a ttyd-rendered terminal at 1000x700, two frames after start only the last seven rows were still visible. Every row is now placed with `CSI row;1H`, so a size mismatch is harmless — rows past the end draw nothing and no write ever scrolls.
The TUI had no capture path in the repository: `capture.py terminal` wraps a command's stdout in a terminal frame without parsing ANSI, and the old gitignored `.future/tools/tui-shot/` died with the inline TUI it drove. `capture.py tui` runs the shipped binary the way the desktop and mobile scenarios run the real app: `demo_agent` (a scripted gRPC server, one fixed session) answers, `future tui --offline` runs in a pty of a fixed size, and `tui_capture.py` keeps the bytes it wrote there. `tui_terminal.py` replays that stream through a terminal cell model — absolute positioning, SGR colours, double-width CJK, the 256-colour palette, the caret the app left — and has headless Chrome rasterize the glyphs. Two runs produce byte-identical PNGs, which is what lets a diff mean "the UI changed". Bugs this found and fixed, each with a test: - the demo agent dropped its event-stream sender on return, so the stream ended after its first frame; the client then spent a connect wait on every call and the surface never painted at all. - the renderer only consumed the CSI sequences it understood, so `ESC[?25h` was printed as the literal text `[?25h` into the prompt row. Only OCR of the finished PNG caught it; the parser now consumes every CSI and OSC form. - `tui_capture` sizes the pty before exec. `pty.fork()` execs first, and a program that reads 0x0 draws nothing (measured: 0 bytes, looked like a hang).
`/model` and `/theme` cycled a value at a time (twenty models, six themes),
`/sessions` refreshed a list nobody could see, and `/new` quietly swapped the
session instead of showing the launchpad. There is now one list component —
`workbench/picker.rs` — that all three menus open:
- incremental search, `↑↓` / `pageUp` / `pageDown`, group headings the highlight
steps over, `✓` on the row in force, and a window that follows the highlight;
- mouse: a click on a row moves the highlight *and* applies it (a pointer has no
second `enter`), the wheel walks the list, a click outside closes it;
- `/model` groups the agent's models by provider under a reasoning slider
(`←`/`→`, the crate's six levels) and commits model + level together;
- `/theme` lists the six palettes and previews them as the highlight moves,
`esc` restores the one the box opened on, only `enter` persists `themeId`;
- `/sessions` switches conversations; `/new` returns to the launchpad with the
header's own state (connection dot, version) intact.
The theme ids are now the inline catalogue's (`crate::themes::THEME_SPECS`), so
`settings.json` → `themeId` means the same thing in both surfaces; ids older
workbench builds wrote (`future-dark`/`future-light`) still resolve. A typed
`/model` in the draft is a command again, not a prompt sent to the agent, and a
verb with an argument (`/model <id>`) keeps going to the app.
Rows are painted and registered as hit regions from one list and one geometry
(`screen::box_geometry`), which is what makes a click land on the row under the
pointer instead of one beside it.
Behaviour measured against the live agent in tmux at 120×38: 20 models in four
provider groups, a click on `glm-5.3` moved the header and the status bar to
`future/glm-5.3`, `esc` during a theme preview left `themeId` untouched, and
`/new` painted the launchpad with `● future-tui v0.0.2` still in the corner.
The two-providers-one-id case (`future/deepseek-flash` vs
`westlakehpc/deepseek-flash`) ticked two rows until the exact match won over the
id-tail fallback.
Screenshots (`docs/tui/assets/workbench-picker-{model,theme,sessions}.png`) come
from that session, the row chosen with a real SGR mouse click.
Tests: `cargo test -p future-tui workbench` (118), `--lib` (1012), and
`workbench_demo --self-test` (which now also clicks a picker row).
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.
What and why
The workbench gains a single picker:
/model,/themeand/sessionsnow open the same overlay instead of three separate menus, so the three lists share one layout, one key map and one place to fix. The frame renderer stops relying on a line feed to advance between rows and addresses every row absolutely, which is what makes the layout survive a row that grows or is skipped. Alongside it, the terminal UI becomes screenshot-able from the real binary: a small harness drives the workbench through a demo agent and renders each pane to a PNG, and three of those captures (model, theme, session pickers) are checked in underdocs/tui/assetsand referenced from the guides.Commits
/model,/themeand/sessionsVerification
Run on the frozen tip (
be092e8f8) with rustc 1.97.0 / clippy 0.1.97 (the CI toolchain):cargo fmt --all -- --check— cleancargo clippy -p future-tui --all-targets -- -D warnings— clean (includes the newtui/examplesdemo binaries)cargo test -p future-tui --lib— 1013 passed, 0 failedScreenshot captures were produced by the new
scripts/screenshots/tui_capture.pyagainst the real TUI; only the three referenced PNGs are committed.Notes
tui/src/workbench/picker.rsand is driven throughworkbench/mod.rs; the old per-command menus are gone, so/model,/themeand/sessionsshare their behaviour by construction.future-tui,scripts/screenshotsanddocs/; no other crate's public API moves.