---
title: "Snapshot tests for TUI render"
---
import RepoFile from '../../../../components/RepoFile.astro'

**Status**: Open — Phase 1, no confirmation needed

## Problem

The TUI has no snapshot-style regression net for the largest composite panes. The render layer has grown significantly since the original analysis:

- <RepoFile path="src/console/manager/render/editor.rs" /> is now **3231L** (was ~1682L — nearly doubled)
- <RepoFile path="src/console/manager/render/list.rs" /> is now **2816L** (was ~2069L)
- <RepoFile path="src/console/manager/render/mod.rs" /> is now **1165L** (was ~500L)
- <RepoFile path="src/console/manager/render/global_mounts.rs" /> is 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)

| Function | File | What to snapshot |
|---|---|---|
| `render_sentinel_description_pane` | <RepoFile path="src/console/manager/render/list.rs" /> | Static "+ New workspace" panel. Zero state. 80×10 terminal. |
| `render_tab_strip` | <RepoFile path="src/console/manager/render/editor.rs" /> | Tab bar with `EditorTab` active. 4 variants × 1 snapshot each. 80×3 terminal. |
| `render_mounts_subpanel` | <RepoFile path="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 | <RepoFile path="src/console/manager/render/global_mounts.rs" /> | Per-subtab renders. New 839L file with no snapshot coverage. |
| Per-tab editor body renders | <RepoFile path="src/console/manager/render/editor.rs" /> | At minimum: General, Mounts, Agents, Secrets tab body renders. |
| Workspace list renders | <RepoFile path="src/console/manager/render/list.rs" /> | Active workspace detail panel with various mount configurations. |

## 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 |

## Steps

1. Add `insta` to `[dev-dependencies]` in <RepoFile path="Cargo.toml" />.
2. Write test modules using `TestBackend` + `insta::assert_snapshot!()`. Start with the 3 original targets, then add the new targets.
3. Run `cargo insta review` to accept the initial snapshots.
4. `cargo nextest run` already runs snapshot comparisons — no additional CI step needed.

## 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.
