0285. TUI agent surface (M24)
- Status: Accepted (2026-11-25; recommended defaults D1–D11 from
plans/tui-agent-surface/PLAN.md) - Date: 2026-11-25
- Plan: M24.1–M24.9
(
plans/tui-agent-surface/PLAN.md); builds on 0005, 0222, 0269
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:
- D1 (Milestone): Track under parallel
milestone
M24(M24.1–M24.9) inPLAN.md. - D2 (Packages): Add pure packages
plugins/tui_headless(landed in M24.1),plugins/tui_editor, andplugins/tui_complete; extendplugins/tui,plugins/tui_theme,plugins/tui_inline,plugins/tui_dashboard,plugins/tui_widgets, andplugins/tty. Keep all new packages pure (capabilities = []) except thetty.is_terminal(fd)FFI shim. - D3 (TTY detection): Expose
tty.is_terminal(fd) -> boolfor fds 0, 1, 2 inplugins/tty, paired with puretui_headless.mode.choose_output(...). - D4 (Headless approvals): Headless output never approves; it reports pending approvals and exits with code 3 unless daemon policy already decided.
- D5 (Hyperlinks): Add
span_link(text, style, url)storing the URL in privateSpanData. Onlytui.present.encodeemits OSC 8; allow onlyhttp,https,file, andmailtoschemes, printable ASCII, max 2,048 bytes; drop invalid URLs while still rendering text. - D6 (Light/dark theme): Add
Caps.background: i64(-1when unknown, else0xRRGGBB) decoded from the OSC 11 reply already queried byprobe.tn. Addtui_theme.theme_for(caps)selecting a light theme when relative luminance > 0.5, falling back todefault_theme(). - D7 (Notifications): Add approved request
ports
terminal.bell(BEL),terminal.notify(OSC 9), andterminal.progress(OSC 9;4) throughencode_request, sanitized and capped at 256 bytes; keep window title inModes.title. - D8 (Session recording): Pure writer in
plugins/tui/scenario.tnplus opt-in driver--record PATH(mode 0600, stderr warning) — landed in M24.3. - D9 (Editor storage):
vec<str>lines with grapheme cursor indices; caps: 1 MiB buffer, undo depth 100, history 500; benchmarked inbench/tui-editor/. - 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).
- 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
- Preserves capability isolation (
capabilities = []for all new widgets/renderers), CWE-150 sanitization, and byte-exact replay determinism. - Unblocks a complete inline and fullscreen coding-assistant TUI
(
examples/tui/assistantandcoding-harness-2) while keepingCapsandSpanDataextensions additive.