Skip to content

fix(cli,screenshots): a kept stop reason; a faithful terminal; doubao notes - #1354

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

huichen merged 9 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

What and why

The screenshot capture path now models a real terminal instead of a plain byte stream, so a captured TUI frame matches what the UI actually draws. The CLI's headless entry point keeps the reason a run stopped even when the Agent also fails to shut down. The doubao thinking-level work is recorded as a live verification instead of staying in a conversation.

Commits

  • fix(screenshots): model the cursor, wrapping and terminal queries a real TUI uses
  • fix(cli): report why the host stopped even when cleanup fails
  • docs(testing): record the doubao thinking-level live verification
  • docs(testing): say that the doubao verification worktrees are gone
  • fix(screenshots): read streams without newline translation; honour ED modes

Verification

  • cargo fmt --all -- --check: clean for every tracked file. The single complaint comes from an untracked scratch file in the local checkout (tui/tests/perf_loop_probe.rs) that is not part of this branch.
  • cargo clippy -p future-cli --all-targets -- -D warnings: clean.
  • cargo test -p future-cli --lib: 1398 passed, 1 failed. The failure is commands::mcp_client::tests::process::the_stderr_tail_keeps_the_last_lines_and_drops_the_oldest in a module this branch does not touch; it passes 3/3 when rerun on its own and is the stderr-tail flake previously reproduced on main.
  • cargo test -p future-cli --lib headless::: 27 passed.
  • python3 -m py_compile scripts/screenshots/tui_capture.py scripts/screenshots/tui_terminal.py: clean.
  • make check-docs: 328 docs OK (placement, bilingual pairing, links, script paths, code fences; provider matrix 13 rows).

Notes

  • The capture scripts now answer the queries a real TUI sends (cursor position reports, wrap and erase-in-display modes) instead of assuming a straight byte stream.
  • Exit status is unchanged: a failure in either the serving loop or the shutdown is still a failure of the entry; only the message keeps both halves.

huichen and others added 9 commits October 25, 2026 20:49
…eal TUI uses

Capturing a second TUI (dsh-tui 0.17.0) as a style reference exposed four places
where the renderer only understood how *our* UI draws. Each is a real terminal
behaviour, not a special case for that app.

- **Relative cursor movement.** dsh-tui skips with `CSI nC` and descends with
  `CSI nB` instead of writing spaces and newlines (445 `26C`, 1299 `1B` in one
  launch). Unknown sequences were consumed, so every glyph landed at the left
  margin — a picture that looks like the *application* rendered badly.
  CUB/CUF/CUU/CUD/CNL/CPL/CHA/VPA/HVP now move the cursor.

- **Movement clamps to the screen.** A cursor cannot leave the grid. Without the
  clamp the column ran past the last one, and the next glyph then looked like an
  overflow, so an app that skips to the right edge tore its own frame apart.

- **Wrapping and scrolling.** A terminal wraps at the right edge and scrolls when
  written past the bottom; both were silently dropped (444 wrapping writes and 89
  scrolls in one dsh-tui launch). Dropping them left the banner in torn fragments
  and everything after the overflow in the wrong rows.

- **Terminal interrogation.** A real terminal answers: DA1, DA2, XTVERSION, the
  OSC 10/11 colour queries, DECRQM for synchronized output, and device status.
  Our pty said nothing, so an app that asks stalled on a degraded first frame —
  measured: the same dsh-tui run drew a torn, left-aligned splash in the pty and
  a clean centred wordmark under tmux, which answers. `tui_capture` now replies.

- The caret is exempt from the alignment check: it is an overlay on the cell the
  app parked the cursor at, and a translucent block over the background reads as
  a fully inked cell, which made a correct frame fail its own check.

Verification, in order of strength:

- every added behaviour has a self-test, and each was re-run with the behaviour
  removed to confirm the test fails;
- `future tui`'s frame is cell-identical to **pyte**'s (0 of 38 rows differ);
- dsh-tui's frame is row-identical to **tmux**'s for 37 of 38 rows, the remaining
  row being the workspace path (different cwd in the two runs).
Verified the fix on the wire against the live Future platform with two
isolated agents built from the same recipe (FUTURE_VERSION pinned), one at
9b13e09 (pre-fix) and one at ab3dcc5:

- new code: medium goes out as reasoning_effort "high", off goes out as
  thinking {"type":"enabled"} with no depth hint; medium/off/high all
  returned a normal reply;
- deepseek-flash is byte-identical to the pre-fix request body at the same
  level, so the new compat flag did not spill over;
- the committed 400 from 20:09 did NOT reproduce: six pre-fix calls with
  reasoning_effort "medium" (and one sending thinking disabled) all
  returned 200. The platform catalogue is field-identical to the 11:59
  cache apart from the proxy BaseURL, so this is a server-side difference,
  not a client-side one. The record says so instead of claiming a
  reproduction.

Also records that the platform catalogue still does not declare
reasoning_effort_values for doubao, which is the alternative fix that
needs a platform-side decision.
The record's reproduction steps pointed at two scratch worktrees that were
removed after the merge; a reader following them would look for paths that
no longer exist.
The foreground host `?`-ed the Agent shutdown before reading the serving
loop's own result, so a cleanup that ran out of its budget replaced the whole
report. Measured on a loaded host: the only line left was "Agent failed to
stop: ... during admitted commands", with nothing saying what had stopped the
entry in the first place - the run had quit because the Agent stopped
answering, and that fact was dropped on the floor.

Combine the two halves in `exit_outcome` instead: both are reported when both
failed, cause first and the cleanup failure named as an additional
complication; a single failure on its own stays exactly the message it was, so
no ordinary exit gains a sentence about a shutdown problem it did not have.

Exit status is unchanged: failure in either half is still a failure, and only
a run where both succeeded is Ok. `until_shutdown`, `StopCause`, the signal
handling and every shutdown timeout/budget are untouched.

Tests: loop failure plus cleanup failure puts both reasons in the final
message; a clean shutdown leaves the loop's reason alone; a failed cleanup on
an ordinary exit is still a failure; both succeeding is success.
… modes

The dsh-tui comparison I published was torn, and the cause was not the app: my
tooling read its capture with a text-mode reader.

`Path.read_text()` (like `open()` in text mode) applies universal newlines and
turns every `\r` into `\n`. In a terminal stream those are different keys. dsh-tui
writes bare CR to return to column 0 and steps rows with `CSI nB` itself, so the
translation turned each "column 0, same row" into "next row": the banner came out
in diagonal fragments and the whole frame looked scrambled. Measured on the same
bytes: read as bytes -> 38/38 rows identical to tmux; read with read_text -> torn.

- `read_stream(path)` reads bytes and decodes them, and the CLI entry uses it.
  `capture.py tui` already decoded bytes, so the harness path was sound; the
  damage was in scripts (and the render CLI) that went through `read_text`.
- ED now honours its parameter. `CSI 3J` clears the scrollback and leaves the
  screen alone; wiping on it (as before) discards the frame just painted. A real
  terminal also does not move the cursor for any ED form, and 0/1 erase only the
  region around the cursor. Found while investigating the tearing; it is not what
  caused it, since dsh-tui follows `3J` with `2J` and a full redraw.

Self-tests pin both: a bare CR survives `read_stream`, and `3J` keeps the screen
while `2J` clears and `0J` clears from the cursor.

Verification, this time printing both sides instead of a count:

- replay of tmux's own `pipe-pane` bytes vs `capture-pane`: 38/38 rows;
- our pty capture vs tmux at the same 30s: 38/38 rows, wordmark centred at rows
  10-14 and 16-20 with nothing above them;
- pyte agrees on both frames: 38/38 for dsh-tui and 38/38 for `future tui`.
@huichen
huichen enabled auto-merge (squash) October 25, 2026 14:23
@huichen
huichen merged commit 2ad1bc7 into main Oct 25, 2026
10 checks passed
@huichen
huichen deleted the pr/huichen branch October 25, 2026 14: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