Repository navigation
refactor(agents): move renderer display surfaces onto the canonical resolver (tranche 1) - #18557
brennanb2025 wants to merge 1 commit into
Conversation
…esolver (tranche 1) Rebuilt on main after tranche 0 landed. Drops a leftover .test.ts that contained no tests and duplicated the shipping-baseline helper.
📝 WalkthroughWalkthroughThe change centralizes pane-agent identity resolution through Merge Risk: 🔵 Low · up to Split tabs can show incorrect workspace activity, sidebar attention, and native-chat agent identity for unrelated panes. The fixes are localized scope guards, so this is mergeable only with bounded owner awareness or follow-up. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, behavior changes, implementation scope, testing, and follow-up. However, it omits the required linked issue, visual proof or an explicit N/A statement, and several template checklist sections. Resolution Add a valid issue reference after
✨ Finishing Touches 💡 1📝 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: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 8acdcce1-522d-40cd-a5a2-cd322c7fcab7
📒 Files selected for processing (45)
src/renderer/src/components/sidebar/WorktreeCard.test.tssrc/renderer/src/components/sidebar/smart-attention-title-status.tssrc/renderer/src/components/sidebar/smart-attention.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.test.tssrc/renderer/src/components/sidebar/worktree-agent-row-type.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/status-bar/workspace-space-presentation.test.tssrc/renderer/src/components/status-bar/workspace-space-presentation.tssrc/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.test.tssrc/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.tssrc/renderer/src/components/tab-bar/terminal-tab-activity-status.test.tssrc/renderer/src/components/tab-bar/terminal-tab-spinner-launch-agent.test.tssrc/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.test.tssrc/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/components/terminal-pane/terminal-tab-agent-type-index.test.tssrc/renderer/src/components/terminal-pane/terminal-tab-agent-type-index.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-chat-state.tssrc/renderer/src/lib/open-tab-occupant-agent.test.tssrc/renderer/src/lib/open-tab-occupant-agent.tssrc/renderer/src/lib/renderer-agent-status-observation-ingress.test.tssrc/renderer/src/lib/tab-agent-from-signals.tssrc/renderer/src/lib/tab-agent-identity-decision-table.test.tssrc/renderer/src/lib/tab-agent-identity-shipping-baseline.tssrc/renderer/src/lib/tab-agent-status-index.test.tssrc/renderer/src/lib/tab-agent-status-index.tssrc/renderer/src/lib/use-tab-agent-opencode-native-title.test.tssrc/renderer/src/lib/use-tab-agent-pi-identity.test.tssrc/renderer/src/lib/use-tab-agent-process-signals.test.tssrc/renderer/src/lib/use-tab-agent-retained-identity.test.tssrc/renderer/src/lib/use-tab-agent-sleeping-session.test.tssrc/renderer/src/lib/use-tab-agent.test.tssrc/renderer/src/lib/use-tab-agent.tssrc/renderer/src/lib/workspace-tab-palette-search.test.tssrc/renderer/src/lib/worktree-status-spinner-launch-agent.test.tssrc/renderer/src/lib/worktree-status.test.tssrc/renderer/src/lib/worktree-status.tssrc/renderer/src/store/slices/pane-foreground-agent.tssrc/renderer/src/store/slices/terminal-helpers.test.tssrc/renderer/src/store/slices/terminal-helpers.tssrc/shared/pane-agent-evidence-sources.tssrc/shared/pane-agent-identity-adapter.test.tssrc/shared/pane-agent-identity-adapter.tssrc/shared/pane-agent-identity-inventory.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| panes.push({ kind: 'title', status: classifyTitleActivity(title), worktreeLastActivityAt }) | ||
| panes.push({ | ||
| kind: 'title', | ||
| status: resolveAttributedTitleStatus(title, tab.launchAgent), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Scope launchAgent to the launched pane.
When a split tab exposes multiple runtime titles, passing tab.launchAgent to every title can attribute a generic spinner in an unrelated sibling and set sidebar attention to working. Apply the same single, non-split guard used by buildTitleDerivedAgentRows, and add a split-pane regression test.
| launchAgent: tab.launchAgent ?? null, | ||
| title, | ||
| uncoveredFallback: { agent: resolveExplicitTerminalTitleAgentType(title), titleOnly: true } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Restrict launchAgent to single-pane tabs. When runtime pane titles exist, this helper applies the tab-scoped launchAgent to every title. A split tab launched as Codex can therefore count an unrelated generic working or permission title as Codex activity. Pass terminalLayoutsByTabId into this path and provide launchAgent only for the single-leaf case, matching buildTitleDerivedAgentRows.
| terminalTitle: hasSingleKnownLeaf ? terminalTab?.title : null, | ||
| launchAgent: terminalTab?.launchAgent ?? null, | ||
| sleepingSessionAgent: (structuredSessionAgent as TuiAgent | null) ?? null | ||
| }) | ||
| }, | ||
| // oxlint-disable-next-line react-hooks/exhaustive-deps -- Preserve the pre-split dependency contract. | ||
| [ | ||
| getNativeChatLeafIds, | ||
| getTabWideAgentHintLeafId, | ||
| runtimePaneTitlesByPaneId, | ||
| structuredSessionAgent, | ||
| terminalTab?.launchAgent, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Scope launchAgent to the sole leaf. resolveTitleAgentForLeaf passes terminalTab?.launchAgent to resolveCanonicalPaneAgentIdentity for every leaf. The canonical resolver gives launch evidence precedence over the pane title, so a sibling title such as PowerShell can resolve as the tab’s launch agent and show the wrong native-chat identity. Pass launchAgent only when hasSingleKnownLeaf is true.
There was a problem hiding this comment.
Important
Two behavioral seams need attention before this lands: the process rung is currently unreachable (no producer writes processProof), and the Pi/OMP identity-group normalization was dropped from the hook/tab paths while title rows still apply it.
Reviewed changes
This tranche routes every renderer surface that previously guessed "which agent owns this pane" through resolveCanonicalPaneAgentIdentity with the approved order (live hook → process → launch → completed hook → sleeping session → sibling → title), frees bare free-text titles from becoming identity, and re-derives the exhaustive decision table against the frozen pre-tranche baseline.
- Canonical ladder adoption — sidebar hook rows (
worktree-agent-row-type.ts), title-derived rows, smart-attention, status-bar workspace counts, tab-bar projection, terminal-pane leaf index, native-chat leaf title, open-tab/search occupant, tab icon (use-tab-agent.ts), worktree spinner attribution, and reset-title all now resolve through the adapter. - Title fencing — the adapter's
uncoveredFallback.titleOnlypath now accepts onlyanchored/ confirmingvendor-markerevidence, so bare names likegrokno longer become identity. - Ordering change —
launchnow outrankscompleted-hookandsleeping-session(documented as temporary until run keys are wired), guarded by an expiry test. - Test-only baseline — the old tab resolver is frozen into
tab-agent-identity-shipping-baseline.ts; the decision table now measures the canonical resolver against it.
⚠️ processProof is read but never produced, so the process rung is dead
The process rung of the canonical ladder only fires when processEvidenceFromProof sees a fresh ForegroundProcessProof. The PR adds PaneForegroundAgentEntry.processProof and reads it from use-tab-agent.ts, open-tab-occupant-agent.ts, terminal-tab-agent-type-index.ts, and native-chat-leaf-title-agent.ts, but no producer writes it: every publish(...) in pane-foreground-agent-tracker.ts and sleeping-record-access.ts emits only { agent, shellForeground, routingTrusted? }. The bare foreground process name was previously rank #2 in resolveTabAgentFromSignals; under the canonical resolver a bare name is explicitly "a weak hint" that "neither enters the covered process rung nor makes the pane covered." Net effect: hook-less agents detected via recognizeAgentProcess (aider, droid, goose, etc.) silently lose their tab icon and sidebar identity, and this gap is not called out in the PR's Follow-up section.
Technical details
# The process rung is unreachable in production
## Affected sites
- src/renderer/src/store/slices/pane-foreground-agent.ts:10 — `processProof` field added, no writer
- src/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.ts:170 — publishes `{ agent, shellForeground, routingTrusted? }`, never `processProof`
- src/shared/pane-agent-identity-adapter.ts:200 — `processEvidenceFromProof` requires a fresh proof; bare `foregroundAgent` never enters evidence
## Required outcome
- Either preserve the bare process-name identity path (a real regression otherwise), or track "wire a `processProof` producer" as explicit tranche-2 follow-up so process-detected agents are not left icon-less in the interim.
## Open questions for the human
- Is dropping bare process-name identity for hook-less agents an intended, accepted interim state, or should the producer land in this tranche?⚠️ Pi/OMP identity-group normalization dropped from hook/tab paths but kept in title rows
resolveCompatibleAgentTypeForOwner/normalizeCompatibleAgentTitleForOwner implement the "OMP wraps Pi" product rule: an OMP-launched pane whose wrapped Pi reports itself should still display OMP. This PR removes that normalization from resolveTabAgentFromSignals (tab icon) and resolveRowAgentType (sidebar hook rows), but leaves it in worktree-title-derived-agent-rows.ts. A live Pi hook under an OMP launch now renders Pi in the tab strip and hook row while the same pane's title-derived row renders OMP — re-introducing the cross-surface disagreement this PR is meant to eliminate. The use-tab-agent-pi-identity.test.ts assertions were flipped (hookAgent: 'pi', launchAgent: 'omp' → 'pi'), but the file's own header comment still claims it "keeps an OMP-owned pane on OMP (and a Pi-owned pane on Pi)", which is now false for the live-hook case.
Technical details
# Pi/OMP wrapper identity is now inconsistent across surfaces
## Affected sites
- src/renderer/src/components/sidebar/worktree-agent-row-type.ts:12 — drops `resolveCompatibleAgentTypeForOwner`
- src/renderer/src/lib/tab-agent-from-signals.ts:56 — canonical resolve with no identity-group awareness
- src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts:156 — still calls `normalizeCompatibleAgentTitleForOwner`
- src/renderer/src/lib/use-tab-agent-pi-identity.test.ts:4 — header comment contradicts the flipped assertions
## Required outcome
- Confirm whether dropping OMP→Pi display normalization is intended. If yes, reconcile the title-row path (and the misleading comments/tests); if no, preserve the identity-group rule on the hook/tab paths.
## Open questions for the human
- Is a live Pi hook under an OMP launch expected to show Pi, or should the user-selected OMP brand still win for display?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| * Once production supplies run keys, the ordering must be revisited (see the expiry test). | ||
| */ | ||
| export function resolveTabAgentFromSignals(args: { | ||
| hasObservedAgentSignal: boolean |
There was a problem hiding this comment.
hasObservedAgentSignal (and defaultTitle at line 60) are now dead parameters: the new body never reads them, yet use-tab-agent.ts and open-tab-occupant-agent.ts still pass them. Either drop them from the signature or document why they are retained.
Focused review of the post-review delta + Electron checkReviewed only the seven requested post-review deltas (cab6843 → 77d4880). Confirmed git rev-parse HEAD is 77d4880; no production or lockfile changes were made by this review. Per-file findings
Rendered Electron E1–E4 checkLaunched this worktree with an isolated ORCA_DEV_USER_DATA_PATH and unique CDP port 9333, then verified window.api.app.getIdentity() reported worktree /Users/brennanbenson/orca/workspaces/orca/t1-review on branch ladder-tranche1-v2 before interacting.
A true host-generated process-proof E1 could not be produced end-to-end because locally invoked agent CLIs exited or were not foreground in the target PTY; E1 used a fresh process-proof-backed store entry and exercised real Electron rendering. This limitation exposed a separate pre-existing integration blocker outside the seven-file delta: pane-foreground-agent-tracker.ts publishes recognized processAgent but never includes the host-stamped processProof in its deps.publish entry (lines 167–174), while pane-agent-identity-adapter.ts intentionally ignores unproved foregroundAgent (lines 199–210). Therefore the canonical process rung is unreachable for hookless agents whose title names a different agent; this is reported for follow-up and was not changed in this focused tranche. DispositionDO NOT LAND until the process-proof producer gap is fixed in its owning scope; the seven reviewed files themselves had no defects requiring changes. |
|
Closing this older implementation and rebuilding consistent agent identity on current main. Create a tracking issue for tab icons, sidebar rows and workspace indicators disagreeing before closing. The remaining problem is tracked in #27668. |

ELI5
Orca used to let several renderer surfaces make their own best guess about which agent owned a pane. This moves those display decisions onto the same evidence ladder, so stronger facts such as a live hook, a verified process, or Orca's launch record win over a terminal title that a user can edit. Anchored provider titles remain a last-resort display signal, while bare task text does not become an agent identity.
This covers the sidebar as well as the tab strip; it is not a tab-only change. Smart attention, tab-agent indexes, terminal/native-chat presentation, worktree status, and pane-foreground display state now follow the same resolver too.
User-facing behavior
grokwith no other agent evidencecodex, then the connection blipsWhat changed
resolveCanonicalPaneAgentIdentitywith the approved order: live hook → verified process → launch → completed hook → sleeping session → sibling → title.MANUAL TESTING
No rendered Electron pass was performed. Validation was automated: the renderer/shared Vitest suite, non-incremental web and node TypeScript checks, Oxlint, changed-code quality checks, both pane-agent inventory ratchets, and the exhaustive decision-table fixture all passed.
Follow-up
Tranche 2 still needs to address
src/renderer/src/lib/notes-send-agent-targets.ts:141: manual action targets still fall back to a title, so a bare title can name an action target even though renderer display now refuses it.