Feature: add link actions to context menu#772
Feature: add link actions to context menu#772dbalders wants to merge 1 commit intopingdotgg:mainfrom
Conversation
Add "Open Link" and "Copy Link Address" when right-clicking a link. Refs pingdotgg#677
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Pull request overview
Adds link-specific actions to the Electron desktop app’s custom context menu so users can open/copy URLs when right-clicking links in chat, aligning behavior with common desktop UX.
Changes:
- Add
clipboardto Electron imports in the desktop main process. - Extend the
webContents"context-menu"handler to detect safe link URLs and add “Open Link” / “Copy Link Address” menu items.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { label: "Open Link", click: () => void shell.openExternal(externalUrl) }, | ||
| { label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) }, |
There was a problem hiding this comment.
shell.openExternal(externalUrl) returns a Promise and can reject; using void here can lead to an unhandled rejection in the main process if opening the URL fails. Consider handling the rejection (e.g., attach a .catch(...) to log/ignore) similar to the try/catch used in the OPEN_EXTERNAL IPC handler.
| if (externalUrl) { | ||
| menuTemplate.push( | ||
| { label: "Open Link", click: () => void shell.openExternal(externalUrl) }, | ||
| { label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) }, |
There was a problem hiding this comment.
For "Copy Link Address", copying externalUrl (derived from new URL(...).toString()) can normalize the string (e.g., add a trailing slash, re-encode characters), so users may not get the exact link they clicked. Consider copying params.linkURL for fidelity while still using externalUrl for the safe "Open Link" action.
| { label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) }, | |
| { | |
| label: "Copy Link Address", | |
| click: () => clipboard.writeText(params.linkURL || externalUrl), | |
| }, |
| const externalUrl = getSafeExternalUrl(params.linkURL); | ||
| if (externalUrl) { | ||
| menuTemplate.push( | ||
| { label: "Open Link", click: () => void shell.openExternal(externalUrl) }, |
There was a problem hiding this comment.
don't think this should be shell.openExternal as that opens it on the host machine. if you run the server on a separate server from the frontend, i'd expect clikcing the link to open it on the current machien, not the host
There was a problem hiding this comment.
Thanks @juliusmarminge. I've been looking into this. This is what codex said:
Keep shell.openExternal here.
In Electron, this code runs in the desktop app main process, so shell.openExternal opens on the same machine running the app, not a remote t3 server: [apps/desktop/src/main.ts (line 1177)](app://-/index.html?hostId=local#).
The browser/web path already opens links client-side with window.open(...), which is exactly what you want when frontend and backend are separated: [apps/web/src/wsNativeApi.ts (line 149)](app://-/index.html?hostId=local#).
I tried it when accessing it via the browser to a remote server and it opened links as expected in the browser:
t3test.mov
But, I'm trying to figure out how to check it from the actual app with a different server. Is there a way to hook the electron app itself into a remote server? Will look into that more tomorrow morning as codex seemed to think thats not possible without editing the codebase. Thanks
What Changed
Added 2 new link-specific elements in the context menu when right-clicking a link in chat:
Image:

This was part of the request from #677. I confirmed that the main issue for #677 of links not working on Windows was resolved previously by #599, but added the quality of life improvement of the extra attributes to the context menu.
Added an if statement to the context menu event to check if what is being right clicked on is a link or not, and if so, add the 2 elements and a separator. This required adding 'clipboard' to the electron import as well.
Why
This makes link behavior more closely resemble standard UX.
UI Changes
This is a UI change specifically.
Before:

After:

Checklist
Note
Add 'Open Link' and 'Copy Link Address' entries to the desktop context menu
When right-clicking a link in the desktop app, two new items appear in the context menu: 'Open Link' (opens via
shell.openExternal) and 'Copy Link Address' (writes to clipboard). Both items are only shown whengetSafeExternalUrlreturns a valid URL, followed by a separator before the standard edit items.Macroscope summarized 956c18d.