Skip to content

fix(tui,agent,screenshots): workbench pointer verbs; a staged model; glyph-exact captures - #1352

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

huichen merged 10 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

The terminal workbench becomes usable with a pointer: dragging a divider follows the cursor, every palette entry actually answers, the header shows the branch the worktree is on, and a model picked before the first session is staged instead of being requested against nothing. Alongside the interaction work, this branch stops doubao from silently keeping its reasoning setting, and makes the TUI screenshot capture place terminal glyphs at their real cell so a captured frame matches what the terminal draws.

Commits

  • fix(agent): doubao can neither be asked to stop thinking nor sent "medium" — the adapter and the model registry now map the reasoning switch and the effort level the provider actually accepts.
  • fix(tui): stage a model picked before the first session, never request it — a selection made while no conversation exists is held as pending instead of being sent to the agent.
  • docs(screenshots): name the TUI capture assets that actually exist — the guide refers to the files the capture path really writes.
  • fix(screenshots): place terminal glyphs at their cell, not by text flow — the cell-accurate renderer replaces the evenly distributed text layout, so narrow and wide glyphs land where the terminal puts them.
  • fix(tui,workbench): the divider follows the pointer, every palette entry answers, the branch reaches the header — live panels gain a pointer-drag divider, palette verbs are dispatched instead of dropped, and the header reads the git branch from the worktree store.

Verification

Run locally at fbd9f7b28 with rustc/clippy 1.97.0 (the version CI pins):

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-tui --all-targets -- -D warnings → clean
  • cargo clippy -p future-agent --all-targets -- -D warnings → clean
  • cargo test -p future-tui --lib → 1025 passed
  • cargo test -p future-agent --lib -- llm:: → 184 passed; -- models:: → 153 passed
  • python3 -m py_compile scripts/screenshots/capture.py scripts/screenshots/tui_terminal.py → clean
  • bash -n tui/scripts/shot.sh → clean
  • make check-docs → 327 docs OK, provider matrix matches the code

Notes

The branch also carries the merge commits that folded each task branch in; the five non-merge commits above are the content. No migration, flag or default change is involved.

Diff vs main

42 files, +1643/−172 — tui/src/workbench/*, tui/src/terminal.rs, agent/src/llm/*, scripts/screenshots/*.py, docs/tui/* and the regenerated capture assets.

…try answers, the branch reaches the header

Four defects the acceptance record had open, each with a test that fails
without the change and a frame from a live 120×38 session:

- **The divider drag was inverted.** The drag added the pointer's displacement
  to the rail width, so a rightward drag widened the rail and pushed the seam
  left (press col 84 → drag col 90 → seam 78, rail 42). It subtracts now, the
  grab is measured from the press cell, and the width clamps to 30..48.
- **Five palette entries answered `Unknown command`.** `/usage` and `/skills`
  name a panel, so the surface focuses it (full screen below the rail's 88
  columns); `/workspace` and `/transcript` answer with what is actually true
  and name the verbs that do move the reader; `/export` runs the agent's own
  HTML exporter and puts the path it wrote on the notice row; `/help` opens
  the key table instead of resolving to a no-op. A read-only panel row no
  longer invents `panel.row.<n>` either. `every_palette_entry_has_a_handler`
  keeps the next entry from rotting the same way.
- **The git branch never reached the header.** New `workbench/git.rs` reads
  `rev-parse --abbrev-ref HEAD` in the session's own cwd (600 ms deadline,
  detached HEAD as `@sha`), cached per cwd; the header draws
  `cwd · ⎇ branch`. Empty outside a repository, so the line degrades to the
  bare path.
- **The first frame could be composed for a stale height.** The driver
  refreshes the terminal size once before the loop's first draw, so the first
  compose — layout and hit map together — uses the size the terminal has now.

The acceptance record's four fails become passes with their new evidence, and
all 16 live frames are re-shot through the repository's own capture tool. The
three defect frames and the old `workbench-120x38.png` (now
`workbench-chat.png`) are deleted: a picture of a bug that no longer exists is
a picture of nothing.

`capture.py tui` grows the scenarios those frames need — `command-usage`,
`command-skills`, `palette-filter`, `launchpad`, `full-panel`, `scrolled`,
`light` and `drag` — so every figure in the record is reproducible with the
shipped tool. The drag step reads the seam from the frame on screen rather
than a hard-coded column, and `light` (the one scenario that persists state)
is documented as last.
The renderer let the browser lay each row out as text and only measured the
*Latin* advance. That is equivalent to a terminal only when every glyph advances
exactly one cell, and in this font stack (Menlo + CJK fallback, 14px, measured in
headless Chrome) it does not:

| glyph                      | advance | cells allotted |
|----------------------------|---------|----------------|
| Latin, box drawing, ▸ · … █ | 8.429px | 8.429 (one)    |
| hanzi                      | 14.000px | 16.858 (two)   |
| full-width punctuation (。)| 7.175px | 16.858 (two)   |

So a Chinese row was squeezed and dragged everything after it left, while the
one-cell border strokes stayed put: the frame looked aligned at its edges and was
wrong inside. On one 120x38 frame, 28 characters sat outside their own cell — the
sidebar's 会话/用量/技能 labels, the digits after a Chinese clause, and one row's
border 1.6 cells left of every other row. Nothing in the pipeline noticed,
because "a PNG was produced" was the only assertion.

- Every cell is now an absolutely positioned box, so placement agrees with the
  grid by construction. A wide cell gets a two-column box and an em equal to it,
  so a hanzi fills both columns instead of sitting narrow with a gap after it.
- verify_alignment re-reads the finished PNG against the grid, and render refuses
  to write a frame with any character missing from its own cell. Pointed at the
  old flow renderer it rejects 309 cells; pointed at this one, zero.
- cell_width measures with white-space:nowrap in a wide window: 100 glyphs
  overflow the default viewport, and a wrapping probe reports the line box (that
  is how a CJK run once measured 7.56px per character instead of 14).
- --self-test pins the emitted geometry (a wide cell is 2*cw wide at its own left
  offset), which the flow renderer cannot satisfy.
`shot.sh` names its output after the scenario and size, while the committed
frames carry shorter names (workbench-chat.png, workbench-panel-usage.png).
The examples now pass the output path, which is correct either way.
…t it

Opening /model on the launchpad and pressing enter printed
"Could not set thinking: session not found — pass a valid session_id" in the
notice row and closed the picker: with nothing attached the agent refuses
set_model/set_thinking_level, so the picker's apply was a request that could
only fail.

An apply with no session now stages the pair instead (SetPendingModel /
SetPendingThinking): the header and the launchpad's chips show the choice, the
driver writes it to settings.json as defaultModel/defaultThinkingLevel, and the
session the first message creates is asked for with it. Once that session
exists the agent is the only source and the staging is cleared. With a session
attached nothing changes — the same two gestures are SetModel + SetThinking.

The surface already decided "launchpad" by an empty session id, but Live only
tracked its own /new flag, so a TUI started against an agent without a session
painted the launchpad and still sent the request; one `detached()` predicate
now answers both questions. The launchpad's model and effort chips follow the
same rule (they hit the same "session not found" wall); mode and permission stay
on the wire, which the agent does accept without a session (measured).

Theme restore needed no change: `esc` after previewing three rows already
repaints the previous palette. Re-verified rather than assumed, by comparing
tmux capture-pane -e of the frame before /theme opened and after `esc`
(byte-identical, 5410 bytes) with the preview frame in between as the control.

Evidence, in a 120x38 tmux pane against an isolated agent (fresh FUTURE_HOME,
fake providers on a closed port):
- /theme: preview → One Light, esc → frame identical to before, themeId never
  written
- /model on the launchpad: clicked-by-keys Beta One + effort high, notice row
  empty, header/chips "beta-one · high"
- first message: new session's header "beta/beta-one · high · open", status bar
  "beta/beta-one · high", then only the fake provider's connect error
- settings.json: defaultModel beta-one, defaultThinkingLevel high

Test: a_model_picked_before_any_session_is_staged_not_requested asserts the
launchpad picker returns only SetPending* (no SetModel/SetThinking/Command) and
the same gestures with a session still return the wire calls.
…dium"

A run on `future/doubao-seed-2.1-pro` died with HTTP 400: `该模型始终思考,
不支持关闭思考;请使用 low、high 或 max。` Two independent causes, both in the
Future-platform derivation for the doubao tokenizer:

- The derived `thinking_level_map` covered only `high` and `xhigh`, so every
  other product level reached the wire as itself. `medium` is not in this
  provider's vocabulary (low/high/max), hence the 400 on a session whose level
  was the default `medium`.
- `thinkingFormat: deepseek` emits `thinking: {"type": "disabled"}` when the
  level is `off`, and this model always thinks, so `off` was a guaranteed 400
  too.

Every level now maps into the accepted set (minimal/low → low, medium/high/
xhigh → high), and `compat.thinkingRequired` says the provider refuses the
disabled spellings: the request asks for *enabled* and, for `off`, simply omits
the depth hint. The flag is per model and defaults to false, so no other
provider's request changes.

Verified: `cargo test -p future-agent --lib -- llm:: models::` 337 passed,
including two new tests — `doubao_maps_every_level_into_the_values_it_accepts`
(each level lands in low/high, and `thinkingRequired` is set) and
`a_model_that_always_thinks_is_never_asked_to_stop` (off goes out enabled for
deepseek/qwen/zai formats, and stays `disabled` without the flag).
`cargo fmt --check` clean; clippy reports only the pre-existing
`agent/src/session/compaction_ops.rs:79` warning.

Not verified: a live call to volcengine. The agent serving this machine still
runs the old binary, so the 400 will persist until it is rebuilt; the check is
`future run --model future/doubao-seed-2.1-pro "<a one-word prompt>"` on a
fresh session after that.
@huichen
huichen enabled auto-merge (squash) October 25, 2026 12:18
@huichen
huichen merged commit b47569e into main Oct 25, 2026
25 checks passed
@huichen
huichen deleted the pr/huichen branch October 25, 2026 12:33
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