Repository navigation
refactor(tui): TuiHost collapses to footer, run_turn and apply - #553
Merged
Merged
Conversation
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.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Second part of #526 (UI epic #523):
TuiHostshrinks from eleven methods to three (footer,run_turn,apply).apply(HostCmd) -> Result<HostReply, String>replacesmodels,set_model,set_effort,request_compaction,new_session,sessions,switch_session,status_linesandset_name. Refs #526, does not close it.Why
Eight of the eleven methods defaulted to
unsupported()and duplicated theHostCmdenum, 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::applydefault: supportsStatus(no lines) and refuses the rest with "not supported by this host", exactly what the removed defaults did.run_host_cmddecides 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-cliTuiSession:footerandrun_turnstay in the trait impl; the nine operations become plain inherent methods (same bodies, same errors), andapplydispatches to them. Its existing unit tests call those methods and are unchanged.docs/tui.md(Architecture: host seam) anddocs/epics.mdupdated in the same PR (AGENTS.md §7); README unaffected.TuiHostoutside this repository (overrideapplyinstead of the removed methods); new public itemtole_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 existingtole-tuitests, including the loop-level footer-refresh test (its host now overridesapply), and the real-terminaltui_e2esuite pass.cora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.FakeHosthas only the three methods, records every command and answers with scripted replies. 7 newtole-tuitests: each change is exactly oneapplycall 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 supportsStatusand refuses the rest.tole-clitest:TuiSession::applydispatches 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/Switchanswer with the session now in use;Statuslines;PickSessionwithout an index).Compactdoing nothing, andNamerouted to the wrong operation.Unrelated flake seen while testing
One full-workspace run failed
tole-coreturn_loop::turn_survives_reopen_between_stepswithLocked { 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-processPrompter, remotely the/approvalsqueue).Related Issues
Refs #526, part of #523. Related: #464, #463, #552.
Generated by Claude Code