Repository navigation
fix(omp): keep child sessions from reporting into the parent pane - #20611
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- In-process child ownership guard — new
src/main/pi/omp-session-status-owner-source.tsemitsownsSessionStatus(ctx)and wraps every generated status handler inonStatus. It binds the pane (ORCA_PANE_KEY+ORCA_AGENT_LAUNCH_TOKEN) to the firstSessionManagerit observes, keyed onglobalThis[Symbol.for('orca.omp.status-session-owners')]so the binding survives module reload and OMP's "rebind factories without re-evaluating the module graph" child path; any later, different manager is dropped before metadata changes orpost(). - Handler registration rename —
agent-status-handler-source.tsnow registers all status hooks throughonStatus(...)instead ofpi.on(...), and adds an emptyonStatus('session_start', () => {})so the root claims ownership at the earliest event. The guard applies to every kind but is inert for pi/prime-agent, whereisOmpRuntime()is false. - Recovery regression coverage —
tests/e2e/omp-child-session-recovery.unit.test.tsdrives generated hooks through normalization, store state, quit capture, sleep-record schema hydration and resume startup, asserting the root prompt/preview/session survive an active child and the child UUID never reaches the serialized record. - Runtime smoke script —
tests/tools/omp-child-session-runtime-smoke.mjsexercises the real OMP loader/EventBus/in-memorySessionManagerwith real HTTP (manual, not collected). - Harness alignment — existing OMP extension tests now mutate one
sessionManagerobject instead of swapping identities, matching the ownership contract.
The load-bearing assumption checks out against upstream OMP: ExtensionRunner pins ctx.sessionManager at construction, subagent runners own a distinct manager, and root setSessionFile (/resume) and #resetToNewSession (/new) mutate the same manager in place — so the root keeps one identity for the pane's lifetime, and it is also the identity whose getSessionId() produced the child corruption this fixes. Focused tests (171 in src/main/pi), pnpm tc:node and check:code-quality:changed are all green.
ℹ️ Ownership is sticky for the pane's lifetime
ownsSessionStatus binds the pane to the first manager it sees and never releases it, so a manager that is replaced on the same pane+launch token is suppressed permanently with no recovery path. That is the intended trade for the false-child-completion bug, and today's OMP keeps the root manager stable across resume/new/reload — but it means the pane would go silent rather than self-heal if OMP ever rebinds a live pane to a fresh manager. Noting it as the invariant future OMP session-lifecycle changes must preserve; no change needed in this PR.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 25b30f7 and 2ddd31de0b65526c7009750787726acd8b35eafe. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe OMP status extension tracks session ownership by pane and launch token. Generated handlers use Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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.
✅ No new issues found.
Reviewed changes
- Runtime smoke test now drives the real runner —
tests/tools/omp-child-session-runtime-smoke.mjsreplaces hand-invoked handlers with OMP's actualExtensionRunner+SessionManager(file-backed root, in-memory child), bounded HTTP delivery checks, error capture, andsetSessionFileresume; it asserts the child stays quiet while rootagent_start/agent_endsurvive module reload,newSession(), and resume. - Unit test renamed for accuracy — the separate-pane case in
omp-session-status-owner.test.tsis retitled to describe the distinct pane/launch ownership key it actually exercises, rather than implying full same-process pane isolation.
The new smoke assertions are able to fail: without the ownership guard the child's session_start/agent_start/agent_end would post, breaking assertQuiet(1), and the final ['agent_start','agent_end'] × 4 check is exact rather than permissive. No production code changed in this delta.
️ Strengthened runtime evidence still has no CI enforcement
The real-ExtensionRunner path is now the strongest evidence in the PR, but the script is deliberately uncollected (tests/tools/*.test.mjs only) and needs a read-only OMP checkout, so nothing in CI fails if the ownership guard regresses against a future runtime binding change. The collected regression coverage remains simulation-only; that is a conscious trade rather than a defect, just worth carrying forward.
Technical details
# Runtime smoke has no automated gate
## Affected sites
- `tests/tools/omp-child-session-runtime-smoke.mjs:1` — manual entry point, requires an external OMP checkout path argument.
- `config/vitest.config.ts:36` — collects `tests/tools/**/*.test.mjs`; this file is `*-smoke.mjs`, so it is skipped.
## Required outcome
- Record the gap so future edits to the extension/runner binding know the real-runtime path is not protected by CI.
## Open questions for the human
- Is a pinned/versioned OMP dependency feasible for CI, or is the manual smoke run the intended permanent posture?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b3a596c3-06bc-4c31-ac01-0266de2652d2
📒 Files selected for processing (2)
src/main/pi/omp-session-status-owner.test.tstests/tools/omp-child-session-runtime-smoke.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/pi/omp-session-status-owner.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| } | ||
| const assertQuiet = async (expectedCount) => { | ||
| // Suppressed events have no completion callback; allow local HTTP dispatch to settle. | ||
| await delay(100) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Wait for the complete status-post timeout.
runner.emit() returns before asynchronous HTTP delivery completes. The generated extension permits status delivery to remain pending for 1000 ms, but assertQuiet() waits only 100 ms.
A delayed child post can arrive after this assertion. It can then satisfy a later expectedCount assertion and hide the ownership regression.
Use a quiet period longer than HOOK_POST_TIMEOUT_MS, or add explicit delivery synchronization.
Proposed fix
- await delay(100)
+ await delay(1100)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await delay(100) | |
| await delay(1100) |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 053fa99f-8e3d-4b7c-8ce6-5c6c57908e2c
📒 Files selected for processing (3)
docs/reference/omp-runtime-session-provenance.mdsrc/main/pi/omp-session-status-owner-source.tssrc/main/pi/omp-session-status-owner.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| ' // SessionManager survives reload/new/resume; task children own a different instance.', | ||
| ' function ownsSessionStatus(ctx): boolean {', | ||
| ' if (!isOmpRuntime()) return true', | ||
| ' if (ctx?.agentKind === "sub") return false', |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,80p' src/main/pi/omp-session-status-owner-source.ts
sed -n '1,120p' docs/reference/omp-runtime-session-provenance.md
rg -n 'agentKind|createContext|ExtensionRunner|omp-agent|@.*omp' package.json pnpm-lock.yaml yarn.lock package-lock.json src tests 2>/dev/null | head -240Repository: stablyai/orca
Length of output: 50372
🏁 Script executed:
set -e
printf '%s\n' '--- manifests and OMP references ---'
rg -n -i --glob 'package.json' --glob 'pnpm-lock.yaml' --glob 'package-lock.json' --glob 'yarn.lock' --glob 'npm-shrinkwrap.json' 'omp|open.*model|e7546987|agentKind' . | head -160
printf '%s\n' '--- focused files ---'
sed -n '1,230p' tests/tools/omp-child-session-runtime-smoke.mjs
sed -n '1,230p' src/main/pi/omp-session-status-owner.test.ts
printf '%s\n' '--- runner/source locations ---'
rg -n --hidden -g '!node_modules/**' -g '!dist/**' -g '!build/**' 'class ExtensionRunner|createContext\s*\(|agentKind' src tests packages apps 2>/dev/null | head -220Repository: stablyai/orca
Length of output: 41587
🌐 Web query:
"e7546987ca526eac8f605fac19ef9805b8f01898" OMP ExtensionRunner createContext agentKind
💡 Result:
<search_synthesis>
The terms ExtensionRunner, createContext, and agentKind are associated with the codebase for a coding agent system, specifically referenced in discussions and implementations related to 'Oh My Pi' (OMP) [1][2]. In this architecture, ExtensionRunner is a class responsible for managing extension lifecycles and context [3][4][5]. The createContext method generates the ExtensionContext object, which provides extensions with access to the agent's current state (e.g., UI, session manager, and model registry) [3][6][5]. The specific reference to agentKind relates to feature requests and discussions about exposing subagent identity (e.g., "main" vs "sub" agent) within the extension context or lifecycle event handlers [1][2]. Developers have sought to add fields like agentKind, agentId, and parentAgentId to the ExtensionContext interface to allow extensions to distinguish between root and sub-agent events [2]. While the core ExtensionRunner logic manages core execution and tool invocation, these identity-related fields are part of ongoing efforts to achieve parity for subagent extensions within the system [1][2]. The alphanumeric string e7546987ca526eac8f605fac19ef9805b8f01898 does not appear to be a recognized identifier, commit hash, or technical reference within the public repositories or documentation related to this project. It resembles a transaction or address hash, which are commonly found in blockchain-related data but are not relevant to the technical implementation of the OMP coding agent [7][8][9][10][11].
</search_synthesis>
<source_evidence>
Citations:
- 1: GitHub issue 10228 in can1357/oh-my-pi (link omitted to avoid creating a cross-reference)
- 2: GitHub issue 5985 in can1357/oh-my-pi (link omitted to avoid creating a cross-reference)
- 3: https://github.com/can1357/oh-my-pi/blob/c0d0ad76/packages/coding-agent/src/extensibility/extensions/runner.ts
- 4: https://cdn.jsdelivr.net/npm/@oh-my-pi/[email protected]/src/extensibility/extensions/runner.ts
- 5: https://github.com/badlogic/pi-mono/blob/38f18be4/packages/coding-agent/src/core/extensions/runner.ts
- 6: https://github.com/can1357/oh-my-pi/blob/d94bdfa1/packages/coding-agent/src/extensibility/extensions/runner.ts
- 7: https://ordinals.com/tx/e754327a9a4021832694d1493c296c441927f79d5a9e231ff2542dd083e5af06
- 8: https://etherscan.io/address/0xe75481858c9aeb9d25a9724231ff01fefb8e9962
- 9: https://etherscan.io/address/0x754cbbe82c17cc32dea516bd73d55982e9517881
- 10: https://optimistic.etherscan.io/address/0x754581ca4b65971e4f30adfc4ad05ebf91c5a038
- 11: https://www.blockexplorer.com/ethereum/tx/0xe75088729589abb9dc717de5611bce7f1f98b9a541daf2dc4aaf812ef53f00f7
Expose agentKind before relying on this filter.
The current OMP ExtensionRunner.createContext contract does not expose agentKind. A child callback without that field can claim the first manager owner. A later root callback then fails the manager check, so child status can control the pane.
Ship the runtime context change with this filter. Add a regression test where the child callback arrives first without agentKind.
There was a problem hiding this comment.
ℹ️ No critical issues — one documentation-hygiene nit below.
Reviewed changes
This re-review covers the single commit pushed since the prior pullfrog review at 2d10236 — a forward-compatible runtime-provenance guard with its regression tests and a reference doc.
- Added an
agentKind === 'sub'short-circuit to the generatedownsSessionStatus, so a child callback is rejected before it can claim a pane when OMP exposes runtime provenance, while runtimes without the field fall through to the existingSessionManageridentity guard. - Added regression coverage proving an earlier child callback is rejected and that a former child transcript resumed as the runtime main session still reports — the rejection test fails without the guard (verified by ablation).
- Documented the provenance contract, its unreleased OMP runtime dependency, and the remaining multi-root/ordering limits in
docs/reference/omp-runtime-session-provenance.md.
The new guard is inert on today's released runtimes (OMP does not yet expose ctx.agentKind) and is already behind the isOmpRuntime() check, so it changes nothing for pi/prime-agent and is safe to ship ahead of the runtime proposal.
ℹ️ Nitpicks
docs/reference/omp-runtime-session-provenance.mdis only tracked because it was force-added:docs/**ignores it (.gitignore:96) and there is no matching!docs/reference/omp-runtime-session-provenance.mdnegation. This mirrors the repo's existing reference-doc norm and is not a blocker, but adding the allow-list line would make the page reproducible from a cleangit add.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one provenance-clarity suggestion inline.
Reviewed changes
This re-review covers the commit pushed since the prior pullfrog review at eb63ea2 — a rework of the OMP ownership guard to derive provenance from the session manager, plus a rewrite of its reference doc.
- Replaced the
ctx.agentKind-only short-circuit withsessionProvenance(ctx), which snapshotsgetSessionId()/getSessionFile()/getHeader().parentSessionfrom the manager, and stores that snapshot as the pane owner. - Rejected a different manager when its
parentSessionmatches the owner's file or id, or when its transcript is nested under the owner's file, and still rejected it otherwise. - Rewrote
docs/reference/omp-runtime-session-provenance.mdto describe the released-runtime fallback and the unresolved child-first ambiguity. - Added a unit test for the parent-metadata/nested-path rejection and dropped
agentKind: 'main'from the resumed-child test so it models released OMP.
The new code is behaviorally inert — see the inline note — so this does not change what ships, but the doc and the test title now describe a distinction the code does not make.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| ' if (owner.manager === current.manager) return true', | ||
| ' if (current.parent === owner.file || current.parent === owner.id) return false', | ||
| ' if (isNestedTaskTranscript(owner.file, current.file)) return false', | ||
| ' return false', |
There was a problem hiding this comment.
These three provenance checks all fall through to return false, so once an owner exists the decision is exactly owner.manager === current.manager — the parent and nested-path branches never change the outcome. I collapsed them to that identity check locally and all 44 focused tests (including the new parent-metadata test) still pass, so the distinction is not actually exercised. If it is being kept as groundwork for a future OMP agentKind, a comment saying every non-owner manager is rejected would avoid implying the metadata drives the decision; otherwise the helpers and branches can go.
Technical details
# Provenance branches do not affect the ownership decision
## Affected sites
- `src/main/pi/omp-session-status-owner-source.ts:36` — `owner.manager === current.manager` returns true for the same manager
- `src/main/pi/omp-session-status-owner-source.ts:37` — `current.parent === owner.file || current.parent === owner.id` returns false
- `src/main/pi/omp-session-status-owner-source.ts:38` — `isNestedTaskTranscript(owner.file, current.file)` returns false
- `src/main/pi/omp-session-status-owner-source.ts:39` — unconditional `return false`
- `src/main/pi/omp-session-status-owner.test.ts:93` — the new parent-metadata test also passes under the pre-change guard
## Required outcome
- The code and `docs/reference/omp-runtime-session-provenance.md` agree on what drives rejection. The doc says the guard "uses the session manager's parent header and nested task transcript path", but any different manager is rejected regardless, so the metadata currently has no effect.
## Suggested approach (optional)
- Collapse to `if (owner) return owner.manager === current.manager`, or keep the branches with a comment that all non-owner managers are rejected and the provenance reads are retained for a future `agentKind` fence.
- `isNestedTaskTranscript` compares with a literal `/` (`candidateFile.startsWith(`${root}/`)`), so it returns false for Windows-style paths — harmless while the result is discarded, but a trap if it ever becomes load-bearing.
## Open questions for the human (optional)
- Is `getHeader().parentSession` a released OMP field, and is it a transcript file path or a session id? The code compares it against both `owner.file` and `owner.id`, which suggests the contract is not pinned down.2ddd31d to
6fb1c19
Compare

OMP loads Orca’s status extension again for in-process task children. Those children share the parent PID, so the PID guard lets a child overwrite the parent pane’s session metadata and send a false completion notification.
The extension binds each pane and launch to the first SessionManager to deliver a status callback. In normal root-first OMP startup this is the root manager: later child callbacks are rejected before metadata changes or status handling, while root events continue across extension reload and session changes. Existing cross-process ownership and completion settling remain intact.
Closes #9181
Also prevents the current-OMP child preview/session-ID corruption reported in #9348 and #16353. Previously corrupted saved records are not repaired.
Validation
2d948aac5948287674dbab6840b0d8de488e8d1e; 88 focused tests passed independently. Implementation run: 171 Pi tests plus node typecheck, lint and formatting passed.newSession(), persisted-file resume/reload, and shutdown while children drain. Positive HTTP delivery uses a bounded deadline; loader/runner/server errors are asserted. Independent smoke rerun passed.ORCA_BACKGROUND_LAUNCH=1 bun tests/tools/omp-child-session-runtime-smoke.mjs /path/to/oh-my-pi. The OMP checkout is read-only. Lifecycle events and their ordering are controlled by the probe; no full TUI or model-driven task turn was run./resumemanager continuity is supported by source inspection plus actualsetSessionFileruntime exercise. Historical shared-event-bus OMP versions were not runtime-tested. Legacy callbacks without a SessionManager retain existing behavior because their ownership cannot be distinguished.Compared with merged #8545 and #8826: this extends their process guard and preserves their settlement behavior with the missing in-process session boundary.
Adversarial review — 2026-09-14
Overall risk: medium; not approved for automatic merge. Normal root-first TUI new/resume/reload behavior is exercised, but the ownership mechanism assumes root callbacks arrive first.
session_startdispatch can initialize a child before Orca receives the root callback. The child then owns pane status and root updates are suppressed. Reproduced through actual OMP loader/ExtensionRunner/SessionManager and real HTTP; the early extension/child initialization is controlled by the probe. This can produce incorrect preview/completion/resume metadata for that configuration.Follow-up changes strengthen validation only; they do not claim to fix these compatibility boundaries. Current upstream checkout tested:
e7546987ca526eac8f605fac19ef9805b8f01898. No historical-version, native-Windows, full model-driven task or app-restart proof claimed for this follow-up.Follow-up
2d10236e40c: 40 focused tests, node typecheck, changed-code quality and independently rerun actual OMP runtime smoke passed. All latest-head CI checks completed successfully (or skipped where not applicable). Two independent subagent reviews and Fable through Orca orchestration completed. Fable independently reran 173 tests, the actual runtime smoke, and the child-first reproduction; it rates the PR medium-low, while the coordinator retains medium overall because the reproduced ordering defect remains.Fable review adjudication: its proposed
/tanregression is not accepted as established: current tan-command-controller passesdisableExtensionDiscovery: truewithout extension paths, and SDK discovery therefore does not load this extension. Its titlebar ownership observation concerns a separate pre-existing mechanism; not changed in this PR. Stock startup source tracing did not identify the child-first defect there, but this is not a universal runtime/third-party-extension compatibility proof. Fable task completed successfully and its supervised terminal was released.Released OMP provenance follow-up
ELI5
OMP runs the status extension for the parent and its in-process task children. Released OMP does not expose the computed child/main flag in
ExtensionContext, so the originalctx.agentKindguard is unavailable at runtime. This update uses the real session manager parent header and nested task transcript path when a root owner is already known, while keeping a nested transcript eligible when no owner is known because it may be a resumed main session.Proof
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/pi/omp-session-status-owner.test.ts— 10 passed.pnpm exec oxfmt --check ...— passed.oxlint— passed.pnpm tc:node— passed.session_startand Windows nested paths./Users/nwparker/projects/oh-my-pi, clean checkout;ExtensionRunner.createContext()has noagentKind, and task children use nested transcript paths.The exact child-first/no-metadata race remains an upstream OMP capability gap. A timeout heuristic would risk silencing a valid resumed child session, so this change does not introduce that user-facing trade-off. A complete fence needs OMP to expose its already-computed
agentKindthroughExtensionRunner.createContext.