Skip to content

Feature: add link actions to context menu#772

Open
dbalders wants to merge 1 commit intopingdotgg:mainfrom
dbalders:context-menu-actions
Open

Feature: add link actions to context menu#772
dbalders wants to merge 1 commit intopingdotgg:mainfrom
dbalders:context-menu-actions

Conversation

@dbalders
Copy link
Copy Markdown
Contributor

@dbalders dbalders commented Mar 10, 2026

What Changed

Added 2 new link-specific elements in the context menu when right-clicking a link in chat:

  • Open Link
  • Copy Link Address

Image:
Screenshot 2026-03-09 at 9 08 20 AM

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:
Screenshot 2026-03-09 at 9 10 37 AM

After:
Screenshot 2026-03-09 at 9 08 20 AM

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes

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 when getSafeExternalUrl returns a valid URL, followed by a separator before the standard edit items.

Macroscope summarized 956c18d.

Add "Open Link" and "Copy Link Address" when right-clicking a link.
Refs pingdotgg#677
Copilot AI review requested due to automatic review settings March 10, 2026 02:47
@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 10, 2026
@dbalders dbalders changed the title Feature: add link actions to context menu (#677) Feature: add link actions to context menu Mar 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 141aa236-9d43-4371-b600-fdc0ee0481e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +1177 to +1178
{ label: "Open Link", click: () => void shell.openExternal(externalUrl) },
{ label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) },
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
if (externalUrl) {
menuTemplate.push(
{ label: "Open Link", click: () => void shell.openExternal(externalUrl) },
{ label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) },
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{ label: "Copy Link Address", click: () => clipboard.writeText(externalUrl) },
{
label: "Copy Link Address",
click: () => clipboard.writeText(params.linkURL || externalUrl),
},

Copilot uses AI. Check for mistakes.
const externalUrl = getSafeExternalUrl(params.linkURL);
if (externalUrl) {
menuTemplate.push(
{ label: "Open Link", click: () => void shell.openExternal(externalUrl) },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants