Skip to content

fix(browser): close guest-owned split tab - #17281

Merged
AmethystLiang merged 3 commits into
mainfrom
cmd-w-should-close-browser-tab
Aug 29, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
cmd-w-should-close-browser-tab

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​163 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​95 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74

Summary

  • forward the browser guest page ID with close-tab shortcuts so split-pane closes target the owning browser workspace even when active-tab mirrors are stale
  • validate source-aware close payloads at the preload boundary while preserving legacy payload-less menu events
  • reuse a canonical live-workspace resolver for normal and floating browser guest close routing
  • add unit coverage plus a real Electron guest Cmd/Ctrl+W regression test

Testing

  • pnpm tc
  • pnpm test src/preload/close-active-tab-payload-admission.test.ts src/main/browser/browser-guest-shortcut-forwarding.test.ts src/main/browser/browser-manager-guest-shortcuts.test.ts src/renderer/src/hooks/useIpcEvents-close-routing-active-browser-tab.test.ts src/renderer/src/hooks/useIpcEvents-close-routing-floating-guest.test.ts src/renderer/src/hooks/useIpcEvents-close-routing-browser-pages.test.ts src/renderer/src/hooks/useIpcEvents-close-routing-session-tabs.test.ts
  • pnpm run test:e2e tests/e2e/browser-split-shortcuts.spec.ts --workers=1 --grep "closes the guest-owned browser split"
  • pnpm run check:code-quality:changed
  • git diff --check

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR fixes source-aware browser guest close routing so Cmd/Ctrl+W targets the guest’s owning live workspace rather than stale active-tab state.

  • Adds the guest page ID to main-workspace close events while preserving separate floating-workspace routing.
  • Validates optional close payloads at the preload boundary and retains legacy payload-less menu behavior.
  • Resolves page ownership from canonical live workspace maps before applying browser teardown and pinned-tab handling.
  • Adds unit and Electron regression coverage for source-aware close routing.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; source-aware closes bypass the empty floating-panel fallback, resolve the guest’s live owner, and preserve the distinct floating-guest route.

Important Files Changed

Filename Overview
src/main/browser/browser-guest-shortcut-dispatch.ts Main-workspace guest close shortcuts now carry the guest page ID while floating guests retain their dedicated event route.
src/preload/close-active-tab-payload-admission.ts Introduces narrow validation for source-aware close payloads while explicitly preserving legacy omitted payloads.
src/preload/index.ts Admits validated close payloads across the preload boundary and ignores malformed event data.
src/renderer/src/hooks/ipc-events/tab-lifecycle-ipc-bridge.ts Resolves source-aware closes before the ambient floating-panel fallback, fixing the previously reported wrong-panel close.
src/renderer/src/lib/browser-workspace-source-resolution.ts Provides canonical live workspace ownership resolution for browser workspace and page IDs.
src/renderer/src/lib/floating-workspace-terminal-actions.ts Reuses canonical ownership resolution while retaining the floating-worktree scope.
tests/e2e/browser-split-shortcuts.spec.ts Expands real Electron split-pane shortcut coverage and strengthens browser guest registration and focus setup.

Sequence Diagram

sequenceDiagram
    participant G as Browser guest
    participant M as Main process
    participant P as Preload bridge
    participant R as Renderer close router
    participant S as Workspace store
    G->>M: Cmd/Ctrl+W
    alt Floating guest
        M->>P: ui:closeFloatingItem(sourceId)
        P->>R: Validated sourceId
        R->>S: Resolve and close floating workspace
    else Main-workspace guest
        M->>P: ui:closeActiveTab(sourceId)
        P->>R: Validated optional payload
        R->>S: Resolve live workspace owner
        S-->>R: worktreeId and workspaceId
        R->>S: Close targeted browser workspace
    end
Loading

Reviews (4): Last reviewed commit: "test(browser-split-shortcuts): remove te..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 29, 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 Plus

Run ID: 1a916d30-b89c-492f-a292-290f4400067a

📥 Commits

Reviewing files that changed from the base of the PR and between 01f3946 and 902ba97.

📒 Files selected for processing (1)
  • tests/e2e/browser-split-shortcuts.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds source-aware payloads to browser guest close events. The preload bridge validates these payloads and preserves legacy events. The renderer resolves source pages to their owning workspaces and ignores stale or orphaned sources. Floating workspace resolution uses the shared resolver. Tests cover IPC forwarding, split-layout close routing, malformed payloads, stale sources, and end-to-end browser closure while retaining the terminal tab.

Merge Risk: ⚪ Minimal · up to 902ba

The change routes guest-owned split-tab close actions to the correct browser workspace while preserving legacy behavior and rejecting invalid sources. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a useful summary and testing details, but it omits most required template sections. It does not provide an ELI5, explicit What Changed or Why sections, a Linked Issue, require… Complete the required template sections. Add the linked issue, provide visual proof or state N/A with a reason, document the change and rationale, address security/platform/SSH/mobile/backwards-compatibility considerations, complete the che…
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 13 files. 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 clearly and concisely describes the main change: fixing closure of browser guest-owned split tabs.
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.
Full details: Description check

Explanation

The description includes a useful summary and testing details, but it omits most required template sections. It does not provide an ELI5, explicit What Changed or Why sections, a Linked Issue, required Visual Proof or N/A statement, AI Disclosure, Review, boundary confirmation, Notes, or checklist status.

Resolution

Complete the required template sections. Add the linked issue, provide visual proof or state N/A with a reason, document the change and rationale, address security/platform/SSH/mobile/backwards-compatibility considerations, complete the checklists, and include AI disclosure when applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

The empty-panel toggle is the ambient fallback only. Guest-initiated
closes (with sourceId) target the main workspace and should not toggle
the panel.
@AmethystLiang
AmethystLiang force-pushed the cmd-w-should-close-browser-tab branch from 6086480 to 01f3946 Compare August 29, 2026 22:01
Removes test case that verified Cmd+W closes guest-owned browser splits when
active-tab mirrors point to a terminal, along with the helper function and
unused fixture properties that only that test required.
@AmethystLiang
AmethystLiang merged commit 2214d29 into main Aug 29, 2026
29 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(browser): close guest-owned split tab

* fix: check sourceId before toggling floating panel on close

The empty-panel toggle is the ambient fallback only. Guest-initiated
closes (with sourceId) target the main workspace and should not toggle
the panel.

* test(browser-split-shortcuts): remove terminal-mirrors close test and un

Removes test case that verified Cmd+W closes guest-owned browser splits when
active-tab mirrors point to a terminal, along with the helper function and
unused fixture properties that only that test required.
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