Skip to content

fix(omp): preserve native WSL status and clear stale spinners - #13923

Closed
OrcaWin wants to merge 4 commits into
mainfrom
OrcaWin/bug-omp-17.2.12-loses-working-status-and-can-lea
Closed

OrcaWin wants to merge 4 commits into
mainfrom
OrcaWin/bug-omp-17.2.12-loses-working-status-and-can-lea

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

OMP changed the terminal-title punctuation it uses on Windows/WSL. Orca read every new title as idle and could leave its fallback spinner running after the live hook row disappeared. This teaches the shared title authority the new states and stops that spinner at the authoritative row-deletion boundary.

What Changed

  • Parse OMP 17.2.12+ native titles: π : is working, π > is idle, and π ! needs input.
  • Preserve legacy no-space π: as idle.
  • Support wrapper prefixes and legal | / marker-shaped text inside OMP labels by treating the label as opaque after the first native marker.
  • Neutralize a stale native working marker through the existing 3-second main/renderer fallback.
  • Publish successful live hook-row drops and stop that pane's synthetic spinner; transient connection clears remain isolated.
  • Add parser, main/renderer parity, stale fallback, status-drop, and main wiring contracts.

Why

Fixes #13890.

Authoritative ownership is split deliberately:

  • The shared title classifier owns title-derived OMP status for main, renderer, local, SSH, and mixed-version remote consumers.
  • AgentHookServer.dropStatusEntry owns definitive removal of a live hook row, so spinner cleanup occurs only after a real deletion. Connection-scoped transient clears do not falsely idle a possibly-working remote PTY.

Alternatives considered:

  • Patch only renderer title handling: rejected because main-side status, mobile titles, and worktree state would still drift.
  • Stop spinners on every clear: rejected because transient SSH clears do not prove the remote PTY stopped working.
  • Reuse wrapper-segment splitting alone: rejected because OMP labels may legally contain the same | delimiter.

Linked Issue

Fixes #13890

Related upstream evidence: can1357/oh-my-pi#8014. Existing PR #13891 was reviewed as reference only; this PR adds authoritative live-row ownership, opaque-label parsing, stale-title neutralization, and a main wiring contract.

Visual Proof

N/A — no layout or styling changed. Rendered Electron validation on physical Windows 11 + Ubuntu 24.04 WSL/ConPTY observed:

  • π : physical-wsl → Pi - Running / ⠋ Pi
  • π > physical-wsl → Pi - Idle / Pi
  • π ! physical-wsl → Needs input
  • A real authenticated hook row followed by renderer agentStatus.drop(paneKey) removed the row and the 80 ms synthetic spinner did not repaint the later idle title.

How to test

Falsifiable invariant:

  • π : → working
  • π > → idle
  • π ! → permission
  • legacy π: → idle
  • wrapper prefixes do not hide the native marker, and everything after it is opaque label text
  • a successful live hook-row drop retires only that pane's synthetic spinner
  • transient connection clears retain possibly-working remote authority

Deterministic baseline/candidate/disabled evidence, using the same oracle command:

pnpm vitest run src/shared/agent-detection.test.ts src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts src/main/synthetic-title-spinner.test.ts src/main/agent-hooks/server.test.ts src/main/startup/agent-hook-spinner-wiring.test.ts --config config/vitest.config.ts
  • Affected latest-main at 991a3fe963: red, 8 failures / 95 tests in the original focused contract.
  • Final rebased candidate at adbcd4f64d over 64aec94cb2: green, 384/384.
  • Same final oracle with native parsing and live-drop notification disabled: red, 23 failures / 361 passing.
  • Restored final candidate: green, 384/384.

Additional validation:

  • pnpm typecheck — passed all node, CLI, and web projects.
  • Touched-file oxlint — passed.
  • Touched-file oxfmt --check — passed.
  • git diff --check — passed.
  • Fresh architecture/security/correctness, performance/resource/UX, and platform/readiness reviews — clean.
  • Full pnpm lint passed code-quality, type-aware, reliability, max-lines, and bundled-skill guide gates, then stopped only on unrelated stale generated skill artifacts already present on current main: resources/skills/current-manifest.json, snapshot-registry.json, and release-mapping.json. They were not regenerated or included.

Risk is limited to title classification and hook-row lifecycle. There is no RPC, stream opcode, persistence, or wire-shape change. macOS/Linux, folder workspaces, git worktrees, Git providers, Git 2.25, SSH, WSL, and remote version skew were considered; all consumers use the shared classifier and old peers continue exchanging the same title bytes.

  • I manually tested these changes locally on physical Windows + WSL/ConPTY/Electron
  • Automated tests added/updated

AI Disclosure

Implemented with OpenAI Codex. Independent review passes covered architecture/security/correctness, performance/resources/UX, and cross-platform/readiness concerns.

Review

Clean for security, Windows/Linux/macOS compatibility, WSL/ConPTY, SSH and remote skew, folder workspaces/worktrees, mobile/shared consumers, backwards compatibility, and performance.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Visual proof is N/A for layout/styling; rendered behavior evidence is documented above
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Focused tests, typecheck, and code-quality gates pass; CI covers the broader matrix and the unrelated generated-manifest lint limitation is documented

Author

  • X / Twitter: N/A

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes add status-drop subscriptions to AgentHookServer. Dropped pane statuses notify listeners after persistence, and main-process wiring stops synthetic title spinners. Native OMP title markers map to working, permission, and idle statuses. Cleanup converts native working markers to idle markers. Tests cover status-drop behavior, spinner wiring, native OMP parsing, opaque labels, and renderer/main title-tracking parity.

Merge Risk: 🟡 Moderate · up to 36e5d

The title parser still fails to recognize legacy π: as idle, so affected OMP sessions may show incorrect or missing status. This localized correctness issue 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 66.67% which is insufficient. The required threshold is 80.00%. 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 summarizes the OMP native status and stale spinner fixes.
Description check ✅ Passed The description includes all required sections and provides clear scope, rationale, testing evidence, and checklist status.
Linked Issues check ✅ Passed The changes satisfy issue #13890 by fixing OMP status parsing and stopping spinners only after live pane-status deletion.
Out of Scope Changes check ✅ Passed All code and tests are directly related to OMP title classification and pane spinner lifecycle cleanup.
✨ 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

🧹 Nitpick comments (1)
src/main/startup/agent-hook-spinner-wiring.test.ts (1)

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

Build the source path from separate segments.

Line 7 passes 'src/main/index.ts' as one path fragment. This embeds / and violates the repository rule to avoid assuming / or \. Use join(process.cwd(), 'src', 'main', 'index.ts').

Proposed fix
-    const source = readFileSync(join(process.cwd(), 'src/main/index.ts'), 'utf8')
+    const source = readFileSync(join(process.cwd(), 'src', 'main', 'index.ts'), 'utf8')

As per coding guidelines, use path.join or Electron/Node path utilities for file paths and never assume / or \.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f57e9a7-09fc-4b47-8c26-75a4d5dbdc78

📥 Commits

Reviewing files that changed from the base of the PR and between 444638d and 2baaea8d0a15d8f9f21995c393a9b9d7e64008e6.

📒 Files selected for processing (8)
  • src/main/agent-hooks/server.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/main/startup/agent-hook-spinner-wiring.test.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/shared/agent-detection.test.ts
  • src/shared/agent-title-status.ts
  • src/shared/omp-native-title-status.ts

Comment thread src/shared/agent-title-status.ts Resolved
@OrcaWin
OrcaWin force-pushed the OrcaWin/bug-omp-17.2.12-loses-working-status-and-can-lea branch from 4ff0cec to 227c24f Compare August 12, 2026 02:28
@OrcaWin

OrcaWin commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@euclodius

Copy link
Copy Markdown

Cross-linking the full OMP status cluster for maintainer triage:

The visible symptom overlaps, but the two issue pairs cover distinct roots. Please choose the preferred implementation within each pair and prioritize a fix—the current stuck/misreported OMP status is materially disrupting normal use.

@OrcaWin
OrcaWin force-pushed the OrcaWin/bug-omp-17.2.12-loses-working-status-and-can-lea branch from adbcd4f to 36e5dd4 Compare August 14, 2026 21:14
@coderabbitai

coderabbitai Bot commented Aug 14, 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.

@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: Pro Plus

Run ID: 3fb71acd-ae49-4ec3-ad18-9fa5fc7498aa

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb8836 and 36e5dd4.

📒 Files selected for processing (8)
  • src/main/agent-hooks/server.test.ts
  • src/main/agent-hooks/server.ts
  • src/main/index.ts
  • src/main/startup/agent-hook-spinner-wiring.test.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/shared/agent-detection.test.ts
  • src/shared/agent-title-status.ts
  • src/shared/omp-native-title-status.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/main/index.ts
  • src/main/startup/agent-hook-spinner-wiring.test.ts
  • src/shared/agent-title-status.ts
  • src/renderer/src/components/terminal-pane/terminal-title-tracker-parity.test.ts
  • src/main/agent-hooks/server.ts
  • src/shared/agent-detection.test.ts
  • src/main/agent-hooks/server.test.ts

@@ -0,0 +1,44 @@
import type { AgentStatus } from './agent-title-core'

const OMP_NATIVE_STATE_RE = /(?:^| \| )\s*π\s+([:>!])(?=\s|$)/u

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle the legacy π: marker as idle.

Line 3 requires whitespace between π and the delimiter. Therefore, getOmpNativeStateMatch('π: label') returns null, and getOmpNativeTitleStatus cannot return the required 'idle' state. A title such as π: legacy | π > later can also skip the first native segment.

Capture whether whitespace separates π from the delimiter. Return 'working' only for π :, return 'idle' for π:, and rewrite only the spaced working marker during cleanup. Add regression coverage for both forms and for wrapper-prefixed titles.

This follows the PR requirement that legacy π: remains idle.

Proposed fix
-const OMP_NATIVE_STATE_RE = /(?:^| \| )\s*π\s+([:>!])(?=\s|$)/u
+const OMP_NATIVE_STATE_RE = /(?:^| \| )\s*π(\s*)([:>!])(?=\s|$)/u

 type OmpNativeStateMatch = {
   delimiter: string
+  hasWhitespace: boolean
   delimiterIndex: number
 }

-  const delimiter = match?.[1]
-  if (delimiter === undefined || match?.index === undefined) {
+  const whitespace = match?.[1]
+  const delimiter = match?.[2]
+  if (
+    whitespace === undefined ||
+    delimiter === undefined ||
+    match?.index === undefined
+  ) {
     return null
   }
   return {
     delimiter,
+    hasWhitespace: whitespace.length > 0,
     delimiterIndex: match.index + match[0].lastIndexOf(delimiter),
   }

 export function getOmpNativeTitleStatus(title: string): AgentStatus | null {
-  const delimiter = getOmpNativeStateMatch(title)?.delimiter
-  if (delimiter === ':') {
-    return 'working'
+  const match = getOmpNativeStateMatch(title)
+  if (match?.delimiter === ':') {
+    return match.hasWhitespace ? 'working' : 'idle'
   }

-  if (match?.delimiter !== ':') {
+  if (match?.delimiter !== ':' || !match.hasWhitespace) {
     return null
   }

Also applies to: 5-19, 23-34, 38-43

@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by #14602, which states: "Supersedes #13891 and #13923, which each fix part of this. Neither is modified or closed by this PR." The stale-spinner/native-WSL-status handling landed 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.

[Bug]: OMP 17.2.12+ loses working status and can leave a spinner stuck on WSL

3 participants