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): linkify rendered inline-code file paths
vastsae5e881b84b83
diff --cc apps/desktop/src/lib/chat-links.tsindex 47e932076,6d9b87f13..d2c412d87--- a/apps/desktop/src/lib/chat-links.ts+++ b/apps/desktop/src/lib/chat-links.ts@@@ -383,6 -382,28 +382,34 @@@ export function linkifyMdastTreeconst next: MdastNode[] = [];for (const child of node.children) {if (!child || typeof child.type !== "string") continue;+ 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). 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) {++ const url =++ target.kind === "url"++ ? target.url++ : /^[A-Za-z]:[\\/]/.test(target.path) || target.path.startsWith("\\\\")++ ? encodeURIComponent(target.path)++ : target.path;+ next.push({+ type: "link",- url: target.kind === "url" ? target.url : target.path,++ url,+ children: [child],+ });+ continue;+ }+ }if (!nextSkip && child.type === "text" && typeof child.value === "string") {const segments = splitChatText(child.value, root, baseDir);if (segments.length === 1 && segments[0].kind === "text") {diff --cc apps/desktop/test/chat-links.test.mjsindex 7846e6616,b76e5f99a..b9de2110c--- a/apps/desktop/test/chat-links.test.mjs+++ b/apps/desktop/test/chat-links.test.mjs@@@ -496,8 -497,30 +497,45 @@@ test("linkifyMdastTree turns bare pathlinkifyMdastTree(tree, ROOT);assert.equal(tree.children[0].children[1].type, "link");assert.equal(tree.children[0].children[1].url, "apps/desktop/src/App.tsx");- assert.equal(tree.children[1].type, "inlineCode");- assert.equal(tree.children[2].children[0].type, "text");+ // A resolvable inline-code path becomes a link whose child stays inline code (#1169).+ 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");+ // 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");+ });++ test("linkifyMdastTree links a spaced Windows path in inline code (#1169)", () => {+ const tree = {+ type: "root",+ children: [+ {+ type: "paragraph",+ children: [{ type: "inlineCode", value: "C:/demo project/readme.md" }],+ },+ ],+ };+ // The issue's workspace root is the spaced directory itself, so the+ // 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, "C:/demo project/readme.md");++ assert.equal(++ tree.children[0].children[0].url,++ encodeURIComponent("C:/demo project/readme.md"),++ );++++ const markup = renderToStaticMarkup(++ React.createElement(ReactMarkdown, {++ remarkPlugins: [remarkChatFileLinks("C:\\demo project")],++ children: "`C:/demo project/readme.md`",++ }),++ );++ assert.ok(++ markup.includes(++ '<a href="C%3A%2Fdemo%20project%2Freadme.md"><code>C:/demo project/readme.md</code></a>',++ ),++ );});test("linkifyMdastTree ignores a missing tree instead of reading type", () => {