Skip to content

[FEATURE] TUI e2e testing: drive infer chat in tmux against the mock gateway #818

Closed

Description

@edenreich

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

Proposed harness shape

  • tests/tmux/ with //go:build tmuxe2e (quarantined from the main test signal; own Taskfile target test:tmux).
  • Setup per test:
    1. Build (or reuse) infer and mock-gateway; start the mock with -port 0 and read its first stdout line for the address.
    2. 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.
    3. Drive: tmux send-keys -t <session> "please stream slowly" Enter.
    4. 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.
    5. Teardown: tmux kill-session.

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_ms kept 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

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions