Skip to content

Gate the Gemini GPU fallback on pane-owner evidence instead of raw title text (title evidence plan, PR 1) - #7458

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/terminal-title-evidence-resolver
Jul 6, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/terminal-title-evidence-resolver

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Rollout PR 1 of the terminal title evidence plan: Phase 1 — name and fence the current behavior. The plan's Phases 2-4 are follow-up PRs. (The plan document itself is no longer part of this PR: the standalone docs PR #7452 was closed, and the in-repo copy was dropped from this branch — the phase framing lives in this description.)

Invariant statement

Raw OSC title text may provide display text and weak status evidence, but it can no longer decide renderer (GPU/WebGL) policy when stronger, pane-scoped owner evidence exists. Display labels, runtime pane titles, and completion tracking now derive from one resolved title decision per frame instead of re-interpreting the title independently.

What changed

  • New terminal-renderer-policy.ts (renderer precedence resolver) and terminal-title-evidence.ts (unified resolvePaneTitleDecision: one owner-aware display label + renderer decision per title frame) in the terminal-pane domain.
  • pty-connection.ts onTitleChange now derives the display label and the per-pane GPU gate from a single resolver call; the raw !isGeminiTerminalTitle(rawTitle) toggle is gone.
  • Renderer precedence per the plan: user off > on (agent-compat exclusions cannot override explicit on) > auto (Gemini compatibility fallback fires only when no current pane-scoped non-Gemini owner exists).
  • The Gemini-fallback veto uses only current, pane-scoped owner evidence: command-inferred foreground agent, or a fresh (not stale, not done) hook row for that pane. Tab-shared launch identity and never-clearing startup seeds are deliberately excluded so a genuine Gemini pane in a split or reused pane keeps its DOM fallback.

Intended behavior changes (everything else is behavior-preserving)

  1. A pane owned by a non-Gemini agent (OMP/Pi/Claude/…) whose title/cwd merely mentions gemini keeps WebGL — the #7428 regression class. This also removes per-frame WebGL dispose churn those panes previously suffered.
  2. Under explicit GPU on, a genuine Gemini pane now keeps WebGL (previously title-forced to DOM even under on). Plan-sanctioned (renderer precedence rule 2). Risk is cosmetic: the original Gemini DOM fallback addressed flicker, not crashes. Default auto behavior for genuine Gemini is unchanged (still DOM).

Review evidence

Three independent adversarial reviews (precedence correctness, perf hot path, reliability gates) + two fix rounds, re-verified by the original finder:

  • Precedence: 6-step precedence traced; user off proven unable to reach WebGL through any ordering (all attach paths gate on shouldUseTerminalWebgl); #7447 string shapes replayed. Found the tab-scoped-owner P2 → fixed (pane-scoped veto) → re-reviewed, residual staleness path also closed (freshness + not-done gate, shared predicate with hasFreshPaneAgentSurface).
  • Perf: net hot-path delta is +1 O(1) getState read and a few short-lived allocations per title frame; no new polling/IPC/timers/writes; WebGL churn strictly reduced. Store-write dedupe paths still hit (byte-identical display strings).
  • Reliability: no stale-closure/disposal/import-boundary regressions; post-dispose title frames no-op; restore window degrades to the safe DOM direction and self-corrects on the next live frame; SSH/remote panes need no local foreground evidence (null owner → safe fallback). Mobile package untouched.
  • Post-hoc independent review round (2026-07-06, two adversarial reviewers — correctness/lifecycle and environment/contract/scope — plus a solo pass): no Critical/High findings. Fixes applied from it: the speculative Phase-2 evidence exports (TerminalTitleEvidence, AgentOwnerDecision, AgentActivityDecision, identity resolveTerminalTitleEvidence) were trimmed from this slice — they land in Phase 2 with their first consumer — and TerminalGpuAccelerationMode now derives from GlobalSettings['terminalGpuAcceleration'] instead of hand-copying the union.

Consumer intents touched / deferred

Touched: renderer policy, display (label), transport hand-off to completion tracking (same values, same frequency). Deferred to Phase 2/3 per plan: aggregate status consumers, AgentOwnerDecision/AgentActivityDecision production (the types now ship with their first consumer rather than unwired here), module split. webglUnavailable/inContextLossContainment resolver inputs are typed and unit-tested but intentionally unwired — the pane manager's downstream capability/context-loss latches remain authoritative.

Tests

  • 431 tests green across terminal-renderer-policy.test.ts, terminal-title-evidence.test.ts, pty-connection.test.ts, agent-detection.test.ts, use-tab-agent.test.ts; pnpm typecheck (node+cli+web), oxlint, oxfmt clean.
  • Key regressions pinned: pane-scoped OMP owner + Gemini-looking title keeps GPU (fails if the old toggle is reverted); genuine Gemini in a split pane DOM-gates despite a non-Gemini tab.launchAgent; reused pane with stale launch/done/stale hook rows DOM-gates; one split pane's title cannot change another pane's GPU state; per-token cwd matrix (gemini/claude/codex/opencode/cursor/omp/pi); user auto/on/off, WebGL-unavailable, context-loss.

Manual validation (desktop + SSH, run 2026-07-05)

Live dev build of this branch (fresh profile), driven via CDP; renderer state probed per pane (WebGL = canvas layers present, DOM = populated .xterm-rows), with screenshots. All passed:

  • Non-Gemini-owned pane with a gemini-classified title keeps WebGL (command-inferred claude wrapper emitting a bare gemini OSC title; display title showed "Gemini CLI" while GPU stayed on — the exact #7428 class, live).
  • Genuine Gemini CLI under auto DOM-gates, and a reused pane whose prior command inference was claude did not stick as a stale veto.
  • Split tab: with fresh pane-scoped non-Gemini hook evidence, only that pane runs WebGL while the genuine-Gemini sibling stays DOM; removing the evidence reverts the pane to DOM on the next title frame. Per-pane isolation and bidirectional policy tracking confirmed live.
  • User setting off forces DOM on a WebGL-eligible pane; back to auto re-attaches WebGL for the shell pane while the Gemini pane correctly stays DOM. Tab label follows the focused pane; sidebar status row agrees ("Gemini CLI - Idle").
  • SSH (throwaway Linux arm64 container, real relay deploy): remote pane with a held gemini title DOM-gates with no crash and no local foreground-process dependency; when the bash prompt title returns, the pane re-attaches WebGL.

Remaining gap (known residual, deliberate boundary): in a shell without OSC 133 integration, a prior agent's still-fresh (<30 min, non-done) pane-scoped hook row — or a command inference that neither 133;D nor a shell-title reversion has cleared — can keep WebGL on a genuine Gemini CLI launched in-place in the same PTY until the row goes stale. Failure direction is cosmetic (the flicker class the fallback targets; a real context loss still self-latches to DOM). Tightening the veto to process-verified ownership is Phase 2 scope. (Sleep/wake status aggregation is also Phase 2 scope and unchanged here.)

brennanb2025 and others added 6 commits July 5, 2026 13:50
Introduce the terminal-title evidence/renderer-policy resolver types and wire
pty-connection's onTitleChange through one owner-aware decision. Raw title text
can no longer disable GPU when stronger owner evidence attributes the pane to
another agent (e.g. OMP/Pi with a gemini-like cwd), and the Gemini compatibility
fallback now honors the user GPU setting precedence (off > on > auto).

Co-authored-by: Orca <[email protected]>
The renderer Gemini-fallback veto now consumes pane-scoped, current ownership
(foreground command inference, live hook row, this pane's initial status) instead
of getAuthoritativePaneAgent, whose shared tab.launchAgent and never-cleared
paneStartup.launchAgent could keep WebGL for a genuine Gemini sibling or reused
pane. Display-label normalization still uses getAuthoritativePaneAgent. Also make
the off-mode confidence match auto for identical inputs, and drop the hot-path
conditional-spread allocations in resolvePaneTitleDecision.

Co-authored-by: Orca <[email protected]>
Close the reused-pane residual: the renderer veto now ignores stale or `done`
explicit rows (shared isFreshActivePaneAgentEntry predicate, reused by
hasFreshPaneAgentSurface) and no longer reads the never-clearing
paneStartup.initialAgentStatus seed. Only live command inference and a fresh,
active hook row can veto the Gemini DOM fallback; genuine OMP/Pi panes stay
protected by the isPiAgentTitle guard inside isGeminiTerminalTitle.

Co-authored-by: Orca <[email protected]>
@brennanb2025 brennanb2025 changed the title Fence terminal renderer policy behind an owner-aware title resolver (plan PR 1) Gate the Gemini GPU fallback on pane-owner evidence instead of raw title text (title evidence plan, PR 1) Jul 5, 2026
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/terminal-title-evidence-plan to main July 6, 2026 01:00
…-title-evidence-resolver

# Conflicts:
#	src/renderer/src/components/terminal-pane/pty-connection.ts
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1a92d4da-eaf9-4b54-b2f4-fc822528746a

📥 Commits

Reviewing files that changed from the base of the PR and between f32b1a4 and c9bbe82.

📒 Files selected for processing (3)
  • src/renderer/src/components/terminal-pane/terminal-renderer-policy.ts
  • src/renderer/src/components/terminal-pane/terminal-title-evidence.test.ts
  • src/renderer/src/components/terminal-pane/terminal-title-evidence.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/terminal-pane/terminal-title-evidence.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/terminal-pane/terminal-renderer-policy.ts

📝 Walkthrough

Walkthrough

This PR adds two new modules for terminal-pane title/renderer handling: a renderer policy resolver (resolvePaneRendererPolicy) computing GPU enablement based on user mode, WebGL/context-loss capability, and Gemini compatibility fallback; and a title evidence module (resolvePaneDisplayTitle, resolvePaneTitleDecision) combining display title normalization with the renderer policy. pty-connection.ts is refactored to call resolvePaneTitleDecision in onTitleChange, using a new pane-scoped renderer ownership resolver and freshness-gated agent-status evidence. Corresponding test suites are added for both new modules and for regression scenarios in pty-connection.test.ts. Unrelated native-chat files receive multi-line formatting changes with no logic modifications.

Changes

Area Changes
Renderer policy New terminal-renderer-policy.ts exporting TerminalGpuAccelerationMode, RendererPolicyDecision, ResolvePaneRendererPolicyInput, resolvePaneRendererPolicy; test suite added
Title evidence New terminal-title-evidence.ts exporting resolvePaneDisplayTitle, PaneTitleDecision, ResolvePaneTitleDecisionInput, resolvePaneTitleDecision; test suite added
Pty connection wiring Consolidated agent-status imports, freshness predicate for active pane agent entries, new getPaneScopedRendererOwner(), onTitleChange refactored to use resolvePaneTitleDecision; regression tests added
Native-chat cleanup Multi-line reformatting of a type alias and test object literals/assertions, no logic change

Sequence Diagram(s)

sequenceDiagram
  participant Pty as pty-connection
  participant Decision as resolvePaneTitleDecision
  participant Policy as resolvePaneRendererPolicy
  participant Manager
  participant Coordinator as agentCompletionCoordinator
  Pty->>Pty: getAuthoritativePaneAgent()
  Pty->>Pty: getPaneScopedRendererOwner()
  Pty->>Decision: title, rawTitle, displayOwner, rendererOwner, gpuMode
  Decision->>Policy: rawTitle, rendererOwnerAgentType, gpuMode, flags
  Policy-->>Decision: RendererPolicyDecision
  Decision-->>Pty: PaneTitleDecision
  Pty->>Manager: setPaneGpuRendering(decision.rendererPolicy.gpuEnabled)
  Pty->>Coordinator: observeTitle(decision.rawTitle)
Loading

Related issues: None referenced in the provided change data.

Related PRs: None referenced in the provided change data.

Suggested labels: terminal-pane, refactor, tests

Suggested reviewers: None specified.

Poem
A rabbit peers at panes so bright,
GPU or DOM, which wins the fight?
Gemini's ghost in title text,
Now gated well, no longer vexed.
Fresh or stale, the agent's clue,
One decision guides them through. 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is informative, but it doesn't follow the required template and omits explicit Screenshots, AI Review Report, Security Audit, and Notes sections. Reformat it to the repo template and add the missing sections, including screenshots or 'No visual change', AI review details, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main behavior change around Gemini GPU fallback gating on pane-owner evidence.
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.
✨ 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/components/terminal-pane/pty-connection.test.ts (1)

1010-1224: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract repeated onTitleChange retrieval boilerplate into a helper.

The createdTransportOptions[N]?.onTitleChange cast + null-check pattern is duplicated identically across 7 tests. A small helper would reduce duplication and centralize the error message.

♻️ Proposed helper
+function getOnTitleChangeCallback(index: number): (title: string, rawTitle: string) => void {
+  const onTitleChange = createdTransportOptions[index]?.onTitleChange as
+    | ((title: string, rawTitle: string) => void)
+    | undefined
+  if (!onTitleChange) {
+    throw new Error(`missing title callback at index ${index}`)
+  }
+  return onTitleChange
+}

Then each test simplifies to const onTitleChange = getOnTitleChangeCallback(0).


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f73c3b9-4e3c-4088-bd26-72d118e86149

📥 Commits

Reviewing files that changed from the base of the PR and between 2e5057f and f32b1a4.

📒 Files selected for processing (10)
  • docs/reference/terminal-title-evidence-plan.md
  • src/renderer/src/components/native-chat/native-chat-runtime-owner.ts
  • src/renderer/src/components/native-chat/native-chat-session-transport.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/terminal-renderer-policy.test.ts
  • src/renderer/src/components/terminal-pane/terminal-renderer-policy.ts
  • src/renderer/src/components/terminal-pane/terminal-title-evidence.test.ts
  • src/renderer/src/components/terminal-pane/terminal-title-evidence.ts

brennanb2025 and others added 2 commits July 6, 2026 11:29
…m settings

Review follow-up: terminal-title-evidence.ts shipped TerminalTitleEvidence,
AgentOwnerDecision, AgentActivityDecision, and the identity
resolveTerminalTitleEvidence with zero production consumers after the plan
doc left this PR; they now land in Phase 2 with their first consumer.
TerminalGpuAccelerationMode now derives from
GlobalSettings['terminalGpuAcceleration'] instead of hand-copying the union.

Co-authored-by: Orca <[email protected]>
@brennanb2025
brennanb2025 merged commit 6aed5c1 into main Jul 6, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/terminal-title-evidence-resolver branch July 6, 2026 22:01
Jinwoo-H added a commit that referenced this pull request Jul 6, 2026
Brings in 9 commits: deferred remote catalogs at startup (#7087),
owner-aware pane title decision gating the Gemini GPU fallback (#7458),
incremental transcript parsing for JSONL agents (#7593), gh rate-limit and
git-status spawn-churn fixes (#7595), WSL Codex session bridging (#7477),
jump-palette subscription gating (#7558), and the IDE font dropdown fix.

Conflict resolutions (our structure, main's semantics):
- pty-connection.ts onTitleChange: kept this branch's third parameter and
  stale-derived-title guard (staleWorkingTitleClear must never feed
  completion tracking), grafted main's resolvePaneTitleDecision so the
  display label, GPU policy, and observeTitle all ride the owner-aware
  decision (#7428/#7447).
- App.tsx startup: kept this branch's publishTerminalViewAttributesAtAppStart
  (hidden-at-launch OSC 10/11 replies) ahead of main's restructured
  local-first startup; dropped this branch's early ui.get() overlap — main's
  #7087 now awaits ui.get at effectively the same point, making it redundant.

Gates: typecheck clean; 4298 tests across src/main/ipc, src/main/daemon,
terminal-pane, pane-manager. The delivery path (ipc/pty.ts, dispatcher,
scheduler, snapshots) had no conflicts and no incoming changes.

Co-authored-by: Orca <[email protected]>
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