1---2name: tui-observe-first3description: >-4 Use when building, fixing, polishing, or comparing any terminal UI —5 ratatui/crossterm REPLs, agent CLI chrome — or when a TUI shows a frozen6 spinner, dead keys, duplicated responses, stale cells, flicker, resume7 failures on dangling tool_use, or when you need side-by-side screenshots8 against reference CLIs.9metadata:10 source: https://skillmd.com/skills/oimiragieo/tui-observe-first11---1213# TUI observe-first1415A TUI is judged **rendered in a real terminal**, never from its source. Render16it, screenshot it, compare it against strong CLIs at the **same terminal grid**,17and cite a screenshot for every finding and fix. Terminal sibling of18`ui-fix-observe-first`.1920## The comparative loop21221. **Reference set**: spawn the CLIs you must beat (e.g. claude, codex, droid)23 and your TUI in the **same** rendering stack and viewport. Reuse the same24 browser/PTY tab for every capture — a resized tab makes an unfair comparison.252. **Capture the same CUJ moments**: welcome, empty composer, slash palette,26 streaming/working, tool receipts, permission dialog, error, interrupt, quit.273. **Teardown**: every finding cites a screenshot. No screenshot = not a finding.28 Rank by impact; fix one issue-class at a time.294. **Re-render after every rebuild**, then dogfood real turns (tools, interrupts).30 Many worst bugs only appear live.3132## What a strong agent TUI usually has3334| Element | Shape |35|---|---|36| Welcome header | Logo + name/version, model · permission-mode, cwd · session — few lines |37| Bottom bar | Mode + key hints left; model · session · cost · ctx% right |38| Working line | Spinner + verb + elapsed + interrupt hint + queued count |39| Turn / tool receipts | Compact status; collapsed summaries, not raw dumps |40| Text | Markdown-lite: bold, inline code, tinted fences |41| Palette | Ranked search; clear selected row; dim aliases |42| Dialogs | Clear selection + quick keys + hint row |43| Input | Distinct prompt; status lives outside the input line |44| Flow | Type-to-queue while running; Esc interrupts; Ctrl+C arms quit |4546## Render-loop laws4748- **Never await a shared engine/session lock in the render loop.** Clone handles49 out and poll with `try_lock`, or the spinner, timer, and keyboard freeze.50- **Every new-turn path goes through one `begin_turn()`** that stamps start time.51 Setting `Running` without a stamp freezes a 0s spinner.52- **Drain completion channels before finalizing** a turn, or leftover deltas53 duplicate response blocks.54- **`Clear` the full frame before drawing** — otherwise stale cells bleed through.55- **Set the terminal cursor explicitly** from the edit column.56- **Repair histories at session load**: dangling `tool_use` without `tool_result`57 breaks resume (API 400). Insert synthetic error tool_results at load.58- **TestBackend tests gate layouts** — they are not proof; screenshots are.5960## Capture traps6162- Compare only at the same font/grid/renderer as your references.63- Browser attach pages can swallow Escape / chords — reproduce keyboard bugs64 against the raw PTY before changing code.65- Scrollback / ready-regex must match the **current** UI string after redesigns.66- `cargo test | tail` can eat exit codes — capture status yourself.6768## Common mistakes6970| Mistake | Reality |71|---|---|72| "It compiles / tests pass, ship it" | Many TUI bugs have green tests. Render + dogfood. |73| Diagnosing look/flow from source | Freeze, bleed-through, grid width, timing do not live in code. |74| Different tabs/sizes for comparisons | PTY grid follows viewport — same tab, same size. |75| Restyling without a reference set | Capture references first, then rank gaps. |7677## Cross-references7879- `ui-fix-observe-first` — web sibling (render → measure → cite → fix)