Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(chat): show a transcript file reference in its folder
vastsa8d153dc3bbbd
diff --git a/apps/desktop/src/hooks/use-chat-file-menu.tsx b/apps/desktop/src/hooks/use-chat-file-menu.tsxindex a9d85f5d2..9a72bb363 100644--- a/apps/desktop/src/hooks/use-chat-file-menu.tsx+++ b/apps/desktop/src/hooks/use-chat-file-menu.tsx@@ -2,9 +2,10 @@* The right-click action every file reference in the conversation shares.** HTML references expose explicit open destinations in the context menu: the- * bundled File Manager, built-in browser, and default browser. Each destination- * goes through the same resolver as a normal click, so a reference that resolves- * to nothing cannot open a lookalike somewhere else.+ * bundled File Manager, built-in browser, and default browser. Every local+ * reference can also be shown in its folder in the system file manager. Each+ * action goes through the same resolver as a normal click, so a reference that+ * resolves to nothing cannot open or reveal a lookalike somewhere else.** Items are data, exactly as `ContextMenu` takes them: every surface keeps the* menu instance it already owns and shares only this vocabulary, so a row that@@ -26,6 +27,7 @@ import { useChatNativeFilesAllowed } from "./use-chat-session-capability";import {useCopyChatFileRef,useOpenChatFileRef,+ useRevealChatFileRef,} from "./use-preview-target";export type ChatFileMenuTarget = {@@ -39,6 +41,7 @@ export function useChatFileMenuItems() {const { t } = useTranslation();const nativeFilesAllowed = useChatNativeFilesAllowed();const openFileRef = useOpenChatFileRef();+ const revealFileRef = useRevealChatFileRef();const copyFileRef = useCopyChatFileRef();return useCallback(({ path, baseDir }: ChatFileMenuTarget): ContextMenuItem[] => [@@ -78,11 +81,19 @@ export function useChatFileMenuItems() {],}]: []),+ ...(nativeFilesAllowed+ ? [{+ id: "reveal-in-folder",+ label: t("chat.revealFileInFolder"),+ icon: <IconFolderOpen size={14} />,+ onSelect: () => revealFileRef(path, baseDir),+ }]+ : []),{id: "copy-full-path",label: t("chat.copyFullPath"),icon: <IconCopy size={14} />,- separatorBefore: nativeFilesAllowed && isHtmlFilePath(path),+ separatorBefore: nativeFilesAllowed,onSelect: () => copyFileRef(path, baseDir, "absolute"),},{@@ -92,7 +103,7 @@ export function useChatFileMenuItems() {onSelect: () => copyFileRef(path, baseDir, "relative"),},],- [copyFileRef, nativeFilesAllowed, openFileRef, t],+ [copyFileRef, nativeFilesAllowed, openFileRef, revealFileRef, t],);}diff --git a/apps/desktop/src/hooks/use-preview-target.ts b/apps/desktop/src/hooks/use-preview-target.tsindex 97a7f781a..4b1c9946b 100644--- a/apps/desktop/src/hooks/use-preview-target.ts+++ b/apps/desktop/src/hooks/use-preview-target.ts@@ -414,6 +414,36 @@ export function useOpenChatFileRef() {);}+/**+ * Show a file reference in the system file manager.+ *+ * It travels through the same completion a click uses (`useOpenChatFileRef`),+ * so a right-click never reveals a differently named file that happens to sit+ * in the same folder: a reference that matched nothing says so instead.+ */+export function useRevealChatFileRef() {+ const { t } = useTranslation();+ const resolveRef = useResolveChatFileRef();+ const paneSessionId = useSlotSessionId();+ const sessionId = useAppStore((s) => paneSessionId || s.activeSessionId);+ const showToast = useAppStore((s) => s.showToast);++ return useCallback(+ (path: string, baseDir?: string) => {+ void (async () => {+ const resolved = await resolveRef(path, baseDir);+ if (!resolved) return;+ try {+ await api.fsReveal(resolved.absolutePath, sessionId ?? undefined);+ } catch {+ showToast(t("chat.fileRevealFailed"), { variant: "error" });+ }+ })();+ },+ [resolveRef, sessionId, showToast, t],+ );+}+/*** Copy a reference as an address a user can paste somewhere else.*diff --git a/apps/desktop/test/chat-file-open-with-menu.test.mjs b/apps/desktop/test/chat-file-open-with-menu.test.mjsindex 6b1078c0d..c53bf65d0 100644--- a/apps/desktop/test/chat-file-open-with-menu.test.mjs+++ b/apps/desktop/test/chat-file-open-with-menu.test.mjs@@ -51,8 +51,11 @@ const calls = {toasts: [],resolved: [],menus: [],+ reveals: [],};+let revealFails = false;+const state = {sessions: [],workspace: { path: "C:/project" },@@ -112,6 +115,10 @@ const previewTarget = loadModule("../src/hooks/use-preview-target.ts", {listPlugins: async () => ({ plugins: [] }),fsOpen: async (path, mimeType, sessionId) =>calls.defaultBrowsers.push([path, mimeType, sessionId]),+ fsReveal: async (path, sessionId) => {+ if (revealFails) throw new Error("reveal refused");+ calls.reveals.push([path, sessionId]);+ },fsResolveRef: async (ref) => {calls.resolved.push(ref);return { match: nextMatch };@@ -169,6 +176,7 @@ function reset(match) {Object.values(calls).forEach((list) => list.splice(0, list.length));nextMatch = match;clipboardFails = false;+ revealFails = false;}/** The match the main process reports for a file of the project's main folder. */@@ -212,6 +220,7 @@ test("the HTML menu exposes three open destinations as one submenu", () => {const menu = calls.menus[0].items;assert.deepEqual(menu.map((item) => item.id), ["open-with",+ "reveal-in-folder","copy-full-path","copy-relative-path",]);@@ -224,10 +233,9 @@ test("the HTML menu exposes three open destinations as one submenu", () => {["open-with-default-browser", "chat.openWithDefaultBrowser:"],],);- assert.equal(menu.some((item) => item.id === "reveal-in-folder"), false);});-test("non-HTML references keep copy actions without an open-with submenu", () => {+test("non-HTML references offer Show in folder and copy actions without an open-with submenu", () => {reset(projectMatch());let openFileMenu = null;function Harness() {@@ -237,6 +245,7 @@ test("non-HTML references keep copy actions without an open-with submenu", () =>renderToStaticMarkup(React.createElement(Harness));openFileMenu({}, { path: "src/dir/a.ts" });assert.deepEqual(calls.menus[0].items.map((item) => item.id), [+ "reveal-in-folder","copy-full-path","copy-relative-path",]);@@ -281,6 +290,55 @@ test("an unresolved HTML reference is reported and opened nowhere", async () =>]);});+/** Select the Show in folder item the right-click offers for a reference. */+async function revealRef(path) {+ let items = null;+ function Harness() {+ items = useChatFileMenuItems()({ path });+ return null;+ }+ renderToStaticMarkup(React.createElement(Harness));+ const item = items.find((entry) => entry.id === "reveal-in-folder");+ assert.ok(item, "the reference offers Show in folder");+ assert.equal(item.label, "chat.revealFileInFolder:");+ item.onSelect();+ await flush();+}++test("Show in folder reveals the resolved absolute path", async () => {+ reset(projectMatch());+ await revealRef("a.ts");+ assert.deepEqual(calls.resolved, ["a.ts"]);+ assert.deepEqual(calls.reveals, [["C:/project/src/dir/a.ts", "session-1"]]);+ assert.deepEqual(calls.toasts, []);++ reset({+ root: "scratch",+ relativePath: "notes.md",+ absolutePath: "C:/data/scratch/session-1/notes.md",+ matchedBy: "exact-relative",+ });+ await revealRef("notes.md");+ assert.deepEqual(calls.reveals, [["C:/data/scratch/session-1/notes.md", "session-1"]]);+});++test("Show in folder reports a missing reference or a refused reveal", async () => {+ reset(null);+ await revealRef("missing.ts");+ assert.deepEqual(calls.reveals, []);+ assert.deepEqual(calls.toasts.map(([message]) => message), [+ "chat.fileRefMissing:missing.ts",+ ]);++ reset(projectMatch());+ revealFails = true;+ await revealRef("a.ts");+ assert.deepEqual(calls.reveals, []);+ assert.deepEqual(calls.toasts.map(([message]) => message), [+ "chat.fileRevealFailed:",+ ]);+});+/** Run one copy item of the reference menu on the reference it names. */async function copyRef(path, kind) {let copy = null;@@ -411,7 +469,6 @@ test("HTTP URLs keep their own menu instead of the file open submenu", () => {// The submenu only recognizes HTML paths, and an HTTP link keeps its own// external/work-panel/copy menu.assert.match(menu, /isHtmlFilePath\(path\)/);- assert.doesNotMatch(menu, /useRevealChatFileRef|reveal-in-folder/);assert.ok(markdown.includes('if (!/^https?:\\/\\//i.test(href)) {'));});@@ -424,6 +481,8 @@ test("the reference labels ship in the catalogs the menu reads", () => {assert.match(en, /openWithDefaultBrowser: "Default browser"/);assert.match(en, /defaultBrowserOpenFailed:/);assert.match(en, /copyFullPath: "Copy full path"/);+ assert.match(en, /revealFileInFolder: "Show in folder"/);+ assert.match(zhCN, /revealFileInFolder: "在文件夹中打开"/);assert.match(en, /copyRelativePath: "Copy relative path"/);assert.match(zhCN, /openWith: "打开方式"/);assert.match(zhCN, /openWithFileManager: "文件管理器"/);@@ -434,7 +493,7 @@ test("the reference labels ship in the catalogs the menu reads", () => {assert.match(zhCN, /copyRelativePath: "复制相对地址"/);});-test("remote workspace references retain copy actions but never offer local open actions", () => {+test("remote workspace references retain copy actions but never offer local open or reveal actions", () => {const before = state.sessions;state.sessions = [{ id: state.activeSessionId, remoteWorkspace: { hostKey: "ssh", path: "/work/app" } }];let items;diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 19943bf0f..55ee6f22e 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -3811,9 +3811,11 @@ Anatomy:full path and Copy relative path on every surface that names it. Unpositioned`.html` and `.htm` references also offer an **Open with** submenu containingFile Manager, built-in browser, and default browser. Each choice completes the- reference first and opens that exact resolved file. Other file types keep the- copy actions only; the transcript menu has no **Show in folder** action. A- file outside the project has no relative path to copy and reports that fact.+ reference first and opens that exact resolved file. In a session that may use+ local files, every reference also offers **Show in folder**, which reveals the+ same resolved file in the system file manager; a remote workspace keeps the+ copy actions only. A file outside the project has no relative path to copy+ and reports that fact.The OS default application is no longer what this click does. HTTP(S)URLs stay text links. Plain clicks follow the Link open destination setting,and right-clicking a URL exposes the same external, work-panel, and copydiff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 2f3204091..96b421e5b 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -1580,9 +1580,11 @@ Project drag/drop follows these patterns:path on every surface that names it. Unpositioned `.html` and `.htm`references also offer an **Open with** submenu containing File Manager,built-in browser, and default browser. Each choice completes the reference- first and opens that exact resolved file. Other file types keep the copy- actions only; the transcript menu has no **Show in folder** action. A file- outside the project has no relative path to copy and reports that fact.+ first and opens that exact resolved file. In a session that may use local+ files, every reference also offers **Show in folder**, which completes the+ reference the same way and reveals that resolved file in the system file+ manager; a remote workspace keeps the copy actions only. A file outside the+ project has no relative path to copy and reports that fact.- In the host `file:` tab, a conversation MP4 that cannot be previewed becauseit is binary or exceeds the text preview limit offers **Open with defaultapplication**. This applies to named `.mp4` files and extensionlessdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 3344c904c..8d3fd8660 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -14654,13 +14654,15 @@ are withdrawn with ADR 0165.that matches nothing. On an HTML reference, open the Open with submenu andchoose File Manager, built-in browser, and default browser; repeat for thescratch HTML file. 9) Use Copy full path and Copy relative path, then do the- same on a reference that resolves in the session scratch store.+ same on a reference that resolves in the session scratch store. 10) Choose+ Show in folder on a project file and on a scratch file.- **Expected**:- Right-clicking a file reference offers Copy full path and Copy relative- path on each transcript surface that names it. The transcript menu has no- Show in folder item. An unpositioned HTML reference also has a second-level- Open with submenu for File Manager, built-in browser, and default browser;- non-HTML references keep only the copy actions. Each open choice resolves+ path on each transcript surface that names it, plus Show in folder in a+ local session. An unpositioned HTML reference also has a second-level+ Open with submenu for File Manager, built-in browser, and default browser.+ Show in folder reveals the resolved file in the system file manager and a+ missing reference reports itself instead. Each open choice resolvesthe reference first, and a missing reference reports itself without openinga same-named file elsewhere.- A copy writes exactly what it names: the absolute address for the full copydiff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex e8da7dfef..01457ff12 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -473,6 +473,8 @@ export const de = {"fileManagerOpenFailed": "Die Datei konnte nicht im Dateimanager geöffnet werden.","builtInBrowserUnavailable": "Der integrierte Browser ist nicht verfügbar.","defaultBrowserOpenFailed": "Die Datei konnte nicht im Standardbrowser geöffnet werden.",+ "revealFileInFolder": "Im Ordner anzeigen",+ "fileRevealFailed": "Die Datei konnte nicht im Ordner angezeigt werden.","copyFullPath": "Vollständigen Pfad kopieren","copyRelativePath": "Relativen Pfad kopieren","relativePathUnavailable": "Die Datei liegt außerhalb des Projekts und hat keinen relativen Pfad",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex a8a8e049a..30b8aa6d8 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -488,6 +488,8 @@ export const en = {fileManagerOpenFailed: "Could not open the file in File Manager.",builtInBrowserUnavailable: "The built-in browser is unavailable.",defaultBrowserOpenFailed: "Could not open the file in the default browser.",+ revealFileInFolder: "Show in folder",+ fileRevealFailed: "Could not show the file in its folder.",copyFullPath: "Copy full path",copyRelativePath: "Copy relative path",relativePathUnavailable: "That file is outside the project, so it has no relative path",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex 355ddf3bc..70adf3ccb 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -473,6 +473,8 @@ export const es = {"fileManagerOpenFailed": "No se pudo abrir el archivo en el administrador de archivos.","builtInBrowserUnavailable": "El navegador integrado no está disponible.","defaultBrowserOpenFailed": "No se pudo abrir el archivo en el navegador predeterminado.",+ "revealFileInFolder": "Mostrar en carpeta",+ "fileRevealFailed": "No se pudo mostrar el archivo en su carpeta.","copyFullPath": "Copiar ruta completa","copyRelativePath": "Copiar ruta relativa","relativePathUnavailable": "El archivo está fuera del proyecto y no tiene ruta relativa",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 4cd9a1a7b..b035967e7 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -473,6 +473,8 @@ export const fr = {"fileManagerOpenFailed": "Impossible d'ouvrir le fichier dans le gestionnaire de fichiers.","builtInBrowserUnavailable": "Le navigateur intégré est indisponible.","defaultBrowserOpenFailed": "Impossible d'ouvrir le fichier dans le navigateur par défaut.",+ "revealFileInFolder": "Afficher dans le dossier",+ "fileRevealFailed": "Impossible d'afficher le fichier dans son dossier.","copyFullPath": "Copier le chemin complet","copyRelativePath": "Copier le chemin relatif","relativePathUnavailable": "Ce fichier est hors du projet et n'a pas de chemin relatif",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex c87a8ae4f..8c2a49cbe 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -485,6 +485,8 @@ export const ko = {fileManagerOpenFailed: "파일 관리자에서 파일을 열 수 없습니다.",builtInBrowserUnavailable: "내장 브라우저를 사용할 수 없습니다.",defaultBrowserOpenFailed: "기본 브라우저에서 파일을 열 수 없습니다.",+ revealFileInFolder: "폴더에서 보기",+ fileRevealFailed: "폴더에서 파일을 표시할 수 없습니다.",copyFullPath: "전체 경로 복사",copyRelativePath: "상대 경로 복사",relativePathUnavailable: "이 파일은 프로젝트 밖에 있어 상대 경로가 없습니다",diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex baa46fe3a..dfaf41c1d 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -475,6 +475,8 @@ export const ptBR = {fileManagerOpenFailed: "Não foi possível abrir o arquivo no gerenciador de arquivos.",builtInBrowserUnavailable: "O navegador integrado está indisponível.",defaultBrowserOpenFailed: "Não foi possível abrir o arquivo no navegador padrão.",+ revealFileInFolder: "Mostrar na pasta",+ fileRevealFailed: "Não foi possível mostrar o arquivo na pasta.",copyFullPath: "Copiar caminho completo",copyRelativePath: "Copiar caminho relativo",relativePathUnavailable: "O arquivo está fora do projeto e não tem caminho relativo",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex d35e40e26..f8c2e437a 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -485,6 +485,8 @@ export const tr = {fileManagerOpenFailed: "Dosya, dosya yöneticisinde açılamadı.",builtInBrowserUnavailable: "Yerleşik tarayıcı kullanılamıyor.",defaultBrowserOpenFailed: "Dosya varsayılan tarayıcıda açılamadı.",+ revealFileInFolder: "Klasörde göster",+ fileRevealFailed: "Dosya klasörde gösterilemedi.",copyFullPath: "Tam yolu kopyala",copyRelativePath: "Göreli yolu kopyala",relativePathUnavailable: "Dosya proje dışında olduğu için göreli yolu yok",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 8f3671780..96faddf06 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -478,6 +478,8 @@ export const zhCN = {fileManagerOpenFailed: "无法在文件管理器中打开此文件。",builtInBrowserUnavailable: "内置浏览器当前不可用。",defaultBrowserOpenFailed: "无法在默认浏览器中打开此文件。",+ revealFileInFolder: "在文件夹中打开",+ fileRevealFailed: "无法在文件夹中打开该文件。",copyFullPath: "复制完整地址",copyRelativePath: "复制相对地址",relativePathUnavailable: "该文件不在项目内,没有相对地址",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 741a18f06..5d6a7688e 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -478,6 +478,8 @@ export const zhTW = {fileManagerOpenFailed: "無法在檔案管理器中開啟此檔案。",builtInBrowserUnavailable: "內建瀏覽器目前無法使用。",defaultBrowserOpenFailed: "無法在預設瀏覽器中開啟此檔案。",+ revealFileInFolder: "在資料夾中開啟",+ fileRevealFailed: "無法在資料夾中開啟該檔案。",copyFullPath: "複製完整位址",copyRelativePath: "複製相對位址",relativePathUnavailable: "該檔案不在專案內,沒有相對位址",