|
| 1 | +# Live PTY UI Testing and Frame Audit Runbook |
| 2 | + |
| 3 | +This runbook documents how to validate Rezi UI behavior autonomously in a real |
| 4 | +terminal (PTY), capture end-to-end frame telemetry, and pinpoint regressions |
| 5 | +across core/node/native layers. |
| 6 | + |
| 7 | +Use this before asking a human for screenshots. |
| 8 | + |
| 9 | +## Why this exists |
| 10 | + |
| 11 | +Headless/unit tests catch many issues, but rendering regressions often involve: |
| 12 | + |
| 13 | +- terminal dimensions and capability negotiation |
| 14 | +- worker transport boundaries (core -> node worker -> native) |
| 15 | +- partial redraw/damage behavior across many frames |
| 16 | + |
| 17 | +The PTY + frame-audit workflow gives deterministic evidence for all of those. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +From repo root: |
| 22 | + |
| 23 | +```bash |
| 24 | +cd <repo-root> |
| 25 | +npx tsc -b packages/core packages/node packages/create-rezi |
| 26 | +``` |
| 27 | + |
| 28 | +## Canonical interactive run (Starship template) |
| 29 | + |
| 30 | +This enables: |
| 31 | + |
| 32 | +- app-level debug snapshots (`REZI_STARSHIP_DEBUG`) |
| 33 | +- cross-layer frame audit (`REZI_FRAME_AUDIT`) |
| 34 | +- worker execution path (`REZI_STARSHIP_EXECUTION_MODE=worker`) |
| 35 | + |
| 36 | +```bash |
| 37 | +cd <repo-root> |
| 38 | +: > /tmp/rezi-frame-audit.ndjson |
| 39 | +: > /tmp/starship.log |
| 40 | + |
| 41 | +env -u NO_COLOR \ |
| 42 | + REZI_STARSHIP_EXECUTION_MODE=worker \ |
| 43 | + REZI_STARSHIP_DEBUG=1 \ |
| 44 | + REZI_STARSHIP_DEBUG_LOG=/tmp/starship.log \ |
| 45 | + REZI_FRAME_AUDIT=1 \ |
| 46 | + REZI_FRAME_AUDIT_LOG=/tmp/rezi-frame-audit.ndjson \ |
| 47 | + npx tsx packages/create-rezi/templates/starship/src/main.ts |
| 48 | +``` |
| 49 | + |
| 50 | +Key controls in template: |
| 51 | + |
| 52 | +- `1..6`: route switch (bridge/engineering/crew/comms/cargo/settings) |
| 53 | +- `t`: cycle theme |
| 54 | +- `q`: quit |
| 55 | + |
| 56 | +## Deterministic viewport (important) |
| 57 | + |
| 58 | +Many regressions are viewport-threshold dependent. Always test with a known |
| 59 | +size before comparing runs. |
| 60 | + |
| 61 | +For an interactive shell/PTY: |
| 62 | + |
| 63 | +```bash |
| 64 | +stty rows 68 cols 300 |
| 65 | +``` |
| 66 | + |
| 67 | +Then launch the app in that same PTY. |
| 68 | + |
| 69 | +## Autonomous PTY execution (agent workflow) |
| 70 | + |
| 71 | +When your agent runtime supports PTY stdin/stdout control: |
| 72 | + |
| 73 | +1. Start app in PTY mode (with env above). |
| 74 | +2. Send key sequences (`2`, `3`, `t`, `q`) through stdin. |
| 75 | +3. Wait between keys to allow frames to settle. |
| 76 | +4. Quit and analyze logs. |
| 77 | + |
| 78 | +Do not rely only on static test snapshots for visual regressions. |
| 79 | + |
| 80 | +## Frame audit analysis |
| 81 | + |
| 82 | +Use the built-in analyzer: |
| 83 | + |
| 84 | +```bash |
| 85 | +node scripts/frame-audit-report.mjs /tmp/rezi-frame-audit.ndjson --latest-pid |
| 86 | +``` |
| 87 | + |
| 88 | +What to look for: |
| 89 | + |
| 90 | +- `backend_submitted`, `worker_payload`, `worker_accepted`, `worker_completed` |
| 91 | + should stay aligned in worker mode. |
| 92 | +- `hash_mismatch_backend_vs_worker` should be `0`. |
| 93 | +- `top_opcodes` should reflect expected widget workload. |
| 94 | +- `route_summary` should show submissions for every exercised route. |
| 95 | +- `native_summary_records`/`native_header_records` confirm native debug pull |
| 96 | + from worker path. |
| 97 | + |
| 98 | +If a log contains multiple app runs, always use `--latest-pid` (or `--pid=<n>`) |
| 99 | +to avoid mixed-session confusion. |
| 100 | + |
| 101 | +## Useful grep patterns |
| 102 | + |
| 103 | +```bash |
| 104 | +rg "runtime.command|runtime.fatal|shell.layout|engineering.layout|engineering.render|crew.render" /tmp/starship.log |
| 105 | +rg "\"stage\":\"table.layout\"|\"stage\":\"drawlist.built\"|\"stage\":\"frame.submitted\"|\"stage\":\"frame.completed\"" /tmp/rezi-frame-audit.ndjson |
| 106 | +``` |
| 107 | + |
| 108 | +## Optional deep capture (drawlist bytes) |
| 109 | + |
| 110 | +Capture raw drawlist payload snapshots for diffing: |
| 111 | + |
| 112 | +```bash |
| 113 | +env \ |
| 114 | + REZI_FRAME_AUDIT=1 \ |
| 115 | + REZI_FRAME_AUDIT_DUMP_DIR=/tmp/rezi-drawlist-dumps \ |
| 116 | + REZI_FRAME_AUDIT_DUMP_MAX=20 \ |
| 117 | + REZI_FRAME_AUDIT_DUMP_ROUTE=crew \ |
| 118 | + npx tsx packages/create-rezi/templates/starship/src/main.ts |
| 119 | +``` |
| 120 | + |
| 121 | +This writes paired `.bin` + `.json` files with hashes and metadata. |
| 122 | + |
| 123 | +## Native trace through frame-audit |
| 124 | + |
| 125 | +Native debug records are enabled by frame audit in worker mode. Controls: |
| 126 | + |
| 127 | +- `REZI_FRAME_AUDIT_NATIVE=1|0` (default on when frame audit is enabled) |
| 128 | +- `REZI_FRAME_AUDIT_NATIVE_RING=<bytes>` (ring size override) |
| 129 | + |
| 130 | +Look for stages such as: |
| 131 | + |
| 132 | +- `native.debug.header` |
| 133 | +- `native.drawlist.summary` |
| 134 | +- `native.frame.*` |
| 135 | +- `native.perf.*` |
| 136 | + |
| 137 | +## Triage playbook for common regressions |
| 138 | + |
| 139 | +### 1) “Theme only updates animated region” |
| 140 | + |
| 141 | +Check: |
| 142 | + |
| 143 | +1. `runtime.command` contains `cycle-theme`. |
| 144 | +2. `drawlist.built` hashes change after theme switch. |
| 145 | +3. `frame.submitted`/`frame.completed` continue for that route. |
| 146 | + |
| 147 | +If hashes do not change, bug is likely in view/theme resolution. |
| 148 | +If hashes change but screen does not, investigate native diff/damage path. |
| 149 | + |
| 150 | +### 2) “Table looks empty or only one row visible” |
| 151 | + |
| 152 | +Check `table.layout` record: |
| 153 | + |
| 154 | +- `bodyH` |
| 155 | +- `visibleRows` |
| 156 | +- `startIndex` / `endIndex` |
| 157 | +- table rect height |
| 158 | + |
| 159 | +If `bodyH` is too small, inspect parent layout/flex and sibling widgets |
| 160 | +(pagination or controls often steal height). |
| 161 | + |
| 162 | +### 3) “Worker mode renders differently from inline” |
| 163 | + |
| 164 | +Run both modes with identical viewport and compare audit summaries: |
| 165 | + |
| 166 | +- worker: `REZI_STARSHIP_EXECUTION_MODE=worker` |
| 167 | +- inline: `REZI_STARSHIP_EXECUTION_MODE=inline` |
| 168 | + |
| 169 | +If only worker diverges, focus on backend transport and worker audit stages. |
| 170 | + |
| 171 | +## Guardrails |
| 172 | + |
| 173 | +- Keep all instrumentation opt-in via env vars. |
| 174 | +- Never print continuous debug spam to stdout during normal app usage. |
| 175 | +- Write logs to files (`/tmp/...`) and inspect post-run. |
| 176 | +- Prefer deterministic viewport + scripted route/theme steps when verifying fixes. |
0 commit comments