Skip to content

refactor(tui): TuiHost collapses to footer, run_turn and apply - #553

Merged
ajianaz merged 1 commit into
developfrom
refactor/tui-host-apply
Nov 10, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/tui-host-apply

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

What

Second part of #526 (UI epic #523): TuiHost shrinks from eleven methods to three (footer, run_turn, apply). apply(HostCmd) -> Result<HostReply, String> replaces models, set_model, set_effort, request_compaction, new_session, sessions, switch_session, status_lines and set_name. Refs #526, does not close it.

Why

Eight of the eleven methods defaulted to unsupported() and duplicated the HostCmd enum, and the trait had one adapter, so a second UI (GPUI, a remote client) had a wide interface to implement for what is really "apply this command". With one call, a remote adapter writes three methods. Agreed as part of the #526 plan (the issue's item 3); the input seam (#551) was part 1.

Changes

  • tole-tui:
    • HostReply { Done, Session(id), Models, Sessions, Lines }: data only. The wording shown to the user ("model → x", "new session s-9", "(failed: ...)") and the pickers stay in the UI (run_host_cmd), so a host has no UI text to produce.
    • TuiHost::apply default: supports Status (no lines) and refuses the rest with "not supported by this host", exactly what the removed defaults did.
    • run_host_cmd decides what to say before handing the command over, then maps the reply. A reply of the wrong kind (e.g. a model list for a model change) is reported in the transcript as (failed: unexpected host reply ...), never a panic.
  • tole-cli TuiSession: footer and run_turn stay in the trait impl; the nine operations become plain inherent methods (same bodies, same errors), and apply dispatches to them. Its existing unit tests call those methods and are unchanged.
  • No slash command is lost; user-visible behavior is unchanged.
  • CHANGELOG (Changed), docs/tui.md (Architecture: host seam) and docs/epics.md updated in the same PR (AGENTS.md §7); README unaffected.
  • Breaking for anyone implementing TuiHost outside this repository (override apply instead of the removed methods); new public item tole_tui::HostReply. Called out in the CHANGELOG.

Testing

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo check -p tole-cli --no-default-features, cargo test --workspace (1203 passed: the previous 1195 plus 8). The 63 existing tole-tui tests, including the loop-level footer-refresh test (its host now overrides apply), and the real-terminal tui_e2e suite pass.
  • Local cora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.
  • The acceptance item "a fake host in tests exercises the same interface a remote adapter will use": FakeHost has only the three methods, records every command and answers with scripted replies. 7 new tole-tui tests: each change is exactly one apply call with the UI's wording and a stale footer; New/Switch report the session id the host names; model and session pickers open from the host's data, and empty or failed ones say so; status lines are shown as given; a failing host is reported and leaves the footer alone; a wrong-kind reply is reported; a host that implements nothing supports Status and refuses the rest.
  • 1 new tole-cli test: TuiSession::apply dispatches every command to its session operation (what each wrote, read back through the session's own readers; bad input refused with the operation's own error; New/Switch answer with the session now in use; Status lines; PickSession without an index).
  • Mutations, each caught: New/Switch wording swapped, the footer never marked stale (3 tests), the adapter's Compact doing nothing, and Name routed to the wrong operation.

Unrelated flake seen while testing

One full-workspace run failed tole-core turn_loop::turn_survives_reopen_between_steps with Locked { holder: <our own pid> }; it passed on the next full run (1203). It is the same signature as an earlier flake, and I reproduced the cause with a throwaway probe (207 of 3000 reopens fail while other threads spawn child processes, 0 of 3000 without) and filed it as #552 with the evidence and a proposed fix. Not part of this PR.

Next in #526

Part 3: model a pending approval as source-agnostic UI state that carries its risk tier (a UI never offers allow-always for Destructive; today the in-process Prompter, remotely the /approvals queue).

Related Issues

Refs #526, part of #523. Related: #464, #463, #552.


Generated by Claude Code

apply(HostCmd) -> Result<HostReply, String> replaces the nine per-command methods; the reply is data only and the UI keeps the wording and the pickers. TuiSession keeps its session operations as plain methods and apply dispatches to them. A reply of the wrong kind is reported, not a panic. No behavior change for users.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit a655449 into develop Nov 10, 2026
15 of 16 checks passed
@ajianaz
ajianaz deleted the refactor/tui-host-apply branch November 11, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants