Skip to content

fix(pi): settle OMP status from agent-end contract - #14884

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14879-omp-status-settle
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14879-omp-status-settle

Conversation

@bbingz

@bbingz bbingz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

ELI5

OMP can emit agent_end both when a turn is truly finished and when it has already scheduled an automatic retry or continuation. Orca was guessing from ctx.isIdle(), which can remain false and leave the tab permanently marked as running. OMP now supplies the exact willContinue signal, so Orca can keep working status only for real continuations and mark the final end immediately.

What Changed

  • Treat OMP agent_end.willContinue === true as non-terminal and keep the pane working.
  • Treat false or an absent field as the final boundary and post Orca's agent_end immediately, without waiting for ctx.isIdle().
  • Apply the rule to both explicitly configured OMP extensions and bare-shell OMP processes runtime-routed through the Pi extension.
  • Keep the existing agent_settled / bounded idle fallback unchanged for Pi and Prime Agent.
  • Add event-harness regressions for current OMP continuation events, current final events, legacy field-absent events, runtime routing, timer cleanup, and Pi/Prime isolation.

Why

OMP's official AgentEndEvent documents willContinue: true as an automatic continuation that subscribers must not treat as a user-visible settle. The field is optional, so treating absence as final preserves compatibility with older OMP releases. Using this event contract removes the mutable-idle race instead of extending a polling timeout or adding a renderer-wide heuristic.

Linked Issue

Fixes #14879

Visual Proof

N/A — this changes generated agent-status hook behavior, not renderer layout or styling. The reporter's stuck-running before state is attached to #14879; the final status transition is covered by the generated-extension event harness.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • TDD RED: the new OMP cases failed 4/4 before the handler change (continuations incorrectly posted done; final events with non-idle context never posted done)

  • pnpm exec vitest run --config config/vitest.config.ts src/main/pi/agent-status-extension-source.test.ts — 36/36 passed

  • pnpm exec vitest run --config config/vitest.config.ts src/main/pi — 3 files, 66/66 passed

  • OMP hook-boundary suites — 3 files, 24/24 passed

  • Direct full Vitest — 5,739 files and 53,499 tests passed; only 2 pre-existing src/main/daemon/node-pty-fd-leak.test.ts cases failed because this Node 24 checkout is not using the repository's expected patched native node-pty behavior

  • pnpm run typecheck — passed

  • pnpm run lint — passed, including 85 reliability gates, max-lines, bundled-skill, and localization checks

  • pnpm build — passed, including desktop, relay, CLI, Electron/Vite, web projection, and native macOS builds

  • focused formatting and git diff --check — passed

pnpm test was not separately rerun because its native preflight is blocked by the same patched node-pty mismatch demonstrated by the two direct-suite failures above.

AI Disclosure

OpenAI Codex diagnosed, implemented, and verified the change against Orca's current source and OMP's official event contract. Grok 4.5 independently reviewed the final state-machine diff for compatibility, timer cleanup, runtime routing, and Pi/Prime isolation and returned PASS.

Review

  • Security: no authentication, token, shell execution, dependency, or untrusted-input surface changed.
  • Cross-platform: the generated TypeScript event logic is platform neutral; both configured and runtime-detected OMP paths are covered. The reported Windows UI was not manually reproduced.
  • Remote/SSH: the same generated extension source is installed through local and SSH relay paths; no RPC or remote-wire schema changed.
  • Backwards compatibility: older OMP events without willContinue settle immediately as they historically did; current OMP continuations are suppressed only for exact boolean true; Pi and Prime retain their existing fallback.
  • Performance/reliability: OMP no longer allocates exponential idle-recheck timers at turn completion, and pending legacy timers are cleared before applying the exact event verdict.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

Author

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f7fc55ed-170c-4969-972e-b3c301cc993c

📥 Commits

Reviewing files that changed from the base of the PR and between e4e54a1 and 59effd3.

📒 Files selected for processing (2)
  • src/main/pi/agent-status-extension-source.test.ts
  • src/main/pi/agent-status-handler-source.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

OMP agent_end handling now uses willContinue to distinguish continuation from terminal completion. Continuing events clear pending checks and produce no report. Terminal events report immediately without calling context.isIdle. Existing non-OMP fallback handling remains unchanged. Tests cover direct and runtime-routed OMP events, while polling coverage remains limited to Pi and Prime agents.

Merge Risk: ⚪ Minimal · up to 59eff

The change updates OMP status handling to distinguish continuations from final agent completion while preserving existing Pi and Prime Agent behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the OMP status settlement fix and matches the main code change.
Description check ✅ Passed The description covers the required sections, linked issue, behavior, testing, compatibility, and review considerations.
Linked Issues check ✅ Passed The changes directly address issue #14879 by settling the OMP status when the agent has finished.
Out of Scope Changes check ✅ Passed The handler changes and regression tests remain focused on OMP status settlement and Pi/Prime behavior isolation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jgrossi

jgrossi commented Aug 20, 2026

Copy link
Copy Markdown

Hey @bbingz 👋 I'm having the same issue you are fixing here 👍

I tested your changes manually by building and running Orca locally with OMP. The willContinue change looks necessary, but it wasn’t sufficient in my testing: OMP posted the final agent_end and Orca returned 204, but the pane still stayed in Running because a leaked nested-shell OSC 133;D had already retired the pane’s hook authority, causing the final status update to be silently suppressed.

The fix that worked was to keep your OMP-specific willContinue handling, while also changing the generic command-finished path to confirm the foreground process before retiring authority: wait briefly for nested shells to settle, then retire only if the execution host confirms that a shell is foreground. I built and tested the patched app, and OMP now transitions from working to OMP ready consistently.

Would you be interested in a new commit on your PR with the generic runtime fix and regression tests?

@nwparker

Copy link
Copy Markdown
Contributor

Closing as orphaned: linked issue #14879 was closed as a duplicate of canonical issue #14278; its OMP status fix is tracked there.

@nwparker nwparker closed this Aug 31, 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.

[Bug]: omp agnet active indicator

5 participants