Skip to content

refactor(agents): move renderer display surfaces onto the canonical resolver (tranche 1) - #18557

Closed
brennanb2025 wants to merge 1 commit into
mainfrom
ladder-tranche1-v2
Closed

brennanb2025 wants to merge 1 commit into
mainfrom
ladder-tranche1-v2

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Scenario Before After
A tab is titled just grok with no other agent evidence The pane could display Grok No agent is displayed because the title is bare free text
A remote pane is running Claude while its tab is titled codex, then the connection blips The icon could flip to Codex It holds Claude and degrades through process → completed hook → launch evidence instead of trusting the title
The same pane appears in the sidebar and tab strip The surfaces could disagree because they used separate ranking rules Both compute identity from the canonical resolver and agree

What changed

  • Routed renderer display consumers through resolveCanonicalPaneAgentIdentity with the approved order: live hook → verified process → launch → completed hook → sleeping session → sibling → title.
  • Kept anchored canonical title evidence available as the final display fallback while fencing bare free-text compatibility results.
  • Preserved local shell-foreground exit handling and the remote connection-blip hold behavior.
  • Kept launch above completed-hook until run keys are supplied, with the rationale and an expiry test that requires the order to be revisited once that happens.
  • Preserved merged per-pane evidence so stale completed status cannot mask fresher process proof.

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.

…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.
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change centralizes pane-agent identity resolution through resolveCanonicalPaneAgentIdentity. Title-only fallbacks now require anchored or matching vendor evidence. Tab, pane, sidebar, status-bar, and worktree code passes launch metadata, sibling agents, completed-hook agents, foreground process agents, and process proof into the canonical resolver. Conflicting sibling identities no longer resolve by insertion order. Tests update title fixtures, precedence expectations, process-proof coverage, and migration decision-table measurements.

Merge Risk: 🔵 Low · up to 77d48

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 severa… Add a valid issue reference after Fixes #. Add before-and-after visual proof, or write N/A with a brief reason if there is no visual or interaction change. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Note…
Docstring Coverage ⚠️ Warning Docstring coverage is 35.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 45 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: moving renderer display surfaces onto the canonical resolver. It is concise and specific.
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.
Full details: Description check

Explanation

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 Fixes #. Add before-and-after visual proof, or write N/A with a brief reason if there is no visual or interaction change. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, including platform coverage and command results.

  • Fix all pre-merge checks with AI
✨ 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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 8acdcce1-522d-40cd-a5a2-cd322c7fcab7

📥 Commits

Reviewing files that changed from the base of the PR and between 7106101 and 77d4880.

📒 Files selected for processing (45)
  • src/renderer/src/components/sidebar/WorktreeCard.test.ts
  • src/renderer/src/components/sidebar/smart-attention-title-status.ts
  • src/renderer/src/components/sidebar/smart-attention.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.test.ts
  • src/renderer/src/components/sidebar/worktree-agent-row-type.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.test.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.ts
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.test.ts
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.ts
  • src/renderer/src/components/tab-bar/terminal-tab-activity-status.test.ts
  • src/renderer/src/components/tab-bar/terminal-tab-spinner-launch-agent.test.ts
  • src/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.test.ts
  • src/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/renderer/src/components/terminal-pane/terminal-tab-agent-type-index.test.ts
  • src/renderer/src/components/terminal-pane/terminal-tab-agent-type-index.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-chat-state.ts
  • src/renderer/src/lib/open-tab-occupant-agent.test.ts
  • src/renderer/src/lib/open-tab-occupant-agent.ts
  • src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts
  • src/renderer/src/lib/tab-agent-from-signals.ts
  • src/renderer/src/lib/tab-agent-identity-decision-table.test.ts
  • src/renderer/src/lib/tab-agent-identity-shipping-baseline.ts
  • src/renderer/src/lib/tab-agent-status-index.test.ts
  • src/renderer/src/lib/tab-agent-status-index.ts
  • src/renderer/src/lib/use-tab-agent-opencode-native-title.test.ts
  • src/renderer/src/lib/use-tab-agent-pi-identity.test.ts
  • src/renderer/src/lib/use-tab-agent-process-signals.test.ts
  • src/renderer/src/lib/use-tab-agent-retained-identity.test.ts
  • src/renderer/src/lib/use-tab-agent-sleeping-session.test.ts
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/renderer/src/lib/use-tab-agent.ts
  • src/renderer/src/lib/workspace-tab-palette-search.test.ts
  • src/renderer/src/lib/worktree-status-spinner-launch-agent.test.ts
  • src/renderer/src/lib/worktree-status.test.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/store/slices/pane-foreground-agent.ts
  • src/renderer/src/store/slices/terminal-helpers.test.ts
  • src/renderer/src/store/slices/terminal-helpers.ts
  • src/shared/pane-agent-evidence-sources.ts
  • src/shared/pane-agent-identity-adapter.test.ts
  • src/shared/pane-agent-identity-adapter.ts
  • src/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),

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 | 🟡 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.

Comment on lines +91 to +93
launchAgent: tab.launchAgent ?? null,
title,
uncoveredFallback: { agent: resolveExplicitTerminalTitleAgentType(title), titleOnly: true }

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 | 🟡 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.

Comment on lines +122 to +133
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,

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 | 🟡 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.

@pullfrog pullfrog 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.

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.titleOnly path now accepts only anchored / confirming vendor-marker evidence, so bare names like grok no longer become identity.
  • Ordering change — launch now outranks completed-hook and sleeping-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?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

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.

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Focused review of the post-review delta + Electron check

Reviewed 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

  • src/renderer/src/components/sidebar/smart-attention.ts — indexing/refactor only; pane attention ownership and live-PTY gating are unchanged, with no identity/ranking regression found.
  • src/renderer/src/components/sidebar/worktree-agent-row-type.ts — now delegates to the canonical resolver with an explicit title-only fallback. Bare free-text titles are rejected; anchored/vendor identity frames are accepted; stronger hook, launch, and completed-hook evidence remains authoritative.
  • src/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.ts — whitespace pane-title handling is correct, and the same title distinction is preserved. Bare decoration is suppressed, anchored/vendor titles resolve, ambiguity remains fenced, and stronger evidence wins.
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts — SSH/direct-remote panes now use inspectRuntimeTerminalProcess behind the remote evidence gate; remote panes remain behind the host-stamped evidence boundary. No tranche regression found.
  • src/renderer/src/components/terminal-pane/use-terminal-pane-chat-state.ts — unified-tab fields are consolidated into one selector. The title-agent callback still captures launchAgent, structured-session identity, and all relevant title values; no stale dependency regression found.
  • src/renderer/src/lib/tab-agent-from-signals.ts — title-only fallback is fenced; bare titles resolve null, anchored/vendor titles resolve, shell-foreground evidence suppresses title-only identity, and the canonical order is preserved.
  • src/shared/pane-agent-identity-adapter.ts — title-only fallback accepts anchored titles and a matching confirmed vendor marker, rejects free-text-only titles, retains conflicting-name ambiguity fences, and uncoveredFallback cannot outrank stronger sources.

Rendered Electron E1–E4 check

Launched 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.

Disposition

DO NOT LAND until the process-proof producer gap is fixed in its owning scope; the seven reviewed files themselves had no defects requiring changes.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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.

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