Skip to content

fix(web): chat links open their menu from the keyboard on macOS - #37405

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Kenmege:fix/macos-keyboard-link-menus
Nov 23, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Kenmege:fix/macos-keyboard-link-menus

Conversation

@Kenmege

@Kenmege Kenmege commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Problem

On macOS, links and file chips in chat messages have no keyboard-opened context menu. Chromium on macOS does not turn Shift+F10 or the ContextMenu key into a contextmenu event, so focusing a link and pressing Shift+F10 does nothing. The same keys work on Windows and Linux. On macOS they already work in the sidebar, draft rows and media actions, which handle the keys themselves.

The existing test "tells the native menu for … whether the keyboard opened it" in ChatMarkdown.permissions.browser.test.tsx fails on macOS on main for both the external link and the file link: the menu is never requested (expected undefined to be 'keyboard').

Change

openContextMenuFromKeyboard in contextMenuSource.ts handles Shift+F10 and ContextMenu on the element. It prevents the key's default, so other platforms don't open a second menu, and it dispatches the element's contextmenu at its lower-left corner. A script-created event cannot keep button: -1, so the dispatched event is recorded and contextMenuSourceOf reports it as keyboard. The native menu therefore gets the same keyboard source it gets on other platforms. The external link in ChatMarkdown and both file-chip variants in MarkdownFileLink use it.

Scope

A small accessibility bug fix on macOS with no visual change, so it has no separate issue. Related: #10390 (screen-reader focus for message link menus on Windows).

Verification

  • On main on macOS 27.2, both cases of "tells the native menu for %s whether the keyboard opened it" fail. With this change they pass, and so do the rest of ChatMarkdown.permissions.browser.test.tsx, ChatMarkdown.browser.test.tsx and MarkdownFileLink.logic.test.ts (41 tests).
  • check:changed passes (format, lint, knip, typecheck, tests, React compiler).
  • Nothing changes visually. The menu opens at the link's lower-left corner, as the file chip already did for keyboard menus.
  • Not checked by hand on Windows or Linux. There the browser's own keyboard contextmenu is suppressed by preventDefault, as in the sidebar's handler.

Model and harness: Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

Chromium on macOS turns neither Shift+F10 nor the ContextMenu key into a contextmenu
event, so links and file chips in messages had no keyboard menu there. They now handle
the keys like the sidebar and media rows do, and the menu reports a keyboard source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T23:34:13.884258Z
We couldn’t complete this review. Comment @codex review to try again.
c66ae63 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 15, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c66ae63

Macroscope's review found this PR approvable — Enables keyboard opening of existing chat-link menus on macOS while preserving keyboard-origin reporting. The change reuses existing menu handlers and does not alter available actions or product defaults.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Chat link controls now support keyboard context-menu requests. A shared helper dispatches marked context-menu events for the ContextMenu and Shift+F10 keys. The event source logic identifies those events as keyboard-originated.

Changes: Keyboard context menus

Layer / File(s) Summary
Context-menu event handling
apps/web/src/contextMenuSource.ts
The helper handles ContextMenu and Shift+F10, prevents the default action, and dispatches a marked contextmenu event at the target’s left and bottom bounds. contextMenuSourceOf recognizes marked native events as keyboard-originated.
Chat link control wiring
apps/web/src/components/ChatMarkdown.tsx, apps/web/src/components/chat/MarkdownFileLink.tsx
External links with an href and resolved favicon host, file-link primary-action chips, and file-options buttons invoke the helper on keydown.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: only21mil, juliusmarminge

Merge Risk: Minimal · up to 415e8

Chat links and file chips now open their context menu from the keyboard on macOS using ContextMenu or Shift+F10. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: keyboard-opened context menus for chat links on macOS. It matches the changeset, which adds a keyboard context-menu handler for Shift+F10 and the ContextMenu key in Ch…
Description check Passed The description follows the template's Problem, Change, Scope, and Verification sections. It explains the macOS cause (Chromium does not emit a contextmenu event for Shift+F10 or the ContextMenu key) …
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: Title check

Explanation

The title names the main change: keyboard-opened context menus for chat links on macOS. It matches the changeset, which adds a keyboard context-menu handler for Shift+F10 and the ContextMenu key in ChatMarkdown and MarkdownFileLink. It follows the conventional commit format from the template.

Full details: Description check

Explanation

The description follows the template's Problem, Change, Scope, and Verification sections. It explains the macOS cause (Chromium does not emit a contextmenu event for Shift+F10 or the ContextMenu key) and the fix. Scope explains why no issue is linked: it is a small accessibility fix with no visual change. Verification gives specific tests, the macOS version, and the check results. The Windows and Linux behavior is not checked by hand, and the author says so. Visual before/after evidence is not needed because the author states there is no visual change. The model and harness line is present.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c66ae63 and 415e88c.

Files selected for processing: 2

  • apps/web/src/components/ChatMarkdown.tsx
  • apps/web/src/components/chat/MarkdownFileLink.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 23, 2026
@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

On macOS 26 (Apple silicon), ran both commits as the real Electron desktop app via vp run dev:desktop, using isolated T3 homes and the same synthetic Replay reply. Light theme; 1440×850 app window on a 1440×900 display; captures crop the central chat area to 880×600. Path tooltips were hidden for privacy on both sides.

Focused each anchor (confirmed document.activeElement), raised the app, and sent real Shift+F10 with System Events (key code 109 + Shift), in this order: external link, package.json, math.ts · L1, src. Dismissed each menu before moving to the next anchor. Every selected still matched a second capture 500 ms later.

Before After
977b7c7932 415e88c487
Before: external link, no keyboard menu After: external link, native keyboard menu
Before: package.json, no keyboard menu After: package.json, native keyboard menu
Before: math.ts · L1, no keyboard menu After: math.ts · L1, native keyboard menu
Before: src folder, no keyboard menu After: src folder, native keyboard menu
Before recording After recording

Base received all four keydowns but produced no contextmenu event or menu request. Head opened exactly one menu per anchor, with source keyboard and coordinates equal to the element’s lower-left corner (integer pixel rounding). Base event transcript · Head event transcript. The end of the base recording shows the existing menu opening when a contextmenu MouseEvent is delivered.

Capture driver · Replay seed script. No tests were used as evidence.

Not shown:

  • The ContextMenu key was not exercised; the Mac keyboard has no such key, so the real keyboard comparison used Shift+F10.
  • The file-options button variant was not exercised; desktop rendered all file and folder chips as primary-action anchors with Open in editor available.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 7e624c0 into pingdotgg:main Nov 23, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants