Skip to content

fix(omp): acknowledge completion delivery and retire stale retries - #20603

Merged
nwparker merged 3 commits into
mainfrom
nwparker/omp-completion-review
Sep 19, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/omp-completion-review

Conversation

@nwparker

@nwparker nwparker commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When OMP finishes a response, Orca should stop showing it as busy. A failed completion notification now gets bounded retries, and starting another turn or switching sessions cancels retries for the old work.

What Changed

  • Stop the title animation on final OMP agent_end, using OMP's willContinue contract.
  • Retry failed OMP hook delivery up to three times. Reject non-2xx responses instead of treating them as delivery.
  • Await WSL curl acknowledgment, including HTTP errors, process failure, and an 11-second watchdog. Keep newer snapshots queued until the fallback settles.
  • Retire pending retries on new activity, session switch, reload registration, and shutdown. Pi and Prime retain their existing lifecycle contract.

Why

A single lost completion left Orca displaying the previous turn as working indefinitely. Retrying only while the snapshot remains current repairs transient delivery failures without submitting an old completion after a new turn has begun.

Linked Issue

Addresses #18262. Secondary source comparison: #18533. Tim Maximilian Lucas is credited as co-author for the matching completion/title approach; this branch also covers WSL acknowledgment and in-process session switches.

Visual Proof

Hidden Electron test forwards generated OMP hooks through a real HTTP proxy to Orca's hook server. The proxy rejects the first final completion with 503; the retry succeeds, the rendered working indicator disappears, and the authoritative pane state becomes done.

Before completion:
Working

After recovery:
Completed

Scope: synthetic OMP lifecycle callbacks, actual generated HTTP transport, and rendered Orca. This is not a full model conversation. WSL process outcomes are covered by deterministic tests.

Testing

  • Manually exercised generated extension with real HTTP fault injection on macOS, Node 24.18.0.
  • Automated regression coverage: 181 tests pass across all nine Pi suites in the isolated PR checkout.
  • Hidden Electron rendered regression: 1 passed (18.5s).
  • Native HTTP completion smoke passes locally and in Linux/macOS/Windows CI, including new-turn, session-switch, and shutdown cancellation (run 34835127047).
  • Node typecheck, changed-file oxlint, formatting, and git diff --check pass.
  • Tests cover HTTP rejection, timeout, retry exhaustion, new turn/shutdown/session-switch cancellation, missing or failing WSL curl, and serialization behind WSL acknowledgment.

Review

Independent agent review identified false WSL acknowledgment and stale retries after session_switch; both are repaired and regression-tested. Independent final review of implementation commit fd7f7a10d2a found no blocking findings, with 95 focused tests passing. Subsequent commits add runtime and rendered test coverage only. OMP source at ~/projects/oh-my-pi was read only.

Agent skill upstream boundary

  • No upstream skill source was copied or translated.

Head 3eca1bcfc54 passes full CI, including all unit-test shards, static analysis, typecheck, Linux/Windows packaging, and native completion HTTP smoke on Linux/macOS/Windows. Ready for review.

Notes

Retries are bounded and cannot recover a permanently unavailable receiver. Sender cancellation cannot retract an HTTP request already accepted by a receiver before timeout; receiver ordering is outside this patch. Status still flows through the execution host's existing hook store. No RPC schema or stream opcode changes; folder workspaces use the same pane-scoped transport.

@nwparker
nwparker marked this pull request as ready for review September 14, 2026 11:02
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The OMP agent-status extension now uses a shared serialized post queue. Failed completion deliveries retry with bounded backoff and stop at session lifecycle boundaries. HTTP errors and WSL curl failures propagate into retry handling. The WSL curl bridge now reports missing configuration, timeouts, process errors, and non-zero exits. OMP titlebar completion handling skips idle polling. Unit, end-to-end, native HTTP smoke, and workflow coverage was added.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 3eca1

After Orca restarts, WSL completion notifications may keep failing and leave the response shown as busy. Refresh the Windows-host fallback coordinates before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 12 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: reliable OMP completion acknowledgment and cancellation of stale retries.
Description check ✅ Passed The description covers the required change summary, rationale, linked issue, visual proof, testing, review, scope boundary, and compatibility notes. It is mostly complete. The checklist section is not…
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 12 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fcaecaa4-e820-4d59-b801-712a67993cb0

📥 Commits

Reviewing files that changed from the base of the PR and between b87a6c0 and 3eca1bc.

📒 Files selected for processing (13)
  • .github/workflows/pi-owner-runtime.yml
  • src/main/pi/agent-status-completion-delivery.test.ts
  • src/main/pi/agent-status-extension-source.test.ts
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/agent-status-extension-test-harness.ts
  • src/main/pi/agent-status-handler-source.ts
  • src/main/pi/agent-status-post-queue-source.ts
  • src/main/pi/agent-status-ui-prompt-source.ts
  • src/main/pi/agent-status-wsl-curl-source.ts
  • src/main/pi/titlebar-extension-source.test.ts
  • src/main/pi/titlebar-extension-source.ts
  • tests/e2e/omp-completion-retry-status.spec.ts
  • tests/tools/omp-completion-runtime-smoke.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

' if (!isWslRuntime()) return',
' postViaWindowsCurl(body, ompRuntime)',
' if (!isWslRuntime()) throw error',
' await postViaWindowsCurl(body, ompRuntime)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Refresh the Windows host coordinates used by the WSL fallback.

resolveHookCoords() returns guest relay coordinates in WSL. Do not pass those coordinates to postViaWindowsCurl(); the fallback must target the Windows host.

An existing PI process retains its PTY environment after an Orca restart, while the server generates a new hook token. The OMP retry path calls postOnce() again, but the fallback still uses stale process.env.ORCA_AGENT_HOOK_PORT and process.env.ORCA_AGENT_HOOK_TOKEN. Retries can therefore fail authentication or target an obsolete host port.

Refresh a separate Windows-host coordinate source after restart and use it in postViaWindowsCurl().

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline. The retry state machine and the WSL acknowledgment path both hold up under tracing.

Reviewed changes

  • Retry queue extracted — agent-status-post-queue-source.ts adds revision/attempts/delivered tracking; failed OMP posts retry 3× (250/500/1000ms), and any newer post() or session boundary retires older retries.
  • Failure now propagates — postOnce throws on non-2xx and rethrows non-WSL fetch errors; WSL falls back to curl.
  • Lifecycle retirement — resetPostQueue() + clearPendingAgentEndCheck() on session_shutdown; OMP session_switch also resets and refreshes session metadata.
  • WSL curl acknowledged — postViaWindowsCurl awaits child close, adds --fail, rejects on non-zero exit, and has an 11s kill watchdog.
  • Titlebar — final OMP agent_end (willContinue !== true) stops the spinner without consulting ctx.isIdle().
  • Tests/CI — new completion-delivery unit suite, titlebar OMP test, hidden-electron retry e2e, cross-platform runtime smoke, and the pi-owner-runtime workflow widened to src/main/pi/**.

I verified the queue interleavings (newer post vs. in-flight settle vs. retry timer vs. reset) and the WSL promise settlement paths; I found no way to re-deliver an obsolete completion or permanently drop a latest one. pnpm test on the three touched files passed (95 tests), pnpm tc:node is clean, and the changed-code quality gate reports 0 findings.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

' revision: ++postRevision,',
' attempts: 0,',
' delivered: false,',
" hookEventName: ompRuntime && hookEventName === 'model_select' && previousCompletion ? 'agent_end' : hookEventName,",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch can never run: no generated handler ever calls post('model_select') — the only event names posted are session_start, before_agent_start, agent_start, tool_execution_start, tool_call, tool_execution_end, tool_approval_requested/resolved, message_end, agent_end, and ui_prompt_*. So previousCompletion (and the comment's protection) is dead. If OMP emits model_select and you meant to preserve an unacknowledged completion across it, a pi.on('model_select', ...) handler is missing; otherwise the branch and the previousCompletion computation should be removed.

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.

1 participant