Repository navigation
Closed
Labels
enhancementNew feature or request
Description
What problem does this solve?
Session hosting is implemented twice, inside tole-cli:
session_host.rs(~1000 lines):Sessions/SessionState(admission, busy flag, claim),open_session,run_session_turn,resume_session_turn. Used byserve,acpandmcp.tui_host.rs:TuiSession { Mutex<Inner> }with its own storage handle, registry, compaction settings,/new,/resume, index registration. Used by the TUI only.
Deletion test: if either vanished, the busy-flag, open and index logic would reappear in the other. Any new client (desktop, remote) would add a third copy. Also, session_host.rs mixes session hosting with tool setup (register_gitea, detect_github_repo, github_repo_from_remote_url) and UpdatePlanTool, which belong with the tool roster.
Proposed solution
One deep module (new crate, working name tole-session) with a small interface and the machinery behind it:
- open / create / resume a session (jail, approver, sessions dir, index registration)
- run a turn (observer + cancel token), resume a turn, interrupt, detach, cancel
- read entries after a
seq(feeds the event stream in the serve issue) - list sessions; settings that live in registers (model, effort, name, compaction request)
Constraints:
- Depends on
tole-coreonly; never ontole-cliortole-tui(no cycle). tole-coreis untouched and stays platform-agnostic.- Behavior-preserving:
serve,acp,mcpand the TUI all go through it; no new capability in this issue. - Tool registration (gitea/github, plan tool) moves out of the host into the tool roster.
Delivery in small PRs (Cora review times out beyond ~15–20 files):
- Move
Sessions/SessionState/open_session/ turn runners verbatim into the new crate;tole-clire-exports. - Migrate
TuiSessiononto it. - Move tool registration to the roster.
Open questions
- Crate name and publishing: crates.io currently gets
tole-corethentole-cliviapublish.yml; a new crate changes the order (checktole-tuitoo). Publish it, or keep itpublish = falseuntil the interface settles? - Does the interface stay sync (std
Mutex, blocking turns, as today) or does the remote face want async? Proposal: keep sync inside, adapt at the edges.
Alternatives considered
- Leave as is and add a third host for desktop: rejected, it triples the busy/jail/approval logic that must stay identical.
- Put it into
tole-core: rejected, it needs storage paths, index and process-level config (core stays host-free).
Acceptance criteria
- One module owns open/turn/cancel/interrupt/detach/list;
tui_host.rsno longer holds its own session lifecycle. - No behavior change: existing
serve,acp,mcp, TUI tests pass unchanged. -
session_host.rsno longer contains tool registration. -
tole-corepublic API unchanged; embedders still build--no-default-features. - Publish plan decided and
publish.ymlupdated if needed.
Part of #523.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat(serve): SSE event stream GET /sessions/{id}/events (#546)
refactor(cli): move tool registration out of session_host into tool_r…
refactor(cli): create and index sessions through one helper (#548)
refactor(cli): one turn runner shared by the server faces and the TUI (…
refactor(cli): one module for a session's durable settings (#550)
ajianaz commentedon Nov 10, 2026
Status after #547, #548, #549, #550 (2026-11-10)
Decided with the owner: do this as shared primitives inside
tole-cli(no newtole-sessioncrate until a second consumer exists, i.e. the GPUI desktop, #527), keep the API synchronous, deliver in small behavior-preserving PRs. Not a literal merge ofTuiSessionintoSessions: the TUI is one swappable session behind one mutex and adds things the server faces do not have (settling a parked turn, compaction, the footer).Shipped
session_host.rsintotool_roster.rs(UpdatePlanTool,PlanEmitter, gitea/github probes).session_host::create_sessioncreates a session file and registers it in the index in one call (run, chat, tui, mission, server faces, TUI/new).turn_runner::{TurnPlan, run_turn_on, run_turn_with, resume_turn_on}, used byrun_session_turn,resume_session_turnandTuiSession::run_turn; the TUI's extras are explicit plan fields (resolve_parked,compaction).session_settingsowns the model / effort / name registers, label validation and the writers; the TUI and ACP write through it, the readers use the same constants.Acceptance criteria
tui_host.rsno longer holds its own session lifecycle. Partly: create + index, the turn, and the settings are shared.TuiSessionstill owns its single storage handle andswitch_session(reopening a session by id through the index, with its own id rules and messages), andSessions/SessionState(busy claim, cancel, interrupt, detach) are not used by the TUI.session_host.rsno longer contains tool registration.tole-corepublic API unchanged;--no-default-featuresbuilds.publish.ymlis unchanged. Revisit when the crate is cut.Left
TuiSession::switch_session/ open-existing lifecycle (needs a decision on the six variants of "open session by id": id charset, index lookup vs sessions dir, error text).Sessions/SessionStateat all (busy/cancel/interrupt/detach), or keep its single-session wrapper.tole-sessioncrate and the publish order, when feat(desktop): tole-desktop — GPUI desktop client (first graphical client) #527 gives it a second consumer.Leaving this issue open for those.
Generated by Claude Code
ajianaz commentedon Nov 10, 2026
Closing #525. Status against the acceptance criteria, checked on current
develop:tui_host.rsno longer holds its own lifecycle: met as shared primitives, deliberately not as one merged type (decided with the maintainer: "shared primitives, TUI keeps its wrapper").session_hostis the one place that creates and registers a session (create_session, used by serve, acp, mcp and the TUI's/new),turn_runneris the one turn runner (run_turn_on,run_turn_with,resume_turn_on), andsession_settingsis the one writer of thefact/*registers (model, effort, name, compaction request).TuiSessionkeeps only what is TUI-specific: one open handle that it swaps, the footer, and the/resumepicker over the index.serve,acp,mcpand the TUI test suites pass unchanged across the whole series.session_host.rsno longer contains tool registration: met.register_gitea,detect_github_repo,github_repo_from_remote_urlandUpdatePlanToollive intool_roster.rs(verified: no references left insession_host.rs).tole-corepublic API unchanged; embedders build--no-default-features: met, core was not touched.publish.ymlneeds no change (tole-tuiwas already in the order, core then tui then cli).Decided not to do, with the reason:
tole-sessioncrate yet. One consumer outside the module does not justify a new published crate (AGENTS.md: adding code is a last resort). Revisit when the GPUI client needs the host as a library. The module boundary is already clean, so extraction is a move.JsonlStorage::openafter resolving the file (the TUI via the global index, the server under its workspace), so a helper would add an abstraction with nothing behind it.Generated by Claude Code