You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pi chats get “Rewind to here”. Pick a sent message and it returns to the composer; that message and everything after it disappear. Pi's own conversation moves back too. Files on disk stay as they are.
What Changed
Pi currently disables rewind. This enables the existing action and uses Pi's RPC fork at the first removed prompt. Before forking, it checks that Pi's active branch ends with the prompts Orca is removing; a mismatch refuses the rewind.
The fork uses Orca's saved-fork and session-replacement path, and resumes on relaunch. Pi's path-shaped fork IDs get a digest for the provider-handle link. The stop-checkpoint helper moves into its own file to keep the adapter under the line limit.
Why
Pi's RPC has fork, but not navigate_tree. Letting Pi do the fork keeps its context in step with the transcript and preserves the abandoned conversation in the original session file.
Related: #28873 and OMP PR #36258, which leaves Pi rewind disabled.
Before: three prompts. After rewinding to TWO: only ONE remains, and TWO is back in the composer.
rewind.mp4
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
On macOS, commit 4fb657a875, Node 24.22.1, Pi 1.5.0: the six new/updated regression suites pass (77 tests), pnpm tc and pnpm run build:electron-vite pass. The changed-code quality gate reports zero new findings across all 19 files.
In an isolated dev build, sent ONE, TWO and THREE, then rewound to TWO. The recording shows the result. After restarting, only ONE remained; asked for earlier prompts, Pi listed only ONE.
Full pnpm build stopped at missing mobile/ dependencies. Full lint/test/build are left to CI. Linux, Windows, SSH and WSL were not run locally.
Risk
Level: Medium
The shared fork-rewind path now serves Pi as well as Claude. Pi refuses mismatched branches instead of guessing where to cut. A plain revert removes the action; forks already created remain valid Pi session files. File rollback is not included.
AI Disclosure
AI-assisted implementation with Claude Opus 5.5. OpenAI GPT via Pi helped with verification and PR preparation. The commit has an Assisted-by: trailer.
Review
Agent review: the new behavior is Pi-only; Claude keeps its existing fork path, and Codex/OMP are untouched. Paths come from Pi's RPC rather than local file access, so there is no added local-only assumption for SSH. Work happens only on rewind, with no new UI components or external inputs. Cross-platform and remote behavior still need CI or maintainer testing.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Conversation rewind only, matching the existing Claude/Codex behavior.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Pi native chats declared rewind: false, so "Rewind to here" was never
offered on a Pi chat. Rewind now asks the running Pi to fork (its RPC
`fork` command) at the first removed prompt, after checking that Pi's
active branch ends with exactly the prompts the chat removes; otherwise
it refuses and leaves the conversation alone. The fork rides the
existing fork-rewind path (saved fork, epoch replacement, forked handle
link), and Pi launch resumes a saved fork the way Claude launch does.
- The Pi adapter reports that its rewind cuts at the prompt, so the
desktop offers the action on sent Pi messages, which carry Orca's own
key rather than a provider item id.
- A fork named by a file path (Pi) gets a digest link id, because
`rewind-<path>` is not a valid handle link id.
- The Pi adapter's stop-checkpoint wait moves to its own module so the
adapter stays within the file-size limit.
Assisted-by: Claude (claude-opus-5-5)
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
The changes add prompt-based rewind support for Pi. The UI can admit submitted prompts when the provider declares prompt-cut support. Structured rewind cuts provide ordered prompt text, and the Pi RPC implementation validates that text against the active branch before forking. The session launch and completion paths select and record the materialized fork. The changes also update Claude target validation and structured rewind handling.
Severity of issue fixed: Medium
Merge Risk: Moderate · up to d73b0
Large Pi chats may be unable to rewind even their latest prompt. Use a bounded history read before merging unless that limitation is explicitly accepted.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely identifies the main change: enabling Pi chat rewind through Pi's native fork mechanism.
Description check
The description follows the required template and explains the user-visible behavior, implementation, rationale, linked issue, visual proof, testing, risks, AI use, compatibility considerations, and c…
Linked Issues check
Issue [#37942] requires rewind for sent Pi messages, removal of the selected prompt and later prompts, restoration of the selected prompt to the composer, movement of Pi's conversation, unchanged file…
Out of Scope Changes check
The changes stay within [#37942]. Pi RPC fork handling, prompt-cut computation, renderer admission, launch resumption, rewind completion, and regression tests directly implement or support Pi conversa…
Full details: Description check
Explanation
The description follows the required template and explains the user-visible behavior, implementation, rationale, linked issue, visual proof, testing, risks, AI use, compatibility considerations, and checklist status. It also explains that full build and cross-platform testing remain for CI or maintainers.
Full details: Linked Issues check
Explanation
Issue [#37942] requires rewind for sent Pi messages, removal of the selected prompt and later prompts, restoration of the selected prompt to the composer, movement of Pi's conversation, unchanged files on disk, and automated coverage. The PR enables Pi rewind support and prompt admission. structuredRewindCut creates a prompt-based Pi target and retains only earlier rows. forkPiRpcSessionForRewind verifies the active branch, calls Pi RPC fork before the first removed prompt, and preserves the source session. The Pi fork, cut, launch-resume, completion, and renderer tests cover the implementation. No unmet coding requirement is shown.
Full details: Out of Scope Changes check
Explanation
The changes stay within [#37942]. Pi RPC fork handling, prompt-cut computation, renderer admission, launch resumption, rewind completion, and regression tests directly implement or support Pi conversation rewind. Shared rewind changes preserve the existing provider paths and support the Pi fork-through-agent behavior. The Claude validation change and checkpoint extraction are supporting changes. No unrelated product behavior is shown.
Full details: Docstring Coverage
Explanation
Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 19 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
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.
Two paths could leave a running agent on a fork Orca never recorded,
while the chat still points at the source conversation:
- Pi's `fork` fails with anything but a Pi error reply (an unreadable
reply, a timeout), so Pi may have forked anyway. Close the Pi child,
as a fork whose state read fails already does; the fork's own error
is still what the rewind reports if closing fails too.
- The fork is made but saving the rewind record fails. Stop the agent
before rethrowing, so its next start resumes the recorded chat.
Assisted-by: Claude (claude-opus-5-5)
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Major · Avoid a full-history RPC read for Pi rewind. · rpc-rewind-fork.ts:58
src/main/pi/rpc-rewind-fork.ts:58 Major · Stability & Availability · Heavy lift
Avoid a full-history RPC read for Pi rewind.
When the get_entries response exceeds the RPC peer’s 8 MiB line limit, readPiEntries(connection, null) rejects. The catch in forkPiRpcSessionForRewind then returns provider-refused, so a large Pi chat cannot rewind even to its latest prompt. Read only the history needed to prove the active-branch cut, or use a bounded history source. (raw.githubusercontent.com)
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 80fdba91-e0c6-43fe-8045-49ae81c079f6
Commits
Reviewing files that changed from the base of the PR and between 4fb657a and d73b06d.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Pi chats get “Rewind to here”. Pick a sent message and it returns to the composer; that message and everything after it disappear. Pi's own conversation moves back too. Files on disk stay as they are.
What Changed
Pi currently disables rewind. This enables the existing action and uses Pi's RPC
forkat the first removed prompt. Before forking, it checks that Pi's active branch ends with the prompts Orca is removing; a mismatch refuses the rewind.The fork uses Orca's saved-fork and session-replacement path, and resumes on relaunch. Pi's path-shaped fork IDs get a digest for the provider-handle link. The stop-checkpoint helper moves into its own file to keep the adapter under the line limit.
Why
Pi's RPC has
fork, but notnavigate_tree. Letting Pi do the fork keeps its context in step with the transcript and preserves the abandoned conversation in the original session file.Related: #28873 and OMP PR #36258, which leaves Pi rewind disabled.
Linked Issue
Fixes #37942
Visual Proof
Before: three prompts. After rewinding to TWO: only ONE remains, and TWO is back in the composer.
rewind.mp4
Testing
On macOS, commit
4fb657a875, Node 24.22.1, Pi 1.5.0: the six new/updated regression suites pass (77 tests),pnpm tcandpnpm run build:electron-vitepass. The changed-code quality gate reports zero new findings across all 19 files.In an isolated dev build, sent ONE, TWO and THREE, then rewound to TWO. The recording shows the result. After restarting, only ONE remained; asked for earlier prompts, Pi listed only ONE.
Full
pnpm buildstopped at missingmobile/dependencies. Full lint/test/build are left to CI. Linux, Windows, SSH and WSL were not run locally.Risk
Level: Medium
The shared fork-rewind path now serves Pi as well as Claude. Pi refuses mismatched branches instead of guessing where to cut. A plain revert removes the action; forks already created remain valid Pi session files. File rollback is not included.
AI Disclosure
AI-assisted implementation with Claude Opus 5.5. OpenAI GPT via Pi helped with verification and PR preparation. The commit has an
Assisted-by:trailer.Review
Agent review: the new behavior is Pi-only; Claude keeps its existing fork path, and Codex/OMP are untouched. Paths come from Pi's RPC rather than local file access, so there is no added local-only assumption for SSH. Work happens only on rewind, with no new UI components or external inputs. Cross-platform and remote behavior still need CI or maintainer testing.
Agent skill upstream boundary
Notes
Conversation rewind only, matching the existing Claude/Codex behavior.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)