Skip to content

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

Merge pull request #527 from Akshayxkill/pi-desktop-fork

vastsa3591c963c515
diff --cc apps/desktop/electron/main/bootstrap/shutdown.ts
index 098ac11ce,0297d9ab9..fa3737229
--- a/apps/desktop/electron/main/bootstrap/shutdown.ts
+++ b/apps/desktop/electron/main/bootstrap/shutdown.ts
@@@ -40,10 -38,8 +40,9 @@@ export type ShutdownDependencies =
pluginPanels: Pick<PluginPanelHost, "closeAll">;
plugins: Pick<PluginRuntime, "disposeAll">;
userMcp: Pick<UserMcpRuntime, "disposeAll">;
+ mcpOAuth?: Pick<McpOAuthManager, "disposeAll">;
browserPane: Pick<BrowserPane, "dispose">;
pluginViews: Pick<PluginViewHost, "dispose">;
- pluginSettingsViews: Pick<PluginViewHost, "dispose">;
updater: Pick<AppUpdaterController, "dispose" | "isInstallingUpdate">;
logger: Pick<Logger, "app">;
confirmQuitDialog: () => Promise<boolean>;
@@@ -62,10 -58,8 +61,9 @@@ export function registerShutdownHandler
pluginPanels,
plugins,
userMcp,
+ mcpOAuth,
browserPane,
pluginViews,
- pluginSettingsViews,
updater,
logger,
confirmQuitDialog,
@@@ -156,10 -145,8 +154,9 @@@
// end every quit in error logs, toasts, and restarts into a closing app.
const pluginShutdown = plugins.disposeAll();
userMcp.disposeAll();
+ mcpOAuth?.disposeAll();
browserPane.dispose();
pluginViews.dispose();
- pluginSettingsViews.dispose();
inflightCheckpointer.dispose();
const sidecarShutdown = getSidecar()?.dispose();
diff --cc apps/desktop/electron/main/index.ts
index 9fba91df3,f2026dc05..04f623770
--- a/apps/desktop/electron/main/index.ts
+++ b/apps/desktop/electron/main/index.ts
@@@ -1483,10 -1477,8 +1480,9 @@@ registerShutdownHandlers(
pluginPanels,
plugins,
userMcp,
+ mcpOAuth,
browserPane,
pluginViews,
- pluginSettingsViews,
updater,
logger,
confirmQuitDialog,
diff --cc apps/desktop/electron/main/plugin-runtime.ts
index 570b3b703,51775828d..b2f542174
--- a/apps/desktop/electron/main/plugin-runtime.ts
+++ b/apps/desktop/electron/main/plugin-runtime.ts
@@@ -1417,7 -1320,26 +1416,26 @@@ export class PluginRuntime
return this.loaded.get(pluginId);
}
+ /**
+ * Read a persisted declared variable without exposing the plugin's private
+ * settings record. Host-rendered scenic destinations use this only after
+ * validating the matching declaration themselves.
+ */
+ getThemeVariableValue(pluginId: string, themeId: string, name: string): unknown {
+ const loaded = this.loaded.get(pluginId);
+ if (!loaded) return undefined;
+ return this.readThemeVariableValues(loaded, themeId)[name];
+ }
+
+ async setScenicThemeBlur(pluginId: string, themeId: string, blur: number): Promise<void> {
+ const loaded = this.loaded.get(pluginId);
+ if (!loaded || !loaded.permissions.has("ui.theme")) {
+ throw apiError("PERMISSION_DENIED", "ui.theme");
+ }
+ await this.hostApi(loaded).themes.setVariables(themeId, { "--nexus-backdrop-blur": blur });
+ }
+
- /** Return the manifest-backed settings view for the installed-plugin UI. */
+ /** Manifest settings as the installed-plugin sheet reads them. Titles stay the author's language; plugin-owned UI localizes via `app.getLocale` / `appearance:changed` (ADR 0280). */
async getPluginSettings(pluginId: string): Promise<PluginSettingDefinition[]> {
const loaded = this.loaded.get(pluginId);
if (!loaded) throw apiError("NOT_FOUND", `plugin not loaded: ${pluginId}`);
diff --cc apps/desktop/electron/main/services/plugin-services.ts
index b1822aa80,de0f59886..f1de272d9
--- a/apps/desktop/electron/main/services/plugin-services.ts
+++ b/apps/desktop/electron/main/services/plugin-services.ts
@@@ -636,9 -589,7 +624,8 @@@ export function createPluginServices(
announceTurnEnded,
pluginPanels,
pluginViews,
- pluginSettingsViews,
browserHost,
browserPane,
+ speech,
};
}
diff --cc apps/desktop/src/features/settings/SettingsPage.tsx
index 5b85d54c7,472faf428..87d2e378c
--- a/apps/desktop/src/features/settings/SettingsPage.tsx
+++ b/apps/desktop/src/features/settings/SettingsPage.tsx
@@@ -54,9 -53,8 +54,9 @@@ import
ImportSection,
UpdatesRow,
} from "./agent-sections";
+import { VoiceSettingsCard } from "./voice-settings";
import { CloseBehaviorSection, DeveloperSection } from "./developer-sections";
- import { PluginSettingsDestination } from "../../components/settings/PluginSettingsDestination";
+ import { PluginScenicThemesDestination } from "../../components/settings/PluginScenicThemesDestination";
type SettingsTab = ReturnType<typeof useAppStore.getState>["settingsTab"];
diff --cc docs/adr/0287-host-rendered-plugin-scenic-settings-surfaces.md
index 000000000,0c8cee3f8..0c8cee3f8
mode 000000,100644..100644
--- a/docs/adr/0287-host-rendered-plugin-scenic-settings-surfaces.md
+++ b/docs/adr/0287-host-rendered-plugin-scenic-settings-surfaces.md
diff --cc docs/adr/0288-package-local-theme-assets.md
index 000000000,4564c9ba0..4564c9ba0
mode 000000,100644..100644
--- a/docs/adr/0288-package-local-theme-assets.md
+++ b/docs/adr/0288-package-local-theme-assets.md
diff --cc docs/adr/README.md
index 52a34bcc4,2e98e9e73..ece478383
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@@ -306,11 -306,5 +306,13 @@@ Each ADR includes
| 0277 | [Draggable chat content width](0277-draggable-chat-content-width.md) | Accepted (D439) |
| 0278 | [Canonical application ID `net.aiuo.pi-desktop`](0278-canonical-application-id.md) | Accepted (D443; amends D141 / D371 / ADR 0204; issue #524) |
| 0279 | [Resumable subagent delegations](0279-resumable-subagent-delegations.md) | Accepted for implementation (amends ADR 0062; ADR 0089; issue #513) |
-| 0280 | [Host-rendered plugin scenic Settings surfaces](0280-host-rendered-plugin-scenic-settings-surfaces.md) | Accepted for implementation |
-| 0281 | [Package-local theme assets remain available](0281-package-local-theme-assets.md) | Accepted for implementation (amends ADR 0255) |
+| 0280 | [Plugin-owned UI localizes from the host locale](0280-plugin-owned-ui-localizes-from-host-locale.md) | Accepted (amends ADR 0267; ADR 0159) |
+| 0281 | [Host speech capability](0281-host-speech-capability.md) | Accepted for implementation (amends ADR 0257) |
+| 0282 | [Retry and right-size the compaction summary before retained-tail recovery](0282-compaction-summary-retry-and-sizing.md) | Accepted (amends ADR 0049; issue #543) |
+| 0283 | [Remote MCP server OAuth 2.1 authentication](0283-remote-mcp-oauth.md) | Accepted |
+| 0284 | [Headless runtime boundary in `packages/host-runtime`](0284-headless-runtime-boundary.md) | Accepted for implementation (D447; ADR 0205 R2 prerequisite) |
+| 0285 | [`RACP-WS` transport in `packages/racp`](0285-racp-ws-transport.md) | Accepted for implementation (D448; ADR 0205 R2) |
+| 0286 | [Remote-host desktop kernel](0286-remote-host-desktop-kernel.md) | Accepted for implementation (D449; ADR 0205 R2) |
++| 0287 | [Host-rendered plugin scenic Settings surfaces](0287-host-rendered-plugin-scenic-settings-surfaces.md) | Accepted for implementation |
++| 0288 | [Package-local theme assets remain available](0288-package-local-theme-assets.md) | Accepted for implementation (amends ADR 0255) |
+| turn-process-and-thinking-display | [Turn process and thinking presentation](turn-process-and-thinking-display.md) | Accepted |
diff --cc docs/spec/07-plugins/03-plugin-api.md
index dccca5c2e,a2c59300e..f11088f0b
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@@ -762,6 -734,24 +762,24 @@@ recognition and speech synthesis remai
text fallback and announce permission or recognition failures through its
accessible status.
+ ## Scenic Settings contribution
+
+ `contributes.scenicThemes` is a declarative presentation contribution, not a
+ plugin page API. It provides localized card metadata for same-plugin themes and
+ declared preview assets. The host owns the Settings DOM, styles, selection,
+ focus behavior, slider draft, and Apply action. The plugin receives no Settings
+ bridge, renderer DOM access, arbitrary CSS, JavaScript, navigation, or actions.
+
+ The host persists Apply through the existing typed theme-variable boundary and
+ only for the declared `--nexus-backdrop-blur` variable. `ui.panel` windows and
+ `contributes.views` retain their independent native-view implementation.
+
+ Theme assets declared for scenic cards may be package-relative, in which case
+ the host resolves them inside the installed plugin package before rewriting the
+ matching CSS `url()` or card preview to `plugin-asset:`. Absolute declared
+ assets retain the external-path route. Neither route grants a plugin arbitrary
-filesystem access (ADR 0281).
++filesystem access (ADR 0288).
+
### audio (requires `audio.capture.background` / `audio.playback.background`)
**Callable, but the device backend is not implemented in this branch.**
diff --cc docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.md
index 000000000,3dedb5484..a17c0c87f
mode 000000,100644..100644
--- a/docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.md
+++ b/docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.md
@@@ -1,0 -1,114 +1,114 @@@
+ # Host-rendered Scenic Settings Implementation Plan
+
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+ **Goal:** Replace the opaque plugin Settings page with host-rendered scenic cards and an Apply-gated blur slider.
+
+ **Architecture:** Plugins submit a strictly validated `scenicThemes` data contribution. Electron main validates same-plugin themes and assets, then returns safe presentation metadata. React renders the content directly in Settings, so neither a native child view nor an iframe exists between the scenic background and controls. The existing typed `themes.setVariables` API stays the only persistence writer.
+
+ **Tech Stack:** TypeScript, Plugin SDK manifest validation, Electron IPC, React, existing theme runtime, CSS, Node test runner.
+
+ **Spec:** `docs/superpowers/specs/2026-09-17-host-rendered-scenic-settings-design.md`
+
+ ## Global Constraints
+
+ - Do not modify Nexus.
+ - Preserve `ui.theme`, `ui.settings`, `ui.window.appearance`, native controls, Settings navigation, work panel behavior, and theme isolation.
+ - Plugins contribute no Settings HTML, JavaScript, CSS, DOM, selectors, or arbitrary actions.
+ - Blur accepts only integer 0 through 20. Card selection is immediate; Apply is the only persistence action.
+ - The outer scenic destination stays transparent. Cards and the blur control are the only material surfaces.
+
+ ---
+
+ ### Task 1: Add the closed scenic manifest contribution
+
+ **Files:**
+ - Modify: `packages/plugin-sdk/src/index.ts`
+ - Modify: `packages/plugin-sdk/src/index.test.ts`
+ - Modify: `docs/spec/07-plugins/02-plugin-manifest-schema.md`
+
+ **Interfaces:** Add `PluginScenicThemesContrib` (`id`, localized `label`, `description`, `keywords`, `icon: "palette"`, `themes`) and `PluginScenicThemeCardContrib` (`themeId`, localized `label`, localized `description`, `previewAsset`).
+
+ - [ ] Write failing tests that reject zero cards, thirteen cards, duplicate `themeId`, string-only card copy, invalid IDs, non-relative preview paths, and unknown icon tokens.
+ - [ ] Run `pnpm --filter @pi-desktop/plugin-sdk test -- index.test.ts` and observe failure because `scenicThemes` is not recognized.
+ - [ ] Implement types and manifest validation. Require 1–12 cards, localized EN/zh-CN values, valid stable id, and relative image asset path.
+ - [ ] Run the SDK test green and commit `feat(plugins): declare scenic Settings contributions`.
+
+ ### Task 2: Provide host-validated scenic metadata
+
+ **Files:**
+ - Modify: `packages/shared/src/protocol.ts`
+ - Modify: `apps/desktop/electron/main/plugin-runtime.ts`
+ - Modify: `apps/desktop/electron/main/ipc/plugin-ui-ipc.ts`
+ - Modify: `apps/desktop/src/lib/api.ts`
+ - Modify: `apps/desktop/test/plugin-appearance-extensions.test.mjs`
+
+ **Interfaces:** Add `PluginScenicThemesDestinationMeta` with destination identity, resolved copy, cards in manifest order, namespaced owned theme IDs, host rewritten `previewUrl`, and current/default blur. Add `api.listPluginScenicThemesDestinations()`.
+
+ - [ ] Write failing test assertions for `pluginScenicThemesDestinations`, `previewUrl`, both `ui.settings` and `ui.theme` checks, same-plugin theme ownership, and no `entry` HTML dependency.
+ - [ ] Run `node --test apps/desktop/test/plugin-appearance-extensions.test.mjs` and observe failure.
+ - [ ] Implement the endpoint. Include only loaded plugins with both grants. Verify every card refers to a registered same-plugin theme and that the preview belongs to that theme's declared assets. Rewrite image URLs through `plugin-asset://`; omit invalid destinations. Return current/default `--nexus-backdrop-blur` values only when that typed length variable is declared as whole integer 0–20.
+ - [ ] Run the focused test green and commit `feat(plugins): expose host scenic destination metadata`.
+
+ ### Task 3: Build the host React scenic destination
+
+ **Files:**
+ - Create: `apps/desktop/src/components/settings/PluginScenicThemesDestination.tsx`
+ - Modify: `apps/desktop/src/features/settings/SettingsPage.tsx`
+ - Modify: `apps/desktop/src/styles/settings.css`
+ - Modify: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`
+
+ **Interfaces:** Component consumes `PluginScenicThemesDestinationMeta`, the existing theme selection API, and typed variable API. It renders host-owned card buttons (`aria-pressed`), native `input type="range"`, `output`, and Apply button.
+
+ - [ ] Write failing test assertions that `SettingsPage` imports `PluginScenicThemesDestination`, contains no `PluginSettingsDestination`, and that the component contains `aria-pressed`, native range, `Apply`, and no iframe. Assert scenic wrapper CSS background is transparent.
+ - [ ] Run `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs` and observe failure.
+ - [ ] Implement transparent outer wrapper and responsive four-card grid. Card click changes theme immediately. Slider changes local draft and output only. Apply sends exactly `{ "--nexus-backdrop-blur": draftBlur }` for the selected owned theme, confirms only after success, restores confirmed value after error, and uses existing toast behavior.
+ - [ ] Style independent image cards and blur-control tile using host CSS. Add selected checkmark, visible focus, narrow layout, and opaque readable reduced-transparency fallback. Do not add a page-sized panel/background or modify chrome/drag rules.
+ - [ ] Run focused test green and commit `feat(settings): render scenic plugin themes in host`.
+
+ ### Task 4: Migrate Nexus Scenic Themes pack
+
+ **Files:**
+ - Modify: `C:/jcode projects/worktrees/nexus-scenic-settings-20260915/plugins/io.github.akshayxkill.nexus-scenic-themes/manifest.json`
+ - Delete: `C:/jcode projects/worktrees/nexus-scenic-settings-20260915/plugins/io.github.akshayxkill.nexus-scenic-themes/settings/index.html`
+ - Delete: `C:/jcode projects/worktrees/nexus-scenic-settings-20260915/plugins/io.github.akshayxkill.nexus-scenic-themes/settings/settings.css`
+ - Delete: `C:/jcode projects/worktrees/nexus-scenic-settings-20260915/plugins/io.github.akshayxkill.nexus-scenic-themes/settings/settings.js`
+ - Modify: `C:/jcode projects/worktrees/nexus-scenic-settings-20260915/tests/nexus-scenic-themes.test.mjs`
+
+ - [ ] Write a failing plugin test requiring four `scenicThemes` cards in Twilight, Alpine, Obsidian, Emerald order; requiring `settingsDestinations` absent; and requiring the three page files absent.
+ - [ ] Run `node --test tests/nexus-scenic-themes.test.mjs` in the plugin checkout and observe failure.
+ - [ ] Replace the manifest HTML destination with four cards using existing declared asset paths and themes. Preserve the three requested permissions and typed blur variable. Remove the obsolete page directory.
+ - [ ] Run plugin test green and commit `feat(nexus-scenic-themes): use host scenic settings` in the plugin checkout.
+
+ ### Task 5: Retire the HTML Settings runtime and synchronize specs
+
+ **Files:**
+ - Delete: `apps/desktop/src/components/settings/PluginSettingsDestination.tsx`
+ - Delete: `apps/desktop/electron/main/plugin-settings-protocol.ts`
+ - Modify: `apps/desktop/electron/main/bootstrap/startup.ts`
+ - Modify: `apps/desktop/electron/main/ipc/plugin-ui-ipc.ts`
+ - Modify: `docs/adr/0255-plugin-appearance-extensions.md`
-- Modify: `docs/adr/0280-host-rendered-plugin-scenic-settings-surfaces.md`
++- Modify: `docs/adr/0287-host-rendered-plugin-scenic-settings-surfaces.md`
+ - Modify: `docs/spec/07-plugins/04-plugin-security.md`
+ - Modify: `docs/spec/06-delivery/04-e2e-test-plan.md`
+ - Modify: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`
+
+ - [ ] Write failing retirement assertions: no `PluginSettingsDestination` import, no `installPluginSettingsProtocol`, ADR 0255 contains `host-rendered`, and security spec forbids plugin Settings DOM/CSS/HTML.
+ - [ ] Run `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs` and observe failure.
+ - [ ] Remove iframe/page protocol lifecycle and document the narrow declarative contract, security boundary, visual ownership, Apply semantics, cleanup fallback, native controls, and manual E2E coverage.
+ - [ ] Run focused test green and commit `refactor(plugins): retire Settings document surfaces`.
+
+ ### Task 6: Validate and manually inspect
+
+ - [ ] Run:
+
+ ```powershell
+ node --test apps/desktop/test/plugin-appearance-extensions.test.mjs apps/desktop/test/plugin-settings-renderer-surface.test.mjs apps/desktop/test/plugin-themes.test.mjs
+ pnpm --filter @pi-desktop/plugin-sdk test
+ pnpm --filter @pi-desktop/shared build
+ pnpm --filter @pi-desktop/desktop exec tsc -p tsconfig.json --noEmit
+ git diff --check
+ ```
+
+ - [ ] Run the fork with `pnpm --filter @pi-desktop/desktop dev`; confirm four image cards appear directly on the scenic canvas without an outer rectangle, blur draft changes do not persist before Apply, Apply persists values, and Windows/Linux controls remain clickable.
+ - [ ] Review the complete diff. Rebase this branch onto local main, merge into local main from the primary checkout, verify commits, and remove only this request worktree/branch. Do not push unless explicitly requested.