Repository navigation
fix(pi): claim the status pane when the inherited owner PID is dead (STA-5245) - #16631
Conversation
…STA-5245) The managed pi/omp/prime-agent status extension suppressed itself whenever ORCA_PI_STATUS_OWNED held a PID other than its own, with no check that the owner still existed. A restart leaves the previous owner's PID in the inherited env, so every later load returned early and the pane stopped reporting status permanently. Probe the owner before suppressing. Only ESRCH proves it is gone; any other probe result keeps suppression so a live foreign owner still cannot double-report. This mirrors the tri-state in main/agent-hooks/managed-hook-owner-identity.ts, which the extension cannot import because it loads inside the pi/omp runtime with no Orca deps. Also extracts the generated-source test harness into its own module so the suite stays under the max-lines limit.
📝 WalkthroughWalkthroughThe status handler now validates inherited owner PIDs and probes process existence before suppressing status-hook registration. Invalid or dead owners can be replaced by the current process, while Merge Risk: 🔵 Low · up to The change restores status reporting after a dead inherited owner, but PID comparison can still mishandle equivalent numeric values with different string formatting and unnecessarily suppress status handlers in a bounded edge case. The PR is mergeable with explicit owner awareness or a small follow-up to normalize PID comparisons. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/pi/agent-status-handler-source.ts (1)
83-85: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCompare numeric PIDs before suppressing registration.
ownerPid !== selfPidcompares strings. For example,"00123"is treated as a foreign live owner whenprocess.pidis123, so registration is skipped. Compare the validated numeric PID withprocess.pid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8fe8bffa-786f-47c1-a025-3d3aeee36dde
📒 Files selected for processing (2)
src/main/pi/agent-status-extension-source.test.tssrc/main/pi/agent-status-handler-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Status: gates green except one, not marking merge-readyHead reviewed and validated: Live reproduction and retest — same rig both timesReal
Control counts vary 2–3 because Review loop — 1 round, clean, and it caught a real gapAn orchestrated codex reviewer ( Verified independently rather than taken on report: Windows — verified, not assumedThe reported environment was Windows + WSL2, so It also confirmed both range bounds are load-bearing on Windows: PerformanceDeterministic count of the new probe per real omp run: 0 calls in the common case — the CIGreen on The one gate I could not closeElectron UI validation is blocked, so this is not marked merge-ready. The user-visible effect is the sidebar/dashboard dot for a pi-family pane, which needs a live authenticated What that leaves untested is narrow: this PR changes no renderer, IPC, or main-process code, and the agent-hooks POSTs that feed the UI were proven to arrive. The unverified span is Orca's existing, unmodified render path. To close it: run a dev Orca with a Known limitationA PID recycled onto an unrelated live process still reads as alive and keeps the pane suppressed. Strictly better than today's permanent silence; closing it would need a start-time-qualified marker written by main at launch, which is out of scope here. |
nwparker
left a comment
There was a problem hiding this comment.
Reviewed owner validation, conservative error handling, Prime frontend suppression, reload and host boundaries. Actual Pi native3OS CI, OMP Linux/WSL, Prime Windows, installed Windows receiver delivery and rendered Pi/Orca spinner before-after all pass. Live/unverifiable owners remain suppressed; PID-reuse limitation is documented. Full PR CI green at c345037. No remaining finding in this fix.
When a Pi-family agent restarts with an exited owner PID in its environment, the old guard suppresses every handler permanently. Probe the owner PID before suppressing: reclaim an exited owner (
ESRCH), retain suppression for a live or unverifiable owner, and keep Prime frontend suppression intact. This preserves the contributor fix while reconciling current main's lifecycle handling.Fixes #16109.
Verification on the pushed head
Head:
c345037f4450ac6b73617847a2f2e5bbd4080780.agent_startandagent_end, receives HTTP204, and the installedlast-status.jsonchangesworking → donefor our own verification pane.working → done. Guest loopback was unavailable, exercising the existing real Windowscurl.exefallback successfully across the host boundary.All host tests used isolated runtime files and our own terminal. No user agent configuration was changed. The installed receiver proof forwards actual network traffic; the persisted state comes from Orca, not a fixture receiver. Initial harness errors (unbundled Prime imports, expecting HTTP200 rather than204, and using
idlerather than Orca'sdone) were corrected before counting the passing runs.Scope and limits
The generated source executes on the agent's own host. No renderer, IPC or remote wire change. This verifies the reported dead-owner failure and recovery across native and WSL execution, including real installed hook delivery. Loader lifecycle events and successor processes are exercised directly; it does not claim every interactive
/restartimplementation or model provider was tested. Reuse of an exited PID by an unrelated live process remains a pre-existing limitation of PID-only ownership; unverifiable liveness intentionally keeps suppression.Actual Pi TUI and Orca spinner proof
Loaded this PR's generated status extension into real Pi0.83.0 inside a hidden, CDP-verified Orca Electron app. Each launch inherited a PID from a child that had actually exited. The model was a deterministic local streaming endpoint; the interactive Pi TUI, agent lifecycle, hook transport and Orca UI were real.
Before: replaced only the owner condition with the original guard. Pi says Working while Orca incorrectly shows Idle; no hook status exists for the pane.
After: the unmodified generated extension reclaims the dead owner. Orca's workspace and tab spinners run while Pi is Working; the accepted state is
workingwith hook provenance.Completion: the real provider response arrives, both spinners stop, Orca shows Pi ready, and the accepted state is
done.The surrounding renderer was the isolated #20070 worktree (no owner-related renderer changes); the injected status source was generated directly from this PR's checked head. Full PR CI is green. Review found no remaining defect in the reported recovery path; the scope limits above remain explicit.