fix(web): Ctrl+C and terminal links work on Windows - #7698
ArjandenHartog wants to merge 3 commits into
Conversation
The Ghostty IME textarea is empty, so native copy wrote a blank clipboard and Electron's Edit menu stole Ctrl+C before SIGINT could reach the PTY. Ctrl+click also waited on a preview menu, so window.open was popup-blocked and left the current browser. Prime the selection, let the renderer own Edit accelerators, and open http links with a same-tick _blank click. Made with Cursor Grok 4.6
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
One finding: the terminal link path now bypasses the in-app preview panel for loopback URLs. Everything else in the changed web files (the new openUrlInHostBrowser helper, localApi browser branch, and the Ghostty copy priming) stays inside the existing owners and introduces no shared-primitive, Tailwind-ownership, or theming problems.
Posted via Macroscope — UI Consistency
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR makes significant behavioral changes to terminal clipboard handling and link opening: removes the context menu for terminal links, introduces new clipboard 'priming' for copy operations, and changes how Edit menu accelerators are processed. These runtime behavior changes warrant human review. You can add or adjust custom eligibility rules. Learn more. |
Electron Edit Copy can fire without a prior keydown, so the deferred copy path now primes the Ghostty selection. Loopback links open the in-app preview again without an async menu; public URLs still open in the current browser on the same click. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Follow-up for the Macroscope notes is in 074db33. Screenshots from a web session (WSL). Ctrl+C on a Ghostty selection copied the highlighted echo line into the clipboard. Headless Chrome could not show a new host-browser tab or the in-app preview panel after Ctrl+click (no new window event, and Terminal with public and loopback links: Selection plus the Copy context menu: |
There was a problem hiding this comment.
One finding in the terminal surface keyboard path: the new unconditional textarea clear on keydown runs before the IME/composition early-return, so it can wipe an in-progress composition preedit. Inline comment with a suggested guard below. Nothing else in the changed web UI scope (no styling, primitive, or theme changes) raised a consistency concern; the link routing now keeps loopback URLs in the in-app preview, and the preview address bar still exposes "Open in system browser".
Posted via Macroscope — UI Consistency
Copy priming parks selection text in the Ghostty textarea. Clearing that field on every later keydown also wiped an in-progress composition, so skip the clear while IME is active. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Closing as part of the open-PR backlog sweep (wave 1). Reason: Windows Ctrl+C/blank clipboard already fixed on main Reopen if this is still wanted and you’re willing to rebase onto current |


What Changed
copyevent whenclipboardDatais actually writable, so Ctrl+C/Cmd+C copies the selected text instead of a blank clipboard.<a target="_blank">click. Desktop still intercepts_blankthroughopenExternal.localhost,127.0.0.1,::1,0.0.0.0) open the in-app preview panel again, without an async preview-vs-browser menu.Why
On Windows (including a WSL terminal) Ctrl+C was eaten by native copy of the empty textarea, so people had to use Ctrl+Shift+C. That chord is also Chrome/Electron Inspect, so it does not work well.
Clicking a printed URL waited on an async preview-vs-browser menu.
window.openafter that menu is popup-blocked, andopenExternalleaves the current browser for the OS default. Opening public URLs during the click keeps the tab in the browser you already have open. Preview does not need that user gesture, so loopback links can still land in the right panel.Fixes #7677. Also addresses the Windows symptoms in #6173, #5917, and #5702.
UI Changes
No visual chrome change. Keyboard copy/interrupt and modifier-click link opening are interaction-only.
Terminal with a public URL and a loopback URL recognized as links:
Selection plus Copy in the terminal context menu. Ctrl+C on that selection copied the highlighted echo line in a web session:
Headless Chrome could not capture a new host-browser tab or the in-app preview panel after Ctrl+click. Those paths are covered by unit tests.
Checklist
Note
Fix terminal
Ctrl+Ccopy and link opening on Windows by letting renderer own clipboard accelerators{ role: "editMenu" }with a customdesktopEditMenu(platform)that setsregisterAccelerator=falseon all Edit roles, so the renderer handles clipboard shortcuts instead of Electron. Adds a Speech submenu on macOS.GhosttyTerminalSurface:primeTerminalCopyInputwrites the terminal selection into the hidden textarea so native copy (keyboard or Edit menu) produces non-empty text.applyTerminalCopyEventclaims copy events viaclipboardDataand falls back todocument.execCommand("copy"). Primed content is cleared before key encoding (except during IME composition) to avoid leaking to the PTY.openUrlInHostBrowserto open http(s) links via a synchronous_blankanchor click (rejecting non-http schemes), andcanOpenTerminalLinkInPreviewto restrict in-app preview to loopback URLs. RefactorsopenTerminalLinkInPreviewto skip the context-menu prompt and deterministically preview or fall back to the browser.shell.openExternalincreateBrowserLocalApinow rejects non-http(s) URLs with an error instead of passing them towindow.open; terminal http(s) links no longer show a context-menu choice.Macroscope summarized f10b1ea.