Skip to content

Route title-status consumers through one pane-agent-evidence seam (title evidence plan, PR 2) - #7600

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/terminal-title-evidence-phase2
Jul 6, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/terminal-title-evidence-phase2

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Almost every change is a pure rename — the new functions delegate to the same underlying parsers, so equivalence is by construction.
  • The one real re-expression is running-agent-targets.ts (stale-row check became decision.hookState === null); the equivalence argument is in "What changed".
  • One file deleted (worktree-card-status.ts) — dead code, nothing imported it, and it disagreed with the live implementation.
  • One test's fixtures changed (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, or resolveTabAgentFromTitle directly. They read src/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

  • New src/renderer/src/lib/pane-agent-evidence.ts: classifyTitleActivity (title-layer classification), resolveTitleActivityLabel vs resolveCommittedTitleAgentType (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: single AGENT_STATUS_STALE_AFTER_MS freshness gate, raw hookState/titleStatus layers, source/confidence, livePtyRequired), and the relocated isExplicitAgentStatusFresh (re-exported from agent-status.ts so existing importers and test mocks are untouched).
  • 19 consumer files migrated (counters, worktree dot, smart attention, title-derived rows, workspace-space count, cleanup blockers, cache-timer seeding twins, sortEpoch compare, synthetic-title writer, send targets, note target, ready-wait, native-chat identity pair, TabBar, notification dispatch, the #7476 stale-tab-title site). Every per-consumer gate and precedence rule stays local and identical.
  • deriveRunningAgentSendTargets is the genuine resolvePaneAgentActivity consumer: its hook layer reads the decision (hookState === null ⟺ stale, fresh hookState ≡ entry.state); its title layer deliberately keeps the send-gated detector (raw title status would flip a bare Codex idle title from stale-disabled to eligible — pinned by existing test).
  • Deleted worktree-card-status.ts (deriveWorktreeCardStatus): dead divergent copy of the card-dot logic — zero production importers (the live card uses resolveWorktreeStatus), and the only consumer whose liveness used the tab.ptyId wake-hint the shared helper documents as wrong. Its test-only describe block went with it.
  • Retired the resolveTabAgentFromTitle alias in use-tab-agent.ts (zero references remain repo-wide).
  • The plan's AgentOwnerDecision owner-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-equivalent resolvePaneAgentActivity mapping above. One test changed semantics-of-fixture only: WorktreeCard.test.ts faked the old mock seam with substring titles; it now uses real classifiable title shapes (Claude - action required, mimo working) since getWorktreeStatus legitimately 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; permission blocks workspace deletion but is absent from the working count; migration-unsupported entries bypass freshness; three different paneKey→tabId parses; done is targetable for send but non-blocking for cleanup; bare-spinner Claude identity split (now typed); idle is 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:

  • Canonical/definition: pane-agent-evidence.ts, shared/agent-detection.ts, shared/terminal-title-agent-type.ts.
  • Transport/completion (plan allowlist): pty-transport.ts, pty-connection.ts (transport-internal sites), agent-completion-coordinator.ts, agent-decorative-title-signature.ts.
  • Identity infrastructure (plan allowlist): agent-title-owner.ts, title-agent-identity.ts, use-tab-agent.ts (internal).
  • Re-export seam kept for test mocks: lib/agent-status.ts (removal is Phase 3 scope with the module split).
  • Main process (allowlisted with follow-up, own slice per plan): src/main/stats/agent-detector.ts, src/main/runtime/orca-runtime.ts.
  • Mobile standalone package (Phase 3 must keep its import path in sync): mobile/src/session/mobile-terminal-tab-agent.ts.
  • getAgentLabel hits in agent-catalog.tsx/QuickCommands/AutomationsPage are the documented name-collision variant (different function).
  • resolveTabAgentFromTitle: zero references.
  • Comment-only mentions in smart-attention.ts, agent-ready-wait.ts, pty-connection.ts name the underlying parser accurately.

Performance

No hot-path regression: every migrated call delegates to the same underlying function (one extra stack frame); deriveRunningAgentSendTargets adds one short-lived object per agent entry per derivation (bounded by agent count, no new polling/timers/subscriptions/store writes); the worktree-agent-activity-summary cached 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

  • 691 tests green across the 22 affected suites (including 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.
  • New pane-agent-evidence.test.ts pins the module semantics: staleness boundary, spinner label-vs-identity split, hook-suppresses-title, raw done passthrough, livePtyRequired flagging.
  • Zero behavioral test edits: the only test-file changes are the deleted dead-code describe block and the real-title fixture swap explained above.

Residual gaps

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

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a new pane-agent-evidence module centralizing title-based agent activity classification (classifyTitleActivity), identity resolution (resolveTitleActivityLabel, resolveCommittedTitleAgentType), staleness gating (isExplicitAgentStatusFresh), and combined evidence decisioning (resolvePaneAgentActivity). Numerous consumers across sidebar, status-bar, tab-bar, terminal-pane, and store-slice modules are updated to call these new helpers instead of prior detectAgentStatusFromTitle, getAgentLabel, resolveTabAgentFromTitle, and resolveExplicitTerminalTitleAgentType functions. running-agent-targets.ts is refactored to use resolvePaneAgentActivity for eligibility gating, and deriveWorktreeCardStatus is removed along with its dedicated implementation and related test helpers. Test coverage is added for the new module.

Changes

Area Change
New module pane-agent-evidence.ts with classification, identity, freshness, and decisioning helpers plus tests
agent-status.ts Delegates to new helpers; re-exports isExplicitAgentStatusFresh
running-agent-targets.ts Eligibility gating rewritten around resolvePaneAgentActivity
worktree-card-status.ts deriveWorktreeCardStatus removed
Sidebar/status-bar/tab-bar/terminal-pane/store-slice consumers Swapped title-detection calls to new helpers
use-tab-agent.ts Removed resolveTabAgentFromTitle re-export alias

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
Loading

Compact metadata

  • Type: Refactor
  • Scope: Renderer (sidebar, status-bar, tab-bar, terminal-pane, store slices, lib)
  • Breaking changes: None (internal helper consolidation)

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,
Sorting "working" from "idle" light,
One module now to rule the trace,
Of every agent's fleeting face,
Hop, commit, and classify with delight! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 clearly names the main change: routing title-status consumers through the pane-agent-evidence seam.
Description check ✅ Passed The description is detailed and covers the core change, testing, review, and risks, though template headings are not exact.
✨ 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.

🧹 Nitpick comments (1)
src/renderer/src/lib/pane-agent-evidence.ts (1)

108-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a short "why" comment for the none → authoritative mapping.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 99ae2dc and fcc0e4b.

📒 Files selected for processing (24)
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
  • src/renderer/src/components/sidebar/WorktreeCard.test.ts
  • src/renderer/src/components/sidebar/smart-attention.ts
  • src/renderer/src/components/sidebar/worktree-card-status.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/status-bar/workspace-space-presentation.ts
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/terminal-pane/cache-timer-seeding.ts
  • src/renderer/src/components/terminal-pane/native-chat-leaf-title-agent.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/use-notification-dispatch.ts
  • src/renderer/src/lib/active-agent-note-target.ts
  • src/renderer/src/lib/agent-ready-wait.ts
  • src/renderer/src/lib/agent-send-title-status.ts
  • src/renderer/src/lib/agent-status-terminal-title.ts
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/lib/pane-agent-evidence.test.ts
  • src/renderer/src/lib/pane-agent-evidence.ts
  • src/renderer/src/lib/running-agent-targets.ts
  • src/renderer/src/lib/use-tab-agent.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/store/slices/terminal-helpers.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/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

@brennanb2025
brennanb2025 merged commit 7237c8e into main Jul 6, 2026
3 checks passed
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