On this page

0285. TUI agent surface (M24)

Context

Tenon's TUI core (tui, tty, tui_dashboard, tui_inline, tui_widgets, tui_keys, tui_theme, tui_md, tui_shell) provides deterministic pure ticking, capability isolation, CWE-150 span sanitization, and presented-frame approvals, while lacking the interactive agent-TUI surface identified in plans/tui/IMPROVEMENTS.md Waves 1–2: headless output, OSC 8/9/11 terminal features, session recording/replay, a multi-line prompt editor, fuzzy completion and command palette, inline scrollback commit + transcript search, and spinner/progress/table widgets.

Decision

Adopt decisions D1–D11 of plans/tui-agent-surface/PLAN.md:

  1. D1 (Milestone): Track under parallel milestone M24 (M24.1–M24.9) in PLAN.md.
  2. D2 (Packages): Add pure packages plugins/tui_headless (landed in M24.1), plugins/tui_editor, and plugins/tui_complete; extend plugins/tui, plugins/tui_theme, plugins/tui_inline, plugins/tui_dashboard, plugins/tui_widgets, and plugins/tty. Keep all new packages pure (capabilities = []) except the tty.is_terminal(fd) FFI shim.
  3. D3 (TTY detection): Expose tty.is_terminal(fd) -> bool for fds 0, 1, 2 in plugins/tty, paired with pure tui_headless.mode.choose_output(...).
  4. D4 (Headless approvals): Headless output never approves; it reports pending approvals and exits with code 3 unless daemon policy already decided.
  5. D5 (Hyperlinks): Add span_link(text, style, url) storing the URL in private SpanData. Only tui.present.encode emits OSC 8; allow only http, https, file, and mailto schemes, printable ASCII, max 2,048 bytes; drop invalid URLs while still rendering text.
  6. D6 (Light/dark theme): Add Caps.background: i64 (-1 when unknown, else 0xRRGGBB) decoded from the OSC 11 reply already queried by probe.tn. Add tui_theme.theme_for(caps) selecting a light theme when relative luminance > 0.5, falling back to default_theme().
  7. D7 (Notifications): Add approved request ports terminal.bell (BEL), terminal.notify (OSC 9), and terminal.progress (OSC 9;4) through encode_request, sanitized and capped at 256 bytes; keep window title in Modes.title.
  8. D8 (Session recording): Pure writer in plugins/tui/scenario.tn plus opt-in driver --record PATH (mode 0600, stderr warning) — landed in M24.3.
  9. D9 (Editor storage): vec<str> lines with grapheme cursor indices; caps: 1 MiB buffer, undo depth 100, history 500; benchmarked in bench/tui-editor/.
  10. D10 (Scrollback commit): Bottom-anchored viewport commits rows above the live region using LF at the last row, painting committed rows into freed lines, then repainting the viewport (no DECSTBM in v1).
  11. D11 (Completion sources): Pure data-driven vec<Candidate> per trigger kind (/ commands, @ files, history) with a pure fuzzy scorer; callers may also compose with M21.9–14 closures where convenient.

Consequences