The best way to control Claude Code, Codex and more from any computer or phone
fix(web): open PDF links in the file viewer (#37064)
Yash Singh committed
Nov 15, 2026 at 00:25 UTC
71adeef080d1a6ee03ddd8fc7493ea5928afed89
4 files changed
+29
-15
apps/web/src/components/chat/MarkdownFileLink.logic.test.ts
new
+27
@@ -0,0 +1,27 @@
1
+import { expect, it } from "vite-plus/test";
2
+
3
+import { shouldUseMarkdownFileBrowserPrimaryAction } from "./MarkdownFileLink.logic";
4
+
5
+it("opens PDFs in the file panel and uses the browser only when no other destination exists", () => {
6
+ expect(
7
+ shouldUseMarkdownFileBrowserPrimaryAction({
8
+ canOpenInEditor: true,
9
+ canOpenInBrowser: true,
10
+ canOpenInPanel: true,
11
+ }),
12
+ ).toBe(false);
13
+ expect(
14
+ shouldUseMarkdownFileBrowserPrimaryAction({
15
+ canOpenInEditor: false,
16
+ canOpenInBrowser: true,
17
+ canOpenInPanel: true,
18
+ }),
19
+ ).toBe(false);
20
+ expect(
21
+ shouldUseMarkdownFileBrowserPrimaryAction({
22
+ canOpenInEditor: false,
23
+ canOpenInBrowser: true,
24
+ canOpenInPanel: false,
25
+ }),
26
+ ).toBe(true);
27
+});
apps/web/src/components/chat/MarkdownFileLink.logic.ts
+2
-10
@@ -1,10 +1,7 @@
1
import type { EnvironmentId } from "@t3tools/contracts";
2
import { splitFilePathPosition } from "@t3tools/shared/fileLinks";
3
4
-import {
5
- shouldOpenMarkdownFileLinkInBrowserByDefault,
6
- type MarkdownFileLinkMeta,
7
-} from "../../markdown-links";
4
+import type { MarkdownFileLinkMeta } from "../../markdown-links";
5
import type { RemoteOpenMode } from "../../remoteOpen";
6
7
export function canUseMarkdownFileShellActions(
@@ -49,14 +46,9 @@ export function markdownFileCopyMenuItems({
46
}
47
48
export function shouldUseMarkdownFileBrowserPrimaryAction(input: {
52
- iconPath: string;
49
canOpenInEditor: boolean;
50
canOpenInBrowser: boolean;
51
canOpenInPanel: boolean;
52
}): boolean {
57
- return (
58
- input.canOpenInBrowser &&
59
- (shouldOpenMarkdownFileLinkInBrowserByDefault(input.iconPath) ||
60
- (!input.canOpenInEditor && !input.canOpenInPanel))
61
- );
53
+ return input.canOpenInBrowser && !input.canOpenInEditor && !input.canOpenInPanel;
54
}
apps/web/src/components/chat/MarkdownFileLink.tsx
-1
@@ -315,7 +315,6 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({
315
canOpenMedia: onOpenMedia !== undefined,
316
});
317
const useBrowserPrimaryAction = shouldUseMarkdownFileBrowserPrimaryAction({
318
- iconPath,
318
canOpenInEditor,
319
canOpenInBrowser,
320
canOpenInPanel,
apps/web/src/markdown-links.ts
-4
@@ -31,10 +31,6 @@ export function shouldOpenMarkdownFileLinkInEditor(
31
return isTerminalLinkActivation(event, platform);
32
}
33
34
-export function shouldOpenMarkdownFileLinkInBrowserByDefault(path: string): boolean {
35
- return /\.pdf$/i.test(path.split(/[?#]/, 1)[0] ?? "");
36
-}
37
-
34
export function rewriteMarkdownFileUriHref(href: string | undefined): string | null {
35
if (!href) return null;
36
const target = parseFileUrlHref(normalizeMarkdownLinkDestination(href));