Skip to content

fix(pi): preserve conversations when switching directories - #4346

Merged
ymichael merged 1 commit into
mainfrom
bb/investigate-and-fix-reported-github-issue-thr_y6cdgfzh4y
Sep 25, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/investigate-and-fix-reported-github-issue-thr_y6cdgfzh4y

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

After update_environment_directory moved a thread from A to B, Pi RPC resumed the saved session with A's directory. Commands continued in A while it existed; after deletion, Pi refused to start. Updating BB's environment alone did not update Pi's saved session location. The original pending-tool defect in #3187 was fixed separately; this closes the remaining durable-directory failure.

What changed

On a directory mismatch, use the existing Pi RPC fork helper, which calls Pi's supported SessionManager.forkFrom() SDK API. Resume the resulting session in B and publish its new provider identity for the same BB thread. The source session is retained, conversation entries are copied by Pi, equivalent paths do not fork, and failed construction removes the unsuccessful destination. There is no hand-written JSONL mutation. The SDK cwd override is not exposed by Pi's RPC/startup interface, so this uses the SDK operation already supported by our RPC extension.

No public Plugin API, CLI, or server/daemon wire changes. No protocol bump. Underlying Pi session identity changes once per directory relocation; subsequent resumes retain it.

How you verified

  • Primary proof: full source-app run at fda15b5f293ec3488e1c926f34f3871c4cb0f03e, launched with pnpm start:worktree; real installed Pi 0.87.1 in RPC mode with openai-codex/gpt-6-sol. Started in A, executed pwd, remembered a conversation-only phrase, invoked the real update_environment_directory tool, then continued through the UI in the same BB thread. The tool returned in 41 ms, next-turn pwd was B, and the phrase was recalled. Released the runtime, removed A, and resumed: pwd remained B and continuity was preserved. The provider ID changed on relocation and stayed stable afterward.
  • Pinned Pi 0.84.0 executable regression tests cover old directory retained/deleted before/deleted after relocation, actual RPC bash execution, retained messages, original file preservation, and repeated resume without another fork. Failure/retry tests ensure no unsuccessful session identity or target file is retained.
  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-provider-pi: 173 tests in 28 files passed; typecheck and lint passed.
  • Before-fix real RPC regression reproduced stale pwd and missing-directory startup failure. Browser screenshot, transcript, event timings, and build provenance are retained in the originating BB thread storage, not committed.

Fixes #3187

AGENT GENERATED

@ymichael
ymichael merged commit c89ac32 into main Sep 25, 2026
18 checks passed
@ymichael
ymichael deleted the bb/investigate-and-fix-reported-github-issue-thr_y6cdgfzh4y branch September 25, 2026 16:39
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.

update_environment_directory commits the switch but strands the Pi tool call until manual interruption

1 participant