Repository navigation
refactor(cli): move tool registration out of session_host into tool_roster - #547
Merged
Merged
Conversation
…oster (#525) UpdatePlanTool, PlanEmitter, register_gitea, detect_github_repo and github_repo_from_remote_url (with their tests) move from session_host.rs to tool_roster.rs. Pure move: no behavior change, same test count. Callers updated, no re-export.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
2 of 3 tasks
ajianaz
added a commit
that referenced
this pull request
Nov 10, 2026
## What Part 2c of #525 (UI epic #523): `session_settings` owns a session's durable settings: the register names (`fact/model`, `fact/reasoning_effort`, `fact/session_name`), the label validation and the writers. The TUI's `/model`, `/effort`, `/name` and `/compact` and ACP's model picker write through it, and the readers use the same constants. Refs #525. ## Why The same registers were written in two places (`tui_host.rs` and ACP's `set_model_option`) and named by repeated string literals in the writers and readers (`turn_runner`, `status`, `acp`). A rename or a validation tweak had to be found in each. Agreed with the owner on 2026-11-10 as the last piece of the shared-primitives plan for #525. ## Changes - `session_settings.rs` (new): `MODEL` / `EFFORT` / `NAME` register constants; `clean_label` (moved from `tui_host.rs`: non-blank, at most 120 chars, no control characters); `set_model`, `set_effort` (validated and canonicalised, or `None` clears the override back to the process default), `set_name`, `request_compaction` (the forced pass of #481), and `write_model` (store as given, for ACP, which validates against its own model list first). - `tui_host.rs`: the setters call the module (its private `commit` helper and `clean_label` are gone; the window cache is still reset after a model switch). - `acp.rs`: `set_model_option` writes through `write_model` (its own validation, busy check and error text stay); `MODEL_REGISTER` is the shared constant. - `turn_runner.rs` (`session_model`, `session_effort`) and `status.rs` read through the constants. - CHANGELOG and `docs/epics.md` updated in the same PR (AGENTS.md §7); README unaffected. Behavior and error text are unchanged (`invalid model id`, `invalid name`, `invalid reasoning effort ...`, and the `storage error:` prefix on a failed write). ## Testing - [x] `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo check -p tole-cli --no-default-features`, `cargo test --workspace` (1187 passed: the previous 1182 plus 5) - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. - [x] 5 new unit tests: label rules (trim, blank, control characters, the 120-char limit); the model is stored where the readers look and a bad id writes nothing; effort is validated, canonicalised (` HIGH ` → `high`), a rejected level changes nothing, and `None` clears to the process default; the name register renames and a bad name is refused (the core's `session_name()` reads it); a compaction request is a durable pending flag. The existing `tui_host` tests (`switches_write_the_registers_the_next_call_and_resume_read`, `name_and_compact_request_are_durable_registers`) run unchanged through the new module. - Mutations, each caught by the new tests and by those unchanged `tui_host` tests: the name register key drifting from what the core reads, clearing the effort being a no-op, and label validation disabled. ## What #525 looks like after this Done as shared primitives inside `tole-cli`, per the owner's decision (no new crate until a second consumer exists, sync API): tool registration moved to the roster (#547), session create + index registration (#548), one turn runner (#549), session settings (this PR). I will post the acceptance-criteria status on the issue, including what is not done: `TuiSession` still owns its single swappable storage handle and `switch_session` (open an existing session by id through the index), and the crate/publish decision is deferred with the crate. ## Related Issues Refs #525, part of #523. --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
5 tasks
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
First part of #525 (UI epic #523):
session_host.rsno longer contains tool registration.UpdatePlanTool,PlanEmitter,register_gitea,detect_github_repoandgithub_repo_from_remote_url(with their tests) move totool_roster.rs, where the rest of the roster already lives. Refs #525, does not close it.Why
session_host.rsmixed session hosting (open, turn, resume, cancel, interrupt, detach, list) with tool setup, which is one of the acceptance criteria of #525 and a prerequisite for mergingTuiSessiononto one host. Owner decisions on 2026-11-10: do #525 as a module insidetole-clifirst (a new crate only when a second consumer exists), keep the API synchronous, and deliver in small PRs.Changes
session_host.rs1019 → 777 lines,tool_roster.rs+254. Only edits inside the moved code:StdArc→std::sync::Arc(the alias is not imported intool_roster) and the self-callcrate::session_host::github_repo_from_remote_url→ a local call.acp.rs(PlanEmitter),main.rstests (github_repo_from_remote_url,detect_github_repo),tests/tool_specs.rs(UpdatePlanTool),tool_roster.rsitself, andsession_host.rsimportsPlanEmitterforopen_session's parameter. No re-export fromsession_host, so there is one way to reach each item; this changes five library paths of the publishedtole-clicrate (noted in CHANGELOG under Changed).docs/epics.mdupdated in the same PR (AGENTS.md §7); README unaffected.Testing
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo check -p tole-cli --no-default-features,cargo check -p tole-cli --no-default-features --features shell-tools,cargo check -p tole-core --no-default-featurescargo test --workspace: 1178 passed, the same count asdevelopbefore the move (no test lost or duplicated). The movedplan_testsand thegithub_repo_from_remote_urltests run from their new location.cora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.grepofsession_host.rsforregister(,Box::new(…Tool,gitea,github,update_planfinds nothing.Next in #525
Part 2: merge
TuiSession(tui_host.rs) onto the shared session-host machinery so the TUI stops keeping its own session lifecycle.Related Issues
Refs #525, part of #523.
Generated by Claude Code