Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): gate inline-code linkification to path-like tokens
yexisu2f7066d7091b
diff --git a/apps/desktop/src/lib/chat-links.ts b/apps/desktop/src/lib/chat-links.tsindex 2a0ad1aa0..6d9b87f13 100644--- a/apps/desktop/src/lib/chat-links.ts+++ b/apps/desktop/src/lib/chat-links.ts@@ -385,8 +385,16 @@ export function linkifyMdastTree(if (!nextSkip && child.type === "inlineCode" && typeof child.value === "string") {// The reported path in #1169 arrives as inline code; a code run that// resolves to a real file reference becomes a link (styled inline- // code stays intact via the renderer's own code handling).- const target = resolvePreviewTarget(child.value, root, baseDir);+ // code stays intact via the renderer's own code handling). A spaced+ // token must still look path-like the way the text scanner demands —+ // absolute or drive-letter anchored — so ordinary prose code runs+ // never turn into chips.+ const value = child.value.trim();+ const spacedPathLike = /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("/") || value.startsWith("~/");+ const target =+ spacedPathLike || !value.includes(" ")+ ? resolvePreviewTarget(value, root, baseDir)+ : null;if (target) {next.push({type: "link",diff --git a/apps/desktop/test/chat-links.test.mjs b/apps/desktop/test/chat-links.test.mjsindex a1bbb7eda..b76e5f99a 100644--- a/apps/desktop/test/chat-links.test.mjs+++ b/apps/desktop/test/chat-links.test.mjs@@ -486,7 +486,7 @@ test("linkifyMdastTree turns bare paths and resolvable inline code into links",children: [{ type: "text", value: "See apps/desktop/src/App.tsx please" }],},{ type: "inlineCode", value: "apps/desktop/src/App.tsx" },- { type: "inlineCode", value: "not a real file at all.txt" },+ { type: "inlineCode", value: "some ordinary prose here" },{type: "link",url: "https://example.com",@@ -501,7 +501,7 @@ test("linkifyMdastTree turns bare paths and resolvable inline code into links",assert.equal(tree.children[1].type, "link");assert.equal(tree.children[1].url, "apps/desktop/src/App.tsx");assert.equal(tree.children[1].children[0].type, "inlineCode");- // An unresolvable code run stays plain inline code.+ // A spaced prose code run is not path-like and stays plain inline code.assert.equal(tree.children[2].type, "inlineCode");assert.equal(tree.children[3].children[0].type, "text");});@@ -517,10 +517,10 @@ test("linkifyMdastTree links a spaced Windows path in inline code (#1169)", () =],};// The issue's workspace root is the spaced directory itself, so the- // reference resolves under it; a foreign drive stays plain text.+ // reference resolves under it; the link keeps the full source path.linkifyMdastTree(tree, "C:\\demo project");assert.equal(tree.children[0].children[0].type, "link");- assert.equal(tree.children[0].children[0].url, "readme.md");+ assert.equal(tree.children[0].children[0].url, "C:/demo project/readme.md");});test("linkifyMdastTree ignores a missing tree instead of reading type", () => {