Continue Pi sessions in Worktrunk worktrees - #3
Merged
Merged
Conversation
Add explicit command flows for continuing the current Pi session in an existing or newly created worktree. Fork the persisted session through Pi's public API, preserve its history, and record the working-directory transition before switching runtimes. Assisted-by: GPT-5.6-sol (pi 0.83.0)
Assisted-by: GPT-5.6-sol (pi 0.83.0)
Owner
Author
|
@edahlseng Thanks again for pointing me to I would appreciate your take on how this fits the workflow you described. |
mavam
force-pushed
the
continue-session
branch
3 times, most recently
from
August 9, 2026 18:02
cae616f to
2459ac6
Compare
Pi does not write new sessions before the first assistant response, so SessionManager.forkFrom had no source file. Snapshot in-memory history for that case and preserve both source and target after switching. Also shorten the visible transition message and give it a user-facing title. Assisted-by: gpt-5.6-sol (pi 0.84.1)
Carry custom session directories into continued worktrees and persist fresh sources before the fallible runtime switch. Avoid cloning persisted histories and cover both storage paths plus switch failure. Assisted-by: gpt-5.6-sol (pi)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Worktree creation and path resolution leave the active Pi session in its original working directory. Continuing in the target currently requires a separate manual session operation.
Solution
/worktree continue [target]for existing worktrees./worktree create <branch> --continuefor a one-step create-and-continue flow.SessionManager.forkFrom()andctx.switchSession()APIs.Prior art
The continuation flow is inspired by
pi-session-move, while keeping the implementation narrowly Worktrunk-specific and avoiding session-history rewrites or a package dependency.This is a follow-up to #1 and #2.