Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

test(e2e): cover markdown file manager activation

vastsa9693817c2225
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 2ad75df5f..4f6b83bb3 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -12795,14 +12795,14 @@ are withdrawn with ADR 0165.
assistant reply and the same reference as a sent user chip. 5) Click the file
path in the tool row's summary, then a path in the `Glob` result's file list
and a path heading of the `Grep` result. 6) Disable the File Manager plugin,
- click a project file reference and the tool row summary again, then re-enable
- it and click both once more. 7) Click a reference that resolves in the
- project's second folder, then one that resolves in its primary folder. 8)
- Right-click the sent `@path` chip, the inline-code reference, the markdown
- link, the local image, a tool row's file path, a tool result's file list, and
- an attachment image chip; then right-click a reference that matches nothing. 9)
- On that chip, use Copy full path and Copy relative path, then do the same on a
- reference that resolves in the session scratch store.
+ then click a project file reference and the tool row summary. 7) Click a
+ reference that resolves in the project's second folder, then one that resolves
+ in its primary folder. 8) Right-click the sent `@path` chip, the inline-code
+ reference, the markdown link, the local image, a tool row's file path, a tool
+ result's file list, and an attachment image chip; then right-click a reference
+ that matches nothing. 9) On that chip, use Copy full path and Copy relative
+ path, then do the same on a reference that resolves in the session scratch
+ store.
- **Expected**:
- Right-clicking a file reference opens the renderer's own menu with the
file's own folder (Show in folder) and both of its addresses (Copy full
@@ -12836,10 +12836,11 @@ are withdrawn with ADR 0165.
Manager view on that file, reached by its absolute path, with no host
`file:` tab; the reference from the primary folder opens in that same view
addressed project-relative (ADR 0263).
- - With the plugin disabled, a project file reference — from the reply and from
- a tool row or result list alike — falls back to the host `file:` tab, the
- surface those clicks used before, which now also reaches the project's other
- folders; re-enabling the plugin restores the File Manager destination.
+ - With the plugin disabled, a direct project-file click from the reply, tool
+ row, or result list starts the bundled File Manager within its existing
+ scope and permission grant, then opens the requested file there. If the
+ scope or grant excludes the current project, or the view still cannot
+ start, the host `file:` tab opens with an unavailable notice.
- **Specs linked**: `04-ux/08-component-spec.md` §8.3, §9.6,
`04-ux/09-interaction-patterns.md` §8a.2, ADR 0104, ADR 0163, ADR 0241,
ADR 0249, ADR 0262, ADR 0263
@@ -12848,8 +12849,10 @@ are withdrawn with ADR 0165.
- **Status**: Unit-covered
(`apps/desktop/test/transcript-file-chips.test.mjs` for the wiring and
`apps/desktop/test/tool-row-file-refs.test.mjs` for the work-panel entry each
- shape of resolution produces); full UI journey Draft (run only in a capable
- environment when this surface changes)
+ shape of resolution produces). The isolated Electron renderer journey in
+ `scripts/e2e-file-ref-line-scroll.mjs` verifies a Markdown link enables the
+ File Manager on demand and a positioned reference still opens in the host
+ viewer; the full packaged UI journey remains Draft.
#### E2E-CHAT-mp4-attachment-opens-in-system-player
diff --git a/scripts/e2e-file-ref-line-scroll.mjs b/scripts/e2e-file-ref-line-scroll.mjs
index c0603c7df..8238b6d29 100644
--- a/scripts/e2e-file-ref-line-scroll.mjs
+++ b/scripts/e2e-file-ref-line-scroll.mjs
@@ -85,7 +85,9 @@ app.whenReady().then(async () => {
console.log(line);
assert.equal(code, 0, output.slice(-4000));
assert.equal(result.fileManagerAvailable, true, "fixture must use the normal project-file setup");
- assert.deepEqual(result.resolveRefs, ["src/scroll-target.txt", "src/scroll-target.txt"]);
+ assert.deepEqual(result.pluginEnableCalls, ["pi.file-manager"]);
+ assert.equal(result.fileManagerLocation, "核查报告.md");
+ assert.deepEqual(result.resolveRefs, ["src/scroll-target.txt", "核查报告.md", "src/scroll-target.txt"]);
assert.deepEqual(result.readPaths, ["src/scroll-target.txt"]);
assert.equal(result.selectedPath, "src/scroll-target.txt");
assert.deepEqual(result.request, { path: "src/scroll-target.txt", seq: 1, line: 65, column: 4 });
diff --git a/scripts/e2e/file-ref-line-scroll.tsx b/scripts/e2e/file-ref-line-scroll.tsx
index 4ae88a117..daf189fb8 100644
--- a/scripts/e2e/file-ref-line-scroll.tsx
+++ b/scripts/e2e/file-ref-line-scroll.tsx
@@ -4,6 +4,7 @@ import { createInstance } from "i18next";
import { I18nextProvider, initReactI18next } from "react-i18next";
import { IPC } from "@pi-desktop/shared";
import { catalogs, flattenCatalog } from "@pi-desktop/i18n";
+import { Markdown } from "../../apps/desktop/src/components/Markdown";
import { FilesTab } from "../../apps/desktop/src/components/workpanel/FilesTab";
import { LinkifiedText } from "../../apps/desktop/src/features/chat/transcript/shared";
import { useAppStore } from "../../apps/desktop/src/stores/app-store";
@@ -15,6 +16,15 @@ const content = Array.from({ length: 90 }, (_, index) => `line ${index + 1}`).jo
const resolveRefs: string[] = [];
const readPaths: string[] = [];
const scrollCalls: Array<{ line: string | undefined; block?: string }> = [];
+const pluginEnableCalls: string[] = [];
+let pluginViews: Array<{ pluginId: string; viewId: string }> = [];
+let fileManagerPlugin = {
+ id: "pi.file-manager",
+ bundled: true,
+ enabled: false,
+ permissions: ["ui.view"],
+ scope: { mode: "global", projects: [] as string[] },
+};
window.piDesktop = {
platform: "darwin",
@@ -25,19 +35,33 @@ window.piDesktop = {
if (channel === IPC.invoke.fsResolveRef) {
const ref = String(input?.ref ?? "");
resolveRefs.push(ref);
+ const relativePath = ref === "核查报告.md" ? ref : targetPath;
return {
ok: true,
data: {
match: {
root: "workspace",
- relativePath: targetPath,
- absolutePath: `/workspace/${targetPath}`,
+ relativePath,
+ absolutePath: `/workspace/${relativePath}`,
matchedBy: "exact-relative",
projectRoot: { path: "/workspace", name: "Fixture", primary: true },
},
},
};
}
+ if (channel === IPC.invoke.pluginViews) {
+ return { ok: true, data: pluginViews };
+ }
+ if (channel === IPC.invoke.pluginList) {
+ return { ok: true, data: { plugins: [fileManagerPlugin] } };
+ }
+ if (channel === IPC.invoke.pluginEnable) {
+ const pluginId = String(args[0] ?? "");
+ pluginEnableCalls.push(pluginId);
+ fileManagerPlugin = { ...fileManagerPlugin, enabled: true };
+ pluginViews = [{ pluginId, viewId: "manager" }];
+ return { ok: true, data: undefined };
+ }
if (channel === IPC.invoke.fsList) {
return { ok: true, data: { entries: [] } };
}
@@ -53,7 +77,7 @@ window.piDesktop = {
useAppStore.setState({
workspace: { path: "/workspace", name: "Fixture" },
activeSessionId: "fixture-session",
- pluginViews: [{ pluginId: "pi.file-manager", viewId: "manager" }],
+ pluginViews: [],
workPanelOpen: false,
workPanelTabs: [],
activeWorkPanelTabId: null,
@@ -88,6 +112,9 @@ void i18n
<div className="fixture-chat">
<LinkifiedText text={`Review ${targetPath}:${targetLine}:4.`} />
</div>
+ <div className="fixture-markdown">
+ <Markdown source="[核查报告.md](核查报告.md)" renderDiagrams={false} />
+ </div>
<FilesTab />
</I18nextProvider>,
),
@@ -102,6 +129,31 @@ void i18n
return false;
};
+ const markdownLink = document.querySelector<HTMLAnchorElement>(
+ ".fixture-markdown a",
+ );
+ if (!markdownLink) throw new Error("Markdown file link did not render");
+ markdownLink.click();
+ const managerStarted = await until(
+ () =>
+ pluginEnableCalls.length === 1 &&
+ useAppStore.getState().workPanelTabs.some(
+ (tab) => tab.id === "plugin:pi.file-manager/manager",
+ ),
+ "on-demand File Manager tab",
+ );
+ if (!managerStarted) {
+ throw new Error(
+ `Markdown click did not start the File Manager: ${JSON.stringify({
+ pluginEnableCalls,
+ workPanelTabs: useAppStore.getState().workPanelTabs,
+ })}`,
+ );
+ }
+ const fileManagerTab = useAppStore.getState().workPanelTabs.find(
+ (tab) => tab.id === "plugin:pi.file-manager/manager",
+ );
+
if (!(await until(
() => Boolean(document.querySelector<HTMLButtonElement>(".chat-file-chip")),
"verified transcript chip",
@@ -123,6 +175,8 @@ void i18n
fileManagerAvailable: useAppStore.getState().pluginViews.some(
(view) => view.pluginId === "pi.file-manager" && view.viewId === "manager",
),
+ pluginEnableCalls,
+ fileManagerLocation: fileManagerTab?.location ?? null,
selectedPath: document.querySelector(".file-viewer-path")?.textContent,
segments: splitChatText(`Review ${targetPath}:${targetLine}:4.`, "/workspace"),
resolveRefs,
@@ -149,6 +203,8 @@ declare global {
};
fileRefLineScrollProbe: () => Promise<{
fileManagerAvailable: boolean;
+ pluginEnableCalls: string[];
+ fileManagerLocation: string | null;
selectedPath: string | null | undefined;
segments: unknown[];
resolveRefs: string[];