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 resolvable inline-code file paths (#1169)
yexisu1dfcb291c28b
diff --git a/apps/desktop/src/lib/chat-links.ts b/apps/desktop/src/lib/chat-links.tsindex 47e932076..2a0ad1aa0 100644--- a/apps/desktop/src/lib/chat-links.ts+++ b/apps/desktop/src/lib/chat-links.ts@@ -357,7 +357,6 @@ export type MdastNode = {const SKIP_MDAST = new Set(["code",- "inlineCode","link","image","definition",@@ -383,6 +382,20 @@ export function linkifyMdastTree(const 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).+ const target = resolvePreviewTarget(child.value, root, baseDir);+ if (target) {+ next.push({+ type: "link",+ url: target.kind === "url" ? target.url : target.path,+ 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 --git a/apps/desktop/test/chat-links.test.mjs b/apps/desktop/test/chat-links.test.mjsindex 7846e6616..a1bbb7eda 100644--- a/apps/desktop/test/chat-links.test.mjs+++ b/apps/desktop/test/chat-links.test.mjs@@ -477,7 +477,7 @@ test("splitChatText turns composer @paths into leaf-name chips", () => {assert.equal(files[2].label, "uuid-photo.png");});-test("linkifyMdastTree turns bare paths into links and skips code", () => {+test("linkifyMdastTree turns bare paths and resolvable inline code into links", () => {const tree = {type: "root",children: [@@ -486,6 +486,7 @@ test("linkifyMdastTree turns bare paths into links and skips code", () => {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: "link",url: "https://example.com",@@ -496,8 +497,30 @@ test("linkifyMdastTree turns bare paths into links and skips code", () => {linkifyMdastTree(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");+ // An unresolvable code run 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; a foreign drive stays plain text.+ linkifyMdastTree(tree, "C:\\demo project");+ assert.equal(tree.children[0].children[0].type, "link");+ assert.equal(tree.children[0].children[0].url, "readme.md");});test("linkifyMdastTree ignores a missing tree instead of reading type", () => {