Skip to content

fix(site): suppress browser context menu on Windows web terminal#26015

Draft
jaaydenh wants to merge 1 commit into
mainfrom
codagt-415/windows-terminal-context-menu
Draft

fix(site): suppress browser context menu on Windows web terminal#26015
jaaydenh wants to merge 1 commit into
mainfrom
codagt-415/windows-terminal-context-menu

Conversation

@jaaydenh
Copy link
Copy Markdown
Contributor

@jaaydenh jaaydenh commented Jun 3, 2026

Right-clicking the workspace terminal on Windows shows image actions like "Copy image" and "Save image as" instead of text-copy entries. The xterm.js canvas/WebGL renderer draws text on a <canvas>, so Chromium-based browsers on Windows offer image-context entries. xterm.js mitigates this by repositioning its hidden helper textarea under the cursor on contextmenu, but the workaround does not reliably retarget the menu on Windows.

Intercept contextmenu on the terminal wrapper when running on Windows and call preventDefault so the misleading menu never appears. Copy still works via selection (which writes to the clipboard automatically) and Ctrl+Shift+C; paste still works via Ctrl+V. macOS and Linux keep the existing browser context menu where xterm.js's textarea trick already works.

Fixes CODAGT-415.

Decision log

Considered four options for the right-click behavior:

  • A: preventDefault globally on every platform.
  • B: Same as A, plus paste-from-clipboard on right-click (PuTTY / Windows Terminal convention).
  • C: preventDefault only on Windows, preserving the macOS browser menu. Chosen.
  • D: Implement a custom React context menu with Copy / Paste / Select All.

Rationale:

  • The bug is Windows-only; the macOS browser context menu currently works correctly because xterm.js's hidden-textarea retargeting succeeds in Safari and Chrome on macOS. Option C avoids regressing that path.
  • Right-click paste (B) was rejected: paste into a shell can execute commands, so silently changing right-click semantics is risky and the issue reporter only asked for the misleading menu to go away.
  • A custom React context menu (D) remains a possible follow-up enhancement; it is more scope than appropriate for a customer fix marked "good first issue".
  • The user-visible expectation from the Linear issue ("Show copy as text") is satisfied because copy-on-select already writes the selection to the clipboard, and Ctrl+Shift+C is wired up to copy in WorkspaceTerminal.tsx.

Note

This pull request was generated by Coder Agents on behalf of @jaaydenh.

Chromium-based browsers on Windows show image actions like "Copy
image" or "Save image as" when right-clicking on the xterm.js
canvas/WebGL renderer, because the underlying <canvas> is treated as
an image. xterm.js mitigates this by repositioning its hidden helper
textarea under the cursor on contextmenu, but the workaround does not
reliably retarget the menu on Windows.

Intercept contextmenu on Windows and call preventDefault so the
misleading menu never appears. Copy still works via selection (which
writes to the clipboard automatically) and Ctrl+Shift+C; paste still
works via Ctrl+V.

Fixes CODAGT-415.
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