Skip to content

fix(pi): keep child sessions from replacing pane ownership - #31739

Closed
ykakade wants to merge 1 commit into
stablyai:mainfrom
ykakade:fix/31526-pi-child-session-ownership-20261021
Closed

ykakade wants to merge 1 commit into
stablyai:mainfrom
ykakade:fix/31526-pi-child-session-ownership-20261021

Conversation

@ykakade

@ykakade ykakade commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A Pi child session could replace the conversation attached to its terminal pane. Child callbacks now leave the lead session in control.

What Changed

The managed extension checks Pi session provenance before callbacks update pane metadata. It rejects child headers and nested task transcripts.

The current terminal session can still change through /new, /resume, and /fork. A fork with a parent header can still own the pane. OMP keeps its existing ownership rules.

Why

The extension previously accepted every non-OMP callback. A child could therefore post its own session ID after the lead became idle.

Linked Issue

Refs #31526. This draft fixes pane takeover. History grouping remains open.

Visual Proof

The change is in generated hook code. The same generated-extension reproduction produced these payload identities before and after:

Before: session_start(root), agent_start(root), session_start(child), agent_start(child)
After:  session_start(root), agent_start(root)

Before, the reproduction failed with Child callback replaced pane identity. After, it passed. No renderer screenshot or live Pi integration run is claimed.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Codex ran ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/pi on macOS: 33 files and 474 tests passed.

pnpm run check:code-quality:changed passed with no new findings.

The new tests cover child callbacks before and after the lead, explicit session changes, a cold-resumed terminal fork, and Windows nested paths.

pnpm build passed all typecheck projects and built the desktop bundles, CLI, and web client. It stopped at mobile-web because mobile dependencies are absent (react-native-web, expo-router, and react-native-safe-area-context). Mobile sources and build scripts are unchanged from origin/main. This dependency prerequisite was not verified on the base. The full test suite was not run.

Full pnpm lint stops on the upstream src/shared/native-chat-ask.ts max-lines error (310, maximum 300). That file is unchanged from origin/main.

AI Disclosure

Codex (gpt-6.1-sol) implemented the change, ran the listed checks, and reviewed the diff. The author still needs to review the draft.

Review

Codex reviewed these areas:

  • Cross-platform: existing Windows path normalization remains in use. The new Windows-path test runs on macOS.
  • SSH/local/remote: the extension checks provenance inside the agent process and adds no local-only filesystem access.
  • Agents/integrations: the Pi guard runs before metadata changes. OMP keeps its previous branch. The Pi-family tests passed.
  • Performance: callbacks add bounded header and path checks, with no new network requests or file reads.
  • UI: no renderer code changed. Rendered behavior was not verified because the required Electron skill is unavailable.
  • Security: the change rejects child attribution and adds no permissions, credentials, or shell commands.

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

This draft fixes pane takeover. History grouping needs a separate, reliable child marker. Pi also writes parentSession for normal user forks, so this change does not hide every transcript with that header.

Only macOS execution is verified. Linux, Windows, SSH, mobile, and mixed-version behavior need CI or user validation. Existing persisted pane bindings and already-running Pi processes need a new Pi launch before they use this extension.

Author X handle: @Yash_2015.

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)
  • 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)

@nwparker

Copy link
Copy Markdown
Contributor

Thanks Yash! Superseded by #33595 (merged, with your co-author credit). Rejecting sessions with a parent header would also block a legitimate /fork, which writes that header too, and in-memory helpers have no header; #33595 uses the session-start reason and owner session instead. Closing in favor of it.

nwparker added a commit that referenced this pull request Oct 25, 2026
…pane (#33595)

In-process pi-subagents helper sessions no longer take over the lead Pi session's pane: Orca's Pi status and title extensions keep the first Pi session in the process as owner and only move ownership on new/resume/fork session starts (helpers start with reason startup), so resume ids, turn completion and the title spinner stay with the lead. OMP behaviour is unchanged.

Fixes #31526
Supersedes #31739

Co-authored-by: Yash Kakade <[email protected]>
Co-authored-by: Brennan Benson <[email protected]>
@nwparker nwparker closed this Oct 25, 2026
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.

2 participants