Repository navigation
Separate pane identity from liveness in the tab-agent resolver (fixes OMP tab flicker) - #7860
Conversation
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.
📝 WalkthroughWalkthroughAdds a shared pane owner resolver and routes terminal pane, mirrored tab sync, and tab identity logic through it. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8a4f48ad-82cd-43e4-b145-9062a54336fc
📒 Files selected for processing (3)
src/renderer/src/lib/use-tab-agent-pi-identity.test.tssrc/renderer/src/lib/use-tab-agent.test.tssrc/renderer/src/lib/use-tab-agent.ts
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.
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.
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6f87e290-1515-4bfa-ae5e-b29e34af14c1
📒 Files selected for processing (2)
src/renderer/src/lib/use-tab-agent-pi-identity.test.tssrc/renderer/src/lib/use-tab-agent.ts
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.
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]>
… OMP tab flicker) (stablyai#7860)
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
launchAgentwas 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
OMPandPi. 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:
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 (
resolveCompatibleAgentTypeForOwnerrewrites 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 byuse-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-iconreadompat every sample (neverpi), with the tab'slaunchAgentconfirmed absent — the exact regression scenario, now holding OMP.Testing
pnpm lint— ran targetedoxlinton the changed files (clean); not the full-suite command.pnpm typecheck—tsgo --noEmitclean on bothconfig/tsconfig.tc.web.jsonandconfig/tsconfig.node.json.pnpm test— ran the affected vitest suites (below); not the full-suite command.pnpm build— not run aspnpm build; the app-level validation builtbuild:electron-vite+build:cliand launched the real Electron bundle.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, pluspty-connection,web-session-tabs-sync, and the fullsidebar/andlib/trees — 4024 tests green;check:max-lines-ratchetclean (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 onisRemote, 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
src/main/changes — renderer + one shared pure module only.launchAgentrehydration at the mirror seam; worth checking for overlap before merge.launchAgentis known; Let pane-scoped evidence beat stale tab icon identity #7755 added the hibernated-session signal but ranked it below the title. This makes identity state-independent and closes the class.