Skip to content

feat: add Pi-style /tree conversation navigation#664

Open
piercebrookins wants to merge 1 commit into
mpfaffenberger:mainfrom
piercebrookins:feat/pi-style-tree
Open

feat: add Pi-style /tree conversation navigation#664
piercebrookins wants to merge 1 commit into
mpfaffenberger:mainfrom
piercebrookins:feat/pi-style-tree

Conversation

@piercebrookins

Copy link
Copy Markdown
Contributor

Summary

Add a built-in /tree plugin for navigating and branching the current conversation without changing Code Puppy's existing /fork background-agent command.

Behavior

  • renders the complete append-only conversation graph with the active path first
  • selecting a user message rewinds before that prompt and restores its text into the idle editor for editing/resubmission
  • selecting assistant/tool entries rewinds at that entry
  • selecting the current leaf is a no-op
  • resubmitting after a rewind preserves the abandoned path as an alternate branch
  • persists inactive branches in atomic, session/agent-keyed sidecars
  • retains branches across provider history compaction and root rewinds
  • supports search, active-path markers, folding, paging, copy, and default/no-tools/user/all filters
  • hides tool-call-only assistant nodes in the default and no-tools views
  • localizes all new user-facing strings

/fork and /forks are intentionally untouched; their existing background sub-agent semantics and tests remain intact.

Implementation

The feature is plugin-first under code_puppy/plugins/tree/:

  • tree_model.py — append-only graph, provider-message extraction, filtering, and Pi-compatible navigation semantics
  • tree_menu.py — prompt_toolkit selector and keyboard controls
  • tree_storage.py — atomic sidecar persistence
  • register_callbacks.py — slash-command/help/lifecycle integration and editor restoration

No command-line command was added to core.

Test plan

  • uv run ruff check code_puppy/plugins/tree tests/plugins/test_tree_plugin.py
  • uv run ruff format --check code_puppy/plugins/tree tests/plugins/test_tree_plugin.py
  • uv run pytest -q tests/plugins/test_tree_plugin.py tests/plugins/test_fork_plugin.py tests/plugins/test_plugin_contributions.py tests/i18n/test_i18n_coverage.py --no-cov
    • 77 passed before the final compaction/tool visibility hardening
  • final focused run:
    • 42 passed across /tree, /fork, and i18n suites
  • full repository suite:
    • 12,457 passed, 81 skipped, 1 xpassed
    • one unrelated order-dependent config assertion failed (protected_token_count expected 25000, observed 24576)
    • the same test passes in isolation

The /tree suite includes a real POSIX pseudo-terminal smoke test that opens the selector, sends Up + Enter, and verifies the selected user prompt rewinds provider history to its parent.

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