Skip to content

[FEATURE]: /tree command for visual session navigation #22067

@jshan9078

Description

@jshan9078

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

After using /fork to branch from a previous message, there's no way to navigate back to the parent conversation or view all branches in the session tree. Users must manually switch between sessions or lose access to previous branches.

Proposed Solution

Implement a /tree command (similar to pi-mono) that provides:

  1. Visual tree browser - ASCII art visualization of the entire session tree showing all branches
  2. Active path highlighting - Shows which branch is currently active
  3. Branch navigation - Click/keyboard to switch between any message in the tree
  4. Optional branch summaries - When leaving a branch, optionally generate an AI summary of the abandoned conversation path

Key Features

  • Navigate to any previous message without losing current branch
  • Visual representation of all conversation paths
  • Keyboard-driven interface (arrow keys, enter to select)
  • Optional labels/bookmarks for quick reference

Reference Implementation

The pi-mono coding agent has a working implementation:

  • Session stored as append-only tree with parent_id tracking
  • /tree command opens visual selector (tree-selector.ts)
  • branch() method moves leaf pointer without modifying history
  • Supports labels, folding, and filtering

Technical Approach (High-Level)

  1. Add parent_id to messages table for tree structure
  2. Add leaf_id to sessions table for current position tracking
  3. Implement tree traversal logic in core session module
  4. Add /tree slash command
  5. Build tree selector UI component

Why This Belongs in OpenCode

Session branching is a first-class feature via /fork, but lacks proper navigation tools. A tree view makes branching discoverable and usable, encouraging users to explore different approaches without fear of losing work.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions