Problem
crates/tui/src/runtime_api.rs combines many API domains in one file:
- sessions
- threads
- tasks
- fleet
- agent runs
- automations
- skills
- MCP
- auth/mobile/runtime helper surfaces
It also mixes request/response types, route registration, route handlers, and manager lifecycle choices. The analysis noted inconsistent lifecycle patterns: some managers are shared through Arc, while others are instantiated per request.
There is also fragile error classification in places that match error.to_string().contains("not found").
Proposed shape
Split into a runtime API module family:
runtime_api/mod.rs
runtime_api/types.rs
runtime_api/auth.rs
runtime_api/sessions.rs
runtime_api/threads.rs
runtime_api/tasks.rs
runtime_api/fleet.rs
runtime_api/agent_runs.rs
runtime_api/automations.rs
runtime_api/skills.rs
runtime_api/mcp.rs
runtime_api/mobile.rs
Exact names can be adjusted to the existing route structure.
Acceptance criteria
Risk
Medium. Route behavior and manager lifecycle are user-facing indirectly, so split this in small PRs.
Problem
crates/tui/src/runtime_api.rscombines many API domains in one file:It also mixes request/response types, route registration, route handlers, and manager lifecycle choices. The analysis noted inconsistent lifecycle patterns: some managers are shared through
Arc, while others are instantiated per request.There is also fragile error classification in places that match
error.to_string().contains("not found").Proposed shape
Split into a runtime API module family:
runtime_api/mod.rsruntime_api/types.rsruntime_api/auth.rsruntime_api/sessions.rsruntime_api/threads.rsruntime_api/tasks.rsruntime_api/fleet.rsruntime_api/agent_runs.rsruntime_api/automations.rsruntime_api/skills.rsruntime_api/mcp.rsruntime_api/mobile.rsExact names can be adjusted to the existing route structure.
Acceptance criteria
Risk
Medium. Route behavior and manager lifecycle are user-facing indirectly, so split this in small PRs.