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 21, 11:00 UTC
fix(web): terminal links open bare compiler filenames (#37071)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 15, 2026 at 08:51 UTC
2cb2fa13855e4348d704f7a887027e1124b79037
4 files changed
+94
-4
apps/web/src/terminal-links.test.ts
+17
-3
@@ -83,9 +83,18 @@ describe("extractTerminalLinks", () => {
83
]);
84
});
85
86
- it("does not treat quoted prose as a path", () => {
87
- expect(extractTerminalLinks('error: "something went wrong"')).toEqual([]);
88
- expect(extractTerminalLinks('error: "something went wrong."')).toEqual([]);
86
+ it.each([
87
+ 'error: "something went wrong"',
88
+ 'error: "something went wrong."',
89
+ "see README.md, Node.js v22 on 127.0.0.1:3000",
90
+ "README.md(42,7): see details",
91
+ "main.cs(42,7): error CS1002: expected semicolon",
92
+ "Connecting to api.example.com:443...",
93
+ "dial tcp: lookup db.internal:5432: no such host",
94
+ "redis.local:6379> PING",
95
+ "postgres@db.internal:5432",
96
+ ])("does not treat prose or unsupported locations as a path: %s", (line) => {
97
+ expect(extractTerminalLinks(line)).toEqual([]);
98
});
99
100
it("keeps quoted paths and URLs separate without duplicate partial paths", () => {
@@ -153,6 +162,11 @@ describe("extractTerminalLinks", () => {
162
"src/foo$contact@support.ts:12:3",
163
"node_modules/.pnpm/react@18.3.1/node_modules/react/index.js:12:5",
164
"app/routes/posts.$id.tsx:5",
165
+ "main.c:1:25",
166
+ "page.test.tsx:5:3",
167
+ "foo$bar.ts:12:3",
168
+ "+page.svelte:12:4",
169
+ "contact@support.ts:12:3",
170
])("keeps the complete relative path %s", (text) => {
171
expect(extractTerminalLinks(`see ${text} for details`)).toEqual([
172
{ kind: "path", text, start: 4, end: 4 + text.length },
apps/web/src/terminal-links.ts
+2
-1
@@ -40,8 +40,9 @@ const POWERSHELL_PROMPT_PATH_PATTERN = /^PS ((?:[A-Za-z]:[\\/]|\\\\|\/)[^>\r\n]*
40
// Bare paths start only at a segment boundary: hover detection runs this on
41
// every frame, so separator-free output must not be rescanned at every suffix.
42
// Parenthesized path segments need a following slash to distinguish compiler locations.
43
+// A bare `name.ext` needs `:line:col` or a TS location after it, so prose and `host:port` stay text.
44
const FILE_PATH_PATTERN =
44
- /(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|(?<![\p{L}\p{M}\p{N}._-])[\p{L}\p{M}\p{N}._-]+(?:[\\/](?:[\p{L}\p{M}\p{N}._$+@-]|\[{1,2}[\p{L}\p{M}\p{N}._-]+\]{1,2}|\([\p{L}\p{M}\p{N}._-]+\)(?=[\\/]))+)+(?:(?::\d+){1,2}|\(\d+,\d+\)(?=:\s+(?:error|warning) TS\d+:))?/gu;
45
+ /(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|(?<![\p{L}\p{M}\p{N}._$+@-])[\p{L}\p{M}\p{N}._$+@-]+(?:(?:[\\/](?:[\p{L}\p{M}\p{N}._$+@-]|\[{1,2}[\p{L}\p{M}\p{N}._-]+\]{1,2}|\([\p{L}\p{M}\p{N}._-]+\)(?=[\\/]))+)+|\.\p{L}[\p{L}\p{M}\p{N}_-]*(?=:\d+:\d|\(\d+,\d+\):\s+(?:error|warning) TS\d+:))(?:(?::\d+){1,2}|\(\d+,\d+\)(?=:\s+(?:error|warning) TS\d+:))?/gu;
46
const QUOTED_FILE_PATH_PATTERN =
47
/(["'`])(?<path>(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\|[\p{L}\p{M}\p{N}._ -]+[\\/])[^\r\n]*?|[\p{L}\p{M}\p{N}._ -]+\.[\p{L}\p{M}\p{N}_-]+(?::\d+){0,2})\1(?<position>(?::\d+){0,2})/gu;
48
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
scripts/scenarios/start-app.ts
+7
@@ -63,6 +63,13 @@ export const prepareHome = Effect.fn("startApp.prepareHome")(function* (home: st
63
yield* fs.writeFileString(shim, HOST_LABEL_SHIM);
64
yield* fs.chmod(shim, 0o755);
65
}
66
+ // Editor discovery is cached, so the recording shim must exist before the server starts.
67
+ const editor = path.join(home, "bin", "cursor");
68
+ yield* fs.writeFileString(
69
+ editor,
70
+ `#!/bin/sh\nprintf '%s\\n' "$@" > "$(dirname "$0")/../editor-args.txt"\n`,
71
+ );
72
+ yield* fs.chmod(editor, 0o755);
73
const noModel = path.join(home, "bin/no-model");
74
yield* fs.writeFileString(noModel, "#!/bin/sh\necho 'scenarios run no model' >&2\nexit 1\n");
75
yield* fs.chmod(noModel, 0o755);
scripts/scenarios/terminal-bare-filename-opens-its-location.e2e.ts
new
+68
@@ -0,0 +1,68 @@
1
+/// <reference lib="dom" />
2
+// The DOM lib types the function this scenario runs in the page.
3
+import { expect } from "e2e";
4
+import * as Effect from "effect/Effect";
5
+import * as FileSystem from "effect/FileSystem";
6
+
7
+import { T3_HOME } from "../e2e.config.ts";
8
+import { runPromise, test, WEB } from "./t3.ts";
9
+
10
+// gcc prints a file compiled from its own folder by bare name.
11
+const DIAGNOSTIC = "main.c:1:25: error: 'missing' undeclared";
12
+const EDITOR_ARGS = `${T3_HOME}/editor-args.txt`;
13
+
14
+/** The file's lines, or none while it does not exist. */
15
+const readLines = (file: string) =>
16
+ runPromise(
17
+ Effect.gen(function* () {
18
+ const fs = yield* FileSystem.FileSystem;
19
+ if (!(yield* fs.exists(file))) return [];
20
+ return (yield* fs.readFileString(file)).trim().split("\n");
21
+ }),
22
+ );
23
+
24
+test(
25
+ "Ctrl+click on a bare compiler filename in the terminal opens that file at its line and column",
26
+ WEB,
27
+ async ({ t3, app, browser, screen }) => {
28
+ await runPromise(
29
+ Effect.flatMap(FileSystem.FileSystem, (fs) => fs.remove(EDITOR_ARGS, { force: true })),
30
+ );
31
+ const project = await t3.project("demo", {
32
+ "main.c": "int main(void) { return missing; }\n",
33
+ // Enough rows that the middle of the terminal shows the diagnostic, whatever its height.
34
+ "build.log": `${DIAGNOSTIC}\n`.repeat(200),
35
+ });
36
+ const thread = await t3.thread({ project, title: "Build", messages: ["Build it"] });
37
+ await t3.open(thread);
38
+
39
+ await screen.getByRole("button", "Toggle terminal drawer").tap();
40
+ const input = screen.getByRole("textbox", "Terminal input");
41
+ // The input mounts before fonts and WASM finish loading and its handlers are installed.
42
+ await expect(input).toHaveAttribute("data-workspace-focus-default", "");
43
+ await input.focus();
44
+ await browser.keyboard.type("cat build.log; touch cat.done\n");
45
+ await expect.poll(() => readLines(`${project}/cat.done`), { timeout: 30_000 }).toEqual([""]);
46
+ await app.screenshot("diagnostic-printed");
47
+
48
+ // The terminal draws on a canvas, so point at the first cells of its middle row.
49
+ const canvas = await browser.evaluate(() => {
50
+ const box = document
51
+ .querySelector('[aria-label="Terminal input"]')
52
+ ?.parentElement?.querySelector("canvas")
53
+ ?.getBoundingClientRect();
54
+ return box ? { x: box.x, y: box.y, width: box.width, height: box.height } : null;
55
+ });
56
+ if (!canvas) throw new Error("The terminal canvas is not on the page.");
57
+ await browser.mouse.move(canvas.x + 16, canvas.y + canvas.height / 2);
58
+ await browser.keyboard.down("Control");
59
+ await browser.mouse.down();
60
+ await browser.mouse.up();
61
+ await browser.keyboard.up("Control");
62
+ await app.screenshot("after-ctrl-click");
63
+
64
+ await expect
65
+ .poll(() => readLines(EDITOR_ARGS), { timeout: 15_000 })
66
+ .toEqual(["--classic", "--goto", `${project}/main.c:1:25`]);
67
+ },
68
+);