Commit Graph

1 Commits (345f8391edbf4b7324e2759bf251f5568cf06255)

Author SHA1 Message Date
mula.liu 8fd235b961 Judge a captured frame by what is on the screen, not by what was sent
`tui-frame-check.py` is the part of `win-tui-capture.sh` that decides whether a
run passed, taken out of the shell script so that fixing the judgement does not
require the real machine to run again — `TUI_REUSE=1` re-reads a saved byte
stream, which is how both bugs in this branch were confirmed fixed against
captures taken before the fix existed. `--selftest` feeds it six screens it made
up — two good ones and four broken ones, including a screen where every Chinese
character makes `len()` measure the frame too narrow — and fails if the judge
goes quiet on a bug or shouts at a good screen.

The four rules it encodes were each paid for with a false verdict:

* the right border is only trusted on rows whose *first* character is a border
  character, because the box-drawing bar also appears in prose and in ASCII mode
  as `|`, and reading the last one on a row found the wrong column;
* columns are counted by accumulated display width, not by `len()`, because a
  terminal emulator keeps one character for a glyph that occupies two cells;
* only a screen that was painted at least eight rows and seen twice is judged,
  so a half-drawn frame cannot be mistaken for a torn one;
* a row that ends in a border but starts with prose is a row sitting *on* a
  border — the shape the toast produced — which is how the judge caught a bug
  nobody had thought to look for.

`win-tui-run.ps1` was missing from the repository while `win-tui-capture.sh`
depended on it, so the proof the last commit described was not in fact
repeatable. It exists here, and it is the reason the captures are trustworthy:
`mode con cols=100 lines=30` fails silently on the ConPTY that Windows OpenSSH
allocates, so every earlier "capture at 100 columns" was a 120-column frame
reflowed by the emulator. It sets the size through `[Console]::WindowWidth` and
reports the size it ended up with, and the emulator replays that rather than the
one we asked for.
2026-10-15 21:20:58 +08:00