Skip to content

feat: add session resume as agent-level capability with /resume command#78

Merged
yishuiliunian merged 2 commits intomainfrom
feat/resume-session
Apr 4, 2026
Merged

feat: add session resume as agent-level capability with /resume command#78
yishuiliunian merged 2 commits intomainfrom
feat/resume-session

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Add ControlCommand::ResumeSession so agents can hot-swap their conversation context to any persisted session at runtime, following the same pattern as Clear/Rewind/ModelSwitch
  • --resume CLI flag now works without an ID (auto-finds latest session for current directory); typed via ResumeIntent enum instead of raw Option<String>
  • TUI /resume <prefix> triggers real agent-level context swap; /resume (no arg) lists recent sessions; /sessions removed as redundant

Changes

  • Protocol: ControlCommand::ResumeSession, AgentEventPayload::SessionResumed
  • Runtime: resume_session.rs — hot-swap session identity, ContextStore, counters, tool_ctx
  • Session: SessionController::resume_session(), load_sub_agent_history(), event handler for SessionResumed
  • Storage: latest_session_for_cwd(), list_sessions_for_cwd(), normalize_cwd() (cwd canonicalization)
  • TUI: /resume command rewrite, CommandEffect::ResumeSession, display reload on event (including sub-agents)
  • CLI/Bootstrap: ResumeIntent enum, resume_intent() accessor, resolve_resume_for_cwd(), resume param threaded through bootstrap

Test plan

  • CI passes (clippy + 48 tests)
  • 26 new test functions across 7 files covering all layers:
    • Storage: cwd query, normalization roundtrip (8 tests)
    • Protocol: serde roundtrip for new variants (3 tests)
    • Session: event handling, controller resume, sub-agent display loading (11 tests)
    • Runtime: session manager cwd filtering (3 tests)
    • TUI: command registration, /sessions removal (2 tests)
    • CLI: resume_intent parsing (3 tests)

Enable agents to hot-swap their conversation context to a persisted session
at runtime, following the same ControlCommand pattern as Clear/Rewind/ModelSwitch.

Architecture:
- ControlCommand::ResumeSession + AgentEventPayload::SessionResumed in protocol layer
- AgentLoopRunner::handle_resume_session replaces session identity, context store,
  and resets counters (runtime layer)
- SessionController::resume_session clears display + sends command (session layer)
- TUI receives SessionResumed event → loads display history including sub-agents

CLI:
- `--resume` (no ID) auto-finds latest session for current directory
- `--resume <ID>` resumes specific session (backward compatible)
- ResumeIntent enum encapsulates the clap sentinel, resume field is private

TUI:
- `/resume` lists recent sessions for current project
- `/resume <prefix>` hot-swaps agent context (prefix match on session ID)
- `/sessions` removed (subsumed by /resume)

Storage: cwd canonicalized via normalize_cwd for reliable path matching.
@yishuiliunian yishuiliunian merged commit eab2ad0 into main Apr 4, 2026
3 checks passed
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.

1 participant