Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
test(electron): cover main output root from inside Rollup chunks
mingkun968b043189e0c53
diff --git a/apps/desktop/test/main-module-path.test.mjs b/apps/desktop/test/main-module-path.test.mjsnew file mode 100644index 000000000..a2b01692d--- /dev/null+++ b/apps/desktop/test/main-module-path.test.mjs@@ -0,0 +1,45 @@+import assert from "node:assert/strict";+import { mkdtemp, realpath, rm } from "node:fs/promises";+import { createRequire } from "node:module";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { fileURLToPath, pathToFileURL } from "node:url";+import test from "node:test";++const require = createRequire(import.meta.url);+const { build } = createRequire(new URL("../../../packages/agent-runtime/package.json", import.meta.url))("esbuild");++test("Main module paths resolve to the output root from inside Rollup chunks", async (t) => {+ const root = await realpath(await mkdtemp(join(tmpdir(), "pi-main-module-path-")));+ t.after(() => rm(root, { recursive: true, force: true }));+ const output = join(root, "probe.mjs");+ await build({+ entryPoints: [fileURLToPath(new URL("../electron/main/module-path.ts", import.meta.url))],+ outfile: output,+ bundle: true,+ platform: "node",+ format: "esm",+ });+ const { getModuleDirectory } = await import(pathToFileURL(output).href);++ // The entry bundle itself (…/out/main/index.js).+ assert.equal(+ getModuleDirectory(pathToFileURL(join(root, "out/main/index.js")).href),+ join(root, "out/main"),+ );+ // A shared chunk (…/out/main/chunks/index-XXXX.js) — the layout that put the+ // window bootstrap, preload and plugin-host paths one level too deep.+ assert.equal(+ getModuleDirectory(pathToFileURL(join(root, "out/main/chunks/index-ABCD1234.js")).href),+ join(root, "out/main"),+ );+ // The relative runtime paths stay exactly what the call sites author.+ assert.equal(+ join(getModuleDirectory(pathToFileURL(join(root, "out/main/chunks/index-ABCD1234.js")).href), "../renderer/index.html"),+ join(root, "out/renderer/index.html"),+ );+ assert.equal(+ join(getModuleDirectory(pathToFileURL(join(root, "out/main/chunks/index-ABCD1234.js")).href), "plugin-host-process.js"),+ join(root, "out/main/plugin-host-process.js"),+ );+});diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex a8b7f613a..1f13efff6 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -888,14 +888,19 @@ identify the platform validation still needed.resources, and the tray starts without a missing-icon warning. Key lifecycleand error records are written to the categorized logs. GitHub auto-update isnot started until after `ensureWindow`, and a hung feed cannot keep updater- status on `checking` for Chromium's ~60s timeout.+ status on `checking` for Chromium's ~60s timeout. The Main output root also+ resolves from inside Rollup shared chunks (`out/main/chunks/*.js`), so the+ renderer entry, preloads, and the forked plugin host keep their authored+ relative paths instead of resolving one level too deep (black screen).- **Specs linked**: `03-runtime/07-process-model.md`, `04-ux/01-ui-ia.md`,`03-runtime/09-logging-and-observability.md`- **Acceptance**: A (app startup)- **Milestone**: M1- **Status**: Partially automated (`runtime-build-contract.test.mjs` covers thedependency build contract; `update-timeout.test.mjs` and- `auto-update.test.mjs` cover the bounded auto-check contract; Electron window+ `auto-update.test.mjs` cover the bounded auto-check contract;+ `main-module-path.test.mjs` covers the Main output-root contract from the+ entry bundle and from inside `out/main/chunks/`; Electron windowlaunch remains Draft)#### E2E-002: IPC bridge is functional