Repository navigation
Route title-status consumers through one pane-agent-evidence seam (title evidence plan, PR 2) - #7600
Conversation
…tle evidence plan, PR 2) Phase 2 of the terminal title evidence plan: renderer product-authority consumers stop importing detectAgentStatusFromTitle / getAgentLabel / resolveExplicitTerminalTitleAgentType / resolveTabAgentFromTitle directly and read the typed pane-agent-evidence module instead. Behavior-preserving: every swap is alias-level or provably equivalent; per-consumer gates and precedence rules stay local. Deletes the dead deriveWorktreeCardStatus divergent copy and retires the resolveTabAgentFromTitle alias. Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer as "Consumer (e.g. terminals.ts)"
participant Evidence as "pane-agent-evidence"
Consumer->>Evidence: classifyTitleActivity(title)
Evidence-->>Consumer: AgentStatus | null
Consumer->>Evidence: resolvePaneAgentActivity(entry, liveTitle, hasLivePty, now)
Evidence->>Evidence: isExplicitAgentStatusFresh(entry, now)
Evidence->>Evidence: classifyTitleActivity(liveTitle)
Evidence-->>Consumer: AgentActivityDecision
Compact metadata
Related issues: None specified Related PRs: None specified Suggested labels: refactor, renderer, agent-status Suggested reviewers: Team members familiar with agent-status detection and terminal-pane title handling Poem A rabbit hopped through titles bright, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
🧹 Nitpick comments (1)
src/renderer/src/lib/pane-agent-evidence.ts (1)
108-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a short "why" comment for the
none→authoritativemapping.Marking
confidence: 'authoritative'when there's no evidence at all is a defensible design choice (absence of any signal is itself a confident claim of "nothing happening"), but it's non-obvious next to the other branch where'authoritative'means "we have a trusted hook row." A one-line comment would prevent future readers/maintainers from mistaking this for a bug.💬 Suggested comment
+ // Why: absence of both hook and title evidence is itself an authoritative + // claim that nothing is happening, unlike the 'fallback' title-only case. return { hookState: null, hookAgentType: undefined, titleStatus: null, source: 'none', confidence: 'authoritative', livePtyRequired: false }As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cdae8a34-e364-4db5-ba06-0f551acadb4c
📒 Files selected for processing (24)
src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.tssrc/renderer/src/components/sidebar/WorktreeCard.test.tssrc/renderer/src/components/sidebar/smart-attention.tssrc/renderer/src/components/sidebar/worktree-card-status.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/status-bar/workspace-space-presentation.tssrc/renderer/src/components/tab-bar/TabBar.tsxsrc/renderer/src/components/terminal-pane/cache-timer-seeding.tssrc/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/use-notification-dispatch.tssrc/renderer/src/lib/active-agent-note-target.tssrc/renderer/src/lib/agent-ready-wait.tssrc/renderer/src/lib/agent-send-title-status.tssrc/renderer/src/lib/agent-status-terminal-title.tssrc/renderer/src/lib/agent-status.tssrc/renderer/src/lib/pane-agent-evidence.test.tssrc/renderer/src/lib/pane-agent-evidence.tssrc/renderer/src/lib/running-agent-targets.tssrc/renderer/src/lib/use-tab-agent.tssrc/renderer/src/lib/worktree-status.tssrc/renderer/src/store/slices/terminal-helpers.tssrc/renderer/src/store/slices/terminals.tssrc/renderer/src/store/slices/workspace-cleanup.ts
💤 Files with no reviewable changes (2)
- src/renderer/src/lib/use-tab-agent.ts
- src/renderer/src/components/sidebar/worktree-card-status.ts
…tle evidence plan, PR 2) (stablyai#7600) Co-authored-by: Orca <[email protected]>
Rollout PR 2 of the terminal title evidence plan (PR 1 was #7458): Phase 2 — route every renderer product-authority title-status consumer through one typed evidence seam. Behavior-preserving by design; the semantic unification of consumer disagreements is explicitly NOT this PR (see "Documented disagreements" below).
ELI5 — what this PR actually does
Terminal programs set a text label (the OSC "title"), and Orca uses that text in ~19 places to decide real things: is this agent working, which icon to show, should the sidebar re-sort, can I send to this agent, is this worktree safe to delete. Title text is easily fooled (a folder named
gemini-project, a task title that mentions another agent), and each of those 19 places parsed it independently. The plan (Phase 1 = #7458, the GPU fallback) is: gradually make real evidence (hooks, launched commands, live processes) the authority and titles a declared, weak fallback — one decision point instead of many.This PR is the plumbing step, on purpose with zero behavior change: all 19 call sites now go through one small module (
pane-agent-evidence.ts) that names what kind of read each one is — "what does this title say" (classifyTitleActivity), "who does the title claim to be" in its two deliberately different flavors (resolveTitleActivityLabel: a bare Claude spinner counts as Claude activity;resolveCommittedTitleAgentType: a spinner is not proof of identity), and "combine the hook row + title with the standard 30-minute freshness rule" (resolvePaneAgentActivity). Every screen keeps its exact old rules; nothing is unified yet.What to actually review:
running-agent-targets.ts(stale-row check becamedecision.hookState === null); the equivalence argument is in "What changed".worktree-card-status.ts) — dead code, nothing imported it, and it disagreed with the live implementation.WorktreeCard.test.ts) — it faked titles through a mock the code no longer reads, so it now uses real title shapes.Why merge a no-op: the next PRs change how titles are trusted in ONE place instead of nineteen, and the audit below documents exactly where today's surfaces already contradict each other (so those fixes become deliberate product decisions, not accidents).
Invariant statement
No renderer product-authority path interprets terminal titles by importing
detectAgentStatusFromTitle,getAgentLabel,resolveExplicitTerminalTitleAgentType, orresolveTabAgentFromTitledirectly. They readsrc/renderer/src/lib/pane-agent-evidence.ts, which names the intent of each read: title-only activity classification, activity-label vs committed title identity, or combined hook+title pane evidence with one shared freshness gate.What changed
src/renderer/src/lib/pane-agent-evidence.ts:classifyTitleActivity(title-layer classification),resolveTitleActivityLabelvsresolveCommittedTitleAgentType(the two historically-accidental identity facets — bare Claude spinner counts as activity, never as committed identity — now explicit and typed),resolvePaneAgentActivity(combined hook+title evidence: singleAGENT_STATUS_STALE_AFTER_MSfreshness gate, rawhookState/titleStatuslayers, source/confidence,livePtyRequired), and the relocatedisExplicitAgentStatusFresh(re-exported fromagent-status.tsso existing importers and test mocks are untouched).#7476stale-tab-title site). Every per-consumer gate and precedence rule stays local and identical.deriveRunningAgentSendTargetsis the genuineresolvePaneAgentActivityconsumer: its hook layer reads the decision (hookState === null ⟺ stale, freshhookState ≡ entry.state); its title layer deliberately keeps the send-gated detector (raw title status would flip a bareCodexidle title from stale-disabled to eligible — pinned by existing test).worktree-card-status.ts(deriveWorktreeCardStatus): dead divergent copy of the card-dot logic — zero production importers (the live card usesresolveWorktreeStatus), and the only consumer whose liveness used thetab.ptyIdwake-hint the shared helper documents as wrong. Its test-only describe block went with it.resolveTabAgentFromTitlealias inuse-tab-agent.ts(zero references remain repo-wide).AgentOwnerDecisionowner-precedence resolver is deliberately absent: the only Phase 2 identity consumer (native-chat toggle) reads hook identity without a freshness gate, so a gated owner resolver would change its behavior. It lands with its first real consumer (per the Gate the Gemini GPU fallback on pane-owner evidence instead of raw title text (title evidence plan, PR 1) #7458 review rule: no unconsumed exports).Behavior preservation
Every migrated call is either an alias-level swap (
classifyTitleActivity ≡ detectAgentStatusFromTitle,resolveTitleActivityLabel ≡ getAgentLabel,resolveCommittedTitleAgentType ≡ resolveExplicitTerminalTitleAgentType) or the proven-equivalentresolvePaneAgentActivitymapping above. One test changed semantics-of-fixture only:WorktreeCard.test.tsfaked the old mock seam with substring titles; it now uses real classifiable title shapes (Claude - action required,mimo working) sincegetWorktreeStatuslegitimately reads through the new module.Documented disagreements (found by audit, deliberately preserved)
A pre-migration audit of all 13 consumer modules catalogued nine cross-consumer disagreements this PR does NOT resolve — each is a product decision, not a mechanical cleanup: jump-palette dot ignores explicit rows while the card dot honors them; the title-bar working count ignores hook state entirely and has no permission/done notion;
permissionblocks workspace deletion but is absent from the working count; migration-unsupported entries bypass freshness; three different paneKey→tabId parses;doneis targetable for send but non-blocking for cleanup; bare-spinner Claude identity split (now typed);idleis the desirable state for ready-wait/timer seeding (inverse of aggregates). The evidence module's layered return shape exists precisely so these stayed faithful.Migration-gate audit (rg, verified post-migration)
Remaining non-test references to the four predicates, all approved:
pane-agent-evidence.ts,shared/agent-detection.ts,shared/terminal-title-agent-type.ts.pty-transport.ts,pty-connection.ts(transport-internal sites),agent-completion-coordinator.ts,agent-decorative-title-signature.ts.agent-title-owner.ts,title-agent-identity.ts,use-tab-agent.ts(internal).lib/agent-status.ts(removal is Phase 3 scope with the module split).src/main/stats/agent-detector.ts,src/main/runtime/orca-runtime.ts.mobile/src/session/mobile-terminal-tab-agent.ts.getAgentLabelhits inagent-catalog.tsx/QuickCommands/AutomationsPage are the documented name-collision variant (different function).resolveTabAgentFromTitle: zero references.smart-attention.ts,agent-ready-wait.ts,pty-connection.tsname the underlying parser accurately.Performance
No hot-path regression: every migrated call delegates to the same underlying function (one extra stack frame);
deriveRunningAgentSendTargetsadds one short-lived object per agent entry per derivation (bounded by agent count, no new polling/timers/subscriptions/store writes); theworktree-agent-activity-summarycached selector is untouched; deleting the dead module removes code. Evidence: code reading of all 24 file diffs — no site changed its call frequency or added I/O.Tests
pty-connection.test.ts,smart-attention,running-agent-targets,active-agent-note-send,workspace-cleanup, sortEpoch, hydration, native-chat, NotesSendMenu);pnpm typecheck(node+cli+web), oxlint, oxfmt clean.pane-agent-evidence.test.tspins the module semantics: staleness boundary, spinner label-vs-identity split, hook-suppresses-title, rawdonepassthrough,livePtyRequiredflagging.Residual gaps