Snapshot tests for TUI render
Status: Open — Phase 1, no confirmation needed
Problem
Section titled “Problem”The TUI has no snapshot-style regression net for the largest composite panes. The render layer has grown significantly since the original analysis:
src/console/manager/render/editor.rsis now 3231L (was ~1682L — nearly doubled)src/console/manager/render/list.rsis now 2816L (was ~2069L)src/console/manager/render/mod.rsis now 1165L (was ~500L)src/console/manager/render/global_mounts.rsis now 839L (new sub-module)
No insta or other snapshot testing library exists in the dependency tree. All render testing uses manual TestBackend + assert! assertions against buffer contents.
Three target functions (updated from original)
Section titled “Three target functions (updated from original)”| Function | File | What to snapshot |
|---|---|---|
render_sentinel_description_pane | src/console/manager/render/list.rs | Static ”+ New workspace” panel. Zero state. 80×10 terminal. |
render_tab_strip | src/console/manager/render/editor.rs | Tab bar with EditorTab active. 4 variants × 1 snapshot each. 80×3 terminal. |
render_mounts_subpanel | src/console/manager/render/list.rs | Mount list subpanel. 3 cases: empty, 1 mount, 3 mounts. 60×20 terminal. |
Additional high-value targets identified in re-analysis:
| Function | File | What to snapshot |
|---|---|---|
| Global mounts editor rendering | src/console/manager/render/global_mounts.rs | Per-subtab renders. New 839L file with no snapshot coverage. |
| Per-tab editor body renders | src/console/manager/render/editor.rs | At minimum: General, Mounts, Agents, Secrets tab body renders. |
| Workspace list renders | src/console/manager/render/list.rs | Active workspace detail panel with various mount configurations. |
Implementation
Section titled “Implementation”Use insta for snapshot storage + review workflow; ratatui::backend::TestBackend for the buffer (already used widely in existing tests — no extra dependency just for the backend).
| Library | Stars | Approach | Fit |
|---|---|---|---|
insta | ~4k | String snapshots with cargo insta review | Best — simple, no async, inline or file-based |
ratatui::backend::TestBackend | built-in | Raw buffer comparison | Already available |
trycmd | ~400 | CLI snapshot testing | Wrong layer — tests full CLI, not render functions |
- Add
instato[dev-dependencies]inCargo.toml. - Write test modules using
TestBackend+insta::assert_snapshot!(). Start with the 3 original targets, then add the new targets. - Run
cargo insta reviewto accept the initial snapshots. cargo nextest runalready runs snapshot comparisons — no additional CI step needed.
Why before Phase 2
Section titled “Why before Phase 2”These snapshot tests are the regression net for the Phase 2 file splits AND the Phase 1.5 DRY extractions. The TUI render layer has extreme boilerplate duplication (120 Style::default() chains, 18 Block::default() constructions, 192 Span constructions) — snapshot tests make it safe to extract shared helpers without silently changing TUI appearance.