Repository navigation
Description
Problem
No frame-level regression tests exist: no teatest, no testdata/*.golden anywhere in the repo. UI regressions (layout, wrapping, borders, component sizing) ship silently, and an agent iterating on the TUI has no red/green loop.
Design
Pure Update/View pump — no tea.Program, and deliberately no teatest: teatest/v2 at HEAD is type-compatible with charm.land/bubbletea/v2 but untagged (pseudo-version) and runs a real program with goroutines/timing, while github.com/charmbracelet/x/exp/golden (charm's own -update golden helper) is already in go.sum.
New tests/integration/chat_tui_golden_test.go, reusing newEnv() from agent_gateway_test.go (builds the real service container against the in-process mock gateway — proven pattern):
newChatApp(t, defaultModel)mirrors the 30 constructor args ofcmd/chat.go:213-244getter-for-getter — it compile-breaks when the ctor changes, which is intended.pump(m, msgs...)feedstea.WindowSizeMsg{Width: 120, Height: 40}, scripteddomain.*Events, andtea.KeyPressMsgthroughUpdate. It does not runInit()or execute returned Cmds — goldens are pure Update/View state (Initcurrently has sync side-effects; skipping it keeps goldens stable through that separate cleanup).frame(m)=ansi.Strip(m.View().Content)(fromcharmbracelet/x/ansi, direct dep), trim trailing spaces per line, drop trailing blank lines — so the alt-screen flicker fix won't churn goldens — thengolden.RequireEqual(t, frame(m)).INFER_TUI_DETERMINISTIC=1set inTestMainviaos.Setenv— the latch is process-wide (sync.OnceValue), sot.Setenv's scoped unset would be misleading.
Initial goldens (5):
- Model picker (
defaultModel=""→ ViewStateModelSelection) - Streamed reply (
ChatStartEvent→StreamingContentEvent×N →ChatCompleteEvent+UpdateHistoryEvent) - Tool lifecycle (
ToolCallPreviewEvent→ToolExecutionProgressEventrunning → completed) - Approval box (
ToolApprovalRequestedEvent, handled atchat.go:514) - Reasoning panel (
StreamingContentEventwithReasoningContent)
Regen workflow: go test ./tests/integration/ -run TestGolden -update → review the diff → commit goldens.
Acceptance criteria
- Five goldens committed under
tests/integration/testdata/ - Second run without
-updatepasses; changing a style constant fails with a readable diff - Runs in the normal
task testjob (no build tag)
Dependencies
Depends on #823.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity