Skip to content

fix(native-chat): gate view toggle to supported agents (Claude/Codex) - #6781

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/native-chat-supported-agents-gate
Jun 29, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/native-chat-supported-agents-gate

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The experimental Native Chat view is only meant to work for Claude and Codex (its transcript/streaming parser is provider-specific). But the "Switch to chat view" toggle was showing for every agent terminal — Grok, Gemini, and the rest — even though native chat can't render those.

Root cause

canToggleNativeChat only checked whether a terminal was running an agent, never which one. The agent's identity was discarded at every call site before the gate could see it:

  • launchAgent was passed but never inspected
  • live detection and title resolution were collapsed to bare booleans (hasDetectedAgent / hasResolvedAgent)

So any truthy agent signal — regardless of provider — satisfied the gate.

Fix

Make the gate agent-aware:

  • Add a NATIVE_CHAT_SUPPORTED_AGENTS allowlist (claude, openclaude, codex) and an isNativeChatSupportedAgent() helper in native-chat-availability.ts.
  • Change the input shape from booleans to agent-identity values (detectedAgent, resolvedAgent) and require a supported agent on every signal path.
  • Thread the real agent identity through all three call sites that drive the toggle:
    • TabBar.tsx — tab context menu (resolves the live agentType via findTabAgentEntry; removed the now-dead tabIdsWithLiveAgent memo)
    • TerminalPane.tsx — pane header + context menu
    • use-native-chat-toggle-shortcut.ts — keyboard chord (stays inert on unsupported agents)

All three mattered: fixing only the menu would still let Grok enter native chat via the header or the shortcut.

Note: openclaude is included as supported (Claude variant, already in the image-attachment allowlist). Easy to drop if native chat shouldn't cover it.

Testing

  • Added negative cases to native-chat-availability.test.ts (Grok/Gemini rejected via launch hint, live detection, and title resolution) — 13/13 pass.
  • Related shortcut/context-menu tests pass (9/9).
  • pnpm typecheck (web project) and oxlint on the changed files are clean.

Made with Orca 🐋

The native chat toggle was shown for every agent terminal, not just the
Claude/Codex sessions native chat can actually render. canToggleNativeChat
only checked *whether* an agent was present (booleans hasDetectedAgent/
hasResolvedAgent + an unused launchAgent), so Grok, Gemini, and others
incorrectly surfaced the 'Switch to chat view' control.

Make the gate agent-aware: add a NATIVE_CHAT_SUPPORTED_AGENTS allowlist
(claude, openclaude, codex) and require a supported agent on each signal
path. Thread the real agent identity through all three call sites — the
tab context menu (TabBar), the pane header/context menu (TerminalPane),
and the keyboard shortcut — instead of collapsing it to a boolean.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The native chat availability logic now uses explicit agent identity fields instead of boolean detection flags. NativeChatAvailabilityInput accepts launchAgent, detectedAgent, and resolvedAgent, and canToggleNativeChat checks whether any of them are supported agents. TabBar, TerminalPane, and useNativeChatToggleShortcut now compute and pass agent identities. Tests were updated with new supported and unsupported agent cases.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, fix, and testing, but omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections with screenshots or "No visual change", a cross-platform AI review, a security audit, and any platform-specific notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. 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 accurately summarizes the main change: restricting the native-chat toggle to supported agents.
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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/TerminalPane.tsx (1)

565-589: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Scope detected-agent eligibility to the leaf being toggled.

This selector returns the first agent status for the tab, but the header/context-menu actions toggle a specific leaf. In mixed split panes, a supported sibling can enable native chat for an unsupported active pane, or an unsupported first entry can hide it for a supported pane. Compute eligibility from makePaneKey(tabId, leafId) for the active/header leaf and the context-menu leaf separately.

Also applies to: 2420-2428, 2901-2903


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d063f717-4003-427d-9ca1-bcdd577510ad

📥 Commits

Reviewing files that changed from the base of the PR and between 95aee59 and 25b3dc9.

📒 Files selected for processing (5)
  • src/renderer/src/components/native-chat/native-chat-availability.test.ts
  • src/renderer/src/components/native-chat/native-chat-availability.ts
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx

Address CodeRabbit: agent-status pane keys are `${terminalTabId}:${leafId}`,
but the tab toggle (TabBar) and keyboard shortcut keyed the lookup by the
unified tab id, which can differ. That left the native-chat toggle inert for
manually-started supported agents unless another signal happened to resolve.
Use the backing terminal tab id (terminalTab.id / tab.entityId), matching the
working NativeChatView resolution path.

Co-authored-by: Orca <[email protected]>
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Re: the "Scope detected-agent eligibility to the leaf being toggled" comment on TerminalPane.tsx (split panes mixing supported/unsupported agents) —

This is a real edge case but it's a pre-existing limitation, not introduced by this PR. The original hasDetectedAgent selector already scanned tab-wide (.some(...) over any pane of the tab); this PR preserved that scope and only added agent identity to it. So a mixed Claude+Grok split could already mis-gate before this change.

Properly fixing it is the "Heavy lift" the comment notes: canToggleChat is currently a single tab-level value threaded into multiple per-leaf pane headers/context-menus, so per-leaf scoping means recomputing eligibility from makePaneKey(tabId, leafId) for each header leaf and the context-menu target leaf. That's a structural change orthogonal to this PR's bug (the toggle showing for unsupported agents at all).

Leaving it out of scope here to keep the fix focused; happy to follow up in a dedicated PR for split-pane per-leaf eligibility.

@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/tab-bar/TabBar.tsx (1)

453-455: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the stale pane-key explanation.

This still says live pane keys use ${unifiedTabId}:…, but the fixed lookup below correctly uses the backing terminal tab id. Keeping both explanations risks reintroducing the mismatch.

Proposed comment update
-  // Why: gate the tab long-press view-mode toggle to agent terminals. A tab is
-  // eligible when it launched an agent or has a live agent-status entry on any of
-  // its panes (paneKey = `${unifiedTabId}:…`), mirroring the toggle button's gate.
+  // Why: gate the tab long-press view-mode toggle to supported agent terminals.
+  // Live status uses pane keys minted from `${terminalTab.id}:${leafId}`, not
+  // unified tab ids, matching the per-tab view-mode gate below.

Based on learnings, live agent-status entries in this path must be keyed by the backing terminal tab id. As per coding guidelines, non-obvious TS/TSX behavior should have short comments explaining why the code behaves that way.

Sources: Coding guidelines, Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 408b2ddf-1955-4041-a608-44278d83768f

📥 Commits

Reviewing files that changed from the base of the PR and between 25b3dc9 and 5d87944.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
  • src/renderer/src/components/tab-bar/TabBar.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts

@Jinwoo-H
Jinwoo-H merged commit 6e2b391 into main Jun 29, 2026
1 check passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/native-chat-supported-agents-gate branch June 29, 2026 20:04
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