Skip to content

Separate pane identity from liveness in the tab-agent resolver (fixes OMP tab flicker) - #7860

Merged
brennanb2025 merged 4 commits into
mainfrom
fix/omp-title-flicker-launchagent-absent
Jul 9, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
fix/omp-title-flicker-launchagent-absent

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Linear: STA-944 — [Bug]: OMP tab label flickers between OMP and Pi

Summary

Fixes the OMP/Pi tab-icon flicker (STA-944): an OMP pane whose launchAgent was dropped — which happens on a mirrored/paired-remote or restored pane — flipped its tab identity OMP (while working) ↔ Pi (while idle) once per turn.

Original report (STA-944, filed vs 1.4.103): using OMP makes the tab label rapidly alternate between OMP and Pi. Reporter (remote-host user) added: only in a worktree, only while an agent is actively running, OMP-specific (Codex unaffected), the pane is mis-detected as Pi on a remote host, and it only happens on a pane that existed before an Orca restart — "something global is getting reset every tick."

Root cause — identity conflated with liveness. OMP wraps Pi and emits byte-identical Pi-compatible title frames, so the title cannot distinguish them; the real identity lives in the pane's hook record (agentStatus.agentType = 'omp', host-stamped, mirror-published, survives reattach). But the live-hook lookup returns null the moment the agent goes idle (state === 'done'), demoting the identity to a low-ranked fallback that the non-distinguishing title could beat. So a launchAgent-less OMP pane showed OMP while working (live hook) and Pi while idle (title won) — the "resets every tick" flicker.

Fix — make identity first-class and state-independent, demote the title to a tie-breaker:

  • Live focused hook = ground truth while working; never overridden by a title.
  • Process identity next (local; agents with no hook/title).
  • Title now only two roles: a cross-group reuse override (names a genuinely different agent → pane was reused) or a legacy standalone identity for a pane with no hook. Within the Pi/OMP group it carries no identity, so the record wins.
  • Idle focused identity (the pane's completed-hook record) is now an explicit ranked signal above the hibernated session, launch bootstrap, and sibling panes — the agent that actually ran and idled here outranks weaker guesses. Suppressed on a local pane once OSC 133;D proves the agent exited (that suppression is focused-pane-scoped; it never clears a sibling's identity).

Supporting primitive src/shared/pane-agent-owner.ts (resolvePaneAgentOwner) unifies "who owns this pane" (launch intent → this pane's hook identity → hibernated record), focused-pane-scoped so a split-pane sibling can't mislabel the focused pane.

Scope: only Pi-compatible agents are affected by the title re-owning (resolveCompatibleAgentTypeForOwner rewrites only within the same title-identity group). Codex→Claude reuse and every non-Pi path resolve exactly as before. Deliberately unchanged: sleeping-session still outranks a stale launch (the intentional hibernation-reuse behavior pinned by use-tab-agent-sleeping-session.test.ts), the sidebar rows (hook-first), the GPU-veto owner (current-pane-only), and the host-side owner.

Screenshots

No visual change to layout — the change is which agent glyph a tab shows. App-level validation drove the real compiled bundle: over ~40s / 3+ working↔idle cycles the tab's resolved data-agent-icon read omp at every sample (never pi), with the tab's launchAgent confirmed absent — the exact regression scenario, now holding OMP.

Testing

  • pnpm lint — ran targeted oxlint on the changed files (clean); not the full-suite command.
  • pnpm typecheck — tsgo --noEmit clean on both config/tsconfig.tc.web.json and config/tsconfig.node.json.
  • pnpm test — ran the affected vitest suites (below); not the full-suite command.
  • pnpm build — not run as pnpm build; the app-level validation built build:electron-vite + build:cli and launched the real Electron bundle.
  • Added or updated high-quality tests that would catch regressions.

Suites run: use-tab-agent.test.ts, use-tab-agent-pi-identity.test.ts, use-tab-agent-sleeping-session.test.ts, pane-agent-owner.test.ts, plus pty-connection, web-session-tabs-sync, and the full sidebar/ and lib/ trees — 4024 tests green; check:max-lines-ratchet clean (no suppression). All pre-existing resolver expectations pass unchanged; new tests cover the launchAgent-absent flicker, idle-identity ranking, live-hook ground truth, cross-group reuse without launch metadata, the sibling-scope guard, the mount-frame guard, and the sibling-kept-on-focused-exit case.

AI Review Report

Ran an adversarial old-vs-new diff review over the resolver's uncovered input space (the goal was behavior-preserving except intended improvements). It surfaced two edges — a split-pane sibling's identity bleeding into the focused pane's ambiguous title, and a one-mount-frame flash for a hookless agent reusing a pane — both fixed and pinned with tests. CodeRabbit raised the sibling-suppression scoping (applied) and a sleeping-vs-launch ordering suggestion (declined with rationale: it would reverse the intentional, tested hibernation-reuse behavior).

Cross-platform: this is renderer-only pure identity resolution over already-computed in-memory signals — no keyboard shortcuts, shortcut labels, file paths, shell commands, or Electron platform APIs are touched. The one platform-ish branch (processProvesShell) keys on isRemote, not the OS. No macOS/Linux/Windows-specific behavior changes.

Security Audit

No new input handling, command execution, path handling, auth/secrets, dependencies, or IPC contracts. The change is pure agent-identity selection over existing terminal title/hook/session state already present in the renderer store; it neither reads untrusted input beyond the existing title/status strings nor executes anything. No security follow-up needed.

Notes

OMP wraps Pi and emits Pi-compatible wrapper title frames. The tab-icon
resolver normalized those frames against the pane's OMP owner using only
`tab.launchAgent`. That works while launchAgent is present (the case #7633
fixed), but a mirrored or restored pane drops launchAgent once the host
stops publishing it (web-session-tabs-sync treats it as host-owned
lifecycle metadata). With no owner to anchor the frames, `⠋ Pi` resolves to
Pi and flips back to OMP only while a live OMP hook row exists — so the tab
flickers Pi↔OMP every time a hook row appears and clears during work.

Anchor the Pi-compatible owner on a durable pane identity when launchAgent
is gone: live hook, then last completed hook, then the hibernated session
record. Live/recent hooks rank above the session record so a genuine Pi
pane stays Pi and a stale record can't hijack it. This mirrors the owner
fallback the mirrored-tab title already uses.

Also splits the Pi/OMP identity cases into use-tab-agent-pi-identity.test.ts
to keep the suite under the max-lines limit.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a shared pane owner resolver and routes terminal pane, mirrored tab sync, and tab identity logic through it. resolveTabAgentFromSignals now derives a durable pane owner for title compatibility and updates live, idle, sibling, and reuse precedence. A new shared test suite covers owner precedence, and a separate Pi/OMP test file expands identity cases while removing the moved block from the original tab-agent test file.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
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 is concise and accurately highlights the main change: separating pane identity from liveness to fix OMP flicker.
Description check ✅ Passed The description includes all required sections and enough detail on summary, testing, AI review, security, and notes.
✨ Finishing Touches
📝 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: Pro

Run ID: 8a4f48ad-82cd-43e4-b145-9062a54336fc

📥 Commits

Reviewing files that changed from the base of the PR and between 60037d6 and bf26ccb.

📒 Files selected for processing (3)
  • src/renderer/src/lib/use-tab-agent-pi-identity.test.ts
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/renderer/src/lib/use-tab-agent.ts

Comment thread src/renderer/src/lib/use-tab-agent.ts Resolved
Fixing the OMP tab-title flicker by adding a fallback chain to one call site
would have been the ninth ad-hoc "who owns this pane" derivation in the
renderer. Each site (tab icon, terminal-pane display owner, mirrored-tab title
owner) reinvented the precedence with a different, drifting fallback set, and
the tab-icon site had the weakest — launchAgent only — which is why a mirrored
or restored pane that drops its host-owned launchAgent flickered Pi<->OMP as
the OMP wrapper's Pi-compatible title frames fought its hook identity.

Extract the precedence into one shared, pure resolvePaneAgentOwner: launch
intent first (bootstrap), falling through to the durable host-stamped hook
identity, then the last completed hook, then the hibernated session record.
The host-stamped identity is published to mirror clients and survives reattach,
so it is the right anchor once launchAgent is gone. Route the three renderer
owner sites through it so they cannot drift apart again.

Deliberately unchanged: the sidebar rows are driven by the hook entry and only
re-own it against launchAgent (a no-op when absent), so they stay hook-first and
do not flicker; the renderer GPU-veto owner is intentionally current-pane-only;
the host-side owner is the origin of the stamped identity.

Splits the Pi/OMP identity cases into use-tab-agent-pi-identity.test.ts to keep
the suite under the max-lines limit.
@brennanb2025 brennanb2025 changed the title Fix OMP tab-title flicker on panes that lost launchAgent Consolidate pane-agent owner resolution (fixes OMP tab-title flicker) Jul 9, 2026
The tab icon conflated "which agent is this pane" with "is it working right
now". A pane's hook record carries its identity in `agentType` regardless of
state, but the live-hook resolver returns null once the agent goes idle
(state === 'done'), demoting the identity to a low-ranked completed-hook
fallback that the non-distinguishing Pi-compatible title could beat. That is
why an OMP pane whose launchAgent was dropped (mirror/restore) flipped OMP↔Pi
across every turn: OMP while working (live hook), Pi while idle (title won).

Make identity first-class and state-independent:
- The focused pane's idle (completed-hook) identity is now an explicit ranked
  signal above the hibernated session, launch bootstrap, and sibling panes —
  the agent that actually ran and idled here outranks weaker guesses.
- A live hook stays ground truth (never overridden by a title).
- The title is demoted to its only two honest roles: a cross-group reuse
  override (it names a genuinely different agent, proving pane reuse) and a
  legacy standalone identity for panes with no hook. Within the Pi/OMP group
  the title carries no identity, so the durable record wins.

The owner that re-owns a pane's ambiguous title is strictly focused-scoped, so
a split-pane sibling's identity cannot mislabel the focused pane. A completed
hook counts as activity evidence for the reuse override, so a hookless agent
reclaiming a pane does not flash the prior agent for one mount frame.

Behavior-preserving for every case the existing suite pins (all pass
unchanged); the reordering only changes uncovered cases, toward the more
accurate identity. Adds regression tests for the idle-identity ranking, the
live-hook ground-truth invariant, cross-group reuse, the sibling-scope guard,
and the mount-frame guard.
@brennanb2025 brennanb2025 changed the title Consolidate pane-agent owner resolution (fixes OMP tab-title flicker) Separate pane identity from liveness in the tab-agent resolver (fixes OMP tab flicker) Jul 9, 2026

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6f87e290-1515-4bfa-ae5e-b29e34af14c1

📥 Commits

Reviewing files that changed from the base of the PR and between 5527462 and b549c73.

📒 Files selected for processing (2)
  • src/renderer/src/lib/use-tab-agent-pi-identity.test.ts
  • src/renderer/src/lib/use-tab-agent.ts

Comment thread src/renderer/src/lib/use-tab-agent.ts Resolved
Comment thread src/renderer/src/lib/use-tab-agent.ts Resolved
The focused pane's local shell-exit evidence (`idleIdentitySuppressed`) also
nulled the sibling split-pane's idle identity, so a focused pane returning to
its shell could hide a still-valid idle sibling agent. Scope the suppression to
the focused pane only. Adds coverage for the sibling-kept-on-focused-exit case
and for a launchAgent-less pane whose live Pi hook stays Pi.
@brennanb2025
brennanb2025 merged commit 1534edc into main Jul 9, 2026
2 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 9, 2026
Clean auto-merge, no conflicts. Brought in from main:
- feat(codex): write in-Codex setting changes back to ~/.codex config (#7960)
  — codex-config-mirror.ts, config-settings-promotion.ts
- Separate pane identity from liveness in the tab-agent resolver, fixes OMP
  tab flicker (#7860) — pane-agent-owner.ts, use-tab-agent.ts
- fix(sidebar): only show projects scrollbar when the list overflows (#7845)

Perf-branch structure preserved (clean auto-merge; pty-connection.ts auto-merged
without conflict). Gates: typecheck 0 errors; lint 0 errors; ipc/pty + daemon +
codex + terminal-pane + lib + runtime + shared + pane-manager suites all pass
(9015 + 2120 tests, 0 failed).

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

1 participant