feat(session): /fork — branch a session, preserving the original - #418
Conversation
|
Thanks for the pull request. A maintainer will review it when available. Please keep the PR focused, explain the why in the description, and make sure local checks pass before requesting review. Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md |
|
This pull request description looks incomplete. Please update the missing sections below before review. Missing items:
|
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughAdds session lineage metadata and SQLite hierarchy APIs, introduces ChangesSession forking
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AishShell
participant SessionStore
participant ResumeFlow
AishShell->>AishShell: Persist current session snapshot
AishShell->>SessionStore: fork_session(parent_uuid, branch_point_message_id, new_uuid)
SessionStore-->>AishShell: Return forked session
AishShell->>ResumeFlow: resume_session_with_options(new_uuid)
ResumeFlow-->>AishShell: Return switch result
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@crates/aish-shell/src/app.rs`:
- Line 3356: Update handle_fork_command to fetch the parent’s latest history row
via store.get_history(&parent_uuid, 1), use the first entry’s entry.id as the
branch point, and pass it to store.fork_session instead of None; return None
when the history is empty, and do not use entry.history_entry_id.
🪄 Autofix (Beta)
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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 155523a5-4f56-42c9-b586-316de701508a
📒 Files selected for processing (11)
crates/aish-i18n/locales/de-DE.yamlcrates/aish-i18n/locales/en-US.yamlcrates/aish-i18n/locales/es-ES.yamlcrates/aish-i18n/locales/fr-FR.yamlcrates/aish-i18n/locales/ja-JP.yamlcrates/aish-i18n/locales/zh-CN.yamlcrates/aish-session/src/models.rscrates/aish-session/src/store.rscrates/aish-shell/src/app.rscrates/aish-shell/src/readline.rscrates/aish-shell/tests/slash_popup_commands.rs
c70ad16 to
004cce6
Compare
fc22229 to
618caea
Compare
`/fork` branches the current session into a new one that copies the parent's context/state, records the parent link + branch point, and switches into the fork so the original is preserved at its branch point. Data layer (aish-session): - SessionRecord gains parent_session_uuid + branch_point_message_id. - fork_session copies the parent's state + metadata; session_roots / list_children expose the tree; migrate_schema adds the columns additively (backward compatible with legacy DBs). - delete_session reparents children to root (clearing the dangling branch point) so deleting a forked parent never orphans its descendants. Reuses the existing persist_session_snapshot + resume path. Closes AI-Shell-Team#413
618caea to
bedcd67
Compare
Summary
Adds the
/forkbuilt-in command: branch the current session into a new one (copied context), then switch into the fork so the original is preserved at its branch point.Closes #413
What it does
fork_sessioncopies the parent's state + metadata into a new session, recordingparent_session_uuid+branch_point_message_id, and switches into it.Data layer (
aish-session)SessionRecordgainsparent_session_uuid+branch_point_message_id.fork_session/session_roots/list_children;migrate_schemaadds the columns additively (idempotent, backward compatible with legacy DBs).delete_sessionreparents children to root (clearing the dangling branch point) so deleting a forked parent never orphans its descendants.Scope
Reuses the existing
persist_session_snapshot+resume_session_with_options. Self-contained toaish-session(store + models) + the/forkcommand inaish-shell+ i18n.Verification
cargo clippy -p aish-session -p aish-shell --all-targets -- -D warningsclean.aish-sessiontests pass (9), includingfork_session_*,list_children_*,migrate_schema_*,delete_session_reparents_children_to_root.slash_popup_commandstests pass.Summary by CodeRabbit
New Features
/forkslash command to branch the current session into a new session while preserving context.Bug Fixes