Skip to content

Commit 12aeb52

Browse files
committed
fix(desktop): Option-click on a chat link opens the system browser
Chromium turns an Option/Alt-click on a target=_blank link into a download, so the shell's window-open handler never runs and a save dialog appears. On desktop, a link bound for the system browser is now opened through the shell when Option/Alt is held. The hosted web app keeps the browser's own behavior. Closes #13981.
1 parent d15210c commit 12aeb52

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ import {
158158
shouldOpenMarkdownFileLinkInEditor,
159159
type MarkdownFileLinkMeta,
160160
} from "../markdown-links";
161+
import { isElectron } from "../env";
161162
import { readLocalApi } from "../localApi";
162163
import { useAssetUrlRefresh, useAssetUrlState } from "../assets/assetUrls";
163164
import { cn } from "../lib/utils";
@@ -2982,15 +2983,23 @@ const CHAT_MARKDOWN_COMPONENTS = {
29822983
// keeps the `_blank` the shell already handles; the in-app browser needs
29832984
// the click intercepted here. A modifier click is the way out of the
29842985
// in-app default, so it is left to the shell too.
2986+
if (event.defaultPrevented) return;
29852987
if (
2986-
event.defaultPrevented ||
29872988
resolveLinkTarget({
29882989
url: href,
29892990
event,
29902991
preference: linkTargetPreference,
29912992
canOpenInApp: canOpenInPreview,
29922993
}) !== "app"
29932994
) {
2995+
// Chromium turns an Option/Alt-click into a download that never reaches the
2996+
// shell. On desktop, open the link here while the key is still down, so link
2997+
// routers such as Finicky can still read it.
2998+
if (isElectron && event.altKey) {
2999+
event.preventDefault();
3000+
event.stopPropagation();
3001+
void readLocalApi()?.shell.openExternal(href);
3002+
}
29943003
return;
29953004
}
29963005
event.preventDefault();

0 commit comments

Comments
 (0)