@devries-cameron20 / t3code-1 / commits / 10b86829e8
Fork 0

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

fix(web): clicking a logged request route no longer opens it in the editor (#15838)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Lars Nieuwenhuis committed Oct 19, 2026 at 20:13 UTC 10b86829e8f2e1e718f6cc6e76a1a01a66d25b2c
2 files changed +43 -1
apps/web/src/terminal-links.test.ts
+31
@@ -171,6 +171,37 @@ describe("extractTerminalLinks", () => {
171 { kind: "path", text, start, end: start + text.length },
172 ]);
173 });
174 +
175 + it.each([
176 + " GET /api/trpc/post.list,user.me?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%7D%7D 200 in 35ms",
177 + "GET /api?+debug 200",
178 + 'Started GET "/posts?page=2" for ::1',
179 + "proxying api/trpc/post.list?batch=1 to the backend",
180 + ])("does not turn a logged request route into an editor link: %s", (line) => {
181 + expect(extractTerminalLinks(line)).toEqual([]);
182 + });
183 +
184 + it("keeps file and URL links before and after a logged request route", () => {
185 + const before = "src/server.ts:12";
186 + const after = "/app/bin/server:3:7";
187 + const url = "https://example.com/api/users?id=42";
188 + const line = `${before} GET /api/users?id=42 200 ${after} ${url}`;
189 + const afterStart = line.indexOf(after);
190 + const urlStart = line.indexOf(url);
191 +
192 + expect(extractTerminalLinks(line)).toEqual([
193 + { kind: "path", text: before, start: 0, end: before.length },
194 + { kind: "path", text: after, start: afterStart, end: afterStart + after.length },
195 + { kind: "url", text: url, start: urlStart, end: urlStart + url.length },
196 + ]);
197 + });
198 +
199 + it("keeps a question mark inside a filesystem path", () => {
200 + const path = "/tmp/report?draft";
201 + expect(extractTerminalLinks(`wrote ${path}`)).toEqual([
202 + { kind: "path", text: path, start: 6, end: 6 + path.length },
203 + ]);
204 + });
205 });
206
207 describe("collectWrappedTerminalLinkLine", () => {
apps/web/src/terminal-links.ts
+12 -1
@@ -34,6 +34,9 @@ const QUOTED_FILE_PATH_PATTERN =
34 const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
35 // Paths also drop a trailing colon: compilers end `file:line:col:` with one.
36 const TRAILING_PATH_PUNCTUATION_PATTERN = /[.,;:!?]+$/;
37 +// A question mark is legal in filenames; only exclude query-bearing request targets.
38 +const REQUEST_ROUTE_PATTERN =
39 + /(?:^|[\s"'`])(?:GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS|CONNECT|TRACE|proxying)\s+["'`]?(?:\/|[A-Za-z0-9_-]+\/)[^\s?]*\?\S*/g;
40
41 function trimClosingDelimiters(value: string, kind: TerminalLinkKind): string {
42 let output = value.replace(
@@ -99,13 +102,21 @@ function collectMatches(
102 }
103
104 export function extractTerminalLinks(line: string): TerminalLinkMatch[] {
105 + const requestRoutes = Array.from(line.matchAll(REQUEST_ROUTE_PATTERN), (match) => ({
106 + start: match.index,
107 + end: match.index + match[0].length,
108 + }));
109 const urlMatches = collectMatches(line, "url", URL_PATTERN, []);
110 const quotedMatches = collectMatches(line, "path", QUOTED_FILE_PATH_PATTERN, urlMatches);
111 const pathMatches = collectMatches(line, "path", FILE_PATH_PATTERN, [
112 ...urlMatches,
113 ...quotedMatches,
114 ]);
108 - return [...urlMatches, ...quotedMatches, ...pathMatches].toSorted((a, b) => a.start - b.start);
115 + return [...urlMatches, ...quotedMatches, ...pathMatches]
116 + .filter(
117 + (match) => match.kind === "url" || !requestRoutes.some((route) => overlaps(match, route)),
118 + )
119 + .toSorted((a, b) => a.start - b.start);
120 }
121
122 export function isTerminalUrl(value: string): boolean {