@devries-cameron20 / t3code Mirror · read-only / commits / 8bc9b78f82
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 21:45 UTC

fix(web): terminal links drop a trailing colon (#13408)

ValeraZSD committed Sep 26, 2026 at 09:12 UTC 8bc9b78f827072a89707f6e4b577710e27263697
2 files changed +34 -4
apps/web/src/terminal-links.test.ts
+25
@@ -97,6 +97,24 @@ describe("extractTerminalLinks", () => {
97 },
98 ]);
99 });
100 +
101 + it("keeps a trailing colon on URLs", () => {
102 + expect(extractTerminalLinks("GET https://example.test/items/foo:")).toEqual([
103 + { kind: "url", text: "https://example.test/items/foo:", start: 4, end: 35 },
104 + ]);
105 + });
106 +
107 + it.each([
108 + ["./main.go:10:5: undefined: x", "./main.go:10:5"],
109 + ["/home/dev/app/src/main.c:10:5: error: expected ';'", "/home/dev/app/src/main.c:10:5"],
110 + ["C:\\dev\\app\\src\\main.c:10:5: error: expected ';'", "C:\\dev\\app\\src\\main.c:10:5"],
111 + ["wrote ./out/report.txt:", "./out/report.txt"],
112 + ])("drops the colon that ends a compiler diagnostic location in %s", (line, text) => {
113 + const start = line.indexOf(text);
114 + expect(extractTerminalLinks(line)).toEqual([
115 + { kind: "path", text, start, end: start + text.length },
116 + ]);
117 + });
118 });
119
120 describe("collectWrappedTerminalLinkLine", () => {
@@ -173,6 +191,13 @@ describe("resolvePathLinkTarget", () => {
191 resolvePathLinkTarget("C:/Users/julius/project/src/main.ts:12", "C:\\Users\\julius\\project"),
192 ).toBe("C:/Users/julius/project/src/main.ts:12");
193 });
194 +
195 + it("keeps the line and column of a compiler diagnostic", () => {
196 + const [link] = extractTerminalLinks("/Users/julius/project/main.c:10:5: error: expected ';'");
197 + expect(resolvePathLinkTarget(link?.text ?? "", "/Users/julius/project")).toBe(
198 + "/Users/julius/project/main.c:10:5",
199 + );
200 + });
201 });
202
203 describe("isTerminalLinkActivation", () => {
apps/web/src/terminal-links.ts
+9 -4
@@ -35,9 +35,14 @@ const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/giu;
35 const FILE_PATH_PATTERN =
36 /(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
37 const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
38 -
39 -function trimClosingDelimiters(value: string): string {
40 - let output = value.replace(TRAILING_PUNCTUATION_PATTERN, "");
38 +// Paths also drop a trailing colon: compilers end `file:line:col:` with one.
39 +const TRAILING_PATH_PUNCTUATION_PATTERN = /[.,;:!?]+$/;
40 +
41 +function trimClosingDelimiters(value: string, kind: TerminalLinkKind): string {
42 + let output = value.replace(
43 + kind === "path" ? TRAILING_PATH_PUNCTUATION_PATTERN : TRAILING_PUNCTUATION_PATTERN,
44 + "",
45 + );
46 if (output.length === 0) return output;
47
48 const trimUnbalanced = (open: string, close: string) => {
@@ -73,7 +78,7 @@ function collectMatches(
78 const start = rawMatch.index ?? -1;
79 if (start < 0 || raw.length === 0) continue;
80
76 - const trimmed = trimClosingDelimiters(raw);
81 + const trimmed = trimClosingDelimiters(raw, kind);
82 if (trimmed.length === 0) continue;
83 if (kind === "path" && isTerminalUrl(trimmed)) continue;
84