Skip to content

fix(agents): report OMP terminal and interactive states - #14279

Closed
devatnull wants to merge 3 commits into
stablyai:mainfrom
devatnull:fix/omp-terminal-agent-end
Closed

devatnull wants to merge 3 commits into
stablyai:mainfrom
devatnull:fix/omp-terminal-agent-end

Conversation

@devatnull

@devatnull devatnull commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca now treats OMP as OMP consistently. It shows completion, questions, and approval waits at the correct time.

What Changed

  • Consume OMP's documented agent_end.willContinue signal.
  • Keep OMP identity stable when generic Pi-compatible frames arrive.
  • Publish OMP ask payloads as interactive prompts.
  • Forward OMP approval request and resolution states.
  • Preserve the existing Pi and Prime idle/settled fallback.

Why

OMP does not expose the agent_settled event Orca expected. Its live hook identity could also be overwritten by the less-specific Pi-compatible owner identity. The fix uses OMP's documented lifecycle events and makes OMP the stable identity within that compatibility pair.

Linked Issue

Fixes #14278

Visual Proof

N/A. The change is in generated hook delivery and status normalization. It is verified at those behavior seams without changing rendered layout.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Verified on macOS:

  • pnpm exec vitest run src/shared/agent-detection.test.ts src/shared/agent-hook-listener.test.ts src/main/pi/agent-status-extension-source.test.ts (241 passed)
  • Targeted oxlint --deny-warnings on changed files
  • pnpm typecheck
  • Full pnpm lint passed before the final focused expansion
  • Full pnpm test reached 4,803 passing and 19 skipped tests. Four unrelated environment-sensitive tests failed: Bitbucket credential state, SSH askpass environment, one benchmark threshold, and one dynamic-import timeout.
  • Desktop and web builds completed. Native build is blocked locally because the checkout requires Node 24 while this host has Node 22.

Linux, Windows, SSH, mobile, and native desktop behavior were not run locally. The generated hook remains platform-neutral and existing WSL/SSH routing is unchanged.

AI Disclosure

OpenAI Codex GPT-5.6 Sol assisted with diagnosis, implementation, and tests.

Review

Reviewed for lifecycle ordering, duplicate completion, stale interactive state, identity stability, security, cross-platform path handling, SSH/WSL routing, mobile status projection, backward compatibility, and hot-path performance. No blocking issue remains in focused review.

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

Copilot AI lite review requested due to automatic review settings August 13, 2026 12:57
@coderabbitai

coderabbitai Bot commented Aug 13, 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: e001a4e2-54d5-405d-ace3-ad3fefd5a9e2

📥 Commits

Reviewing files that changed from the base of the PR and between 0168474 and 7ab45ff.

📒 Files selected for processing (1)
  • src/main/pi/agent-status-extension-source.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/pi/agent-status-extension-source.test.ts

📝 Walkthrough

Walkthrough

OMP status handlers now emit tool approval request and resolution events with tool and approval data. OMP agent_end events report completion only when willContinue is false. Agent hook processing now supports OMP approval cards, resolution cleanup, and interactive ask prompts. Compatible agent resolution preserves the OMP agent type. Tests cover these status and state transitions.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #14278 by handling OMP completion, identity stability, ask prompts, approvals, and Pi fallback behavior.
Out of Scope Changes check ✅ Passed The code and tests remain focused on OMP status handling, identity resolution, interactive prompts, approvals, and related regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely summarizes the main OMP terminal and interactive state changes.
Description check ✅ Passed The description covers the required sections, explains the changes and rationale, links issue #14278, and documents testing results and limitations.

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.

🧹 Nitpick comments (2)
src/main/pi/agent-status-extension-source.test.ts (2)

377-386: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the approval resolution event.

Add a tool_approval_resolved dispatch and assert its tool_name, approved, and reason payload. The listener restores working state only after this event. A source regression can otherwise leave an OMP pane blocked without failing this test.

Proposed test addition
+    await harness.callHook('tool_approval_resolved', {
+      toolName: 'bash',
+      approved: true,
+      reason: 'Runs an external command'
+    })
+    await vi.waitFor(() => expect(harness.fetchMock).toHaveBeenCalledTimes(3))
+    expect(JSON.parse(String(harness.fetchMock.mock.calls[2]?.[1]?.body)).payload).toEqual({
+      hook_event_name: 'tool_approval_resolved',
+      tool_name: 'bash',
+      approved: true,
+      reason: 'Runs an external command'
+    })

861-873: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test an absent willContinue value.

Add an agent_end event without willContinue and expect one completion post. The required terminal condition is willContinue !== true. The current test would not detect a regression that only completes for willContinue === false.

Proposed test addition
     await harness.callHook('agent_end', { willContinue: true }, context)
     expect(harness.fetchMock).not.toHaveBeenCalled()

+    await harness.callHook('agent_end', {}, context)
+    await vi.waitFor(() => expect(harness.fetchMock).toHaveBeenCalledTimes(1))
+
     await harness.callHook('agent_end', { willContinue: false }, context)
-    await vi.waitFor(() => expect(harness.fetchMock).toHaveBeenCalledTimes(1))
+    expect(harness.fetchMock).toHaveBeenCalledTimes(1)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fb1bb598-6427-4c81-b2fd-9680dc7c20c6

📥 Commits

Reviewing files that changed from the base of the PR and between 9a81874 and 1e88e40.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Orca’s OMP agent status reporting so terminal/interactive states are correctly surfaced, using OMP’s documented agent_end.willContinue signal and forwarding OMP interactive/approval lifecycle events while preserving existing Pi/Prime fallback behavior.

Changes:

  • Treat OMP agent_end as terminal only when willContinue !== true, avoiding “stuck working” status.
  • Publish OMP ask tool payloads as interactive prompts (same { questions } envelope used elsewhere).
  • Forward OMP tool_approval_requested / tool_approval_resolved into Orca’s blocked/working state model and interactive prompt envelope.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/shared/agent-hook-listener.ts Normalizes OMP ask into interactive prompts and maps OMP approval request/resolution events into tool snapshots + blocked/working states.
src/shared/agent-hook-listener.test.ts Adds coverage for OMP approval blocked→working transitions and verifies OMP ask now publishes an interactive prompt.
src/main/pi/agent-status-handler-source.ts Emits OMP approval lifecycle hook posts and uses agent_end.willContinue to decide whether to post terminal agent_end.
src/main/pi/agent-status-extension-source.test.ts Verifies approval event posting and adds coverage ensuring only terminal OMP agent_end is reported (configured + runtime-routed).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@euclodius

Copy link
Copy Markdown

Cross-linking #13891 / #13890 because these fixes cover complementary layers of the same OMP stuck-working failure.

In our Windows + WSL2 reproduction with OMP 17.2.14, the pane could remain working after OMP returned to its prompt. #14279 addresses the authoritative hook path: terminal agent_end.willContinue settlement, stable OMP identity, and interactive/approval lifecycle delivery.

#13891 addresses the fallback/cleanup path that remains relevant even with this PR:

  • OMP 17.2.12+ WSL/ConPTY native titles use π : (working), π > (idle), and π ! (permission); Orca previously classified all three as idle.
  • A pane-scoped hook status clear did not stop Orca's main-process synthetic title spinner.

There is no production-file overlap between the lifecycle handler here and #13891; only agent-detection.test.ts is touched by both for different cases. I believe both fixes are needed: this PR makes the hook stream settle correctly, while #13891 keeps title fallback and spinner cleanup correct when hook delivery is missing, delayed, or cleared.

@euclodius

Copy link
Copy Markdown

Completing the OMP status cross-links: #13891 and #13923 are competing implementations for the separate #13890 WSL/ConPTY native-title and stale-spinner root cause. This PR and #14330 remain the competing implementations for #14278 (agent_end / willContinue).

These pairs are complementary across distinct roots. Please choose the preferred implementation within each pair and prioritize landing the fixes; users are currently seeing the same disruptive stuck/misreported OMP status from both paths.

@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by #15713, which states: "Supersedes #14279 for these remaining gaps. Thanks to @devatnull — the diagnosis that ask/approval/identity are missing from the OMP hook path is carried forward (Co-authored-by)." Your diagnosis is credited there. Please reopen if anything from this branch is still missing.

@nwparker nwparker closed this Sep 14, 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.

OMP terminal agent_end can leave status stuck as working

6 participants