Skip to content

Expose session tree inspection and navigation over RPC #313

Description

@m-aebrer

Summary

The planned web dashboard (#307) needs session-tree visibility and navigation for parity with the TUI's /tree command. Core already implements both (SessionManager.getTree(), AgentSession.navigateTree()), but neither is reachable as a first-class RPC command — tree navigation is only wired internally for extension command context actions.

Current Behavior

  • fork, get_fork_messages, switch_session, and new_session (with parentSession) exist over RPC.
  • SessionManager.getTree() returns SessionTreeNode[] (full entries with children and labels) but is not exposed.
  • AgentSession.navigateTree(targetId, { summarize, customInstructions, replaceInstructions, label }) is invoked in rpc-mode.ts only via commandContextActions for extensions — an external RPC client cannot call it.
  • The TUI /tree flow includes selector UX and optional branch summarization; none of that flow is scriptable.

Proposed Behavior

  • New RPC command get_tree returning a serializable tree DTO — per node: entry id, parentId, entry type/role, short content preview, timestamp, label, children. Do not serialize full message payloads; get_messages covers content after navigation.
  • New RPC command navigate_tree taking targetId plus the same options the core method accepts (summarize, customInstructions, replaceInstructions, label), returning { cancelled } consistent with the existing internal wiring.
  • Explicit errors for unknown target ids or navigation during streaming (matching existing AgentSession guards).

Acceptance Criteria

  • get_tree and navigate_tree commands and typed responses added to rpc-types.ts and handled in rpc-mode.ts.
  • Tree DTO is documented and stable (no raw internal entry dumps).
  • After navigate_tree, get_state and get_messages reflect the post-navigation session state.
  • RpcClient gains corresponding methods.
  • Tests cover tree retrieval, navigation with and without summarization options, and error paths.
  • docs/rpc.md documents both commands.

Context

Technical Notes

  • SessionTreeNode (session-manager.ts) holds full entries; the DTO mapping should trim to what a tree UI needs. The TUI tree selector is a reference for which fields matter (label, role, preview, timestamp).
  • Branch summarization settings (getBranchSummarySettings) influence the summarize flow; RPC should honor explicit options and not silently apply TUI prompt behavior.

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