verify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApps here render via the kitty graphics protocol, so they can be verified
without a real terminal. Every verification is recorded: the harness in
captures every frame the app emits, overlays your
inputs (click ripples, caption bar), encodes a video, and generates a summary
page. Do not hand-roll one-off pty scripts that only dump PNGs.
tools/verify-recorder/这里的应用通过 kitty graphics protocol 渲染,因此无需真实终端即可进行验证。每次验证都会被记录: 中的 harness 会捕获应用输出的每一帧,叠加输入操作(点击涟漪、字幕栏),编码视频并生成摘要页面。不要临时编写只能转储 PNG 的一次性 pty 脚本。
tools/verify-recorder/Writing a verification
编写验证
Write a driver script (in /tmp is fine) using the checked-in package:
python
import sys
sys.path.insert(0, "<repo>/tools/verify-recorder")
from driver import Driver
from recorder import Recorder
rec = Recorder("wheel-pan", title="Wheel pan keeps cursor anchored")
d = Driver(["<repo>/engine/target/debug/typing"], rec,
cols=120, rows=32, xpixel=1200, ypixel=800)
d.pump(3.0) # pump between actions so frames arrive
rec.check("app painted", d.frame_size is not None, f"{d.frame_size}")
w, h = d.frame_size # REAL framebuffer size — always use this
d.text("hello", "type into editor") # every input takes a description
d.click(w // 2, h // 3, "select the note") # mouse coords are pixels (1016 mode)
d.wheel(w // 2, h // 2, down=True, n=3, description="scroll content")
d.pump(1.0)
rec.check("scroll redrew", len(rec.frames) > 40, f"{len(rec.frames)} frames")
rec.still("after-scroll") # named snapshot for the summary page
d.stop("ctrl+c") # or "ctrl+q" depending on the app
rec.finish() # composites markers, encodes mp4, writes summary- spawns the argv in a pty (TERM=xterm-kitty, TIOCSWINSZ with pixel dims, answers the
Drivermouse probe), decodes kitty\x1b[?1016$pframes, and feeds them to the recorder. Node apps: spawna=T,f=32,o=zwith["npx", "tsx", "src/main.tsx", ...]the package dir (tsx resolves tsconfig from cwd; a wrong cwd silently drops jsx config).cwd= - Input methods: ,
key("enter"/"esc"/"ctrl+q"/"super+shift+z"),text,click/press/drag(a drag needs all three —releasesends press+release together),click,move. Descriptions become the video caption bar and the summary timeline — write what the step is testing.wheel - for every assertion;
rec.check(name, ok, detail)to pin the current frame into the summary.rec.still(name) - Give checks real assertions (frame deltas, decoded pixel colors via
) — the summary shows pass/fail.
recorder.png_read(rec.frames[-1]["path"])
使用仓库中已提交的 package 编写 driver 脚本(放在 中也可以):
/tmppython
import sys
sys.path.insert(0, "<repo>/tools/verify-recorder")
from driver import Driver
from recorder import Recorder
rec = Recorder("wheel-pan", title="Wheel pan keeps cursor anchored")
d = Driver(["<repo>/engine/target/debug/typing"], rec,
cols=120, rows=32, xpixel=1200, ypixel=800)
d.pump(3.0) # pump between actions so frames arrive
rec.check("app painted", d.frame_size is not None, f"{d.frame_size}")
w, h = d.frame_size # REAL framebuffer size — always use this
d.text("hello", "type into editor") # every input takes a description
d.click(w // 2, h // 3, "select the note") # mouse coords are pixels (1016 mode)
d.wheel(w // 2, h // 2, down=True, n=3, description="scroll content")
d.pump(1.0)
rec.check("scroll redrew", len(rec.frames) > 40, f"{len(rec.frames)} frames")
rec.still("after-scroll") # named snapshot for the summary page
d.stop("ctrl+c") # or "ctrl+q" depending on the app
rec.finish() # composites markers, encodes mp4, writes summary- 会在 pty 中启动 argv(TERM=xterm-kitty、使用像素尺寸的 TIOCSWINSZ,并响应
Drivermouse probe),解码 kitty 的\x1b[?1016$p帧,然后将其传给 recorder。对于 Node 应用:使用a=T,f=32,o=z指定 package 目录来启动cwd=(tsx 会根据 cwd 解析 tsconfig;cwd 错误会悄悄导致 jsx 配置失效)。["npx", "tsx", "src/main.tsx", ...] - 输入方法:、
key("enter"/"esc"/"ctrl+q"/"super+shift+z")、text、click/press/drag(拖拽需要依次执行全部三个操作——release会同时发送 press+release)、click、move。description 会成为视频字幕栏和摘要时间线的内容——请写明该步骤正在测试什么。wheel - 每项断言都应使用 ;使用
rec.check(name, ok, detail)将当前帧固定到摘要页面中。rec.still(name) - 为检查项提供真实断言(帧差异、通过 解码得到的像素颜色)——摘要页面会显示通过/失败状态。
recorder.png_read(rec.frames[-1]["path"])
Ending a verification (required)
结束验证(必需)
rec.finish()pixel open file:///tmp/verify-runs/<name>-<stamp>/summary.htmlThat page is the deliverable: what was tested (clickable timeline that seeks
the video), the checks table, the stills, and the video of the whole run.
Watch out for FAIL rows before declaring the verification passed.
rec.finish()pixel open file:///tmp/verify-runs/<name>-<stamp>/summary.html该页面是最终交付物:展示测试了什么(可点击并跳转视频的时间线)、检查项表格、stills,以及整个运行过程的视频。宣布验证通过前,请留意 FAIL 行。
Gotchas
注意事项
- The engine rounds the window down to the cell grid, so the framebuffer can
be narrower than the requested winsize. Take coordinates from
, never from the requested pixels, or clicks land ~5% off.
d.frame_size - Keep pumping after quit (does) or the exit is never observed.
d.stop - Escape must be kitty CSI-u (handles it); a bare
d.key("esc")makes the app swallow the next escape sequence as literal text.\x1b - If a press lands on a node without handlers, the engine dispatches the click at the release position — a missed drag can silently click something else.
- Hover state only updates on move events; end interactions with a if the screenshot should show hover styling.
move - Apps taking a file path argv need an ABSOLUTE path (their cwd is the package dir).
- Run artifacts live in :
/tmp/verify-runs/<name>-<stamp>/,frames/,events.jsonl,run.json,verification.mp4.summary.html
- engine 会将窗口尺寸向下取整到 cell 网格,因此 framebuffer 可能比请求的 winsize 更窄。坐标必须取自 ,绝不能使用请求的像素尺寸,否则点击位置会偏差约 5%。
d.frame_size - 退出后仍要持续 pump(会负责此操作),否则永远观察不到退出事件。
d.stop - Escape 必须使用 kitty CSI-u 格式(已处理这一点);单独发送
d.key("esc")会让应用将下一个 escape sequence 当作纯文本吞掉。\x1b - 如果 press 落在一个没有 handlers 的 node 上,engine 会在 release 位置分发 click——拖拽失误可能会悄悄点击到其他元素。
- Hover 状态仅在 move 事件时更新;如果截图应显示 hover 样式,请使用 结束交互。
move - 需要文件路径 argv 的应用必须使用绝对路径(其 cwd 为 package 目录)。
- 运行产物位于 :
/tmp/verify-runs/<name>-<stamp>/、frames/、events.jsonl、run.json、verification.mp4。summary.html