Skip to content

feat(tui): /fork and /tree over session forks (#463) - #567

Merged
ajianaz merged 3 commits into
developfrom
feat/463-fork-tree
Nov 11, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/463-fork-tree

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Part of #463 (TUI polish, part 2): the TUI commands /fork [entry-id] and /tree, a UI over the session branching that #210 shipped. The issue stays open for export/copy, themes and keybindings.

Why

tole branch and tole sessions --tree exist, but a TUI user had to leave the UI to fork or to find a related session. In-file branching (several branches in one session file) is a separate, still-deferred follow-up and is out of scope.

Changes

  • /fork [entry-id]: forks the open session at a settled entry (default: the last one, as tole branch does) into a new session and switches to it in place, like /new and /resume. The fork is indexed (face branch), so /resume and sessions --all list it. An unknown or unsettled entry, or a session with nothing settled yet, is refused with the core error; the session and the sessions directory stay as they were.
  • Lock finding: forking a session whose writer lock this process holds is safe. JsonlStorage::fork only replays the source read-only (no lock, no repair, no write) and the new file takes its own sidecar lock. The host holds the session mutex across the fork, so no turn appends while the source is read.
  • /tree: a picker over the family of the open session (parent chain up to the root and every fork below it, siblings and grandchildren included), indented with └─ by depth, (@entry) on forks, the open session marked (current) and preselected. Picking another row sends the existing HostCmd::Switch; picking the current row only says so. A session with no parent and no forks shows itself with a note. The depth marker is in the SessionItem label (no new field; the label is already host-composed text for /resume).
  • Seam: new HostCmd::{Fork(Option<String>), PickTree} answered with HostReply::Session / HostReply::Sessions; new PickKind::Tree. Hosts that do not implement them refuse them like other commands.
  • tole-cli: session_index::{tree_nodes, tree_order, family} and TreeNode::of; sessions --tree now shares the same scan and ordering. tole-core is unchanged.
  • While a turn runs both commands are ignored, like /new and /resume. No transcript replay after the switch (unchanged limitation).
  • Docs: docs/tui.md (commands table, "Forking" section, "Not implemented"), CHANGELOG Unreleased, README status line and docs/epics.md (AGENTS.md section 7).

Testing

  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, cargo check -p tole-cli --no-default-features, cargo test --workspace: all green.
  • Unit tests (fake host, no crossterm types): command parsing, ignored while running, replies and refusals, tree picker (indentation, current marked and preselected, switching, lone session note).
  • Host tests in tui_host.rs: fork at default and at an explicit entry while this process holds the lock, forkedFrom correct, source byte-identical and resumable, new work lands only in the fork, unsettled/unknown/empty refused leaving no file; tree with parent, siblings and grandchildren; tree after fork. Unit test for family.
  • pty e2e (tui_e2e.rs): /fork then a new message lands in the fork (with history) and not the original; /tree lists, switches back, the next message lands in the original; sessions --all and --tree show the fork.
  • Mutation checks (each made a test fail, then restored): fork ignoring the requested entry, mutating the source after the fork, /tree switching to the wrong id, a fork shown under no/wrong parent.
  • cora is not installed in the authoring environment: the staged diff was reviewed by hand; the CI Cora Review is the gate.

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 05fd947 into develop Nov 11, 2026
19 of 20 checks passed
ajianaz pushed a commit that referenced this pull request Nov 11, 2026
/fork and /tree (#567) and /export and /copy (#568) each raised the length of
the COMMANDS table from 9 to 11. Merged, the table has 13 entries, which git
could not flag as a conflict because the changed lines differ.
ajianaz added a commit that referenced this pull request Nov 11, 2026
[tui.keys] in the user config rebinds ten convenience actions (tool output, reasoning, model picker, cycle model, cycle thinking, newline, queue follow-up, pop queue, history) to a key spec or a list; the default keymap is the keys the TUI always had. y, n, Esc, Ctrl+C, Enter, Backspace, Tab and every bare character are never rebindable, and at an approval prompt only y, n, Esc and Ctrl+C act whatever the keymap says. A project config cannot set keys (ignored with a warning), and an invalid keymap falls back to the default with one startup note. Closes #463 with #567, #568 and #569.
@ajianaz
ajianaz deleted the feat/463-fork-tree branch November 20, 2026 08:35
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.

2 participants