Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): linkify Windows C:/ paths in terminal output (#1483)

Maansen48196e67a73f
diff --git a/apps/web/src/terminal-links.test.ts b/apps/web/src/terminal-links.test.ts
index 1e5fb3940..db0544fce 100644
--- a/apps/web/src/terminal-links.test.ts
+++ b/apps/web/src/terminal-links.test.ts
@@ -43,6 +43,32 @@ describe("extractTerminalLinks", () => {
},
]);
});
+
+ it("finds Windows absolute paths with forward slashes", () => {
+ const line = "see C:/Users/someone/project/src/file.ts:42 for details";
+ const path = "C:/Users/someone/project/src/file.ts:42";
+ const start = line.indexOf(path);
+ expect(extractTerminalLinks(line)).toEqual([
+ {
+ kind: "path",
+ text: path,
+ start,
+ end: start + path.length,
+ },
+ ]);
+ });
+
+ it("trims trailing punctuation from Windows forward-slash paths", () => {
+ const line = "(C:/tmp/x.ts).";
+ expect(extractTerminalLinks(line)).toEqual([
+ {
+ kind: "path",
+ text: "C:/tmp/x.ts",
+ start: 1,
+ end: 12,
+ },
+ ]);
+ });
});
describe("resolvePathLinkTarget", () => {
@@ -60,6 +86,12 @@ describe("resolvePathLinkTarget", () => {
resolvePathLinkTarget("/Users/julius/project/src/main.ts:12", "/Users/julius/project"),
).toBe("/Users/julius/project/src/main.ts:12");
});
+
+ it("keeps Windows absolute paths with forward slashes unchanged", () => {
+ expect(
+ resolvePathLinkTarget("C:/Users/julius/project/src/main.ts:12", "C:\\Users\\julius\\project"),
+ ).toBe("C:/Users/julius/project/src/main.ts:12");
+ });
});
describe("isTerminalLinkActivation", () => {
diff --git a/apps/web/src/terminal-links.ts b/apps/web/src/terminal-links.ts
index 1119fc908..e07904e18 100644
--- a/apps/web/src/terminal-links.ts
+++ b/apps/web/src/terminal-links.ts
@@ -11,7 +11,7 @@ export interface TerminalLinkMatch {
const URL_PATTERN = /https?:\/\/[^\s"'`<>]+/g;
const FILE_PATH_PATTERN =
- /(?:~\/|\.{1,2}\/|\/|[A-Za-z]:\\|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
+ /(?:~\/|\.{1,2}\/|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}/g;
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
function trimClosingDelimiters(value: string): string {
diff --git a/apps/web/src/wsTransport.test.ts b/apps/web/src/wsTransport.test.ts
index e66ed7fc0..c9b963286 100644
--- a/apps/web/src/wsTransport.test.ts
+++ b/apps/web/src/wsTransport.test.ts
@@ -175,7 +175,7 @@ describe("WsTransport", () => {
expect(warnSpy).toHaveBeenNthCalledWith(
1,
"Dropped inbound WebSocket envelope",
- "SyntaxError: Expected property name or '}' in JSON at position 2 (line 1 column 3)",
+ expect.stringMatching(/^SyntaxError:/),
);
expect(warnSpy).toHaveBeenNthCalledWith(
2,