Skip to content

docs: cover mid-session forking (/branch + praisonai session fork) - #2734

Merged
MervinPraison merged 1 commit into
mainfrom
claude/issue-2733-20260806-1245
Aug 6, 2026
Merged

docs: cover mid-session forking (/branch + praisonai session fork)#2734
MervinPraison merged 1 commit into
mainfrom
claude/issue-2733-20260806-1245

Conversation

@praisonai-triage-agent

@praisonai-triage-agent praisonai-triage-agent Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #2733

Summary

  • New page docs/features/session-forking.mdx — the mid-session forking feature page (hero mermaid, <Steps> Quick Start, choice-guide + sequence diagrams, guardrails, JSON output, <AccordionGroup> best practices, <CardGroup> related).
  • docs/cli/session.mdx — new Fork a Session section (praisonai session fork <id> [--at-message N] [--title]), session list Parent column added to sample output / notes / --json, forked-child line linked, help block + Related card updated.
  • docs/cli/interactive-tui.mdx/branch [title], /branch --at N, and /session lineage rows added to the command table; Related link added.
  • docs/docs.jsonfeatures/session-forking added under the Features → State & Sessions group.

Source verification

Verified against PraisonAI merge commit 6ca4b97:

  • /branch [title] / --at N (-a N, positive, ≤ user turns), worker-busy refusal, No active session / Could not fork fallbacks — interactive_legacy.py::_handle_branch_command.
  • session fork <id> --at-message N (0-based, validated 0..count-1), --title, JSON {forked, parent_id, session_id, from_message_index, title}commands/session.py::session_fork.
  • session list Parent column (8-char prefix, - for root) + JSON parent_id; /session prints Forked from: / Forks:.

All new pages placed in docs/features/ (never docs/concepts/). docs.json validated as JSON.

Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added comprehensive documentation for session forking through the REPL and CLI.
    • Documented /branch, /branch --at N, and session fork commands, including options, validation, errors, and JSON output.
    • Added guidance for viewing parent/child session relationships and fork metadata.
    • Added Session Forking to the documentation navigation and related links.

@MervinPraison

Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison

Copy link
Copy Markdown
Owner

/review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@MervinPraison MervinPraison added pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:conflict Blocked: merge conflict or rebase pending labels Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d783cb69-abe7-47a1-9271-946f6df43577

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The documentation adds session forking guidance for the REPL and CLI. It covers fork points, parent-child lineage, JSON output, validation, errors, related commands, and navigation.

Changes

Session Forking Documentation

Layer / File(s) Summary
Session forking concepts and workflows
docs/features/session-forking.mdx
Adds workflows, fork-point options, lineage details, output examples, guardrails, error handling, diagrams, and best practices.
CLI session forking reference
docs/cli/session.mdx
Documents parent-session fields, forked-session listings, the session fork command, validation behavior, output fields, and related CLI links.
Interactive commands and documentation navigation
docs/cli/interactive-tui.mdx, docs/docs.json
Documents /branch and /session, adds related links, and adds the session-forking page to navigation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Suggested reviewers: mervinpraison

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main documentation change: mid-session forking through /branch and praisonai session fork.
Linked Issues check ✅ Passed The documentation changes address issue #2733 requirements for commands, lineage, options, validation, outputs, navigation, and repository documentation standards.
Out of Scope Changes check ✅ Passed All changes are documentation updates directly related to the session-forking objectives in issue #2733.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch claude/issue-2733-20260806-1245
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-2733-20260806-1245

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli/interactive-tui.mdx`:
- Around line 162-164: Update the `/help` output example in the interactive TUI
documentation to include both `/branch` and `/session`, matching the command
table; alternatively, clearly mark the transcript as abbreviated.

In `@docs/cli/session.mdx`:
- Line 186: Update the later JSON output (--json) example in
docs/cli/session.mdx to include a "parent_id": null field in each session
record, keeping it consistent with the session list --json description and the
existing specimen structure.

In `@docs/features/session-forking.mdx`:
- Around line 102-105: Update the Store return step in the fork_session sequence
diagram to describe the returned value as the forked session ID, not a fork
session object, while leaving the surrounding session rebinding flow unchanged.
- Around line 155-170: Add a Default column to both fork option tables in
docs/features/session-forking.mdx (lines 155-170) and docs/cli/session.mdx
(lines 249-253), documenting the SDK defaults for every option. Include None for
from_message_index/--at-message and title, and the appropriate defaults for the
remaining options; update each table’s header and rows consistently.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b1ed8959-dcc0-42aa-a48b-6f7ec55e1d05

📥 Commits

Reviewing files that changed from the base of the PR and between 8216b8f and e2d6181.

📒 Files selected for processing (4)
  • docs/cli/interactive-tui.mdx
  • docs/cli/session.mdx
  • docs/docs.json
  • docs/features/session-forking.mdx

Comment on lines +162 to +164
| `/branch [title]` | Fork the current conversation here and switch onto the fork; parent stays resumable |
| `/branch --at N` | Fork from N user turns back |
| `/session` | Show current session info, including `Forked from:` / `Forks:` lineage when set |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the /help example consistent with the command table.

The table now lists /branch and /session, but the /help output below omits both commands. Add them to the output or mark the transcript as abbreviated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cli/interactive-tui.mdx` around lines 162 - 164, Update the `/help`
output example in the interactive TUI documentation to include both `/branch`
and `/session`, matching the command table; alternatively, clearly mark the
transcript as abbreviated.

Comment thread docs/cli/session.mdx
| `--all` | Show sessions from all projects |
| `--project <id>` | Show sessions for a specific project ID — that project's store only |
| `--json` | Output as JSON (includes `usage`, `total_tokens`, and `cost` per session) |
| `--json` | Output as JSON (includes `usage`, `total_tokens`, `cost`, and `parent_id` per session) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep both session list --json examples consistent.

This line says every session record includes parent_id. The later JSON output (--json) example at lines 147-164 omits that field. Add "parent_id": null to that specimen.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cli/session.mdx` at line 186, Update the later JSON output (--json)
example in docs/cli/session.mdx to include a "parent_id": null field in each
session record, keeping it consistent with the session list --json description
and the existing specimen structure.

Comment on lines +102 to +105
REPL->>Store: fork_session(current_id, ...)
Store->>Fork: Create with parent_id set
Store-->>REPL: fork session object
REPL->>REPL: Rebind session + reload history

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the store return value in the diagram.

HierarchicalSessionStore.fork_session returns the new session ID as str. Change “fork session object” to “forked session ID.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/features/session-forking.mdx` around lines 102 - 105, Update the Store
return step in the fork_session sequence diagram to describe the returned value
as the forked session ID, not a fork session object, while leaving the
surrounding session rebinding flow unchanged.

Comment on lines +155 to +170
| Option | Type | Description |
|--------|------|-------------|
| `[title]` | `str` | Optional name for the fork (anything after the command that isn't `--at N`). |
| `--at N` / `-a N` | `int` | Fork from `N` **user turns** back. Must be `> 0` and `≤` total user turns. |

**`praisonai session fork` — CLI verb**

```bash
praisonai session fork <session_id> [--at-message N] [--title "..."]
```

| Argument / Flag | Type | Description |
|-----------------|------|-------------|
| `session_id` | `str` | Session to fork. Resolved project store first, then global. |
| `--at-message N` | `int` | Fork from this **0-based message index**. Valid range is `0..count-1`. |
| `--title "..."` | `str` | Optional title for the forked session. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline praisonaiagents/session/hierarchy.py --items all
ast-grep outline praisonai_code/cli --items all --type function --match 'fork|session'
rg -n -C 8 --type py '\bfork_session\s*\(|at_message|at-message|session.*fork' \
  praisonai_code/cli praisonaiagents/session/hierarchy.py

Repository: MervinPraison/PraisonAIDocs

Length of output: 42426


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching session.*mdx:"
fd -a 'session.*\.mdx$' docs/features docs/cli 2>/dev/null | sed 's#^\./##' || true

echo
echo "Relevant option tables:"
if [ -f docs/features/session-forking.mdx ]; then
  sed -n '140,180p' docs/features/session-forking.mdx
fi
if [ -f docs/cli/session.mdx ]; then
  sed -n '235,258p' docs/cli/session.mdx
fi

echo
echo "Search docs for session fork defaults/required/no:"
rg -n --type mdx '\s*(Default\s*=|Default:)|\bRequired\b|No Default|None' docs/features docs/cli || true

Repository: MervinPraison/PraisonAIDocs

Length of output: 4293


Add the missing Default values to fork tables.

Both fork tables should include the SDK default for each option, including the None defaults for from_message_index / --at-message and title.

  • docs/features/session-forking.mdx#L155-L170: add a Default column to the REPL and CLI option tables.
  • docs/cli/session.mdx#L249-L253: add a Default column to the session fork option table.
📍 Affects 2 files
  • docs/features/session-forking.mdx#L155-L170 (this comment)
  • docs/cli/session.mdx#L249-L253
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/features/session-forking.mdx` around lines 155 - 170, Add a Default
column to both fork option tables in docs/features/session-forking.mdx (lines
155-170) and docs/cli/session.mdx (lines 249-253), documenting the SDK defaults
for every option. Include None for from_message_index/--at-message and title,
and the appropriate defaults for the remaining options; update each table’s
header and rows consistently.

Source: Coding guidelines

@MervinPraison

Copy link
Copy Markdown
Owner

Automated merge-conflict rebase started (in-band Claude). Rebasing onto latest main, resolving conflicts, force-pushing with --force-with-lease.

…ssion fork CLI verb (fixes #2733)

Add docs/features/session-forking.mdx and update session.mdx and
interactive-tui.mdx to document /branch, praisonai session fork, fork
lineage (parent_id/children_ids, session list Parent column, /session
Forked from/Forks), and guardrails. Verified against PraisonAI merge
commit 6ca4b97.

Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
@MervinPraison
MervinPraison force-pushed the claude/issue-2733-20260806-1245 branch from e2d6181 to 71acf79 Compare August 6, 2026 13:02
@MervinPraison

Copy link
Copy Markdown
Owner

Rebase complete

Resolved merge conflicts and rebased claude/issue-2733-20260806-1245 onto main (8661724).

Files resolved:

Auto-merged cleanly:

  • docs/docs.json — nav entries from both sides combined without conflicts

Verified:

  • docs/docs.json is valid JSON
  • All Mintlify page paths referenced in docs/docs.json exist on disk

@MervinPraison MervinPraison added pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/merge-ready Eligible for merge gate auto-merge and removed pipeline/blocked:conflict Blocked: merge conflict or rebase pending pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:ci Blocked: CI not green on HEAD labels Aug 6, 2026
@MervinPraison

Copy link
Copy Markdown
Owner

Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge on an APPROVE verdict.

@MervinPraison MervinPraison added claude-merge-gate-active pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI and removed pipeline/merge-ready Eligible for merge gate auto-merge labels Aug 6, 2026
@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

MERGE_GATE_VERDICT: APPROVE

Review summary

Check Result
Files changed 4 docs-only (docs/cli/, docs/features/, docs/docs.json)
Size ~410 lines / 4 files — under docs-primary limit (1200 / 40)
Folder placement New page in docs/features/session-forking.mdx ✅; no docs/concepts/ changes
docs.json Nav-only — adds one entry ("features/session-forking") to the sessions group ✅
Sensitive paths No .github/workflows/, no mint.json, no non-nav docs.json edits ✅
Labels pipeline/awaiting-merge-gate, claude-merge-gate-active — no blocking labels ✅
Reviews CodeRabbit COMMENTED (4 minor suggestions, not CHANGES_REQUESTED) ✅
CI on HEAD scan-conflicts → SUCCESS, pipeline-sync → SUCCESS, all others SKIPPED — no failures ✅
Mintlify compliance Frontmatter, hero diagram, <Steps>, <AccordionGroup>, <CardGroup> all present ✅
Secrets None detected ✅

Content quality: docs/features/session-forking.mdx is a well-structured, beginner-friendly feature page covering the /branch REPL command and praisonai session fork CLI verb with decision diagrams, guardrails section, and lineage docs. Updates to docs/cli/session.mdx and docs/cli/interactive-tui.mdx are consistent and accurate. CodeRabbit's four suggestions (help transcript abbreviation note, parent_id: null in list example, sequence diagram label, Default column in tables) are minor polish items and do not block merge.

@MervinPraison MervinPraison added pipeline/merge-ready Eligible for merge gate auto-merge and removed claude-merge-gate-active pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI labels Aug 6, 2026
@MervinPraison
MervinPraison merged commit 0e58ed8 into main Aug 6, 2026
6 checks passed
@MervinPraison

Copy link
Copy Markdown
Owner

Merged by Claude PR merge gate (claude-merge-gate.yml).
Verdict: MERGE_GATE_VERDICT: APPROVE
SHA: 71acf79
Method: merge

@MervinPraison

Copy link
Copy Markdown
Owner

Merge gate scan — not eligible for auto-merge.

  • not open
  • already merged by gate
  • mergeState=UNKNOWN

Actions: wait for CI and the Claude review chain, or add label needs-manual-review and merge manually.
Opt out: label no-auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merged-by-gate pipeline/merge-ready Eligible for merge gate auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: cover mid-session forking — /branch REPL command + praisonai session fork CLI verb (PraisonAI #3731 / merged in #3755)

1 participant