Skip to content

Expose cross-project session listing and session deletion over RPC #312

Description

@m-aebrer

Summary

The planned web dashboard (#307) has a fleet-centric home screen: sessions across all projects, with resume and delete actions. RPC mode cannot serve this today — session listing is per-project only, and session deletion does not exist outside a TUI component. This issue extends the RPC surface so the dashboard can be a pure RPC consumer instead of importing SessionManager directly (the hybrid boundary the closed draft PR used).

Current Behavior

  • list_sessions (rpc-mode.ts, case "list_sessions") calls SessionManager.list(cwd, sessionDir) — current project only.
  • SessionManager.listAll() (session-manager.ts) already lists sessions across all project directories but is not exposed over RPC.
  • Session deletion exists only as a private deleteSessionFile() helper inside the TUI session selector (modes/interactive/components/session-selector.ts): tries the trash CLI first, falls back to unlink, and the TUI guards against deleting the currently active session. None of this is available to core or RPC consumers.

Proposed Behavior

  • New RPC command list_all_sessions returning the same per-session metadata as list_sessions (path, id, cwd, name, created, modified, messageCount, firstMessage) for all projects.
  • New RPC command delete_session taking a session file path:
    • Refuses to delete the currently active session (explicit error).
    • Trash-first with unlink fallback, reporting which method was used.
    • Loud, descriptive errors on failure — no silent fallback.
  • Move the trash/unlink deletion logic from the TUI component into core (e.g. SessionManager), and refactor the TUI session selector to use the shared implementation.

Acceptance Criteria

  • list_all_sessions and delete_session commands and typed responses added to rpc-types.ts and handled in rpc-mode.ts.
  • Deletion logic lives in core; the TUI session selector delegates to it (no behavior change in the TUI).
  • delete_session errors clearly when targeting the active session, a nonexistent path, or a path outside the sessions directory.
  • RpcClient gains corresponding methods.
  • Tests cover both commands including error paths.
  • docs/rpc.md documents both commands.

Context

Technical Notes

  • SessionManager.listAll() accepts an onProgress callback; the RPC response can be a single reply (progress streaming not needed for the first version, but listing may be slow with many sessions — worth noting in docs).
  • switch_session already takes a session path cross-project; delete_session should follow the same path-based addressing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Important for workflow completenessenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions