Repository navigation
Closed
Labels
enhancementNew feature or request
Description
What problem does this solve?
A second UI (GPUI desktop) can only reuse tole-tui's logic if that logic is not welded to the terminal. Findings from reading the crate:
lib.rsis ~2170 lines.editor,files,menu,transcriptandsanitizealready import no ratatui/crossterm.App::on_keytakes a crosstermKeyEvent(about 100KeyEvent/KeyCodementions) andApp::drawis ratatui. State, key decoding and rendering live in one module.Msg,Action,HostCmd,Footerandtranscript::Kind/Outare already UI-neutral.TuiHosthas 11 methods, 8 of which default tounsupported()and duplicate theHostCmdenum. It has one adapter (TuiSession), so the seam is hypothetical today.
Proposed solution
Inside tole-tui first, no new crate:
- Introduce a UI-neutral
Inputenum (chars, Enter, Alt+Enter, arrows, Esc, Ctrl combos, paste);App::on_input(Input) -> Action. A thin crossterm adapter mapsKeyEventtoInput. The existing keybinding table indocs/tui.mdstays the behavior contract. - Keep
drawin a rendering module that readsAppstate; no state changes there. - Collapse the per-command
TuiHostmethods into oneapply(HostCmd)path (plusrun_turn,footer,sessions), so a remote adapter has a small interface to implement. - Model a pending approval as source-agnostic UI state (today: in-process
Prompter; remote: the/approvalsqueue). It carries the risk tier so a UI never offers allow-always forDestructive.
Extract a tole-ui-core crate only when the GPUI client (separate issue) starts consuming this state, i.e. when there is a second real consumer. Until then the module boundary inside tole-tui is enough (AGENTS.md: adding code is a last resort).
Alternatives considered
- Create
tole-ui-corenow: rejected, one consumer means a speculative seam. - Copy the state machine into the desktop crate: rejected, two copies of keybinding/steer/queue semantics will drift.
Acceptance criteria
-
Apphas no crossterm types; terminal key mapping is an adapter. - Behavior unchanged: all
tole-tuitests pass;docs/tui.mdkey table still true. -
TuiHostshrinks (target: a handful of methods) without losing a slash command. - A fake host in tests exercises the same interface a remote adapter will use.
- Not blocked on the serve issue, but should land after the session-host extraction to avoid reworking
TuiSessiontwice.
Part of #523. Related: #464 (epic: tole-tui), #463 (themes, keybindings).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat(serve): SSE event stream GET /sessions/{id}/events (#546)
refactor(tui): UI-neutral input seam, crossterm as an adapter (#551)
refactor(tui): TuiHost collapses to footer, run_turn and apply (#553)
refactor(tui): approvals as source-agnostic UI state carrying the ris…
ajianaz commentedon Nov 10, 2026
Acceptance status at close (all four parts merged; last one is #555):
Apphas no crossterm types: met.App::on_input(Input)is the logic entry; the crossterm mapping is theterm_inputadapter (App::on_keyis the terminal entry point). Every key the logic does not distinguish isKey::Other.tole-tuitests (76) and the 5 ptytui_e2etests pass; the key table indocs/tui.mdis the contract for both entry points.TuiHostshrinks: met. 11 methods down to 3 (footer,run_turn,apply(HostCmd) -> Result<HostReply, String>); no slash command lost.applyinterface a remote adapter would implement.ApprovalRequestcarries theRisktier (can_allow_always()keepsDestructivenever allow-always),Prompter::askblocks for in-process turns,Prompter::posttakes a reply closure for a remote source; an unanswered request is denied on drop.App::drawand the styling helpers live in a privaterendermodule that only readsApp.TuiSessionwas not reworked twice.Not done, on purpose: no
tole-ui-corecrate (still no second consumer, as the issue says). A remote adapter that implementsTuiHostis the next consumer and belongs to the client issues (#527 to #529).Generated by Claude Code