Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): enable context menus in the browser #10670

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/10670/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Right-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 WebFrameMain to ElectronMenu for native popup calls.
  • Behavioral Change: Destroyed contents or owner windows no longer open a menu or execute contents-specific actions.
Macroscope summarized 267907e.

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. 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.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 267907e

      Macroscope'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.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire11.3 KiB13.6 KiB+2.3 KiB (+20.2%)15.1 KiB✅
      CodexThread snapshot wire5.5 KiB7.0 KiB+1.6 KiB (+29.0%)7.3 KiB✅
      CodexLive turn WebSocket wire5.9 KiB6.6 KiB+719 B (+12.0%)7.8 KiB✅
      CodexLive turn WebSocket decoded49.7 KiB57.1 KiB+7.3 KiB (+14.7%)66.4 KiB✅
      CodexLive turn messages1610−6 (−37.5%)21✅
      ClaudeTotal thread wire11.3 KiB13.6 KiB+2.3 KiB (+19.9%)15.1 KiB✅
      ClaudeThread snapshot wire5.5 KiB7.0 KiB+1.6 KiB (+28.6%)7.3 KiB✅
      ClaudeLive turn WebSocket wire5.9 KiB6.5 KiB+702 B (+11.7%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded50.6 KiB57.8 KiB+7.3 KiB (+14.4%)66.4 KiB✅
      ClaudeLive turn messages169−7 (−43.8%)21✅

      Baseline: 83d769f · PR result: 267907e · Source CI: success

      Scenario 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.

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      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.ts
      • apps/desktop/src/electron/ElectronMenu.ts
      • apps/desktop/src/window/DesktopWindow.test.ts
      • apps/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.ts
      ElectronMenuTemplateInput accepts an optional WebFrameMain. popupTemplate forwards the frame to Menu.popup, with test coverage.
      WebContents context-menu installation
      apps/desktop/src/window/DesktopWindow.ts, apps/desktop/src/window/DesktopWindow.test.ts
      DesktopWindow 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 c6e40

      Native 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 action

      Suggested reviewers: stienswout, bil0000, maria-rcks

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly identifies the primary change: enabling native context menus in the desktop browser.
      Description check✅ PassedThe 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.
    6. 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.

    7. juliusmarminge merged thisb5f7fa0

    8. juliusmarminge closed this

Sign in to join this conversation.