Skip to content

fix(native-chat): target native chat to the active split leaf - #8569

Merged
AmethystLiang merged 3 commits into
mainfrom
native-chat-active-split-leaf
Jul 13, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
native-chat-active-split-leaf

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Related issue: #8401. Canonical first-flush PR: #8418. This independent follow-up fixes native-chat ownership inside split terminal tabs; it does not change transcript I/O or runtime transport.

Tab-level native-chat actions previously projected whichever pane appeared first, while every split leaf could inherit tab-wide launch metadata. Closing a chat-owning leaf could therefore leave the composer attached to a plain-shell sibling. This PR:

  • resolves tab-level agent identity from the active layout leaf instead of pane-map insertion order;
  • accepts tab-wide launch/title evidence only while the tab is unsplit;
  • keeps chat attached to an eligible chosen leaf and repairs close/reassignment only to an eligible active sibling;
  • exits to terminal view when no eligible leaf remains, including mounted and cold-parked tabs;
  • makes the shortcut, tab strip, and pane header use the same hydration/layout eligibility rules;
  • rejects stale/rootless/nested active-leaf snapshots and clears launch/title identity that belonged to a closed pane.

Screenshots

No visual design change. The behavior is split ownership and close/reassignment routing, covered by deterministic layout and pane-lifecycle regressions.

Testing

  • pnpm lint (full lint/custom gates in both passes; changed-file lint rerun after rebase)
  • pnpm typecheck (full typecheck in review; web typecheck rerun after rebase)
  • Full repository pnpm test was not run; the reviewer passed 12 focused files / 143 tests, then the exact rebased changed-test set passed 69/69
  • pnpm build was not run
  • Added regressions for mixed splits, insertion order, stale/nested layouts, hydration, shortcut/tab-strip parity, active-leaf changes, mounted closes, parked closes, launch/title cleanup, and plain-shell survivors

AI Review Report

Two separate gpt-5.6-sol xhigh agents implemented and adversarially reviewed the exact branch diff. The second pass found and fixed three high-confidence gaps: stale nested active-leaf acceptance, shortcut/tab-strip hydration divergence, and launch/title evidence leaking from a closed launch-owning pane to a shell survivor.

The review traced layout serialization, active/expanded leaves, selectors, shortcut and tab-strip gates, pane hydration, mounted and parked close paths, title/launch evidence, local versus SSH readability, performance, and overlap with #8418/#8157/#8288. It explicitly checked macOS, Linux, and Windows behavior; no hardcoded shortcut modifier, label, path separator, shell behavior, or platform-specific Electron branch was introduced.

Security Audit

No command execution, filesystem access, IPC/RPC method, dependency, secret, auth, or credential changes. The routing helpers consume existing in-memory layout and pane identity, and the stricter eligibility checks reduce the chance of sending terminal input to a shell pane under the wrong agent identity.

Notes

@coderabbitai

coderabbitai Bot commented Jul 13, 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: c7a7016a-3411-441f-b0c9-a83225bbbabc

📥 Commits

Reviewing files that changed from the base of the PR and between 6f1899b and cd7ef80.

📒 Files selected for processing (2)
  • 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
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.ts
  • src/renderer/src/components/tab-bar/tab-agent-types-by-tab-id.test.ts

📝 Walkthrough

Walkthrough

Native chat routing now resolves agents and chat ownership from terminal layout leaves, handles stale or hydating layouts, and restricts tab-wide fallback to safe topologies. Terminal panes use the resolved route and selected launch agent when rendering chat. Pane-close handling now clears launch identity only for the owning PTY and updates tab titles from surviving runtime panes, including parked-tab cleanup. Tests cover routing, fallback safety, active-leaf selection, and close behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: routing native chat to the active split leaf.
Description check ✅ Passed The description includes all required sections and covers the main behavior, testing status, review summary, security audit, and notes.
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.

@AmethystLiang
AmethystLiang merged commit 5be44d1 into main Jul 13, 2026
1 check passed
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