Skip to content

About

Tree view and manager for CLI agent session forks (Claude Code, Codex, OpenCode, Qoder and more)

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

sessiontree

English | 中文

CI License: MIT Python

Tree view and manager for CLI agent session forks — see your /branch lineage like tree, and jump straight into any session.

CLI agent harnesses (Claude Code, Codex, OpenCode, and more) store forked conversations as flat session lists; /resume shows an undifferentiated picker. sessiontree rebuilds the fork lineage from native session data and gives you a navigable tree:

 sessiontree — my-project [Claude Code]
 ├─ RAG knowledge base          (32 msgs, 2h ago)
 │   ├─ Embedding concepts        (8 msgs, 1h ago)
 │   │   └─ LangGraph vs LangChain ● (5 msgs, just now)
 │   └─ Chroma selection          (3 msgs, yesterday)
 └─ WeChat mini-app debugging    (17 msgs, 3d ago)

sessiontree screenshot

sessiontree demo

Contents

Features

  • Fork lineage tree built from native forkedFrom metadata — no wrapper, no lock-in; your sessions stay untouched by default
  • Enter any node to resume it; f to fork a new branch from it (you're first asked to name the new branch — optional, stored as an alias); ←/→ collapse/expand branches (mouse clicks only move the highlight — no accidental session entry)
  • Four-layer labels: your alias → native session title → AI title → first user message
  • Rename (r) writes an alias by default; on supported harnesses (Claude Code, pi, Qoder, Hermes) an optional write mode sets the session's real name — the harness itself writes it (via its own -n resume flag driven in a hidden tmux session, or Hermes's native sessions rename), never by hand-editing storage
  • Preview pane, label filtering (/), archiving (h / u / v), settings menu (s: skins, language zh/en, effects & art toggles, command palette toggle, OK/Back rows); press ? for the full key reference — the footer only shows the everyday keys
  • Turn browser — Tab expands the bottom pane to browse every prompt you sent in the highlighted session, full text, newest first; / searches prompts (n/N cycle matches), Enter resumes the session, Tab/Esc collapses
  • Full-text search — press g to search every prompt you've sent across all sessions of the current workspace; type-as-you-search, results newest first with highlighted snippets, Enter resumes the session
  • Falling-petal background effect 🌸 — petals drift through the blank cells of the tree, never covering text; on by default with the sakura skin, fully configurable
  • Character art 🎨 — your anime character rendered as quadrant-block art fused into the tree background, responsive to window size, zero terminal requirements
  • Active-session detection with soft warning before double-entering
  • Zero extra moving parts — no daemon, no LLM calls, no index files: session storage is read directly (read-only), everything runs offline
  • One-line session summaries — press x on a session to enable its one-sentence summary, generated lazily by the selected harness's own CLI from the injected conversation (the copied mainline prefix in fork files is cut automatically), cached per session and invalidated by file changes. Sessions are off by default, so browsing never triggers generation; the settings menu holds the global master switch and the preview shows a clear hint for disabled sessions.
  • Status line shows where you are — after several p switches the line only showed the last directory name, so the status line now appends the current project's full absolute path (middle-elided at cell width, root side and project name kept) plus a counter: the N-th project opened in this session (p increments, Esc back-step decrements).
  • Fast on huge session stores — preview scans pre-filter by line string and cache per file, so moving the cursor over a 20 MB+ session costs microseconds instead of a full-file re-parse; the project picker caches its pre-scan by a file snapshot, so re-opening p shows session counts instantly (an actively-written project re-scans automatically).
  • Branch discipline hooks (contrib) — contrib/branch-charter turns forking into a repeatable discipline: a forked session gets a charter reminding it to write its decision down when it concludes, and the parent session is nudged when a branch finishes — the lightweight alternative to LLM-generated merge summaries

Install

Not yet on PyPI — install straight from GitHub:

pip install git+https://github.com/Criss404/sessiontree

Or from a clone (for development, see CONTRIBUTING.md):

git clone https://github.com/Criss404/sessiontree
cd sessiontree
pip install -e .

Requires Python 3.11+; textual and pillow are pulled in automatically. The optional real-name rename feature additionally needs tmux on your PATH.

Usage

cd your-project
sessiontree                 # auto-detect installed harnesses; open the current project on the most recently active one
sessiontree claude          # limit to one harness (choices: claude, codex, opencode, pi, qoder, deepseek, mimocode, hermes, codebuddy)
sessiontree --print         # print a non-interactive text tree, then exit
sessiontree --all           # include archived sessions
sessiontree --project SLUG  # open a specific project slug within the selected harness
sessiontree --init-config   # write commented config.toml + theme.tcss templates, then exit

Installed harnesses are detected automatically (a harness counts as present when its session data exists). Press p to browse every project grouped by harness and switch between them; the tree header shows the active source ([Claude Code] / [Codex]). To restrict auto-detection, set [harness] enabled = ["claude", "codex"] in config.toml; the positional argument overrides it.

State (aliases, archive flags) lives in ~/.config/sessiontree/state.json; override the directory with SESSIONTREE_DATA_DIR. Session data is untouched by default — the only exception is the explicit real-name write mode in the rename dialog (r, then ↑/↓), which asks for confirmation and lets the harness itself write the name: Claude Code / pi / Qoder are resumed with their own -n flag inside a hidden tmux session (requires tmux; a few normal runtime records are appended by the resume), Hermes is renamed via its native sessions rename command. Success is verified against harness storage before your alias is cleared; on timeout or failure nothing changes. Live sessions and unsupported harnesses (Codex, OpenCode, Mimocode, CodeBuddy) keep the option disabled with the reason shown.

Turn browser: press Tab to expand the bottom pane into a scrollable list of every prompt you sent in the highlighted session (full text — AI replies are deliberately excluded; user prompts are the most stable field across agent harnesses). ↑/↓ move by turn, PgUp/PgDn/Home/End jump, / searches your prompts with n/N cycling matches, Enter resumes the session (harness CLIs offer no way to open positioned at a turn, so it opens at the end), Tab collapses. The footer is context-aware: each pane only shows its own keys. Pane height: [ui] dialog_height (default 0.6). While the tree shrinks, character art scales down proportionally; set [art] shrink = "clip" to keep it full-size with the lower body covered instead.

Key bindings

Key Action
↑ / ↓ move through the tree
← / → collapse / expand the highlighted branch
Enter resume the highlighted session
f fork a new branch from the highlighted session
r rename (alias by default; real-name write mode where supported)
Tab toggle the turn browser
/ filter tree labels (in the turn browser: search your prompts)
n / N next / previous match in the turn browser
g full-text search across every session of the workspace
p project picker — every harness, tab-paged
x toggle this session's one-line summary
s settings menu (skins, language, effects, art, palette)
h / u / v archive / unarchive / toggle the archived view
? full key reference
Esc close a dialog / clear the filter / back-step through projects
Ctrl+R hot-reload config.toml + theme.tcss
q quit

Theming

Everything visual is customizable. Generate commented templates first:

sessiontree --init-config    # writes config.toml + theme.tcss (never overwrites)

settings menu, sakura skin

config.toml — icons, colors, layout numbers, and the node line template:

[icons]
active = "🔥"                # any string works
[colors]
active = "magenta"           # rich/Textual color names or hex
[ui]
preview_lines = 3
transparent = true           # ANSI mode: your terminal background image shows through
[format]
node = "{label}{marks} ({count}, {age})"   # reorder or drop fields freely

Skins & language — press s for the settings menu: ←/→ changes values in place. Skins (default → sakura 🌸 → penguin 🐧 → sailor ⚓ → cyan 💧, each mapped to a full Textual theme so dialogs restyle too) and the effects toggle apply instantly; the UI language (中文 / English) is applied with Enter or the [ OK ] row; [ Back ]/Esc just closes. All choices are remembered in state.json. Set the startup skin with [ui] skin = "sakura". Keys you set explicitly in [icons]/[colors] always win over the skin.

Background effects — falling petals rendered only into blank cells of the tree (text is never covered; a petal passing "behind" a label simply disappears for that frame). auto follows the skin: on for sakura (pink 、 · ❀ ✿), penguin (snow · ❄ ❆ ✻), sailor (stardust · ✦ ✧ ˚) and cyan (ice · ✧ ˚ ❋), off for default (which has a neutral grey · ✻ set for when you force it on). Toggle it live in the settings menu, or configure:

[effects]
enabled = "auto"     # auto = follow skin; "on" / "off" force it
fps = 15             # refresh smoothness only (lower it on slow terminals/SSH)
fall_speed = 4       # rows per second, independent of fps
density = 0.008      # petal count ≈ tree cells × density
chars = ["、", "·", "❀", "✿"]   # earlier entries appear more often
color = "pink1"
drift = 1.2          # sideways moves per second; 0 = fall straight down

The animation pauses while a dialog is open and stops entirely while you are inside a session. Measured cost (WSL, 120×40): ≈7% of one core at 5 fps, ≈19% at 30 fps.

Character art — render an anime character (or any transparent PNG) as quadrant-block character art fused into the blank cells of the tree: 2×2 subpixels per cell with fg/bg colors (chafa-family technique, pure Pillow, no graphics protocol needed — works in any terminal). Text and petals always stay on top; petals fall around the character. The art scales with the window (height-fit, anchored bottom-right).

[art]
image = "~/Pictures/mychar.png"   # transparent PNG or animated GIF/APNG; unset = off
max_width = 0.6                   # max share of the tree width
dim = 1.0                         # lower = watermark feel (e.g. 0.5)
crop = "full"                     # "head" auto-crops to head & shoulders
fps = 10                          # playback rate for animated images
anchor = "bottom-right"           # or "bottom-left"
margin = 1                        # cells kept free at the anchored edge
alpha_min = 40                    # pixel visibility threshold (1-255); raise for harder edges
shrink = "scale"                  # when the turn browser shrinks the tree: "scale" or "clip"

[art.sakura]                      # per-skin binding: this skin gets its own art
image = "~/Pictures/miku.png"

Animated GIF/APNG files play automatically (frames are pre-converted per window size; animation pauses while a dialog is open). Per-skin [art.<skin>] tables override the global [art] so each skin can carry its own character.

The sailor skin ships with a bundled example so you can see the feature out of the box — an AI-generated original character by the author, distributed with the repository under the MIT license. Your own [art] / [art.sailor] settings always override it.

Animated art must have a built-in alpha channel (sprite sheets, APNG, or alpha PNG sequences). Opaque-background GIFs (e.g. from Giphy/Tenor) require per-frame background removal, which flickers frame-to-frame and is not supported — start from transparent source frames instead.

Toggle it live in the settings menu (s → Art row).

Making your own art asset: any image works best after background removal. Recommended (author-side only, not a runtime dependency):

pip install rembg && rembg i -m isnet-anime input.jpg output.png

theme.tcss — Textual CSS loaded automatically when present; restyle layout, borders, highlights, dialogs. Press Ctrl+R in the TUI to hot-reload both files while tweaking.

Background images: set the image in your terminal emulator (e.g. Windows Terminal backgroundImage) and enable transparent = true — the tree renders over your wallpaper. Bad config never crashes the app; it falls back to defaults and shows a warning.

Environment variables

Optional overrides, handy when a harness stores its data in a non-standard place or its binary is not on your PATH. Full table with defaults in docs/CONFIGURATION.md.

  • SESSIONTREE_DATA_DIR — directory for sessiontree's own state and config (default ~/.config/sessiontree)
  • SESSIONTREE_CLAUDE_BIN, SESSIONTREE_OPENCODE_BIN, SESSIONTREE_PI_BIN, SESSIONTREE_QODER_BIN, SESSIONTREE_DEEPSEEK_BIN, SESSIONTREE_MIMOCODE_BIN, SESSIONTREE_HERMES_BIN, SESSIONTREE_CODEBUDDY_BIN — override the path to a harness binary (used for resume / fork / real-name rename)
  • SESSIONTREE_CLAUDE_PROJECTS, SESSIONTREE_QODER_PROJECTS, SESSIONTREE_CODEBUDDY_PROJECTS — override a JSONL project root directory
  • SESSIONTREE_OPENCODE_DB, SESSIONTREE_MIMOCODE_DB, SESSIONTREE_HERMES_DB — override a SQLite database path
  • SESSIONTREE_PI_SESSIONS — override pi's sessions directory

Platform support

v2 supports the Claude Code, Codex, OpenCode, pi, Qoder, Mimocode, Hermes, and CodeBuddy CLIs on Linux / WSL. Claude Code, Qoder, and CodeBuddy are read from their JSONL session files; pi from its JSONL sessions (native lineage in the file header); Codex from its rollout JSONL (user prompts come from event_msg records); DeepSeek (dsh) is read from its zstd-compressed JSONL session files under ~/.dsh (native parentSession lineage, so forks restore directly); OpenCode, Mimocode (an OpenCode-family store), and Hermes are read directly (read-only) from their SQLite databases, with internal sub-sessions (subagent tasks, checkpoint writers) filtered out so the tree shows only your own sessions and forks. Codex and the OpenCode family do not record fork lineage natively (--fork copies the history but stores no parent link), so sessiontree records the lineage itself for the forks it spawns (f key) and nests them in the tree; forks made outside sessiontree still appear as siblings. Hermes records lineage natively via its in-session /branch command but has no external fork flag, so the f key shows a hint instead of spawning. Real-name rename is available on Claude Code, pi, Qoder (tmux-driven -n resume; Windows-side claude.exe under WSL works) and Hermes (sessions rename, which sets the harness title; a Hermes in-session display name, if set, still takes precedence in the tree). Under WSL, Claude Code data stored on the Windows side is read automatically, and Windows-form working directories are mapped back to WSL paths; a session whose directory can't be reached locally is still listed but refuses to spawn rather than launch in the wrong place. macOS is untested.

Documentation

中文文档:README.zh-CN.md · 教程 · 配置参考 · 更新日志 · 参与贡献

License

MIT

About

Tree view and manager for CLI agent session forks (Claude Code, Codex, OpenCode, Qoder and more)

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages