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, 19:45 UTC
fix(web): SCP-style Git remotes no longer become terminal file links (#35404)
Julius Marminge committed
Nov 12, 2026 at 09:34 UTC
a2685e64d34945bed0f6317b48b38ef57a7cb558
2 files changed
+22
-1
apps/web/src/terminal-links.test.ts
+11
@@ -64,6 +64,10 @@ describe("extractTerminalLinks", () => {
64
expect(extractTerminalLinks(`see ${quote}${text}${quote}.`)).toEqual([
65
{ kind: "path", text, start: 5, end: 5 + text.length },
66
]);
67
+ const atText = "src/my contact@support.vue:12:3";
68
+ expect(extractTerminalLinks(`see ${quote}${atText}${quote}.`)).toEqual([
69
+ { kind: "path", text: atText, start: 5, end: 5 + atText.length },
70
+ ]);
71
});
72
73
it.each([
@@ -127,6 +131,11 @@ describe("extractTerminalLinks", () => {
131
"src/𐐀.ts:12",
132
"src/app/[id]/page.tsx:3:10",
133
"src/routes/(app)/+page.svelte:12:4",
134
+ "src/routes/(app)/+page@.svelte:12:3",
135
+ "src/contact@support.vue:12:3",
136
+ String.raw`src\contact@support.ts:12:3`,
137
+ "src/équipe@home.ts:12:3",
138
+ "src/foo$contact@support.ts:12:3",
139
"node_modules/.pnpm/react@18.3.1/node_modules/react/index.js:12:5",
140
"app/routes/posts.$id.tsx:5",
141
])("keeps the complete relative path %s", (text) => {
@@ -198,6 +207,8 @@ describe("extractTerminalLinks", () => {
207
" at main (file:///Users/jane/app/src/index.mjs:3:7)",
208
"+redis://localhost:6379/0",
209
"-redis://localhost:6379/0",
210
+ "git clone git@github.com:acme/widgets.git",
211
+ "remote: git@gitlab.com:group/sub/project.git",
212
])("does not turn part of a non-web URL into an editor link: %s", (line) => {
213
expect(extractTerminalLinks(line)).toEqual([]);
214
});
apps/web/src/terminal-links.ts
+11
-1
@@ -46,6 +46,9 @@ const REQUEST_ROUTE_PATTERN =
46
// The tail of `redis://host/0` or `file:///a.mjs` is not a path. One-letter schemes stay drives,
47
// a diff's `+` or `-` may lead, and the lookbehind keeps runs from being rescanned at every suffix.
48
const SCHEME_URL_PATTERN = /(?<![A-Za-z\d+.-])[+-]?[A-Za-z][A-Za-z\d+.-]+:\/\/[^\s"'`<>]+/gu;
49
+// Nor is the tail of an SCP-style Git remote such as `git@github.com:acme/widgets.git`. Only a
50
+// path wholly inside the tail is dropped, so `src/contact@support.vue:12:3` keeps its link.
51
+const SCP_REMOTE_PATTERN = /(?<![\w.@-])[\w.-]+@[\w.-]+:[^\s"'`<>]+/gu;
52
53
function trimClosingDelimiters(value: string, kind: TerminalLinkKind): string {
54
let output = value.replace(
@@ -119,6 +122,10 @@ export function extractTerminalLinks(line: string): TerminalLinkMatch[] {
122
[...line.matchAll(REQUEST_ROUTE_PATTERN), ...line.matchAll(SCHEME_URL_PATTERN)],
123
(match) => ({ start: match.index, end: match.index + match[0].length }),
124
);
125
+ const remoteTails = Array.from(line.matchAll(SCP_REMOTE_PATTERN), (match) => ({
126
+ start: match.index + match[0].indexOf(":") + 1,
127
+ end: match.index + match[0].length,
128
+ }));
129
const urlMatches = collectMatches(line, "url", URL_PATTERN, promptMatches);
130
const quotedMatches = collectMatches(line, "path", QUOTED_FILE_PATH_PATTERN, [
131
...promptMatches,
@@ -131,7 +138,10 @@ export function extractTerminalLinks(line: string): TerminalLinkMatch[] {
138
]);
139
return [...promptMatches, ...urlMatches, ...quotedMatches, ...pathMatches]
140
.filter(
134
- (match) => match.kind === "url" || !nonPathRanges.some((range) => overlaps(match, range)),
141
+ (match) =>
142
+ match.kind === "url" ||
143
+ (!nonPathRanges.some((range) => overlaps(match, range)) &&
144
+ !remoteTails.some((tail) => match.start >= tail.start && match.end <= tail.end)),
145
)
146
.toSorted((a, b) => a.start - b.start);
147
}