The best way to control Claude Code, Codex and more from any computer or phone
fix(web): make terminal links appear clickable only when clickable (#7488)
oliver committed
Aug 24, 2026 at 14:32 UTC
883e1a3cd9d70f6906a8eb1458a7a05d1d9e0d55
5 files changed
+28
-23
apps/web/src/components/ThreadTerminalDrawer.tsx
+2
-2
@@ -43,7 +43,7 @@ import {
43
} from "~/terminal/ghostty/surface";
44
import { type GhosttyColor, type GhosttyTheme } from "~/terminal/ghostty/core";
45
import { useOpenInPreferredEditor } from "../editorPreferences";
46
-import { isTerminalLinkActivation, resolvePathLinkTarget } from "../terminal-links";
46
+import { isTerminalLinkActivation, isTerminalUrl, resolvePathLinkTarget } from "../terminal-links";
47
import {
48
isDiffToggleShortcut,
49
isTerminalClearShortcut,
@@ -750,7 +750,7 @@ export function TerminalViewport({
750
if (!isTerminalLinkActivation(event)) return;
751
const latestTerminal = terminalRef.current;
752
if (!latestTerminal) return;
753
- if (/^https?:\/\//u.test(text)) {
753
+ if (isTerminalUrl(text)) {
754
if (!localApi) {
755
writeSystemMessage(latestTerminal, "Opening links is unavailable in this browser.");
756
return;
apps/web/src/terminal-links.test.ts
+19
@@ -4,6 +4,7 @@ import {
4
collectWrappedTerminalLinkLine,
5
extractTerminalLinks,
6
isTerminalLinkActivation,
7
+ isTerminalUrl,
8
resolvePathLinkTarget,
9
resolveWrappedTerminalLinkRange,
10
wrappedTerminalLinkRangeIntersectsBufferLine,
@@ -37,6 +38,24 @@ describe("extractTerminalLinks", () => {
38
]);
39
});
40
41
+ it("classifies uppercase schemes as URLs at activation time too", () => {
42
+ expect(isTerminalUrl("HTTPS://example.com/docs")).toBe(true);
43
+ expect(isTerminalUrl("Http://example.com")).toBe(true);
44
+ expect(isTerminalUrl("src/components/main.ts")).toBe(false);
45
+ expect(isTerminalUrl("httpsdocs/readme.md")).toBe(false);
46
+ });
47
+
48
+ it("finds URLs regardless of scheme casing", () => {
49
+ expect(extractTerminalLinks("open HTTPS://example.com/docs")).toEqual([
50
+ {
51
+ kind: "url",
52
+ text: "HTTPS://example.com/docs",
53
+ start: 5,
54
+ end: 29,
55
+ },
56
+ ]);
57
+ });
58
+
59
it("trims trailing punctuation from links", () => {
60
const line = "(https://example.com/docs), ./src/main.ts:12.";
61
expect(extractTerminalLinks(line)).toEqual([
apps/web/src/terminal-links.ts
+6
-2
@@ -36,7 +36,7 @@ export interface WrappedTerminalLinkLine {
36
segments: ReadonlyArray<WrappedTerminalLinkLineSegment>;
37
}
38
39
-const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/g;
39
+const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/giu;
40
const FILE_PATH_PATTERN =
41
/(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
42
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
@@ -80,7 +80,7 @@ function collectMatches(
80
81
const trimmed = trimClosingDelimiters(raw);
82
if (trimmed.length === 0) continue;
83
- if (kind === "path" && /^https?:\/\//i.test(trimmed)) continue;
83
+ if (kind === "path" && isTerminalUrl(trimmed)) continue;
84
85
const candidate: TerminalLinkMatch = {
86
kind,
@@ -172,6 +172,10 @@ export function extractTerminalLinks(line: string): TerminalLinkMatch[] {
172
return [...urlMatches, ...pathMatches].toSorted((a, b) => a.start - b.start);
173
}
174
175
+export function isTerminalUrl(value: string): boolean {
176
+ return /^https?:\/\//iu.test(value);
177
+}
178
+
179
export function collectWrappedTerminalLinkLine(
180
bufferLineNumber: number,
181
getLine: (bufferLineIndex: number) => TerminalBufferLineLike | null | undefined,
apps/web/src/terminal/ghostty/surface.test.ts
-8
@@ -20,7 +20,6 @@ import {
20
resolveTerminalMouseTrackingState,
21
shouldBlinkTerminalCursor,
22
shouldReportTerminalMouse,
23
- shouldShowTerminalLinkHover,
23
terminalGridCellAt,
24
terminalScrollbarGeometry,
25
terminalScrollbarOffsetAtPointer,
@@ -438,13 +437,6 @@ describe("application mouse reporting", () => {
437
motionData: "\u001b[<35;8;4M",
438
});
439
});
441
-
442
- it("only shows link hover during mouse tracking when the link modifier is held", () => {
443
- expect(shouldShowTerminalLinkHover(false, false)).toBe(true);
444
- expect(shouldShowTerminalLinkHover(false, true)).toBe(true);
445
- expect(shouldShowTerminalLinkHover(true, false)).toBe(false);
446
- expect(shouldShowTerminalLinkHover(true, true)).toBe(true);
447
- });
440
});
441
442
describe("terminal font resolution", () => {
apps/web/src/terminal/ghostty/surface.ts
+1
-11
@@ -483,13 +483,6 @@ export function isTerminalLinkPointerGesture(
483
: event.ctrlKey && !event.metaKey;
484
}
485
486
-export function shouldShowTerminalLinkHover(
487
- mouseTracking: boolean,
488
- linkModifierActive: boolean,
489
-): boolean {
490
- return !mouseTracking || linkModifierActive;
491
-}
492
-
486
export function ghosttyMouseButton(button: number): number | null {
487
switch (button) {
488
case 0:
@@ -1409,10 +1402,7 @@ export class GhosttyTerminalSurface {
1402
1403
private refreshHoveredLink(): void {
1404
const pointer = this.hoverPointer;
1412
- const link =
1413
- pointer && shouldShowTerminalLinkHover(this.core.isMouseTracking(), this.linkModifierActive)
1414
- ? this.linkAt(pointer.x, pointer.y)
1415
- : null;
1405
+ const link = pointer && this.linkModifierActive ? this.linkAt(pointer.x, pointer.y) : null;
1406
this.setHoveredLink(link);
1407
}
1408