Repository navigation
Description
Summary
Let the agent test its own TUI: drive infer chat (Bubble Tea) inside a tmux session against the mock inference-gateway from #815, sending keystrokes with tmux send-keys and asserting on tmux capture-pane output — hermetic end-to-end UI behavior tests with no real LLM and no human at the keyboard.
Motivation
#815 covers headless infer agent and piped infer chat, but the interactive TUI requires a real TTY (isInteractiveTerminal gates on stdin+stdout char devices; there is no teatest harness in the repo). Everything that only exists in the TUI is untested end-to-end today: streaming/progressive rendering, spinners, tool-call rows, the interactive approval prompt (the one branch headless can never reach — it blocks or IPCs instead), error banners, keybindings.
tmux gives us a real PTY, deterministic geometry, and text screen capture — the same trick humans use to watch the agent work.
Prerequisite
- [FEATURE] Add mock inference-gateway binary for hermetic end-to-end testing of chat and headless mode #815 / the
mock-gatewaybinary (task build:mockgateway): scenario-scripted responses make UI states reproducible (slow-streamfor spinner/streaming,parallel-readsfor tool rows,write-blockedfor the approval prompt,error-hardfor error banners).
Proposed harness shape
tests/tmux/with//go:build tmuxe2e(quarantined from the main test signal; own Taskfile targettest:tmux).- Setup per test:
- Build (or reuse)
inferandmock-gateway; start the mock with-port 0and read its first stdout line for the address. tmux new-session -d -x 120 -y 40 "env INFER_GATEWAY_URL=<url> INFER_GATEWAY_RUN=false INFER_STORAGE_ENABLED=false HOME=<tmp> <bin>/infer chat"— fixed 120x40 geometry pins wrapping.- Drive:
tmux send-keys -t <session> "please stream slowly" Enter. - Assert: poll
tmux capture-pane -pt <session>(no-e→ ANSI stripped → theme-independent) until a regex matches or a 15s deadline; on timeout, dump the last capture into the test failure. - Teardown:
tmux kill-session.
- Build (or reuse)
Candidate test cases (reusing #815 scenarios)
| scenario | UI behavior pinned |
|---|---|
slow-stream |
spinner appears, content renders progressively, input disabled while streaming |
parallel-reads |
four tool-call rows render with names/args, results fill in |
write-blocked prompt |
interactive approval prompt appears → send-keys approve → tool executes (the branch headless cannot reach); reject path leaves the file absent |
error-hard |
error banner rendered, chat remains usable afterwards |
text-only |
prompt echo, assistant message, ready-for-input state |
Esc during slow-stream |
cancellation notice ("interrupted"), partial content preserved |
Assertion rules (flake budget)
- Text-only assertions — regex/substring on the captured pane; never colors, never exact layout coordinates.
- All waits poll-based with deadlines; no sleeps as synchronization.
- Fixed terminal geometry; scenario
delay_mskept small.
CI
Separate job (apt-get install -y tmux on ubuntu-24.04), allowed to be slower, initially non-required while the flake budget is established.
Out of scope
- Pixel/golden screenshot comparison
- Terminal resize behavior
- Non-tmux terminals (iTerm2/Ghostty specifics)
- Web terminal mode (
infer chat --web) — separate concern with its own server
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(gateway): hermetic mock gateway with INFER_GATEWAY_MOCK mode, sc…