fix(desktop): enable context menus in the browser #10670
main fromrefs/pull/10670/head·merged by juliusmarminge View on GitHubRight-clicking inside an embedded browser tab or sign-in popup showed no native context menu. The menu handler was only installed on T3's main renderer.
Reuse that handler for attached browser contents and their popups. Editing actions focus the page that was clicked, spelling and image actions use its contents, and Electron receives the originating frame. Repeated attachment does not install duplicate handlers, and callbacks tolerate a closed browser tab.
Validation:
- All 40 focused desktop-window and Electron-menu tests pass, covering tabs, popups, action targeting, disabled actions, duplicate attachment, and closed-tab callbacks.
- Targeted lint passes.
- Desktop typechecking passes with the repository's TypeScript 7 compiler.
- All executed CI checks pass. Macroscope approved; CodeRabbit found no actionable code issues. Bugbot was unavailable because the team reached its spending limit.
- CodeRabbit's generic docstring-coverage warning does not reflect a repository requirement. The native focus behavior is documented inline; adding comments that restate the installer would conflict with the repository's documentation guidance.
https://github.com/user-attachments/assets/1541e172-dd54-4657-be89-9a8e1adb7f95
Note
Enable context menus for host and guest contents in DesktopWindow#
- Replaces the single host-webContents context-menu listener with an installer tracking registered contents in a
WeakSet. - Registers handlers for the host renderer, attached webview guests, and popup windows recursively.
- Focuses the originating contents before showing editing roles, applying spelling and image actions to that specific contents object.
- Passes an optional
WebFrameMaintoElectronMenufor native popup calls. - Behavioral Change: Destroyed contents or owner windows no longer open a menu or execute contents-specific actions.
Summary by CodeRabbit#
New Features
- Context menus now work consistently in the main window, embedded web content, and popup windows.
- Menu actions such as copy, paste, spelling corrections, link handling, and image copying are preserved across supported content.
- Context menus now focus the content that triggered them, providing more reliable editing and selection behavior.
Bug Fixes
- Prevented duplicate context-menu handlers.
- Avoided showing or processing menus after window content has been closed.
- Improved context-menu behavior for browser guests and sign-in popups.
Model: GPT-6. Harness: Codex.
Closes discussions#
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
267907eMacroscope's review found this PR approvable — The production change is localized to Electron’s existing context-menu path, extending it to embedded browser guests and popups while preserving action targeting and adding lifecycle guards. Optional frame plumbing is backward-compatible, and focused tests cover registration, targeting, duplicate attachment, and closed contents.
Notes:
- No code objects were reviewed. Approvability was decided on eligibility alone.
All clear
Posted via Macroscope — Effect Service ConventionsThread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 11.3 KiB 13.6 KiB +2.3 KiB (+20.2%) 15.1 KiB ✅ Codex Thread snapshot wire 5.5 KiB 7.0 KiB +1.6 KiB (+29.0%) 7.3 KiB ✅ Codex Live turn WebSocket wire 5.9 KiB 6.6 KiB +719 B (+12.0%) 7.8 KiB ✅ Codex Live turn WebSocket decoded 49.7 KiB 57.1 KiB +7.3 KiB (+14.7%) 66.4 KiB ✅ Codex Live turn messages 16 10 −6 (−37.5%) 21 ✅ Claude Total thread wire 11.3 KiB 13.6 KiB +2.3 KiB (+19.9%) 15.1 KiB ✅ Claude Thread snapshot wire 5.5 KiB 7.0 KiB +1.6 KiB (+28.6%) 7.3 KiB ✅ Claude Live turn WebSocket wire 5.9 KiB 6.5 KiB +702 B (+11.7%) 7.8 KiB ✅ Claude Live turn WebSocket decoded 50.6 KiB 57.8 KiB +7.3 KiB (+14.4%) 66.4 KiB ✅ Claude Live turn messages 16 9 −7 (−43.8%) 21 ✅ Baseline:
83d769f· PR result:267907e· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 113.9 KiB
- Claude decoded thread snapshot: 114.6 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
5b63af6b-8bc1-45ff-9a82-59f5131f10b9📥 Commits
Reviewing files that changed from the base of the PR and between 6ba15c027a6d411c7f75cc0ca59b601a295c3633 and c6e40f286b554d7c3e7f083eb45b534be7466443.
📒 Files selected for processing (4)
apps/desktop/src/electron/ElectronMenu.test.tsapps/desktop/src/electron/ElectronMenu.tsapps/desktop/src/window/DesktopWindow.test.tsapps/desktop/src/window/DesktopWindow.ts
Limit details: You’ve used all 10 included reviews currently available.
📝 Walkthrough
Walkthrough#
DesktopWindow now installs native context menus for the host renderer, embedded browser guests, and popup windows. Menus focus the triggering contents, guard destroyed contents, preserve edit and copy actions, and forward popup frame context.
Changes#
Native context-menu support
Layer / File(s) Summary Popup frame contract
apps/desktop/src/electron/ElectronMenu.ts,apps/desktop/src/electron/ElectronMenu.test.tsElectronMenuTemplateInputaccepts an optionalWebFrameMain.popupTemplateforwards the frame toMenu.popup, with test coverage.WebContents context-menu installation
apps/desktop/src/window/DesktopWindow.ts,apps/desktop/src/window/DesktopWindow.test.tsDesktopWindow installs deduplicated listeners for host, embedded, and popup contents. The handler focuses contents, checks destruction state, preserves edit, spelling, image, and link actions, and passes frame context. Tests cover these paths and popup ownership. Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
c6e40Native context menus now work in embedded browser tabs and sign-in popups, with actions targeted to the originating content and safeguards for closed tabs. The covered behavior is ready to merge.
Sequence Diagram(s)#
sequenceDiagram participant WebContents participant DesktopWindow participant ElectronMenu participant NativeMenu WebContents->>DesktopWindow: emit context-menu event DesktopWindow->>WebContents: focus triggering contents DesktopWindow->>ElectronMenu: create menu with frame ElectronMenu->>NativeMenu: open popup NativeMenu->>WebContents: execute edit or copy actionSuggested reviewers:
stienswout,bil0000,maria-rcks🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation 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 identifies the primary change: enabling native context menus in the desktop browser. Description check ✅ Passed The description clearly explains what changed, why it changed, validation results, and the affected browser contents. It does not reproduce the template headings or checklist, and it does not provide … - Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch `fix-browser-context-menu`
Comment `@coderabbitai help` to get the list of available commands.Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged thisb5f7fa0
juliusmarminge closed this
Sign in to join this conversation.
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.