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 22, 23:15 UTC
fix(web): terminal links keep Unicode file paths intact (#20264)
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Maciek Geneja committed
Oct 20, 2026 at 05:19 UTC
9ac1355e01efd84c0aded502b44b41b24ebb4130
2 files changed
+17
-2
apps/web/src/terminal-links.test.ts
+13
@@ -58,6 +58,7 @@ describe("extractTerminalLinks", () => {
58
['"my file.ts":12:7', "my file.ts:12:7", 17],
59
["'my file.ts:12:7'", "my file.ts:12:7", 16],
60
["`my file.ts`", "my file.ts", 11],
61
+ ['"mój plik.ts":12', "mój plik.ts:12", 16],
62
])("finds a quoted basename in %s", (line, text, end) => {
63
expect(extractTerminalLinks(line)).toEqual([{ kind: "path", text, start: 1, end }]);
64
});
@@ -128,6 +129,18 @@ describe("extractTerminalLinks", () => {
129
]);
130
});
131
132
+ it.each([
133
+ "src/żółć.ts:12:7",
134
+ "żółć/main.ts:12",
135
+ String.raw`żółć\main.ts:12`,
136
+ "src/cafe\u0301.ts:12",
137
+ "src/𐐀.ts:12",
138
+ ])("keeps the complete Unicode relative path %s", (text) => {
139
+ expect(extractTerminalLinks(`see ${text} for details`)).toEqual([
140
+ { kind: "path", text, start: 4, end: 4 + text.length },
141
+ ]);
142
+ });
143
+
144
it("finds Windows absolute paths with forward slashes", () => {
145
const line = "see C:/Users/someone/project/src/file.ts:42 for details";
146
const path = "C:/Users/someone/project/src/file.ts:42";
apps/web/src/terminal-links.ts
+4
-2
@@ -27,10 +27,12 @@ export interface WrappedTerminalLinkLine {
27
}
28
29
const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/giu;
30
+// Bare paths start only at a segment boundary: hover detection runs this on
31
+// every frame, so separator-free output must not be rescanned at every suffix.
32
const FILE_PATH_PATTERN =
31
- /(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:[\\/][A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
33
+ /(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|(?<![\p{L}\p{M}\p{N}._-])[\p{L}\p{M}\p{N}._-]+(?:[\\/][\p{L}\p{M}\p{N}._-]+)+(?::\d+){0,2}/gu;
34
const QUOTED_FILE_PATH_PATTERN =
33
- /(["'`])(?<path>(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\|[A-Za-z0-9._ -]+[\\/])[^\r\n]*?|[A-Za-z0-9._ -]+\.[A-Za-z0-9_-]+(?::\d+){0,2})\1(?<position>(?::\d+){0,2})/g;
35
+ /(["'`])(?<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;
36
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
37
// Paths also drop a trailing colon: compilers end `file:line:col:` with one.
38
const TRAILING_PATH_PUNCTUATION_PATTERN = /[.,;:!?]+$/;