Skip to content

fix(omp): reliably clear completion spinner - #18533

Closed
timaxlucas wants to merge 4 commits into
stablyai:mainfrom
timaxlucas:fix/omp-completion-spinner
Closed

timaxlucas wants to merge 4 commits into
stablyai:mainfrom
timaxlucas:fix/omp-completion-spinner

Conversation

@timaxlucas

@timaxlucas timaxlucas commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When OMP finishes, Orca now clears the terminal's working spinner immediately and retries the final completion signal if a brief hook-delivery failure occurs.

What Changed

  • Stop the Orca title spinner directly on terminal OMP agent_end; OMP's willContinue flag distinguishes intermediate ends.
  • Retry failed OMP agent_end hook posts after 250 ms, 1 s, and 4 s.
  • Fence retries by run generation so an old completion can never stop a newer turn.
  • Treat non-2xx hook responses as failed delivery.
  • Keep Pi and Prime behavior unchanged.

Why

Issue #18262 records a completed, idle OMP turn whose final completion never became Orca agent_stop, leaving the sidebar/tab in working state. Completion is the one status transition that cannot be safely dropped. The direct title teardown removes the local visual dependency on a later idle poll, while bounded generation-fenced retries heal transient loopback delivery failures without creating an unbounded queue or affecting a newer run.

Linked Issue

Fixes #18262

Visual Proof

After an Orca-managed OMP turn containing sleep 5 settled, the sidebar changed from Working Spinner PR visual - Running now to Unread agent completion Spinner PR visual, and the pane title no longer contained a braille spinner.

Settled OMP terminal without a working spinner

Testing

  • I manually tested these changes locally on macOS 26.6 with an Orca-managed OMP 18.1.7 turn.
  • Automated tests added/updated: OMP terminal-title teardown, failed completion retry, generation fencing, and Pi non-retry.
  • pnpm exec vitest run src/main/pi — 7 files, 93 tests passed.
  • pnpm tc:node — passed.
  • pnpm check:code-quality:changed — passed with zero findings.
  • git diff --check upstream/main...HEAD — passed.

AI Disclosure

Implemented with OpenAI Codex GPT-5.6-Sol; manually reviewed and runtime-verified.

Review

Please focus on retry fencing around a new before_agent_start / agent_start and OMP's terminal willContinue !== true contract.

Agent skill upstream boundary

  • Not applicable; this change copies or translates no upstream skill-installer source.

Notes

  • Cross-platform: generated extension uses existing fetch/AbortController/timer primitives; WSL curl fallback remains unchanged.
  • Remote SSH: hook transport and pane generation remain scoped to the existing Orca endpoint and pane key.
  • Performance: retries occur only after failed terminal OMP completion delivery and are capped at three attempts.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Visual proof attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build (focused tests, node typecheck, and changed-code quality passed locally; CI will cover the full matrix)

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds run-generation tracking and bounded retries for failed OMP agent_end posts. New agent runs cancel stale completion retries. Delivery methods now report HTTP and WSL curl outcomes. Agent start handlers initialize run state. Titlebar extension generation now receives the selected agent kind and stops OMP terminal animations synchronously. Tests cover retry, cancellation, agent-kind configuration, and runtime detection.

Merge Risk: 🟡 Moderate · up to 36b4a

Completion state can still remain stuck on WSL or be incorrectly cleared for a newer run. These lifecycle reliability gaps should be fixed before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: reliably clearing the OMP completion spinner.
Description check ✅ Passed The description follows the required template and explains the change, reason, linked issue, visual proof, testing, scope, and review focus. The full validation checklist remains unchecked, but the de…
Linked Issues check ✅ Passed The changes address issue #18262 by stopping the OMP spinner on terminal agent_end, retrying failed completion delivery, fencing retries by run generation, treating non-2xx responses as failures, and …
Out of Scope Changes check ✅ Passed The code and test changes remain focused on OMP completion delivery, spinner teardown, run-generation fencing, and related titlebar behavior. No unrelated implementation changes are evident.
  • Fix all pre-merge checks with AI

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.

@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 scoping note inline.

Reviewed changes

  • Terminal OMP spinner teardown — getPiTitlebarExtensionSource now takes a kind and, on a terminal OMP agent_end (willContinue !== true), stops the braille spinner synchronously instead of polling ctx.isIdle.
  • Bounded completion-hook retry — a failed terminal OMP agent_end post is retried at 250 ms / 1 s / 4 s, fenced by an incrementing runGeneration so an old completion can never stop (or be mistaken for) a newer turn.
  • Delivery semantics — postOnce now returns a boolean and treats non-2xx responses as undelivered; Pi/Prime behavior and non-OMP hooks are unchanged.

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

@timaxlucas
timaxlucas force-pushed the fix/omp-completion-spinner branch from e3d3884 to 0cc7e96 Compare September 4, 2026 08:48
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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 new issues found.

Reviewed changes

  • Titlebar now uses runtime OMP detection — extracted getPiAgentOmpRuntimeDetectionSourceLines(configuredOmp) from agent-status-runtime-detection-source.ts and reused it in the titlebar, replacing the install-time const OMP_RUNTIME = ${kind === 'omp'} with the same isOmpRuntime() the status extension uses. The status extension's CONFIGURED_HOOK_PATH === '/hook/omp' short-circuit is now the equivalent CONFIGURED_OMP_RUNTIME boolean, so status behavior is unchanged.
  • Routed-OMP regression coverage — the titlebar harness now passes title/argv into the VM context, and two it.each cases prove a terminal agent_end from a process-title or argv-routed OMP runtime stops the spinner synchronously without consulting ctx.isIdle.

The prior scoping note is fully addressed: the titlebar and status extension now share one detector, so a bare-shell pi that later re-execs omp tears down its spinner the same way status reports it. Verified pnpm exec vitest run src/main/pi/titlebar-extension-source.test.ts src/main/pi/agent-status-extension-omp-delivery.test.ts — 18 tests pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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.

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-extension-source.ts (1)

196-196: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Retry only terminal OMP agent_end events.

Line 196 retries every failed OMP agent_end. An intermediate event with failed.extra.willContinue === true passes this guard. It can then arrive after later lifecycle events, despite the terminal-only retry requirement. Return before scheduling when failed.extra.willContinue === true. Add a regression test for this case.

Proposed fix
-    '  if (failed.hookEventName !== 'agent_end' || !failed.ompRuntime) return',
+    "  if (failed.hookEventName !== 'agent_end' || !failed.ompRuntime || failed.extra.willContinue === true) return",

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 3b7797e3-6756-4c25-8345-a829aa16a66e

📥 Commits

Reviewing files that changed from the base of the PR and between 0cc7e96 and fed0048.

📒 Files selected for processing (7)
  • src/main/pi/agent-status-extension-omp-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-runtime-detection-source.ts
  • src/main/pi/agent-status-wsl-curl-source.ts
  • src/main/pi/titlebar-extension-source.test.ts

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

@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

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-extension-source.ts (1)

204-204: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Fence active retry requests by run generation.

When line 204 retries an agent_end request and beginAgentRun() starts a new run, the request remains active. The HTTP receiver processes it without a run identifier, so the late event normalizes to done and can replace the new run’s working status. Include a monotonic run identifier in each payload and reject terminal events from non-current runs.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 34efb243-741a-4832-a13d-45225a48e74c

📥 Commits

Reviewing files that changed from the base of the PR and between fed0048 and 36b4a40.

📒 Files selected for processing (3)
  • src/main/pi/agent-status-extension-omp-lifecycle.test.ts
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/titlebar-extension-source.ts

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

' if (!isWslRuntime()) return',
' if (!isWslRuntime()) return false',
' postViaWindowsCurl(body, ompRuntime)',
' return true',

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

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 29148


🏁 Script executed:

#!/bin/bash
set -eu
file='src/main/pi/agent-status-extension-source.ts'
printf '%s\n' '--- target hunk ---'
sed -n '220,315p' "$file"
printf '%s\n' '--- relevant symbols ---'
rg -n -C 5 'postViaWindowsCurl|drainPosts|scheduleOmpAgentEndRetry|pendingAgentEndRetry|runGeneration|curl' "$file"
printf '%s\n' '--- related tests/harness references ---'
rg -n -C 4 'postViaWindowsCurl|drainPosts|WSL|curl child|retry delays|AgentEndRetry|agent end retry' src test tests 2>/dev/null || true

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
file='src/main/pi/agent-status-extension-source.ts'
printf '%s\n' '--- target file size ---'
wc -l "$file"
printf '%s\n' '--- imports and declarations ---'
sed -n '1,140p' "$file"
printf '%s\n' '--- delivery and retry implementation ---'
sed -n '140,315p' "$file"
printf '%s\n' '--- exact tracked references ---'
rg -n -C 6 --glob '*.ts' --glob '*.tsx' \
  'postViaWindowsCurl|drainPosts|scheduleOmpAgentEndRetry|pendingAgentEndRetry' \
  src/main src/shared tests 2>/dev/null || true
printf '%s\n' '--- candidate harness filenames ---'
git ls-files | grep -Ei 'agent-status|omp|hook.*(test|harness)|wsl.*(test|harness)' | head -80

Repository: stablyai/orca

Length of output: 25857


🏁 Script executed:

#!/bin/bash
set -eu
file='src/main/pi/agent-status-extension-source.ts'
sed -n '1,315p' "$file"
printf '%s\n' '--- exact references ---'
rg -n -C 6 --glob '*.ts' --glob '*.tsx' \
  'postViaWindowsCurl|drainPosts|scheduleOmpAgentEndRetry|pendingAgentEndRetry' \
  src/main src/shared tests 2>/dev/null || true
printf '%s\n' '--- candidate files ---'
git ls-files | grep -Ei 'agent-status|omp|hook.*(test|harness)|wsl.*(test|harness)' | head -80

Repository: stablyai/orca

Length of output: 25606


🏁 Script executed:

#!/bin/bash
set -eu
file='src/main/pi/agent-status-wsl-curl-source.ts'
printf '%s\n' '--- helper size and source ---'
wc -l "$file"
cat -n "$file"
printf '%s\n' '--- spawn/process contract references ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' \
  'getPiAgentStatusWslCurlSourceLines|spawn\\(|spawnSync|curl\\.exe|resolveWindowsCurlPath' \
  src/main src/shared tests 2>/dev/null | head -240
printf '%s\n' '--- exact agent-status test files ---'
git ls-files | grep -E '(^|/)(agent-status|pi-agent-status|.*wsl-curl.*)(\\.test)?\\.(ts|tsx|mjs|cjs)$' || true

Repository: stablyai/orca

Length of output: 4074


🏁 Script executed:

#!/bin/bash
set -eu
file='src/main/pi/agent-status-wsl-curl-source.ts'
wc -l "$file"
cat -n "$file"
printf '%s\n' '--- related references ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' \
  'getPiAgentStatusWslCurlSourceLines|spawn\(|spawnSync|curl\.exe|resolveWindowsCurlPath' \
  src/main src/shared tests 2>/dev/null | head -240
printf '%s\n' '--- exact tests ---'
git ls-files | grep -E '(^|/)(agent-status|pi-agent-status|.*wsl-curl.*)(\.test)?\.(ts|tsx|mjs|cjs)$' || true

Repository: stablyai/orca

Length of output: 22868


Propagate WSL curl delivery failures.

When postOnce() falls back to postViaWindowsCurl(), return false if curl cannot spawn, emits error, or exits nonzero. drainPosts() currently receives true unconditionally at line 272, so it skips the OMP completion retries and can lose the event during an Orca restart. Add a harness case that forces child failure and checks all retry delays.

@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 new issues found.

Reviewed changes

  • Retry timer now keeps the process alive — pendingAgentEndRetry.unref() was removed, so a pending terminal-completion retry survives process teardown and is still bounded by the existing three-attempt [250, 1000, 4000] schedule.
  • Runtime detection consolidated — getPiAgentOmpRuntimeDetectionSourceLines was folded back into a single getPiAgentStatusRuntimeDetectionSourceLines(kind), reverting the CONFIGURED_OMP_RUNTIME boolean short-circuit to CONFIGURED_HOOK_PATH === '/hook/omp'; the titlebar and status extension now spread the same function, and the titlebar only calls isOmpRuntime().
  • WSL transport hardening reverted — the async curl close-observation and -f flag from fed0048 were reverted, restoring fire-and-forget WSL delivery unchanged from the last reviewed state (0cc7e96).
  • Delivery tests merged — agent-status-extension-omp-delivery.test.ts was folded into agent-status-extension-omp-lifecycle.test.ts with try/finally fake-timer cleanup.

I re-checked the prior CodeRabbit concern (retrying intermediate agent_end): post('agent_end') is only reached for terminal OMP completion, since the intermediate willContinue === true path returns before postAgentEndOnce(), and the post carries no willContinue in extra. So the retry guard is already terminal-only and needs no additional willContinue check.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Current main already contains the verified fix via merged #20603, which covers both missed delivery and the received-done spinner case. Current-main evidence: 71 focused lifecycle/title/completion tests plus a real OMP HTTP 503 retry smoke. Closing this conflicting duplicate; credit to the original PR author for the retry/fencing direction.

@nwparker nwparker closed this Sep 19, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Correction: Current main already contains the verified fix via merged #20603, covering both missed final completion delivery and the received-done spinner case. Evidence: 71 focused lifecycle/title/completion tests plus a real OMP HTTP 503 retry smoke. This stale conflicting branch is superseded; credit to the original PR author for the retry and fencing direction.

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]: Missed OMP completion leaves tab spinner working across turns on Orca 1.4.194

2 participants