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(desktop): give development builds their own installation
vastsa8a9758bbc7f6
diff --git a/apps/desktop/electron/main/data-paths.ts b/apps/desktop/electron/main/data-paths.tsnew file mode 100644index 000000000..cbcbcda7d--- /dev/null+++ b/apps/desktop/electron/main/data-paths.ts@@ -0,0 +1,89 @@+import { homedir } from "node:os";+import { join, resolve } from "node:path";+import { APP_NAME } from "@pi-desktop/shared";++/**+ * The two directories that define an installation, and the development split+ * between them.+ *+ * A packaged PI-Desktop and a `pnpm dev` host used to share both: the+ * name-derived `userData` — where Electron keeps the single-instance lock,+ * renderer `localStorage`, and the plugin panel partitions — and+ * `~/.pi-desktop`, where host-core keeps `pi.sqlite` beside the persistence+ * outbox and the log tree. Sharing them meant a shipped app that was already+ * running held the lock, so the development launch quit on arrival; a+ * development host that won the race instead put a second host-core over the+ * same single-writer database, which is the divergence D236 exists to+ * prevent. Neither is workable while someone debugs against the app they use.+ *+ * Only the development side moves, and only these two names differ. A shipped+ * installation keeps `PI-Desktop` and `~/.pi-desktop`, so no upgrade relocates+ * a user's database, secrets, plugins, or renderer-local state, and+ * `PI_DESKTOP_DATA_DIR` still overrides either profile outright.+ */++/** `userData` directory of a development installation, beside the shipped one. */+export const DEVELOPMENT_INSTALLATION_NAME = `${APP_NAME} Dev`;++/** Data directory of a shipped installation, below the user's home. */+export const INSTALLATION_DATA_DIR_NAME = ".pi-desktop";++/** Data directory of a development installation, below the user's home. */+export const DEVELOPMENT_DATA_DIR_NAME = ".pi-desktop-dev";++export type DataDirInput = {+ /** `PI_DESKTOP_DATA_DIR`; an explicit directory wins over either profile. */+ override: string | undefined;+ /** True for a development build. */+ development: boolean;+ /** The user's home directory. */+ home: string;+};++/**+ * The data directory one installation owns.+ *+ * `PI_DESKTOP_DATA_DIR` stays the escape hatch it always was: an explicit+ * directory wins, which is how the E2E harnesses, the capture rig, and+ * side-by-side profiles keep choosing their own root. The result is absolute,+ * because it reaches host-core as a child-process environment variable from a+ * working directory that need not be this one, and because `homedir()` is the+ * only other input that could be relative. Without an override the profile+ * picks the name, and that name is the whole difference between the two+ * installations.+ */+export function resolveDataDir({+ override,+ development,+ home,+}: DataDirInput): string {+ const explicit = override?.trim();+ if (explicit) return resolve(explicit);+ return resolve(+ join(+ home,+ development ? DEVELOPMENT_DATA_DIR_NAME : INSTALLATION_DATA_DIR_NAME,+ ),+ );+}++/**+ * The data directory this process owns.+ *+ * Electron main passes its own verdict for `development`, because only it can+ * ask `app.isPackaged`, and it publishes the resolved directory back to+ * `PI_DESKTOP_DATA_DIR` at boot. That publication is what keeps the plugin+ * runtime — which resolves this root from the environment rather than taking+ * it as a parameter — on one directory instead of falling back to the shipped+ * default, which would strand a development host's plugin data inside the+ * packaged profile.+ */+export function desktopDataDir(+ development: boolean = process.env.PI_DESKTOP_DEV === "1",+): string {+ return resolveDataDir({+ override: process.env.PI_DESKTOP_DATA_DIR,+ development,+ home: homedir(),+ });+}diff --git a/apps/desktop/electron/main/index.ts b/apps/desktop/electron/main/index.tsindex 0062e5a77..beba179fc 100644--- a/apps/desktop/electron/main/index.ts+++ b/apps/desktop/electron/main/index.ts@@ -7,7 +7,6 @@ import {Tray,} from "electron";import { join } from "node:path";-import { homedir } from "node:os";import {applyNetworkProxyFromAppSettings,currentNetworkProxy,@@ -94,6 +93,10 @@ import {planExecutionFromUnknown,} from "@pi-desktop/host-runtime";import { readWindowState, writeWindowState } from "./window-preferences";+import {+ desktopDataDir,+ DEVELOPMENT_INSTALLATION_NAME,+} from "./data-paths";import { createPlanUiProbe } from "./plan-ui-probe";import type { McpControlController, McpControlServer } from "./mcp-control";import type { AgentHostBridge } from "./agent-host-bridge";@@ -175,23 +178,39 @@ const ErrorCodes = {ignoreBrokenStdio();installMainProcessErrorHandlers();+// A development build is a second installation beside the shipped app, so it+// takes its own `userData`: the single-instance lock below lives there, and a+// shipped app that is already running must not refuse the developer the lock+// (D236, ADR 0094). An explicit `--user-data-dir` wins, because that is how the+// E2E harnesses point a build at a throwaway profile — overriding it would run+// their assertions against the developer's own state instead.+const isDevelopmentBuild =+ process.env.PI_DESKTOP_DEV === "1" || !app.isPackaged;+app.setName(APP_NAME);+if (isDevelopmentBuild && !app.commandLine.hasSwitch("user-data-dir")) {+ app.setPath(+ "userData",+ join(app.getPath("appData"), DEVELOPMENT_INSTALLATION_NAME),+ );+}if (process.platform === "win32") {app.setAppUserModelId(APP_ID);}-// One data directory admits exactly one desktop process. host-core owns+// One installation admits exactly one desktop process. host-core owns// `pi.sqlite` exclusively (D002), Electron main owns the persistence outbox and// the log tree beside it, and the tray, the global launcher shortcut, and the// updater are singletons of the running app — a second process fights the first// for every one of them and leaves the user with two shells over one database.//-// Electron keeps the lock in `userData`, which is derived from the app name set-// just above, so it is taken after `setName` and before anything else in this+// Electron keeps the lock in `userData`, which the name and profile set just+// above decide, so it is taken after `setName` and before anything else in this// module touches the data directory. That scope is the installation, not-// `PI_DESKTOP_DATA_DIR`: a run pointed at its own data directory (E2E-// harnesses, the capture rig, a side-by-side profile) shares no state with the-// default installation and stays launchable while one is running.+// `PI_DESKTOP_DATA_DIR`: a development build is its own installation, and a run+// pointed at its own data directory (E2E harnesses, the capture rig, a+// side-by-side profile) shares no state with the shipped one either. Both stay+// launchable while the other is running.const singleInstanceRequired = !process.env.PI_DESKTOP_DATA_DIR;const hasSingleInstanceLock = singleInstanceRequired? app.requestSingleInstanceLock()@@ -241,8 +260,6 @@ const launcherState: LauncherState = {};let windowCreationPromise: Promise<void> | null = null;let applicationBooted = false;-const isDevelopmentBuild =- process.env.PI_DESKTOP_DEV === "1" || !app.isPackaged;const pendingApplicationMenuCommands: AppMenuCommand[] = [];type MenuRendererReadyGate = {window: BrowserWindow;@@ -517,8 +534,11 @@ const {safeOpenExternal,} = desktopServices;-const dataDir =- process.env.PI_DESKTOP_DATA_DIR || join(homedir(), ".pi-desktop");+const dataDir = desktopDataDir(isDevelopmentBuild);+// The plugin runtime resolves this root from the environment rather than taking+// it as a parameter, and a profile split across two directories is the+// divergence D236 closes.+process.env.PI_DESKTOP_DATA_DIR = dataDir;// Agent extensions (D387/D388, ADR 0214): plugins contribute the modules,// the sidecar loads them; this bridge carries commands, diagnostics, anddiff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 44bbd0652..2861a6460 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -12,7 +12,6 @@ import type { Stats } from "node:fs";import { open as openFile } from "node:fs/promises";import { randomUUID } from "node:crypto";import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";-import { homedir } from "node:os";import {busTopicAllowed,isDeniedFsPath,@@ -78,6 +77,7 @@ import {resolveRealPathWithinRoot,resolveWithinRoot,} from "@pi-desktop/host-runtime";+import { desktopDataDir } from "./data-paths";import { McpServerClient, type McpServerClientOptions } from "./plugin-mcp";import { PluginToolInvocations, type PluginToolInvocation } from "./plugin-tool-invocations";import { DevPluginWatcher, type DevPluginWatcherDeps } from "./plugin-watcher";@@ -4026,11 +4026,16 @@ export class PluginRuntime {return result;}- /** Per-plugin data directory. Host-owned; the fs API cannot reach it. */+ /**+ * Per-plugin data directory. Host-owned; the fs API cannot reach it.+ *+ * Electron main publishes the resolved data directory to+ * `PI_DESKTOP_DATA_DIR` at boot, so this reads the installation's own root+ * and a development host never writes plugin data into the packaged+ * profile's tree (D236).+ */private pluginDataDir(pluginId: string): string {- const root = process.env.PI_DESKTOP_DATA_DIR- ? resolve(process.env.PI_DESKTOP_DATA_DIR)- : join(homedir(), ".pi-desktop");+ const root = desktopDataDir();return join(root, "plugins", "data", pluginId.replace(/[^a-zA-Z0-9._-]/g, "_"));}diff --git a/apps/desktop/electron/main/services/plugin-services.ts b/apps/desktop/electron/main/services/plugin-services.tsindex 9b3e41ae0..cfada9d69 100644--- a/apps/desktop/electron/main/services/plugin-services.ts+++ b/apps/desktop/electron/main/services/plugin-services.ts@@ -1,5 +1,4 @@import { dialog, globalShortcut, shell, type BrowserWindow } from "electron";-import { homedir } from "node:os";import { join } from "node:path";import {IPC,@@ -572,10 +571,7 @@ export function createPluginServices({},getScratchDir: (sessionId) => {if (!sessionId) return null;- const root =- process.env.PI_DESKTOP_DATA_DIR?.trim() ||- join(homedir(), ".pi-desktop");- return join(root, "scratch", sessionId);+ return join(dataDir, "scratch", sessionId);},onState: emitBrowserState,});diff --git a/apps/desktop/test/development-profile.test.mjs b/apps/desktop/test/development-profile.test.mjsnew file mode 100644index 000000000..e168576de--- /dev/null+++ b/apps/desktop/test/development-profile.test.mjs@@ -0,0 +1,134 @@+import assert from "node:assert/strict";+import { dirname, join, resolve } from "node:path";+import { register } from "node:module";+import { tmpdir } from "node:os";+import test from "node:test";+import { fileURLToPath, pathToFileURL } from "node:url";+import { readMainModule } from "./helpers/source-contracts.mjs";++const here = dirname(fileURLToPath(import.meta.url));++register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));+const {+ DEVELOPMENT_DATA_DIR_NAME,+ DEVELOPMENT_INSTALLATION_NAME,+ INSTALLATION_DATA_DIR_NAME,+ resolveDataDir,+} = await import("../electron/main/data-paths.ts");++const indexSource = await readMainModule("index.ts");++test("a development build owns a different data directory than the shipped app", () => {+ const home = join(tmpdir(), "pi-desktop-profile-home");++ assert.equal(+ resolveDataDir({ override: undefined, development: false, home }),+ join(home, INSTALLATION_DATA_DIR_NAME),+ );+ assert.equal(+ resolveDataDir({ override: undefined, development: true, home }),+ join(home, DEVELOPMENT_DATA_DIR_NAME),+ );++ // A shipped installation must keep the directory its users already have, so+ // the split can only have moved the development side.+ assert.equal(INSTALLATION_DATA_DIR_NAME, ".pi-desktop");+ assert.equal(DEVELOPMENT_DATA_DIR_NAME, ".pi-desktop-dev");+ assert.equal(DEVELOPMENT_INSTALLATION_NAME, "PI-Desktop Dev");+});++test("PI_DESKTOP_DATA_DIR still overrides either profile", () => {+ const home = join(tmpdir(), "pi-desktop-profile-home");+ const override = join(tmpdir(), "pi-desktop-explicit-profile");++ for (const development of [false, true]) {+ assert.equal(+ resolveDataDir({ override, development, home }),+ override,+ );+ }++ // Every call site this replaced treated a blank value as unset, which is what+ // keeps `PI_DESKTOP_DATA_DIR=` from naming a relative directory.+ assert.equal(+ resolveDataDir({ override: " ", development: true, home }),+ join(home, DEVELOPMENT_DATA_DIR_NAME),+ );+});++test("an explicit data directory reaches the child processes as an absolute path", () => {+ // host-core and the plugin host read the value as an environment variable+ // from a different working directory, so a relative override would resolve to+ // two different trees.+ const relative = join("pi-desktop-relative-profile");+ assert.equal(+ resolveDataDir({+ override: relative,+ development: false,+ home: join(tmpdir(), "pi-desktop-profile-home"),+ }),+ resolve(relative),+ );+});++test("a development build takes its own userData before the single-instance lock", () => {+ // The lock lives under `userData`, so the profile has to be applied before+ // Electron asks for it; otherwise a running packaged app refuses the lock and+ // `pnpm dev` quits on arrival.+ const setUserData = indexSource.search(+ /app\.setPath\(\s*"userData",\s*join\(app\.getPath\("appData"\), DEVELOPMENT_INSTALLATION_NAME\)/,+ );+ const setName = indexSource.indexOf("app.setName(APP_NAME)");+ const lock = indexSource.indexOf("app.requestSingleInstanceLock()");++ assert.ok(setUserData > 0, "main must give the development build its own userData");+ assert.ok(lock > 0, "main must request the single-instance lock");+ assert.ok(setName > 0 && setName < setUserData);+ assert.ok(setUserData < lock);++ // An explicit `--user-data-dir` wins. The E2E harnesses point a build at a+ // throwaway profile with that switch, so overriding it would run their+ // assertions against the developer's own state instead.+ assert.match(+ indexSource,+ /if \(isDevelopmentBuild && !app\.commandLine\.hasSwitch\("user-data-dir"\)\) \{/,+ );++ // The two profiles are told apart by the same verdict everywhere, and it is+ // reached before the name the lock path derives from.+ const development = indexSource.search(+ /const isDevelopmentBuild =\s*\n?\s*process\.env\.PI_DESKTOP_DEV === "1" \|\| !app\.isPackaged;/,+ );+ assert.ok(development > 0 && development < setUserData);+});++test("main resolves one data directory and publishes it to everything below", () => {+ assert.match(indexSource, /const dataDir = desktopDataDir\(isDevelopmentBuild\);/);+ // The plugin runtime resolves this root from the environment rather than+ // taking it as a parameter, so the resolved value has to be the one it reads.+ assert.match(indexSource, /process\.env\.PI_DESKTOP_DATA_DIR = dataDir;/);+ assert.doesNotMatch(indexSource, /join\(homedir\(\), "\.pi-desktop"\)/);++ // Publishing happens after the lock verdict, which reads the same variable:+ // moving the write above `singleInstanceRequired` would make every launch+ // look like it had been given an explicit data directory and skip the lock.+ const lockVerdict = indexSource.indexOf(+ "const singleInstanceRequired = !process.env.PI_DESKTOP_DATA_DIR;",+ );+ assert.ok(lockVerdict > 0);+ assert.ok(+ indexSource.indexOf("process.env.PI_DESKTOP_DATA_DIR = dataDir;") > lockVerdict,+ );+});++test("downstream data directories follow the profile instead of the shipped default", async () => {+ const runtimeSource = await readMainModule("plugin-runtime.ts");+ assert.match(runtimeSource, /const root = desktopDataDir\(\);/);+ assert.doesNotMatch(runtimeSource, /join\(homedir\(\), "\.pi-desktop"\)/);++ // The plugin services already receive the resolved directory; the scratch+ // root was the one place that re-derived it.+ const servicesSource = await readMainModule("services/plugin-services.ts");+ assert.match(servicesSource, /return join\(dataDir, "scratch", sessionId\);/);+ assert.doesNotMatch(servicesSource, /join\(homedir\(\), "\.pi-desktop"\)/);+});diff --git a/docs/adr/0094-single-instance-per-data-directory.md b/docs/adr/0094-single-instance-per-data-directory.mdindex b4ae39963..ea419c9f7 100644--- a/docs/adr/0094-single-instance-per-data-directory.md+++ b/docs/adr/0094-single-instance-per-data-directory.md@@ -82,3 +82,17 @@ result with none of the cost.Rejected because the failure is silent data divergence over a single-writerdatabase, and the user has no signal that two shells are open on one workspace.++## Amendment (D599)++The alternatives below still stand: the lock is not scoped to+`PI_DESKTOP_DATA_DIR`, and `userData` is not relocated under it.++What changed is that a development build is no longer the same installation as+the packaged app. It takes `PI-Desktop Dev` in the OS application-data root and+`~/.pi-desktop-dev`, so `pnpm dev` starts while the packaged app holds its lock+and the two never share `pi.sqlite`, the outbox, or the log tree. An explicit+`--user-data-dir` still wins, because the E2E harnesses point a build at a+throwaway profile with it. Only the development side moved: a shipped+installation keeps `PI-Desktop` and `~/.pi-desktop`, so no existing profile is+relocated. See D599.diff --git a/docs/spec/02-architecture/03-repo-structure.md b/docs/spec/02-architecture/03-repo-structure.mdindex 715bc62de..7c2f54e07 100644--- a/docs/spec/02-architecture/03-repo-structure.md+++ b/docs/spec/02-architecture/03-repo-structure.md@@ -128,7 +128,9 @@ Cross-boundary contracts:## 3. Runtime data (not in git)-`PI_DESKTOP_DATA_DIR` overrides the default location.+`PI_DESKTOP_DATA_DIR` overrides the default location: `~/.pi-desktop` for a+packaged installation, `~/.pi-desktop-dev` for a development build, which is+how `pnpm dev` runs beside the packaged app (D599).```text~/.pi-desktop/diff --git a/docs/spec/03-runtime/04-data-storage.md b/docs/spec/03-runtime/04-data-storage.mdindex 6b0fc29a9..b3b5dc255 100644--- a/docs/spec/03-runtime/04-data-storage.md+++ b/docs/spec/03-runtime/04-data-storage.md@@ -47,6 +47,12 @@ read time; their path-scoped memory and filesystem instructions remain readable.## 2. File layout+A packaged installation keeps this tree in `~/.pi-desktop`. A development build+keeps the same tree in `~/.pi-desktop-dev`, because a shipped app and a+`pnpm dev` host are two installations that have to run at the same time (D599,+ADR 0094). `PI_DESKTOP_DATA_DIR` replaces either root outright and is resolved+to an absolute path before it reaches host-core as a child-process variable.+```text~/.pi-desktop/├── pi.sqlite # index database (WAL: + -wal/-shm) — host-core onlydiff --git a/docs/spec/03-runtime/07-process-model.md b/docs/spec/03-runtime/07-process-model.mdindex e80c4f4c4..b629e8c18 100644--- a/docs/spec/03-runtime/07-process-model.md+++ b/docs/spec/03-runtime/07-process-model.md@@ -37,6 +37,13 @@ run pointed at its own `PI_DESKTOP_DATA_DIR` (E2E harnesses, the capture rig, aside-by-side profile) shares no database, outbox, or logs with the defaultinstallation and stays launchable while one is running (D236, ADR 0094).+A development build is its own installation rather than a second process of+the same one: it runs under `PI-Desktop Dev` in the OS application-data root+and reads `~/.pi-desktop-dev`. `pnpm dev` therefore starts while a packaged app+holds its lock, and the two never share a database, an outbox, or a log tree+(D599, ADR 0094). An explicit `--user-data-dir` is honored instead, because the+E2E harnesses point a build at a throwaway profile with it.+1. Electron main starts2. Load English locale defaults3. Spawn Rust host-corediff --git a/docs/spec/03-runtime/09-logging-and-observability.md b/docs/spec/03-runtime/09-logging-and-observability.mdindex d88d69011..54d3299c0 100644--- a/docs/spec/03-runtime/09-logging-and-observability.md+++ b/docs/spec/03-runtime/09-logging-and-observability.md@@ -29,6 +29,10 @@ Default runtime level:| audit | sensitive permission, tool, and plugin actions | host-core SQLite `audit_log` table || plugin | per-plugin logs | `~/.pi-desktop/plugins/logs/<id>.log` |++The `~/.pi-desktop` paths above are the packaged installation's. A development+build writes the same tree under `~/.pi-desktop-dev`, and `PI_DESKTOP_DATA_DIR`+replaces either root (D599).`app`, `host`, and `agent` are NDJSON files written by the Electron main`Logger` (`apps/desktop/electron/main/logger.ts`). Host and agent stderr linesare wrapped into records on their channel. The audit channel is stored indiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 63a6f1187..f7fa42c4d 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -8784,16 +8784,21 @@ This test plan spec is accepted when:both the window and the process list. 2) Minimize the window into the tray,then launch again. 3) On Windows/Linux with close behavior `tray`, close thewindow, then launch again. 4) While the app is running, launch a build with- `PI_DESKTOP_DATA_DIR` set to an empty directory. 5) Quit the app, confirm no- process remains, and launch once more.+ `PI_DESKTOP_DATA_DIR` set to an empty directory. 5) Still while the packaged+ app is running, start a development build (the `dev` script, with no+ `PI_DESKTOP_DATA_DIR`). 6) Quit the app, confirm no process remains, and+ launch once more.- **Expected**: Steps 1–3 never create a second window, tray icon, host-core,agent sidecar, or log file: the existing window is restored and focused, theduplicate process exits, and the running instance's session list, in-flightturn, and `pi.sqlite` are untouched. Step 4 starts normally as an independent- instance against its own data directory. Step 5 starts a clean single- instance, proving the lock is released on exit and never leaves a stale block.+ instance against its own data directory. Step 5 also starts normally: the+ development build takes its own `userData` and `~/.pi-desktop-dev`, so it+ neither waits for nor disturbs the running packaged app. Step 6 starts a clean+ single instance, proving the lock is released on exit and never leaves a stale+ block.- **Specs linked**: `03-runtime/07-process-model.md`,- `08-meta/decisions-log.md` (D236, D002), ADR 0094+ `08-meta/decisions-log.md` (D236, D599, D002), ADR 0094- **Acceptance**: A (app lifecycle), Quality- **Milestone**: M6+- **Status**: Unit/source-contract covered; native cross-platform relaunchdiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex a96938d9d..ee4023b35 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -301,6 +301,7 @@ Gold source: local Codex electron captures; latest row wins where rows conflict.| D275 | Preserve the active task boundary across context compaction | **Amends D203 / ADR 0064 in the agent runtime: checkpoints record opaque `details.retainedTailMode`. An active-turn checkpoint retains only the latest user message (up to the existing 20,000-token cap) when the provider must continue after a tool result, `toolUse`, or overflow recovery. A completed-turn checkpoint has an empty retained tail at terminal boundaries, before a new prompt, and for manual compaction; its summary is authoritative for completed work. Legacy records without the mode normalize to their latest user message. No visible transcript, storage schema, host ownership, or protocol shape changes.** | Keeping several recent user prompts while compacting away completion messages made the next prompt look like a continuation of an old task (issue #22). The boundary must be explicit at restore time while active tool loops still retain the prompt needed to continue. || D278 | Subagent model selection | **Task.model overrides definition pin; only models with `availableForSubagents` appear in the delegation catalog; on-demand RPC resolves models not pre-resolved at launch** | The parent agent needs per-task model choice without exposing the full provider configuration. An opt-in flag keeps the delegation catalog bounded and intentional, and on-demand resolution avoids stale bindings for models added after sidecar launch. See §3/02 §5f, §3/11 §7, and E2E-166. || D365 | Named quiet intervals on the live activity row | **Amend D338 / ADR 0175: `AgentActivity` adds `preparing`, `compacting`, and `recovering`; `starting` shows its own label; `waiting-subagents` carries a live running snapshot (`name`, `lastPhase`, `lastToolName`) that updates on child tool/thinking changes, not on every token. The row stays one compact inline status and does not restore an activity-group capsule.** | Compaction, silent-turn recovery, the post-tool gap, and startup all looked like a stuck generic wait, and a parent wait hid what its delegates were doing (ADR 0198, E2E-008c / E2E-094) |+| D599 | A development build is its own installation | **Narrow D236 / amend ADR 0094: a development build (unpackaged, or `PI_DESKTOP_DEV=1`) takes `PI-Desktop Dev` as its Electron `userData` — and with it the single-instance lock, renderer `localStorage`, the plugin panel partitions, and browser pane cookies — and reads `~/.pi-desktop-dev`. An explicit `--user-data-dir` still wins, which is how the E2E harnesses point a build at a throwaway profile. A packaged installation keeps `PI-Desktop` and `~/.pi-desktop`, so no existing profile is relocated. `PI_DESKTOP_DATA_DIR` still overrides either profile and is made absolute before it reaches host-core as a child-process environment variable; Electron main publishes the resolved directory back to that variable so the plugin runtime reads one root. No IPC, protocol, schema, or packaged-installation path change. See `03-runtime/07-process-model.md` and E2E-150.** | A packaged app that was already running held the lock, so `pnpm dev` quit on arrival; a development host that won the race instead put a second host-core over the same single-writer `pi.sqlite`, the outbox, and the log tree. |## M0. Model catalog decisions@@ -6351,3 +6352,28 @@ that was sitting at the bottom — including after the turn had finished.seven-level ladder, provider filtering, and clamping rules are unchanged.Renderer only: no protocol, storage, host, permission, or migration change.See `04-ux/08-component-spec.md`, `04-ux/07-ui-design-system.md`, and E2E-050.++## 2026-09-20 — A development build is its own installation (D599)++- A packaged PI-Desktop and a `pnpm dev` host no longer share the two+ directories that define an installation. A development build runs under+ `PI-Desktop Dev` in the OS application-data root — its own Electron+ `userData`, and with it the single-instance lock, renderer `localStorage`,+ the plugin panel partitions, and browser pane cookies — and reads+ `~/.pi-desktop-dev`. A packaged installation keeps `PI-Desktop` and+ `~/.pi-desktop` unchanged, so no existing profile is relocated.+- A shipped app that is already running therefore no longer refuses the lock a+ development launch needs, and the two never put a second host-core over one+ `pi.sqlite`, one persistence outbox, or one log tree. `PI_DESKTOP_DATA_DIR`+ still wins over either profile and is now made absolute before it reaches+ host-core as a child-process environment variable. Electron main publishes the+ resolved directory back to that variable so the plugin runtime reads one root+ instead of falling back to the shipped default.+ An explicit `--user-data-dir` still wins, because the E2E harnesses point a+ build at a throwaway profile with it.+- Decision D599 narrows D236 and amends ADR 0094: the lock keeps its+ installation scope, and a development build is now a second installation+ rather than an ambiguous second process. No IPC channel, host protocol,+ storage schema, or packaged-installation path changed. See+ `03-runtime/07-process-model.md`, `03-runtime/04-data-storage.md`, and+ `02-architecture/03-repo-structure.md`.diff --git a/docs/zh-CN/spec/02-architecture/03-repo-structure.md b/docs/zh-CN/spec/02-architecture/03-repo-structure.mdindex 505ea910f..839a6a32f 100644--- a/docs/zh-CN/spec/02-architecture/03-repo-structure.md+++ b/docs/zh-CN/spec/02-architecture/03-repo-structure.md@@ -113,7 +113,8 @@ Node 对 pi 的包装:## 3. 运行时数据(不在 git 中)-`PI_DESKTOP_DATA_DIR` 可覆盖默认位置。+`PI_DESKTOP_DATA_DIR` 可覆盖默认位置:正式打包版为 `~/.pi-desktop`,开发构建为+`~/.pi-desktop-dev`,`pnpm dev` 借此与正式版并行运行(D599)。```text~/.pi-desktop/diff --git a/docs/zh-CN/spec/03-runtime/04-data-storage.md b/docs/zh-CN/spec/03-runtime/04-data-storage.mdindex 6140d1a84..ed36a8308 100644--- a/docs/zh-CN/spec/03-runtime/04-data-storage.md+++ b/docs/zh-CN/spec/03-runtime/04-data-storage.md@@ -38,6 +38,11 @@## 2. 文件布局+正式打包版把上述目录树放在 `~/.pi-desktop`;开发构建放在 `~/.pi-desktop-dev`,+因为正式版与 `pnpm dev` 是两个需要同时运行的安装(D599、ADR 0094)。+`PI_DESKTOP_DATA_DIR` 会整体替换任一默认根目录,并在作为子进程环境变量传给+host-core 之前被解析为绝对路径。+```text~/.pi-desktop/├── pi.sqlite # index database (WAL: + -wal/-shm) — host-core onlydiff --git a/docs/zh-CN/spec/03-runtime/07-process-model.md b/docs/zh-CN/spec/03-runtime/07-process-model.mdindex 26c140abf..3117b71b1 100644--- a/docs/zh-CN/spec/03-runtime/07-process-model.md+++ b/docs/zh-CN/spec/03-runtime/07-process-model.md@@ -36,6 +36,12 @@ PI-Desktop.app截图装置、并行 profile)与默认安装不共享数据库、outbox 或日志,在已有实例运行时仍可启动(D236、ADR 0094)。+开发构建本身就是独立安装,而不是同一安装的第二个进程:它运行在操作系统应用+数据根目录下的 `PI-Desktop Dev`,数据目录为 `~/.pi-desktop-dev`。因此正式打包版+持有锁时 `pnpm dev` 仍可启动,两者不会共享数据库、outbox 或日志树(D599、+ADR 0094)。显式 `--user-data-dir` 仍然优先,E2E 装置正是用它把构建指向临时+profile。+1. Electron 主启动2. 加载英文语言环境默认值3. 生成 Rust host-corediff --git a/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md b/docs/zh-CN/spec/03-runtime/09-logging-and-observability.mdindex 108747c14..90e0f9da5 100644--- a/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md+++ b/docs/zh-CN/spec/03-runtime/09-logging-and-observability.md@@ -31,6 +31,9 @@| audit | 敏感的权限、工具和插件操作 | host-core SQLite `audit_log` 表 || plugin | 每个插件的日志 | `~/.pi-desktop/plugins/logs/<id>.log` |++表中的 `~/.pi-desktop` 路径属于正式打包版。开发构建把同一棵目录树写在+`~/.pi-desktop-dev` 下,`PI_DESKTOP_DATA_DIR` 会整体替换任一默认根目录(D599)。`app`、`host` 和 `agent` 是由 Electron 主进程 `Logger`(`apps/desktop/electron/main/logger.ts`)写入的 NDJSON 文件。host 和agent 的 stderr 行会被包装成对应通道的记录。audit 通道由 host-corediff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex ccdf8126c..0e3df55d3 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -5983,13 +5983,16 @@ IPC 请求无法关闭。`.AppImage`、macOS 上的 `open -n`),同时观察窗口与进程列表。2)把窗口最小化到托盘后再次启动。3)在关闭行为为 `tray` 的 Windows/Linux 上关闭窗口后再次启动。4)在应用运行期间,用指向空目录的 `PI_DESKTOP_DATA_DIR` 启动一个构建。- 5)退出应用,确认没有残留进程,然后再启动一次。+ 5)在正式版仍在运行时启动一个开发构建(`dev` 脚本,不设+ `PI_DESKTOP_DATA_DIR`)。6)退出应用,确认没有残留进程,然后再启动一次。- **预期**:步骤 1–3 不会创建第二个窗口、托盘图标、host-core、agent sidecar 或日志文件:已有窗口被恢复并聚焦,重复的进程退出,运行中实例的会话列表、进行中的轮次和 `pi.sqlite` 都不受影响。步骤 4 作为面向自有数据目录的独立实例正常- 启动。步骤 5 干净地启动单个实例,证明锁在退出时释放,不会留下过期阻塞。+ 启动。步骤 5 同样正常启动:开发构建使用自己的 `userData` 与+ `~/.pi-desktop-dev`,既不等待也不打扰正在运行的正式版。步骤 6 干净地启动单个+ 实例,证明锁在退出时释放,不会留下过期阻塞。- **链接规格**:`03-runtime/07-process-model.md`、- `08-meta/decisions-log.md`(D236、D002)、ADR 0094+ `08-meta/decisions-log.md`(D236、D599、D002)、ADR 0094- **验收**:A(应用程序生命周期),质量- **里程碑**:M6+- **状态**:Unit/source-contract 已覆盖;原生跨平台再次启动之旅diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 3aee8ed93..c3aa09ced 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -305,6 +305,7 @@| D275 | 在上下文压缩期间保留活动任务边界 | **修订 D203 / ADR 0064(代理运行时):检查点记录不透明的 `details.retainedTailMode`。当提供商必须在工具结果、`toolUse` 或溢出恢复后继续时,活动回合检查点只保留最新的用户消息(沿用现有 20,000 令牌上限)。在终止边界、发送新提示之前和手动压缩时,已完成回合检查点的保留尾部为空,摘要是已完成工作的权威内容。没有该模式的旧记录归一化为最新的用户消息。不改变可见转录本、存储 schema、主机所有权或协议形状。** | 压缩掉完成消息却保留多个最近用户提示,会让下一条提示看起来像旧任务的延续(issue #22)。恢复时必须显式保留任务边界,同时活动工具循环仍需保留继续当前任务所需的提示。 || D278 | 子代理模型选择 | **Task.model 覆盖定义中固定的模型;只有带 `availableForSubagents` 的模型出现在委托目录中;启动时未预解析的模型由按需 RPC 解析** | 父代理需要按任务选择模型,又不能暴露完整的服务商配置。选择加入的标志让委托目录保持有界且有意为之,按需解析则避免 sidecar 启动后新增模型的绑定过期。参见 §3/02 §5f、§3/11 §7 与 E2E-166。 || D365 | 为实时活动行的每个安静间隔命名 | **修订 D338 / ADR 0175:`AgentActivity` 增加 `preparing`、`compacting`、`recovering`;`starting` 显示独立标签;`waiting-subagents` 携带实时运行快照(`name`、`lastPhase`、`lastToolName`),随子级工具/思考变化更新而非逐 token 更新。该行保持为一条紧凑的内联状态,不恢复活动分组胶囊。** | 压缩、静默回合恢复、工具后间隙与启动都像卡住的通用等待,父级等待也隐藏了委托在做什么(ADR 0198,E2E-008c / E2E-094) |+| D599 | 开发构建是一个独立安装 | **收窄 D236 / 修订 ADR 0094:开发构建(未打包,或 `PI_DESKTOP_DEV=1`)以 `PI-Desktop Dev` 作为 Electron `userData`(随之独立的单实例锁、渲染层 `localStorage`、插件面板 partition 与浏览器面板 Cookie),数据目录为 `~/.pi-desktop-dev`。显式 `--user-data-dir` 仍然优先,E2E 装置正是用它把构建指向临时 profile。正式安装仍保持 `PI-Desktop` 与 `~/.pi-desktop`,既有 profile 不会被搬迁。`PI_DESKTOP_DATA_DIR` 仍优先于两种 profile,并在作为子进程环境变量传给 host-core 之前被绝对化;Electron 主进程把解析结果回写到该变量,使插件运行时读到同一个根目录。不改 IPC、协议、schema 或正式安装路径。见 `03-runtime/07-process-model.md` 与 E2E-150。** | 已在运行的正式版持有锁,`pnpm dev` 一启动就退出;而抢到锁的开发 host 会把第二个 host-core 压到同一个单写者 `pi.sqlite`、outbox 与日志树上。 |## M0. 模型目录决策@@ -4544,3 +4545,10 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.- 合并后的「模型 × 推理」菜单根层现在直接展示一个原生 range 输入,每个已启用等级一个刻度,并配有可点击的刻度标签,位置就在「推理等级」条目正下方。拖动滑块或点击刻度都会通过同一条 `configureActiveSession` 路径立即提交等级,并停留在菜单原处,因此临时调整不必再往子菜单里跑一趟。「推理等级」条目本身仍然打开经典单选列表,保留其单选语义、末尾勾选、上/下/Enter/左键契约与返回根层的行为。- 滑块在获得焦点时自行掌管方向键/Home/End/Enter,因此这些按键用于调整等级而不再驱动菜单导航,Escape 仍然关闭菜单。拖过多个刻度只保留最后一次待提交的档位,提交按 latest-wins 串行,空闲会话的持久化不会把中间档写进去;会话或模型变化会作废未完成的提交。本地拖动前导值避免受控输入在 store 确认回写之前被弹回。刻度标签可点但不进入 Tab 顺序。当菜单只列出一个等级时,滑块整体隐藏。- 等级值仍是未翻译的规范字符串,在绑定暴露已启用规范档位时也包括会话级 `omit`(D456)。七级阶梯、提供方过滤与钳制规则均未改动;仅渲染层:无协议、存储、宿主、权限或迁移改动。见 `04-ux/08-component-spec.md`、`04-ux/07-ui-design-system.md` 与 E2E-050。++## 2026-09-20 —— 开发构建是一个独立安装(D599)++- 正式打包版与 `pnpm dev` 不再共享定义「一个安装」的那两个目录。开发构建运行在操作系统应用数据根目录下的 `PI-Desktop Dev`(即独立的 Electron `userData`,随之独立的单实例锁、渲染层 `localStorage`、插件面板 partition 与浏览器面板 Cookie),数据目录为 `~/.pi-desktop-dev`。正式安装仍保持 `PI-Desktop` 与 `~/.pi-desktop` 不变,既有 profile 不会被搬迁。+- 因此已在运行的正式版不再拒绝开发启动所需的锁,两者也不会把两个 host-core 压到同一个 `pi.sqlite`、同一个持久化 outbox 或同一棵日志树上。`PI_DESKTOP_DATA_DIR` 仍然优先于两种 profile,并且在作为子进程环境变量传给 host-core 之前被绝对化;Electron 主进程把解析结果回写到该变量,使插件运行时读到同一个根目录,而不是回退到正式版默认值。+- 显式 `--user-data-dir` 仍然优先,E2E 装置正是用它把构建指向临时 profile。+- 决策 D599 收窄 D236 并修订 ADR 0094:锁仍以「安装」为作用域,而开发构建现在是第二个安装,不再是一个含义模糊的第二个进程。未改动任何 IPC 通道、宿主协议、存储 schema 或正式安装的路径。见 `03-runtime/07-process-model.md`、`03-runtime/04-data-storage.md` 与 `02-architecture/03-repo-structure.md`。