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(plugins): host-render scenic theme settings
Maez4243d68e7794
diff --git a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts b/apps/desktop/electron/main/bootstrap/app-lifecycle.tsindex 685ef4a99..1b2d0b837 100644--- a/apps/desktop/electron/main/bootstrap/app-lifecycle.ts+++ b/apps/desktop/electron/main/bootstrap/app-lifecycle.ts@@ -61,7 +61,6 @@ export type ApplicationLifecycleDependencies = {applyCloseBehavior: (behavior: CloseBehavior) => void;browserPane: BrowserPane;pluginViews: PluginViewHost;- pluginSettingsViews: PluginViewHost;plugins: PluginRuntime;logger: Pick<Logger, "app">;refreshReleaseNotes: () => void;@@ -94,7 +93,6 @@ export function createApplicationLifecycle({applyCloseBehavior,browserPane,pluginViews,- pluginSettingsViews,plugins,logger,refreshReleaseNotes,@@ -273,7 +271,6 @@ export function createApplicationLifecycle({createTray,browserPane,pluginViews,- pluginSettingsViews,plugins,logger,});diff --git a/apps/desktop/electron/main/bootstrap/shutdown.ts b/apps/desktop/electron/main/bootstrap/shutdown.tsindex 14e7bb944..0297d9ab9 100644--- a/apps/desktop/electron/main/bootstrap/shutdown.ts+++ b/apps/desktop/electron/main/bootstrap/shutdown.ts@@ -40,7 +40,6 @@ export type ShutdownDependencies = {userMcp: Pick<UserMcpRuntime, "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>;@@ -61,7 +60,6 @@ export function registerShutdownHandlers({userMcp,browserPane,pluginViews,- pluginSettingsViews,updater,logger,confirmQuitDialog,@@ -149,7 +147,6 @@ export function registerShutdownHandlers({userMcp.disposeAll();browserPane.dispose();pluginViews.dispose();- pluginSettingsViews.dispose();inflightCheckpointer.dispose();const sidecarShutdown = getSidecar()?.dispose();diff --git a/apps/desktop/electron/main/bootstrap/window.ts b/apps/desktop/electron/main/bootstrap/window.tsindex a9c3e78e9..c9b45ea4b 100644--- a/apps/desktop/electron/main/bootstrap/window.ts+++ b/apps/desktop/electron/main/bootstrap/window.ts@@ -100,7 +100,6 @@ export type WindowLifecycleDependencies = {createTray: () => void;browserPane: BrowserPane;pluginViews: PluginViewHost;- pluginSettingsViews: PluginViewHost;plugins: PluginRuntime;logger: Pick<Logger, "app">;};@@ -128,7 +127,6 @@ export async function createWindow({createTray,browserPane,pluginViews,- pluginSettingsViews,plugins,logger,}: WindowLifecycleDependencies): Promise<void> {@@ -587,7 +585,6 @@ export async function createWindow({browserPane.setWindow(window);pluginViews.setWindow(window);- pluginSettingsViews.setWindow(window);window.on("closed", () => {screen.removeListener("display-metrics-changed", reconcileDisplayTopology);screen.removeListener("display-added", reconcileDisplayTopology);@@ -613,7 +610,6 @@ export async function createWindow({windowState.mainWindow = null;browserPane.setWindow(null);pluginViews.setWindow(null);- pluginSettingsViews.setWindow(null);if (process.platform !== "darwin" &&windowState.pluginLauncherWindow &&diff --git a/apps/desktop/electron/main/index.ts b/apps/desktop/electron/main/index.tsindex 36c9085e4..f2026dc05 100644--- a/apps/desktop/electron/main/index.ts+++ b/apps/desktop/electron/main/index.ts@@ -680,7 +680,6 @@ const {emitBrowserState,pluginPanels,pluginViews,- pluginSettingsViews,browserHost,browserPane,announceTurnEnded,@@ -923,7 +922,6 @@ applicationLifecycle = createApplicationLifecycle({applyCloseBehavior: applyCloseBehaviorForLifecycle,browserPane,pluginViews,- pluginSettingsViews,plugins,logger,refreshReleaseNotes: () => updater.refreshReleaseNotes(),@@ -1326,7 +1324,6 @@ function registerIpc() {activeUserSubagentDocuments,disabledBuiltinSubagents,pluginViews,- pluginSettingsViews,pluginScopes,rememberPluginScopes,pluginPanels,@@ -1482,7 +1479,6 @@ registerShutdownHandlers({userMcp,browserPane,pluginViews,- pluginSettingsViews,updater,logger,confirmQuitDialog,diff --git a/apps/desktop/electron/main/ipc/plugin-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ipc.tsindex c4e66ab54..f0f217186 100644--- a/apps/desktop/electron/main/ipc/plugin-ipc.ts+++ b/apps/desktop/electron/main/ipc/plugin-ipc.ts@@ -21,7 +21,6 @@ export type PluginIpcDependencies = {agentExtensions: AgentExtensionBridge;browserHost: BrowserHost;pluginViews: PluginViewHost;- pluginSettingsViews: PluginViewHost;pluginScopes: Map<string, ActivationScope>;rememberPluginScopes: (list: any[]) => void;sendToRenderer: (channel: string, payload?: unknown) => void;@@ -36,7 +35,6 @@ export function registerPluginIpc({agentExtensions,browserHost,pluginViews,- pluginSettingsViews,pluginScopes,rememberPluginScopes,sendToRenderer,@@ -342,7 +340,6 @@ export function registerPluginIpc({handle(IPC.invoke.pluginDisable, async (id: string) => {if (!host) throw new Error("host unavailable");pluginViews.closePlugin(id);- pluginSettingsViews.closePlugin(id);if (id === BROWSER_PLUGIN_ID) browserHost.disposeGuest();await plugins.unload(id);logger.app("plugin", "info", "plugin disabled", { pluginId: id });@@ -354,7 +351,6 @@ export function registerPluginIpc({handle(IPC.invoke.pluginUninstall, async (id: string) => {if (!host) throw new Error("host unavailable");pluginViews.closePlugin(id);- pluginSettingsViews.closePlugin(id);await plugins.unload(id);logger.app("plugin", "info", "plugin uninstalled", { pluginId: id });const res = await host.call("plugins.uninstall", { id });diff --git a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ui-ipc.tsindex e8c568a2a..80ddbfc8b 100644--- a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts+++ b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts@@ -1,7 +1,7 @@import { existsSync } from "node:fs";import { join } from "node:path";-import { IPC, type PluginSettingsDestinationMeta, type PluginViewMeta } from "@pi-desktop/shared";-import { resolvePluginLocalizedString } from "@pi-desktop/plugin-sdk";+import { IPC, type PluginScenicThemesDestinationMeta, type PluginViewMeta } from "@pi-desktop/shared";+import { normalizeThemeAssetPath, pluginThemeId, resolvePluginLocalizedString, themeAssetUrl } from "@pi-desktop/plugin-sdk";import type { BrowserHost } from "../browser-host";import { BROWSER_PLUGIN_ID, BROWSER_VIEW_ID } from "../browser-host";import type { PluginRuntime } from "../plugin-runtime";@@ -16,7 +16,6 @@ export type PluginUiIpcDependencies = {plugins: PluginRuntime;browserHost: BrowserHost;pluginViews: PluginViewHost;- pluginSettingsViews: PluginViewHost;pluginPanels: PluginPanelHost;pluginActiveInProject: (pluginId: string, projectPath: string | null | undefined) => boolean;currentWorkspacePath: () => string | null;@@ -30,7 +29,6 @@ export function registerPluginUiIpc({plugins,browserHost,pluginViews,- pluginSettingsViews,pluginPanels,pluginActiveInProject,currentWorkspacePath,@@ -107,47 +105,74 @@ export function registerPluginUiIpc({);});- handle(IPC.invoke.pluginSettingsDestinations, async () => {- const destinations: PluginSettingsDestinationMeta[] = [];+ handle(IPC.invoke.pluginScenicThemesDestinations, async () => {+ const destinations: PluginScenicThemesDestinationMeta[] = [];for (const loaded of plugins.listLoaded()) {- if (!loaded.permissions.has("ui.settings")) continue;- for (const destination of loaded.manifest.contributes?.settingsDestinations ?? []) {- const entry = resolveInsidePluginRoot(loaded.path, destination.entry);- if (!entry || !existsSync(entry)) continue;- destinations.push({- pluginId: loaded.manifest.id,- destinationId: destination.id,- ref: pluginViewKey(loaded.manifest.id, destination.id),- label: resolvePluginLocalizedString(destination.label, getUpdaterLocale(), destination.id),- pluginName: loaded.manifest.name,- icon: destination.icon,- keywords: (destination.keywords ?? []).map((keyword) => resolvePluginLocalizedString(keyword, getUpdaterLocale(), "")),+ if (!loaded.permissions.has("ui.settings") || !loaded.permissions.has("ui.theme")) continue;+ const scenicThemes = loaded.manifest.contributes?.scenicThemes;+ if (!scenicThemes) continue;+ const pluginId = loaded.manifest.id;+ const cards: PluginScenicThemesDestinationMeta["themes"] = [];+ let valid = true;+ for (const card of scenicThemes.themes) {+ const contribution = (loaded.manifest.contributes?.themes ?? []).find((theme) => theme.id === card.themeId);+ const namespacedThemeId = pluginThemeId(pluginId, card.themeId);+ const theme = plugins.getThemes().find((candidate) => candidate.id === namespacedThemeId);+ const previewAsset = normalizeThemeAssetPath(card.previewAsset);+ const ownsTheme = theme?.pluginId === pluginId;+ const ownsPreview = !!contribution && !!previewAsset && (contribution.assets ?? []).some((asset) => normalizeThemeAssetPath(asset) === previewAsset);+ const blur = contribution?.variables?.find((variable) => variable.name === "--nexus-backdrop-blur");+ const validBlur = blur?.type === "length" && blur.unit === "px" && blur.min === 0 && blur.max === 20 && Number.isInteger(blur.default);+ if (!ownsTheme || !ownsPreview || !validBlur) {+ valid = false;+ break;+ }+ const stored = plugins.getThemeVariableValue(pluginId, namespacedThemeId, "--nexus-backdrop-blur");+ const currentBlur = typeof stored === "number" && Number.isInteger(stored) && stored >= 0 && stored <= 20 ? stored : blur.default;+ cards.push({+ themeId: namespacedThemeId,+ label: resolvePluginLocalizedString(card.label, getUpdaterLocale(), card.themeId),+ description: resolvePluginLocalizedString(card.description, getUpdaterLocale(), ""),+ previewUrl: themeAssetUrl(pluginId, previewAsset),+ blur: currentBlur,+ blurDefault: blur.default,});}+ if (!valid || !cards.length) continue;+ destinations.push({+ pluginId,+ destinationId: scenicThemes.id,+ ref: pluginViewKey(pluginId, scenicThemes.id),+ label: resolvePluginLocalizedString(scenicThemes.label, getUpdaterLocale(), scenicThemes.id),+ description: resolvePluginLocalizedString(scenicThemes.description, getUpdaterLocale(), ""),+ pluginName: loaded.manifest.name,+ icon: "palette",+ keywords: (scenicThemes.keywords ?? []).map((keyword) => resolvePluginLocalizedString(keyword, getUpdaterLocale(), "")),+ themes: cards,+ });}return destinations.sort((a, b) => a.pluginName.localeCompare(b.pluginName) || a.destinationId.localeCompare(b.destinationId));});- handle(IPC.invoke.pluginSettingsViewOpen, async (payload: { pluginId?: string; destinationId?: string }) => {+ handle(IPC.invoke.pluginScenicThemesSetBlur, async (payload: { pluginId?: string; themeId?: string; blur?: unknown }) => {const pluginId = String(payload?.pluginId ?? "");- const destinationId = String(payload?.destinationId ?? "");+ const themeId = String(payload?.themeId ?? "");+ const blur = payload?.blur;+ if (!Number.isInteger(blur) || (blur as number) < 0 || (blur as number) > 20) {+ throw new Error("INVALID_ARGUMENT: blur must be an integer from 0 to 20");+ }const loaded = plugins.getLoaded(pluginId);- if (!loaded || !loaded.permissions.has("ui.settings")) throw new Error("PERMISSION_DENIED: ui.settings");- const destination = (loaded.manifest.contributes?.settingsDestinations ?? []).find((entry) => entry.id === destinationId);- const htmlPath = destination ? resolveInsidePluginRoot(loaded.path, destination.entry) : null;- if (!htmlPath || !existsSync(htmlPath)) throw new Error("settings destination entry missing");- pluginSettingsViews.open({ pluginId, viewId: destinationId, locale: getUpdaterLocale(), theme: getPluginPanelTheme(), htmlPath, netDomains: loaded.manifest.net?.domains?.map(String) });- return { ok: true };- });- handle(IPC.invoke.pluginSettingsViewSetBounds, async (bounds: { x: number; y: number; width: number; height: number }) => {- pluginSettingsViews.setBounds(bounds ?? { x: 0, y: 0, width: 0, height: 0 });- return { ok: true };- });- handle(IPC.invoke.pluginSettingsViewSetVisible, async (payload: { pluginId?: string; destinationId?: string; visible?: boolean }) => {- pluginSettingsViews.setVisible(String(payload?.pluginId ?? ""), String(payload?.destinationId ?? ""), payload?.visible === true);+ const destination = loaded?.manifest.contributes?.scenicThemes;+ if (!loaded || !destination || !loaded.permissions.has("ui.settings") || !loaded.permissions.has("ui.theme")) {+ throw new Error("PERMISSION_DENIED: scenic theme controls unavailable");+ }+ const owned = destination.themes.some((card) => pluginThemeId(pluginId, card.themeId) === themeId);+ if (!owned) throw new Error("NOT_FOUND: scenic theme not found");+ await plugins.setScenicThemeBlur(pluginId, themeId, blur as number);return { ok: true };});+handle(IPC.invoke.pluginViewOpen,async (payload: {diff --git a/apps/desktop/electron/main/ipc/register.ts b/apps/desktop/electron/main/ipc/register.tsindex b5ddbba20..f282fd9bf 100644--- a/apps/desktop/electron/main/ipc/register.ts+++ b/apps/desktop/electron/main/ipc/register.ts@@ -124,7 +124,6 @@ export function registerIpcHandlers(dependencies: RegisterIpcDependencies) {refreshUserMcp,describeError,pluginViews,- pluginSettingsViews,pluginScopes,rememberPluginScopes,pluginPanels,@@ -334,7 +333,6 @@ export function registerIpcHandlers(dependencies: RegisterIpcDependencies) {agentExtensions,browserHost,pluginViews,- pluginSettingsViews,pluginScopes,rememberPluginScopes,sendToRenderer,@@ -373,7 +371,6 @@ export function registerIpcHandlers(dependencies: RegisterIpcDependencies) {plugins,browserHost,pluginViews,- pluginSettingsViews,pluginPanels,pluginActiveInProject,currentWorkspacePath,diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex 8d060d5d6..51775828d 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -1016,7 +1016,7 @@ export function resolveInsidePlugin(pluginPath: string, relative: string): strin* referencing one is refused instead of served from a half-honoured list.*/function resolveThemeAssets(- _pluginPath: string,+ pluginPath: string,declared: readonly string[],): { files: Map<string, string>; dropped: number } {const files = new Map<string, string>();@@ -1024,16 +1024,15 @@ function resolveThemeAssets(let total = 0;let dropped = 0;for (const asset of declared) {- // A theme asset is an absolute path; `normalizeThemeAssetPath` rejects- // package-relative references, so nothing is resolved against the package- // root any more. The plugin is the one naming the file.const normalized = normalizeThemeAssetPath(asset);- if (!normalized) {+ if (!normalized || normalized.split("/").includes("node_modules")) {dropped += 1;continue;}- const absolute = normalized;- if (!existsSync(absolute)) {+ const absolute = isExternalThemeAssetPath(normalized)+ ? normalized+ : resolveInsidePlugin(pluginPath, normalized);+ if (!absolute || !existsSync(absolute)) {dropped += 1;continue;}@@ -1321,6 +1320,25 @@ 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. */async getPluginSettings(pluginId: string): Promise<PluginSettingDefinition[]> {const loaded = this.loaded.get(pluginId);diff --git a/apps/desktop/electron/main/plugin-view-host.ts b/apps/desktop/electron/main/plugin-view-host.tsindex dfd5c16f3..31fb264e4 100644--- a/apps/desktop/electron/main/plugin-view-host.ts+++ b/apps/desktop/electron/main/plugin-view-host.ts@@ -364,7 +364,6 @@ export class PluginViewHost {],},});-const wc = view.webContents;// A docked view gets exactly one web contents. `window.open` would mint a// chromeless window outside the egress policy applied above.diff --git a/apps/desktop/electron/main/services/plugin-services.ts b/apps/desktop/electron/main/services/plugin-services.tsindex fa752a081..de0f59886 100644--- a/apps/desktop/electron/main/services/plugin-services.ts+++ b/apps/desktop/electron/main/services/plugin-services.ts@@ -414,7 +414,6 @@ export function createPluginServices({// surface. Drop it; the renderer re-opens it on the pluginChanged event if// the tab is still active and the plugin came back.pluginViews.closePlugin(pluginId);- pluginSettingsViews.closePlugin(pluginId);if (pluginId === BROWSER_PLUGIN_ID) browserHost.disposeGuest();sendToRenderer(IPC.event.pluginChanged,{ reason: "crash", pluginId });},@@ -442,7 +441,6 @@ export function createPluginServices({});// Views were loaded from the previous revision of the plugin's files.pluginViews.closePlugin(pluginId);- pluginSettingsViews.closePlugin(pluginId);if (pluginId === BROWSER_PLUGIN_ID) browserHost.disposeGuest();sendToRenderer(IPC.event.pluginChanged,{ reason: "reload", pluginId });},@@ -517,17 +515,7 @@ export function createPluginServices({data: { api: "view.egress", ok: false, url, ts: Date.now() },});});- // Settings extensions use the same sandboxed preload and egress policy as- // work-panel views, but have their own visible surface and lifecycle.- const pluginSettingsViews = new PluginViewHost(({ pluginId, url }) => {- logger.app("plugin", "warn", "plugin.api", {- pluginId,- code: "PERMISSION_DENIED",- data: { api: "settings.egress", ok: false, url, ts: Date.now() },- });- });pluginPanels.addSenderResolver((senderId) => pluginViews.pluginIdForSender(senderId));- pluginPanels.addSenderResolver((senderId) => pluginSettingsViews.pluginIdForSender(senderId));const browserHost = new BrowserHost({pane: browserPane,isPluginLoaded: (pluginId) => Boolean(plugins.getLoaded(pluginId)),@@ -601,7 +589,6 @@ export function createPluginServices({announceTurnEnded,pluginPanels,pluginViews,- pluginSettingsViews,browserHost,browserPane,};diff --git a/apps/desktop/src/components/settings/PluginScenicThemesDestination.tsx b/apps/desktop/src/components/settings/PluginScenicThemesDestination.tsxnew file mode 100644index 000000000..848755a0b--- /dev/null+++ b/apps/desktop/src/components/settings/PluginScenicThemesDestination.tsx@@ -0,0 +1,108 @@+import { useEffect, useMemo, useState } from "react";+import type { PluginScenicThemesDestinationMeta } from "@pi-desktop/shared";+import { api } from "../../lib/api";+import { useAppStore } from "../../stores/app-store";+import { Button, cx } from "../ui";++type Props = {+ destination: PluginScenicThemesDestinationMeta;+ selectTheme: (themeId: string) => Promise<void>;+};++const clampBlur = (value: number) => Math.max(0, Math.min(20, Math.round(value)));++/**+ * The host owns every pixel of this destination. Plugins supply only the+ * already validated card metadata and declared backdrop assets.+ */+export function PluginScenicThemesDestination({ destination, selectTheme }: Props) {+ const selectedTheme = useAppStore((state) => state.settings?.theme);+ const showToast = useAppStore((state) => state.showToast);+ const selectedCard = useMemo(+ () => destination.themes.find((theme) => theme.themeId === selectedTheme) ?? destination.themes[0],+ [destination.themes, selectedTheme],+ );+ const [confirmedBlur, setConfirmedBlur] = useState(selectedCard?.blur ?? 6);+ const [draftBlur, setDraftBlur] = useState(selectedCard?.blur ?? 6);+ const [saving, setSaving] = useState(false);++ useEffect(() => {+ const blur = selectedCard?.blur ?? selectedCard?.blurDefault ?? 6;+ setConfirmedBlur(blur);+ setDraftBlur(blur);+ }, [selectedCard]);++ if (!selectedCard) return null;++ const chooseTheme = async (themeId: string) => {+ try {+ await selectTheme(themeId);+ } catch (error) {+ showToast(error instanceof Error ? error.message : String(error), { variant: "error" });+ }+ };++ const apply = async () => {+ if (saving || draftBlur === confirmedBlur) return;+ setSaving(true);+ try {+ await api.setPluginScenicThemeBlur(destination.pluginId, selectedCard.themeId, draftBlur);+ setConfirmedBlur(draftBlur);+ } catch (error) {+ setDraftBlur(confirmedBlur);+ showToast(error instanceof Error ? error.message : String(error), { variant: "error" });+ } finally {+ setSaving(false);+ }+ };++ return (+ <section className="plugin-scenic-themes-destination" aria-label={destination.label}>+ <p className="plugin-scenic-themes-description">{destination.description}</p>+ <div className="plugin-scenic-theme-grid">+ {destination.themes.map((theme) => {+ const selected = theme.themeId === selectedTheme;+ return (+ <button+ key={theme.themeId}+ type="button"+ className={cx("plugin-scenic-theme-card", selected && "active")}+ aria-pressed={selected}+ onClick={() => void chooseTheme(theme.themeId)}+ >+ <img src={theme.previewUrl} alt="" />+ <span className="plugin-scenic-theme-card-shade" aria-hidden />+ <span className="plugin-scenic-theme-card-content">+ <span className="plugin-scenic-theme-card-title">{theme.label}</span>+ <span className="plugin-scenic-theme-card-description">{theme.description}</span>+ </span>+ {selected && <span className="plugin-scenic-theme-card-check" aria-hidden>✓</span>}+ </button>+ );+ })}+ </div>+ <div className="plugin-scenic-blur-control">+ <div className="plugin-scenic-blur-copy">+ <span className="plugin-scenic-blur-label">Backdrop blur</span>+ <span className="plugin-scenic-blur-help">Applies to {selectedCard.label}</span>+ </div>+ <div className="plugin-scenic-blur-actions">+ <label className="sr-only" htmlFor="plugin-scenic-backdrop-blur">Backdrop blur</label>+ <input+ id="plugin-scenic-backdrop-blur"+ type="range"+ min="0"+ max="20"+ step="1"+ value={draftBlur}+ onChange={(event) => setDraftBlur(clampBlur(Number(event.target.value)))}+ />+ <output htmlFor="plugin-scenic-backdrop-blur">{draftBlur}px</output>+ <Button variant="primary" disabled={saving || draftBlur === confirmedBlur} onClick={() => void apply()}>+ {saving ? "Applying…" : "Apply"}+ </Button>+ </div>+ </div>+ </section>+ );+}diff --git a/apps/desktop/src/components/settings/PluginSettingsDestination.tsx b/apps/desktop/src/components/settings/PluginSettingsDestination.tsxdeleted file mode 100644index ff8827669..000000000--- a/apps/desktop/src/components/settings/PluginSettingsDestination.tsx+++ /dev/null@@ -1,44 +0,0 @@-import { useEffect, useRef, useState } from "react";-import { api } from "../../lib/api";--/** Renderer placeholder for the host-owned isolated Settings extension view. */-export function PluginSettingsDestination({ pluginId, destinationId, label }: {- pluginId: string;- destinationId: string;- label: string;-}) {- const ref = useRef<HTMLDivElement | null>(null);- const [failed, setFailed] = useState(false);- useEffect(() => {- let live = true;- void api.pluginSettingsViewOpen(pluginId, destinationId).then(- () => { if (live) setFailed(false); },- () => { if (live) setFailed(true); },- );- return () => { live = false; };- }, [pluginId, destinationId]);- useEffect(() => {- if (failed) return;- void api.pluginSettingsViewSetVisible(pluginId, destinationId, true);- return () => { void api.pluginSettingsViewSetVisible(pluginId, destinationId, false); };- }, [pluginId, destinationId, failed]);- useEffect(() => {- const node = ref.current;- if (!node || failed) return;- let frame = 0;- const report = () => {- cancelAnimationFrame(frame);- frame = requestAnimationFrame(() => {- const rect = node.getBoundingClientRect();- void api.pluginSettingsViewSetBounds({ x: rect.x, y: rect.y, width: rect.width, height: rect.height });- });- };- const observer = new ResizeObserver(report);- observer.observe(node);- window.addEventListener("resize", report);- report();- return () => { observer.disconnect(); window.removeEventListener("resize", report); cancelAnimationFrame(frame); };- }, [pluginId, destinationId, failed]);- if (failed) return <div className="settings-recovery" role="status">Unable to load {label}.</div>;- return <div ref={ref} className="plugin-settings-destination" aria-label={label} />;-}diff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsxindex 41d88504a..428f6690c 100644--- a/apps/desktop/src/features/app/AppShell.tsx+++ b/apps/desktop/src/features/app/AppShell.tsx@@ -305,6 +305,7 @@ export function AppShell() {)}style={{ "--ds-sidebar-width": `${sidebarWidth}px` } as CSSProperties}>+ <div className="app-scenic-backdrop" aria-hidden />{shell}<ProjectCreateDialog />{splash}diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsxindex 9dfcbdeb2..472faf428 100644--- a/apps/desktop/src/features/settings/SettingsPage.tsx+++ b/apps/desktop/src/features/settings/SettingsPage.tsx@@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";import type {AppSettings,GlobalPermissionMode,- PluginSettingsDestinationMeta,+ PluginScenicThemesDestinationMeta,ShortcutPlatform,} from "@pi-desktop/shared";import { useAppStore } from "../../stores/app-store";@@ -54,7 +54,7 @@ import {UpdatesRow,} from "./agent-sections";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"];@@ -83,11 +83,11 @@ export function SettingsPage() {const [query, setQuery] = useState("");const [recoveringSettings, setRecoveringSettings] = useState(!settings);const [settingsRecoveryFailed, setSettingsRecoveryFailed] = useState(false);- const [extensions, setExtensions] = useState<PluginSettingsDestinationMeta[]>([]);- const [activeExtension, setActiveExtension] = useState<PluginSettingsDestinationMeta | null>(null);+ const [extensions, setExtensions] = useState<PluginScenicThemesDestinationMeta[]>([]);+ const [activeExtension, setActiveExtension] = useState<PluginScenicThemesDestinationMeta | null>(null);useEffect(() => {- const refresh = () => void api.listPluginSettingsDestinations().then(setExtensions, () => setExtensions([]));+ const refresh = () => void api.listPluginScenicThemesDestinations().then(setExtensions, () => setExtensions([]));refresh();return api.onPluginChanged(refresh);}, []);@@ -166,6 +166,10 @@ export function SettingsPage() {await refreshProviders();};+ const selectPluginTheme = async (theme: string) => {+ await saveSettings({ theme: theme as AppSettings["theme"] });+ };+// Nav structure comes from the shared settings index (lib/settings-search)// so the global search dialog and this page stay in sync; only the icons// are view-level.@@ -256,7 +260,10 @@ export function SettingsPage() {<buttonkey={item.id}className={cx("settings-nav-item", tab === item.id && "active")}- onClick={() => setSettingsTab(item.id)}+ onClick={() => {+ setActiveExtension(null);+ setSettingsTab(item.id);+ }}><span className="settings-nav-icon">{item.icon}</span><span className="settings-nav-label">{t(item.labelKey)}</span>@@ -303,7 +310,7 @@ export function SettingsPage() {<h1 className="settings-section-title">{activeExtension?.label ?? t(activeTitleKey)}</h1>{activeExtension ? (- <PluginSettingsDestination pluginId={activeExtension.pluginId} destinationId={activeExtension.destinationId} label={activeExtension.label} />+ <PluginScenicThemesDestination destination={activeExtension} selectTheme={selectPluginTheme} />) : <>{tabNeedsSettings && !settings ? (diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex 31399ca28..c01072f57 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -54,7 +54,7 @@ import type {PluginSettingDefinition,PluginServiceStatus,PluginViewMeta,- PluginSettingsDestinationMeta,+ PluginScenicThemesDestinationMeta,PluginTheme,MarketPluginSummary,MarketPluginDetail,@@ -877,7 +877,8 @@ export const api = {togglePluginLauncher: () => invoke(IPC.invoke.pluginLauncherToggle),dismissPluginLauncher: () => invoke(IPC.invoke.pluginLauncherDismiss),listPluginThemes: () => invoke<PluginTheme[]>(IPC.invoke.pluginThemes),- listPluginSettingsDestinations: () => invoke<PluginSettingsDestinationMeta[]>(IPC.invoke.pluginSettingsDestinations),+ listPluginScenicThemesDestinations: () => invoke<PluginScenicThemesDestinationMeta[]>(IPC.invoke.pluginScenicThemesDestinations),+ setPluginScenicThemeBlur: (pluginId: string, themeId: string, blur: number) => invoke(IPC.invoke.pluginScenicThemesSetBlur, { pluginId, themeId, blur }),listPluginServices: () => invoke<PluginServiceStatus[]>(IPC.invoke.pluginServices),/*** Work panel views, already filtered by permission, activation scope, and@@ -910,12 +911,6 @@ export const api = {visible,sessionId,}),- pluginSettingsViewOpen: (pluginId: string, destinationId: string) =>- invoke(IPC.invoke.pluginSettingsViewOpen, { pluginId, destinationId }),- pluginSettingsViewSetBounds: (bounds: { x: number; y: number; width: number; height: number }) =>- invoke(IPC.invoke.pluginSettingsViewSetBounds, bounds),- pluginSettingsViewSetVisible: (pluginId: string, destinationId: string, visible: boolean) =>- invoke(IPC.invoke.pluginSettingsViewSetVisible, { pluginId, destinationId, visible }),marketRefresh: (force = true) =>invoke<{providerId: string;diff --git a/apps/desktop/src/styles/base.css b/apps/desktop/src/styles/base.cssindex 03386b223..5d7c2f25b 100644--- a/apps/desktop/src/styles/base.css+++ b/apps/desktop/src/styles/base.css@@ -161,6 +161,8 @@ html {}.app-shell {+ position: relative;+ isolation: isolate;display: flex;height: 100%;min-height: 0;@@ -168,6 +170,18 @@ html {color: var(--ds-text-primary);}+.app-shell > :not(.app-scenic-backdrop) {+ z-index: 1;+}++.app-scenic-backdrop {+ position: fixed;+ inset: 0;+ z-index: 0;+ display: block;+ pointer-events: none;+}+.app-shell-boot {align-items: center;justify-content: center;diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.cssindex d87c80afb..dab9bf2b8 100644--- a/apps/desktop/src/styles/chrome.css+++ b/apps/desktop/src/styles/chrome.css@@ -990,7 +990,7 @@position: fixed;top: 0;right: 0;- z-index: 200; /* above titlebar (10) and work panel chrome */+ z-index: 1000; /* above every renderer surface and draggable titlebar */display: flex;align-items: center;width: var(--ds-window-controls-width);@@ -1007,6 +1007,14 @@* viewport-fixed position must not follow MainPane while the work panel reflows. */.window-controls.window-controls-in-pane {position: fixed;+ isolation: isolate;+}++/* Electron resolves app-region hit testing across siblings. The controls must+ * be a later compositor layer than Settings, plugin content, or a work-panel+ * drag header. */+.app-shell > .window-controls {+ z-index: 1100;}.window-control-btn {diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.cssindex 34c05bcea..eca27af2e 100644--- a/apps/desktop/src/styles/settings.css+++ b/apps/desktop/src/styles/settings.css@@ -8,6 +8,47 @@background: var(--ds-bg-primary);}+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .app-shell.settings-mode,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell-full,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-content,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-content-inner,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-titlebar {+ background: transparent !important;+}++:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell-full .settings-nav {+ background: color-mix(in oklab, var(--ds-bg-sidebar) 72%, transparent);+ backdrop-filter: blur(18px) saturate(1.08);+}++:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-panel {+ background: color-mix(in oklab, var(--ds-bg-elevated) 72%, transparent);+ backdrop-filter: blur(14px) saturate(1.06);+}++/* Scenic plugin themes own the image canvas. Keep the host Settings page as+ * transparent compositing surfaces so the single root scenic layer remains+ * visible beneath it; ordinary themes never match this attribute. */+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .app-shell.settings-mode,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell-full,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-content,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-content-inner,+:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-titlebar {+ background: transparent !important;+}++:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-shell-full .settings-nav {+ background: color-mix(in oklab, var(--ds-bg-sidebar) 72%, transparent);+ backdrop-filter: blur(18px) saturate(1.08);+}++:root[data-plugin-theme^="plugin:io.github.akshayxkill.nexus-scenic-themes:"] .settings-panel {+ background: color-mix(in oklab, var(--ds-bg-elevated) 72%, transparent);+ backdrop-filter: blur(14px) saturate(1.06);+}+.settings-shell,.settings-shell-full {position: relative;@@ -18,6 +59,65 @@background: var(--ds-bg-primary);}+.plugin-scenic-themes-destination {+ display: grid;+ gap: 18px;+ background: transparent;+}++.plugin-scenic-themes-description {+ margin: -8px 0 0;+ color: var(--ds-text-muted);+}++.plugin-scenic-theme-grid {+ display: grid;+ grid-template-columns: repeat(2, minmax(0, 1fr));+ gap: 14px;+}++.plugin-scenic-theme-card {+ position: relative;+ min-height: 178px;+ overflow: hidden;+ border: 1px solid color-mix(in srgb, var(--ds-border) 84%, transparent);+ border-radius: 14px;+ background: color-mix(in srgb, var(--ds-bg-elevated) 76%, transparent);+ box-shadow: 0 12px 28px color-mix(in srgb, #000 24%, transparent);+ color: var(--ds-text-primary);+ cursor: pointer;+ isolation: isolate;+ text-align: left;+}++.plugin-scenic-theme-card:hover { border-color: var(--ds-accent); }+.plugin-scenic-theme-card:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 3px; }+.plugin-scenic-theme-card.active { border-color: var(--ds-accent); box-shadow: 0 0 0 1px var(--ds-accent), 0 12px 28px color-mix(in srgb, #000 30%, transparent); }+.plugin-scenic-theme-card > img { position: absolute; z-index: -2; width: 100%; height: 100%; inset: 0; object-fit: cover; }+.plugin-scenic-theme-card-shade { position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg, transparent 18%, color-mix(in srgb, #000 72%, transparent) 100%); }+.plugin-scenic-theme-card-content { position: absolute; right: 16px; bottom: 15px; left: 16px; display: grid; gap: 3px; }+.plugin-scenic-theme-card-title { font-weight: 650; font-size: 15px; text-shadow: 0 1px 7px #000; }+.plugin-scenic-theme-card-description { color: color-mix(in srgb, #fff 78%, transparent); font-size: 12px; text-shadow: 0 1px 5px #000; }+.plugin-scenic-theme-card-check { position: absolute; top: 12px; right: 12px; display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: var(--ds-accent); color: var(--ds-accent-foreground); font-weight: 700; }++.plugin-scenic-blur-control { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px; border: 1px solid color-mix(in srgb, var(--ds-border) 84%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--ds-bg-elevated) 82%, transparent); box-shadow: 0 10px 24px color-mix(in srgb, #000 16%, transparent); }+.plugin-scenic-blur-copy { display: grid; gap: 3px; }+.plugin-scenic-blur-label { font-weight: 600; }+.plugin-scenic-blur-help { color: var(--ds-text-muted); font-size: 12px; }+.plugin-scenic-blur-actions { display: flex; align-items: center; gap: 12px; min-width: min(100%, 360px); }+.plugin-scenic-blur-actions input { flex: 1; min-width: 110px; }+.plugin-scenic-blur-actions output { min-width: 34px; color: var(--ds-text-muted); font-variant-numeric: tabular-nums; }++@media (max-width: 720px) {+ .plugin-scenic-theme-grid { grid-template-columns: 1fr; }+ .plugin-scenic-blur-control { align-items: stretch; flex-direction: column; }+ .plugin-scenic-blur-actions { min-width: 0; }+}++@media (prefers-reduced-transparency: reduce) {+ .plugin-scenic-theme-card, .plugin-scenic-blur-control { background: var(--ds-bg-elevated); }+}+/* The band spans the content column only. Spanning the full window width* painted --ds-bg-primary over the nav rail, so the strip above the rail read* as a different color from the rail underneath it. */@@ -220,9 +320,13 @@margin: 0;}-/* The renderer owns this measured hole; the sandboxed WebContentsView paints- only here, never over the rail, titlebar, or native window controls. */+/* The renderer owns this sandboxed iframe. It stays in normal Settings flow,+ so it cannot cover the titlebar, native controls, rail, or resize edges. */.plugin-settings-destination {+ display: block;+ box-sizing: border-box;+ border: 0;+ background: transparent;min-height: min(720px, calc(100vh - 150px));width: 100%;}diff --git a/apps/desktop/test/plugin-appearance-extensions.test.mjs b/apps/desktop/test/plugin-appearance-extensions.test.mjsindex 9cb335887..21b18ba9e 100644--- a/apps/desktop/test/plugin-appearance-extensions.test.mjs+++ b/apps/desktop/test/plugin-appearance-extensions.test.mjs@@ -17,26 +17,38 @@ test("theme variables remain host-generated and plugin-scoped", () => {assert.match(shell, /pluginTheme\.variablesCss/);});-test("settings destinations are permission-gated and use the isolated view host", () => {+test("scenic settings destinations are permission-gated and host-rendered", () => {const ipc = read("electron/main/ipc/plugin-ui-ipc.ts");const page = read("src/features/settings/SettingsPage.tsx");- const component = read("src/components/settings/PluginSettingsDestination.tsx");- assert.match(ipc, /pluginSettingsDestinations/);+ const component = read("src/components/settings/PluginScenicThemesDestination.tsx");+ assert.match(ipc, /pluginScenicThemesDestinations/);assert.match(ipc, /ui\.settings/);- assert.match(ipc, /pluginSettingsViews\.open/);+ assert.match(ipc, /ui\.theme/);assert.match(page, /settings\.groupExtensions/);- assert.match(page, /PluginSettingsDestination/);- assert.match(component, /pluginSettingsViewSetBounds/);- assert.match(component, /pluginSettingsViewSetVisible/);+ assert.match(page, /PluginScenicThemesDestination/);+ assert.match(component, /aria-pressed/);+ assert.doesNotMatch(component, /<iframe/);});-test("settings extension surfaces are cleaned up on plugin lifecycle changes", () => {+test("settings extension surfaces are cleaned up by the renderer lifecycle", () => {const services = read("electron/main/services/plugin-services.ts");const lifecycle = read("electron/main/ipc/plugin-ipc.ts");- const window = read("electron/main/bootstrap/window.ts");- const shutdown = read("electron/main/bootstrap/shutdown.ts");- assert.match(services, /pluginSettingsViews\.closePlugin/);- assert.match(lifecycle, /pluginSettingsViews\.closePlugin/);- assert.match(window, /pluginSettingsViews\.setWindow/);- assert.match(shutdown, /pluginSettingsViews\.dispose/);+ assert.doesNotMatch(services, /pluginSettingsViews/);+ assert.doesNotMatch(lifecycle, /pluginSettingsViews/);+});++test("scenic settings metadata is host-validated before it reaches the renderer", () => {+ const ipc = read("electron/main/ipc/plugin-ui-ipc.ts");+ const protocol = read("../../packages/shared/src/protocol.ts");+ const api = read("src/lib/api.ts");++ assert.match(protocol, /pluginScenicThemesDestinations/);+ assert.match(ipc, /pluginScenicThemesDestinations/);+ assert.match(ipc, /scenicThemes/);+ assert.match(ipc, /ui\.settings/);+ assert.match(ipc, /ui\.theme/);+ assert.match(ipc, /previewUrl/);+ assert.match(ipc, /themeAssetUrl/);+ assert.match(ipc, /theme\?\.pluginId === pluginId/);+ assert.match(api, /listPluginScenicThemesDestinations/);});diff --git a/apps/desktop/test/plugin-settings-renderer-surface.test.mjs b/apps/desktop/test/plugin-settings-renderer-surface.test.mjsnew file mode 100644index 000000000..2df4b28f7--- /dev/null+++ b/apps/desktop/test/plugin-settings-renderer-surface.test.mjs@@ -0,0 +1,39 @@+import test from "node:test";+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";++const root = new URL("../", import.meta.url);+const read = (path) => readFileSync(new URL(path, root), "utf8");++test("scenic extensions are host-rendered, accessible, and have no iframe canvas", () => {+ const page = read("src/features/settings/SettingsPage.tsx");+ const component = read("src/components/settings/PluginScenicThemesDestination.tsx");+ const css = read("src/styles/settings.css");+ assert.match(page, /PluginScenicThemesDestination/);+ assert.doesNotMatch(page, /PluginSettingsDestination/);+ assert.match(component, /aria-pressed/);+ assert.match(component, /type="range"/);+ assert.match(component, /"Apply"/);+ assert.doesNotMatch(component, /<iframe/);+ assert.match(css, /\.plugin-scenic-themes-destination\s*\{[\s\S]*?background:\s*transparent/s);+});++test("scenic blur persists only after the host-owned Apply action", () => {+ const ipc = read("electron/main/ipc/plugin-ui-ipc.ts");+ const protocol = read("../../packages/shared/src/protocol.ts");+ const api = read("src/lib/api.ts");+ const component = read("src/components/settings/PluginScenicThemesDestination.tsx");+ assert.match(protocol, /pluginScenicThemesSetBlur/);+ assert.match(ipc, /pluginScenicThemesSetBlur/);+ assert.match(ipc, /--nexus-backdrop-blur/);+ assert.match(api, /setPluginScenicThemeBlur/);+ assert.match(component, /setPluginScenicThemeBlur/);+ assert.match(component, /setDraftBlur/);+});++test("window controls have a compositor layer above Settings destinations", () => {+ const chrome = read("src/styles/chrome.css");+ assert.match(chrome, /\.window-controls\s*\{[\s\S]*?z-index:\s*1000/s);+ assert.match(chrome, /\.window-controls\.window-controls-in-pane\s*\{[\s\S]*?isolation:\s*isolate/s);+ assert.match(chrome, /\.app-shell\s*>\s*\.window-controls\s*\{[\s\S]*?z-index:\s*1100/s);+});diff --git a/apps/desktop/test/plugin-themes.test.mjs b/apps/desktop/test/plugin-themes.test.mjsindex ee28024bf..0e4f344ff 100644--- a/apps/desktop/test/plugin-themes.test.mjs+++ b/apps/desktop/test/plugin-themes.test.mjs@@ -89,6 +89,54 @@ test("sidebar paints color and optional image layers separately", () => {assert.match(darwin, /--ds-bg-sidebar-image/);});+test("scenic plugins use the normal full-window shell for compositing", () => {+ const baseSrc = readFileSync(join(desktopRoot, "src/styles/base.css"), "utf8");+ const settingsSrc = readFileSync(join(desktopRoot, "src/styles/settings.css"), "utf8");+ assert.match(baseSrc, /\.app-shell\s*\{[^}]*position:\s*relative;[^}]*isolation:\s*isolate/s);+ assert.match(baseSrc, /\.app-scenic-backdrop\s*\{[^}]*position:\s*fixed;[^}]*inset:\s*0/s);+ assert.match(baseSrc, /\.app-shell\s*>\s*:not\(\.app-scenic-backdrop\)[^}]*z-index:\s*1/s);+ assert.match(settingsSrc, /data-plugin-theme\^="plugin:io\.github\.akshayxkill\.nexus-scenic-themes:/);+ assert.match(settingsSrc, /\.app-shell\.settings-mode[^}]*background:\s*transparent\s*!important/s);+ assert.match(settingsSrc, /\.settings-content[^}]*background:\s*transparent\s*!important/s);+});++test("scenic plugin themes expose a full-window settings compositing hook", () => {+ const settingsCss = readFileSync(join(desktopRoot, "src/styles/settings.css"), "utf8");+ assert.match(settingsCss, /data-plugin-theme\^="plugin:io\.github\.akshayxkill\.nexus-scenic-themes:/);+ assert.match(settingsCss, /\.app-shell\.settings-mode[^}]*background:\s*transparent\s*!important/s);+ assert.match(settingsCss, /\.settings-content[^}]*background:\s*transparent\s*!important/s);+ assert.match(settingsCss, /\.settings-shell-full\s+\.settings-nav[^}]*background:\s*color-mix/s);+ assert.match(settingsCss, /\.settings-panel[^}]*background:\s*color-mix/s);+});++test("scenic background is a host root layer, not an app-shell pseudo-element", () => {+ assert.match(appSrc, /className=\"app-scenic-backdrop\"/);+ assert.match(readFileSync(join(desktopRoot, "src/styles/base.css"), "utf8"), /\.app-scenic-backdrop\s*\{[^}]*position:\s*fixed/s);+ assert.match(readFileSync(join(desktopRoot, "src/styles/base.css"), "utf8"), /\.app-shell\s*>\s*:\s*not\(\.app-scenic-backdrop\)/);+});++test("core Settings navigation dismisses an active plugin destination", () => {+ const source = readFileSync(join(desktopRoot, "src/features/settings/SettingsPage.tsx"), "utf8");+ assert.match(source, /setActiveExtension\(null\);\s*setSettingsTab\(item\.id\);/s);+});++test("scenic plugin controls theme the native window-control band without changing geometry", () => {+ const themesRoot = "C:/jcode projects/worktrees/nexus-scenic-settings-20260915/plugins/io.github.akshayxkill.nexus-scenic-themes/themes";+ for (const name of ["twilight-mountains", "alpine-light", "obsidian-horizon", "emerald-afterglow"]) {+ const css = readFileSync(join(themesRoot, `${name}.css`), "utf8");+ assert.match(css, /\.window-controls\s*\{[^}]*background:/s);+ assert.doesNotMatch(css, /\.window-controls\s*\{[^}]*position\s*:/s);+ }+});++test("host-rendered scenic Settings destinations leave native controls outside extension content", () => {+ const component = readFileSync(join(repoRoot, "apps/desktop/src/components/settings/PluginScenicThemesDestination.tsx"), "utf8");+ const css = readFileSync(join(repoRoot, "apps/desktop/src/styles/settings.css"), "utf8");+ assert.doesNotMatch(component, /<iframe/);+ assert.match(css, /\.plugin-scenic-themes-destination\s*\{[\s\S]*?background:\s*transparent/s);+});++test("themes only load with ui.theme and are withdrawn on unload", () => {const register = runtimeSrc.slice(runtimeSrc.indexOf("private registerThemes"));assert.match(register, /permissions\.has\("ui\.theme"\)/);diff --git a/docs/adr/0261-plugin-appearance-extensions.md b/docs/adr/0261-plugin-appearance-extensions.mdindex c2c3ae739..f0a6967ef 100644--- a/docs/adr/0261-plugin-appearance-extensions.md+++ b/docs/adr/0261-plugin-appearance-extensions.md@@ -10,12 +10,12 @@ Plugins can contribute static sanitized themes, but cannot safely vary a declare## Decision-1. `ui.settings` is an independent permission. Only a loaded plugin holding it and declaring an existing HTML entry contributes a Settings item.+1. `ui.settings` is an independent permission. A loaded plugin holding it and `ui.theme` may contribute one validated data-only scenic destination.2. The host renders contributed items only in the **Extensions** group after all core Settings groups. Core ordering, search shell, titlebar and fallback navigation remain host-owned.-3. A Settings entry is hosted in the same isolated per-plugin `WebContentsView` model as a plugin work-panel view: sandboxed preload, context isolation, disabled Node integration, partitioned session and manifest egress policy. The renderer supplies only a measured content rectangle.+3. The host renders every scenic Settings DOM node in its normal React tree. Plugins cannot contribute an entry document, DOM, styles, scripts, or actions.4. `pi.themes.setVariables(themeId, values)` requires `ui.theme`. It accepts values only for the caller's declared theme variables. The manifest declares one of `length` (`px`), finite `number`, strict hex `color`, or a fixed `select` value. The host rejects host-reserved names, undeclared keys, unsafe CSS fragments and cross-plugin ids.5. The host persists accepted values in plugin-private settings and serializes a separate host-generated variable rule after static sanitized theme CSS. Static `plugin-asset://` references remain valid; no runtime stylesheet, image, font, layout, filesystem or network authority is granted.-6. Disable, uninstall, crash and reload remove every owned Settings view. If an active destination disappears, the renderer returns to General.+6. Disable, uninstall, crash and reload remove every owned destination. If an active destination disappears, the renderer returns to General.## Consequencesdiff --git a/docs/adr/0280-host-rendered-plugin-scenic-settings-surfaces.md b/docs/adr/0280-host-rendered-plugin-scenic-settings-surfaces.mdnew file mode 100644index 000000000..0c8cee3f8--- /dev/null+++ b/docs/adr/0280-host-rendered-plugin-scenic-settings-surfaces.md@@ -0,0 +1,37 @@+# ADR 0280 — Host-rendered plugin scenic Settings surfaces++- **Status:** Accepted for implementation+- **Date:** 2026-09-17+- **Related:** ADR 0104, ADR 0255++## Context++An Electron `WebContentsView` and a sandboxed iframe each create an independent+compositing surface. Although an extension document can make its own background+transparent, its page canvas remains an opaque rectangle between the root scenic+backdrop and the Settings content. Native child surfaces can also intercept the+renderer-drawn Windows/Linux controls.++## Decision++The generic plugin Settings document surface is retired for appearance+extensions. `contributes.scenicThemes` supplies declarative localized card+metadata only. Electron main validates the permissions, same-plugin theme+ownership, declared preview image, and the exact `--nexus-backdrop-blur`+`length` variable. The host React Settings tree renders all controls inside its+existing transparent scenic canvas.++Card selection is immediate. The bounded 0–20 integer blur control is a local+draft until the user presses Apply; the host then uses the existing typed theme+variable persistence boundary. There is no iframe, page protocol, bridge, or+second document canvas.++## Consequences++- A single root scenic backdrop remains visible through Settings surfaces.+- Host-owned layout, focus, search, narrow-window behavior, drag regions, and+ native controls cannot be changed or intercepted by plugins.+- Plugins cannot contribute Settings HTML, CSS, JavaScript, selectors, DOM, or+ arbitrary actions through this capability.+- This deliberately narrow destination does not replace isolated work-panel+ views or plugin panels.diff --git a/docs/adr/0281-package-local-theme-assets.md b/docs/adr/0281-package-local-theme-assets.mdnew file mode 100644index 000000000..08c26958c--- /dev/null+++ b/docs/adr/0281-package-local-theme-assets.md@@ -0,0 +1,43 @@+# ADR 0281: Package-local theme assets remain available++- Status: Accepted for implementation+- Date: 2026-09-17+- Decision: D444+- Amends: ADR 0255++## Context++ADR 0255 made external absolute paths available to theme contributions. That+supports a theme whose plugin owns a user-selected image outside its package,+but an absolute path cannot identify an image in an installed marketplace+archive on another machine.++Host-rendered scenic Settings destinations need preview images and background+images that travel with their theme package. Requiring an absolute path would+make a packaged theme either non-portable or dependent on a separate file+selection capability.++## Decision++1. A declared theme asset may be either an extension-whitelisted absolute path+ or an extension-whitelisted package-relative path.+2. The host resolves a package-relative path with `resolveInsidePlugin`, rejects+ traversal and `node_modules`, verifies existence and the shared asset budget,+ then records the resolved file under its package-relative key.+3. Absolute assets retain ADR 0255's existing validation, percent-encoded URL+ keys, and runtime registration behavior.+4. The `plugin-asset:` protocol remains the sole renderer access path. It only+ serves a file recorded by the loaded plugin's asset registry, uses the+ extension MIME allowlist, no-store, nosniff, and revokes the registry on+ disable, unload, or crash.+5. Scenic card previews must name one declared asset owned by the same plugin.+ They do not add filesystem, network, renderer-DOM, or image-upload authority.++## Consequences++- Marketplace theme packs can ship portable local art without exposing arbitrary+ filesystem reads.+- Existing themes that intentionally name an external absolute path keep+ working.+- Theme authors must declare every image and font; an undeclared CSS `url()` is+ rejected before it reaches the renderer.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 02afac254..2e98e9e73 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -306,3 +306,5 @@ 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) |diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex d70f88c25..64585a979 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -635,7 +635,11 @@ system while preserving their different data ownership:6. General shows the host-backed Appearance card; the AI destination showsPermissions and Defaults, including the Command shell row; theShortcuts destination shows the Keyboard shortcuts card; Info shows the- Developer card. No additional settings destinations are rendered. Token+ Developer card. Plugin-contributed destinations, when present, appear after+ every core group under Extensions. Each destination is a renderer-composited+ sandboxed surface: it preserves the existing Settings rail, titlebar,+ Windows/Linux minimize/maximize controls, native drag/resize regions, and+ content geometry. Tokenusage lives in plugin `pi.token-insights`, not Settings.7. Provider secrets never display raw key values8. Model configuration shows compact Defaults, separate vendor accounts, thediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 3bd2dabfa..d89c1d503 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -11,17 +11,18 @@### E2E-PLUGIN-appearance-extension-lifecycle- **Preconditions:** A fixture plugin declares `ui.theme`, `ui.settings`, one- asset-backed theme with a typed `--fixture-backdrop-blur` `0..20px` variable,- and one Settings HTML entry.+ asset-backed scenic card with a typed `--nexus-backdrop-blur` `0..20px` variable.- **Steps:** Open Settings, find the final Extensions group by search andkeyboard navigation, open the entry, change the variable, select/reselect thetheme, restart, then disable, reload and uninstall the plugin while its entryis active.-- **Expected:** Only the declared variable rule changes; static- `plugin-asset://` URLs remain valid; the value restores after restart; no- plugin page covers native controls or core Settings. Invalid/cross-plugin- values are refused. Every lifecycle transition removes the entry and returns- the app to General.+- **Expected:** Only the declared variable rule changes after Apply; static+ `plugin-asset://` URLs remain valid; the value restores after restart; host-+ rendered cards retain the scenic backdrop behind their translucent content,+ have no opaque native rectangle, and leave Windows/Linux minimize/maximize+ controls clickable while Settings is open. Invalid/cross-plugin values are+ refused. Every lifecycle transition removes the entry and returns the app to+ General.- **Status:** Documented; run after integration into main.- Document every user-visible and protocol-visible behavior that MVP must verify.diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.mdindex f55d222bf..5007c588d 100644--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md@@ -9,10 +9,13 @@ exactly one type: `length` (`unit: "px"`, numeric `min`, `max`, and `default`),(fixed safe `values` and default). Host-reserved prefixes are refused. Valuesare not CSS fragments.-`contributes.settingsDestinations` declares sandboxed Settings entries with a-stable `id`, localized `label`, closed icon token, optional localized keywords,-and a plugin-relative `.html` `entry`. An entry requires `ui.settings`; it is-rendered only in the host-owned Extensions group.+`contributes.scenicThemes` declares a data-only host-rendered Settings entry:+a stable `id`, localized label and description, `palette` icon token, localized+keywords, and one to twelve ordered cards. Every card names a same-plugin+theme, localized name/description, and a relative image asset declared by that+theme. It requires both `ui.settings` and `ui.theme`. Plugins provide neither+Settings HTML nor CSS or JavaScript: the host renders the Extensions entry,+cards, range control, and Apply action in its normal React tree.## 1. Purpose@@ -140,6 +143,7 @@ type PluginContributes = {providers?: PluginProviderContrib[]; // Host-owned provider rows; needs `provider.register` (spec 13)settings?: PluginSettingContrib[];themes?: PluginThemeContrib[];+ scenicThemes?: PluginScenicThemesContrib;windowAppearance?: PluginWindowAppearanceContrib; // native window background; needs `ui.window.appearance`mcpServers?: PluginMcpServerContrib[];services?: PluginServiceContrib[];@@ -210,6 +214,20 @@ type PluginThemeContrib = {// each matching `url()` is rewritten to `plugin-asset://`};+type PluginScenicThemesContrib = {+ id: string;+ label: { en: string; "zh-CN": string };+ description: { en: string; "zh-CN": string };+ keywords?: Array<{ en: string; "zh-CN": string }>;+ icon: "palette";+ themes: Array<{+ themeId: string;+ label: { en: string; "zh-CN": string };+ description: { en: string; "zh-CN": string };+ previewAsset: string;+ }>;+};+type PluginWindowAppearanceContrib = {backgroundColor?: { light?: string; dark?: string }; // #rrggbb | #rrggbbaa};diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.mdindex bea2377f9..5305abee7 100644--- a/docs/spec/07-plugins/03-plugin-api.md+++ b/docs/spec/07-plugins/03-plugin-api.md@@ -734,6 +734,24 @@ recognition and speech synthesis remain page-owned. A panel should provide atext fallback and announce permission or recognition failures through itsaccessible 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 0278).+### audio (requires `audio.capture.background` / `audio.playback.background`)**Callable, but the device backend is not implemented in this branch.**diff --git a/docs/spec/07-plugins/04-plugin-security.md b/docs/spec/07-plugins/04-plugin-security.mdindex b298ccce1..234bdd044 100644--- a/docs/spec/07-plugins/04-plugin-security.md+++ b/docs/spec/07-plugins/04-plugin-security.md@@ -43,6 +43,15 @@ Main risks:delivery ledger, permission ceiling, turn binding, callback, cancellation,and transcript provenance.+### Host-rendered scenic Settings destinations++`contributes.scenicThemes` is data only. The host validates both grants,+same-plugin theme ownership, declared preview assets, and the exact bounded+`--nexus-backdrop-blur` variable before it renders cards in Extensions. A plugin+cannot supply Settings HTML, CSS, JavaScript, selectors, DOM, arbitrary actions,+or direct renderer IPC. The host owns the transparent canvas, layout, focus,+native controls, titlebar, Apply action, and lifecycle fallback to General.+Clipboard history is host-owned and remains in the Electron main process only.It is never written to the plugin data directory or the host database. The hostrecords explicit clipboard writes and user-initiated Composer paste events; itdiff --git a/docs/superpowers/plans/2026-09-15-renderer-plugin-settings-surfaces.md b/docs/superpowers/plans/2026-09-15-renderer-plugin-settings-surfaces.mdnew file mode 100644index 000000000..255011665--- /dev/null+++ b/docs/superpowers/plans/2026-09-15-renderer-plugin-settings-surfaces.md@@ -0,0 +1,285 @@+# Renderer Plugin Settings Surfaces 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 opaque native Settings extension views with renderer-composited, sandboxed plugin iframes so scenic backdrops remain visible throughout the Settings destination.++**Architecture:** A new host-owned `plugin-settings:` protocol serves only resources beneath a currently loaded, `ui.settings`-granted plugin package and adds CSP headers. Its synthetic bridge script exposes `window.pluginBridge` and uses `postMessage`. `PluginSettingsDestination` owns a sandboxed iframe and forwards only source-validated, destination-bound bridge requests through a new main IPC handler to the established `PluginRuntime.invokePanelBridge` authorization path. Native `PluginViewHost` remains for work-panel views only.++**Tech Stack:** Electron custom protocols and IPC, React/TypeScript, existing Plugin Runtime bridge, Node contract tests.++**Spec:** `docs/superpowers/specs/2026-09-15-renderer-plugin-settings-surfaces-design.md`++## Global Constraints++- Do not modify Nexus or alter the BrowserWindow transparency/native resize model.+- The iframe must be `sandbox="allow-scripts"`; no same-origin, popup, top-navigation, form, download, Electron, Node, or host-DOM capability.+- `plugin-settings:` may serve only a loaded plugin with `ui.settings`, only package-local static resources, with host-authored CSP and no network egress.+- Settings destinations must not instantiate `WebContentsView`; native work-panel views keep their current implementation.+- Retain existing `PluginRuntime.invokePanelBridge` channel validation, permissions, audit boundary, and plugin identity validation.+- Update plugin architecture/security/settings specifications, an ADR, and the E2E plan. Do not run E2E unless requested.++---++### Task 1: Define the Settings resource protocol and bridge contract++**Files:**+- Create: `apps/desktop/electron/main/plugin-settings-protocol.ts`+- Modify: `apps/desktop/electron/main/bootstrap/startup.ts`+- Modify: `apps/desktop/electron/main/services/plugin-services.ts`+- Modify: `apps/desktop/electron/main/ipc/plugin-ui-ipc.ts`+- Modify: `packages/shared/src/protocol.ts`+- Test: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++**Interfaces:**+- Produces `registerPluginSettingsScheme(): void` called before Electron readiness.+- Produces `installPluginSettingsProtocol(resolve): void`, where `resolve(pluginId, path)` returns `{ absolutePath, isEntry } | null` only for active `ui.settings` destinations.+- Produces `pluginSettingsUrl(pluginId, destinationId): string` used by renderer after host validation.+- Produces IPC `pluginSettingsBridgeInvoke({ pluginId, destinationId, requestId, channel, payload })` that verifies active contribution and delegates to `PluginRuntime.invokePanelBridge`.++- [ ] **Step 1: Write a failing contract test**++```js+test("Settings destinations use a host-owned sandbox resource protocol instead of a native view", () => {+ const protocol = read("electron/main/plugin-settings-protocol.ts");+ const ipc = read("electron/main/ipc/plugin-ui-ipc.ts");+ assert.match(protocol, /plugin-settings/);+ assert.match(protocol, /registerSchemesAsPrivileged/);+ assert.match(protocol, /Content-Security-Policy/);+ assert.match(protocol, /connect-src 'none'/);+ assert.match(ipc, /pluginSettingsBridgeInvoke/);+ assert.match(ipc, /invokePanelBridge/);+ assert.doesNotMatch(ipc, /pluginSettingsViews\.open/);+});+```++- [ ] **Step 2: Run the test to verify it fails**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: FAIL because the protocol and bridge IPC do not yet exist.++- [ ] **Step 3: Implement the protocol and validated bridge endpoint**++```ts+export const PLUGIN_SETTINGS_SCHEME = "plugin-settings";++protocol.handle(PLUGIN_SETTINGS_SCHEME, (request) => {+ const resource = resolve(pluginIdFromUrl(request.url), pathFromUrl(request.url));+ if (!resource) return notFound();+ return responseForPluginSettingsResource(resource);+});++handle(IPC.invoke.pluginSettingsBridgeInvoke, async (payload) => {+ const destination = requireActiveSettingsDestination(payload.pluginId, payload.destinationId);+ return plugins.invokePanelBridge(destination.pluginId, payload.channel, payload.payload);+});+```++The HTML response must reference the synthetic `/__pi_bridge__.js` file before+plugin scripts. The bridge script may only use `window.parent.postMessage` and+may not expose any Electron or Node object.++- [ ] **Step 4: Run the contract test to verify it passes**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: PASS.++- [ ] **Step 5: Commit**++```bash+git add apps/desktop/electron/main/plugin-settings-protocol.ts apps/desktop/electron/main/bootstrap/startup.ts apps/desktop/electron/main/services/plugin-services.ts apps/desktop/electron/main/ipc/plugin-ui-ipc.ts packages/shared/src/protocol.ts apps/desktop/test/plugin-settings-renderer-surface.test.mjs+git commit -m "feat(plugins): serve settings pages in renderer"+```++### Task 2: Replace the native Settings placeholder with a sandboxed iframe++**Files:**+- Modify: `apps/desktop/src/components/settings/PluginSettingsDestination.tsx`+- Modify: `apps/desktop/src/lib/api.ts`+- Modify: `apps/desktop/src/styles/settings.css`+- Test: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++**Interfaces:**+- Consumes `api.pluginSettingsDestinationUrl(pluginId, destinationId)` and `api.pluginSettingsBridgeInvoke(...)`.+- Produces an `<iframe sandbox="allow-scripts">` whose postMessage listener accepts only its `contentWindow` and a bounded bridge request envelope.++- [ ] **Step 1: Extend the failing contract test**++```js+test("the renderer owns a Settings extension iframe and preserves native geometry", () => {+ const component = read("src/components/settings/PluginSettingsDestination.tsx");+ assert.match(component, /<iframe/);+ assert.match(component, /sandbox="allow-scripts"/);+ assert.match(component, /event\.source !== frame\.contentWindow/);+ assert.match(component, /pluginSettingsBridgeInvoke/);+ assert.doesNotMatch(component, /pluginSettingsViewSetBounds/);+ assert.doesNotMatch(component, /pluginSettingsViewSetVisible/);+});+```++- [ ] **Step 2: Run the test to verify it fails**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: FAIL because the old component measures a native child view.++- [ ] **Step 3: Implement the renderer-owned surface**++```tsx+<iframe+ ref={frameRef}+ className="plugin-settings-destination"+ sandbox="allow-scripts"+ src={src}+ title={label}+/>+```++On a bridge request, verify the message source equals `frameRef.current?.contentWindow`, verify the envelope is a finite request id plus string channel and object payload, call the host API with the immutable component `pluginId` / `destinationId`, then return the matching response only to that iframe. Render the existing recovery state on a failed URL or bridge setup. The CSS must make the iframe transparent at the host level, fill its Settings content area, and leave scroll/drag/control ownership with the existing Settings shell.++- [ ] **Step 4: Run the contract test to verify it passes**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: PASS.++- [ ] **Step 5: Commit**++```bash+git add apps/desktop/src/components/settings/PluginSettingsDestination.tsx apps/desktop/src/lib/api.ts apps/desktop/src/styles/settings.css apps/desktop/test/plugin-settings-renderer-surface.test.mjs+git commit -m "feat(settings): compose plugin destinations in renderer"+```++### Task 3: Remove Settings-native-view lifecycle plumbing and preserve bridge events++**Files:**+- Modify: `apps/desktop/electron/main/services/plugin-services.ts`+- Modify: `apps/desktop/electron/main/bootstrap/window.ts`+- Modify: `apps/desktop/electron/main/bootstrap/shutdown.ts`+- Modify: `apps/desktop/electron/main/bootstrap/app-lifecycle.ts`+- Modify: `apps/desktop/electron/main/index.ts`+- Modify: `apps/desktop/electron/main/ipc/plugin-ipc.ts`+- Test: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++**Interfaces:**+- Removes `pluginSettingsViews` as a dependency and lifecycle surface.+- Emits `pluginSettingsDestinationEvent` to the main renderer so the active iframe receives sanctioned appearance/workspace events.++- [ ] **Step 1: Extend the failing contract test**++```js+test("Settings extensions create no WebContentsView and clean up through renderer lifecycle", () => {+ const services = read("electron/main/services/plugin-services.ts");+ const lifecycle = read("electron/main/ipc/plugin-ipc.ts");+ assert.doesNotMatch(services, /pluginSettingsViews/);+ assert.doesNotMatch(lifecycle, /pluginSettingsViews/);+ assert.match(services, /pluginSettingsDestinationEvent/);+});+```++- [ ] **Step 2: Run the test to verify it fails**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: FAIL because the native Settings host is still wired into service and lifecycle dependencies.++- [ ] **Step 3: Implement the lifecycle simplification**++Remove `pluginSettingsViews` construction, sender resolving, browser-window attachment, shutdown disposal, and close calls. Keep plugin load state as the authoritative lifecycle check in the renderer URL/bridge endpoint. Add a whitelisted renderer event carrying `{ pluginId, event, payload }`; `PluginSettingsDestination` ignores every event not for its immutable plugin id and forwards the rest through source-checked postMessage.++- [ ] **Step 4: Run the contract test to verify it passes**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: PASS.++- [ ] **Step 5: Commit**++```bash+git add apps/desktop/electron/main/services/plugin-services.ts apps/desktop/electron/main/bootstrap/window.ts apps/desktop/electron/main/bootstrap/shutdown.ts apps/desktop/electron/main/bootstrap/app-lifecycle.ts apps/desktop/electron/main/index.ts apps/desktop/electron/main/ipc/plugin-ipc.ts apps/desktop/test/plugin-settings-renderer-surface.test.mjs+git commit -m "refactor(plugins): retire native settings views"+```++### Task 4: Synchronize the public extension contract and delivery documents++**Files:**+- Create: `docs/adr/0250-renderer-composited-plugin-settings-surfaces.md`+- Modify: `docs/adr/README.md`+- Modify: `docs/spec/07-plugins/02-plugin-manifest-schema.md`+- Modify: `docs/spec/07-plugins/03-plugin-api.md`+- Modify: `docs/spec/07-plugins/04-plugin-security.md`+- Modify: `docs/spec/04-ux/06-settings-ia.md`+- Modify: `docs/spec/06-delivery/04-e2e-test-plan.md`+- Test: `apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++**Interfaces:**+- Documents `plugin-settings:` resource isolation, sandbox-only iframe, host message bridge, and Settings/native-control lifecycle.++- [ ] **Step 1: Extend the failing contract test**++```js+test("the public contract records the sandbox and one-canvas architecture", () => {+ assert.match(read("../../docs/adr/0250-renderer-composited-plugin-settings-surfaces.md"), /allow-scripts/);+ assert.match(read("../../docs/spec/07-plugins/04-plugin-security.md"), /plugin-settings/);+ assert.match(read("../../docs/spec/06-delivery/04-e2e-test-plan.md"), /renderer-composited Settings destination/);+});+```++- [ ] **Step 2: Run the test to verify it fails**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: FAIL because the ADR/spec scenarios do not yet exist.++- [ ] **Step 3: Write the ADR and update specifications**++Record that a Settings extension is renderer-composited while panels/work views remain native, enumerate the protocol’s asset and CSP policy, preserve the fixed bridge and permission boundary, and add manual E2E scenarios for scenic backdrops, core navigation, native title controls, reduced transparency, and plugin disable/uninstall.++- [ ] **Step 4: Run the contract test to verify it passes**++Run: `node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs`++Expected: PASS.++- [ ] **Step 5: Commit**++```bash+git add docs/adr docs/spec apps/desktop/test/plugin-settings-renderer-surface.test.mjs+git commit -m "docs(plugins): specify renderer settings surfaces"+```++### Task 5: Validate, refresh, merge, and clean up++**Files:**+- No production changes expected.++- [ ] **Step 1: Run focused tests**++Run:++```powershell+node --test apps/desktop/test/plugin-settings-renderer-surface.test.mjs+node --test apps/desktop/test/plugin-appearance-extensions.test.mjs+node --test apps/desktop/test/plugin-themes.test.mjs+git diff --check+pnpm run build:js+pnpm --filter @pi-desktop/desktop exec tsc -p tsconfig.json --noEmit+```++Expected: all commands succeed. E2E is intentionally not run without explicit user authorization.++- [ ] **Step 2: Manually verify in the fork build**++Run `pnpm --filter @pi-desktop/desktop dev`, open Settings → Extensions → Nexus Scenic Themes, switch among the four cards, then navigate to General and back. Confirm the backdrop is recognisable through the page, there is no black rectangle, title controls work, and no panel covers the rail or resize edge.++- [ ] **Step 3: Review, refresh, and integrate**++```bash+git diff main...HEAD --check+git fetch+git rebase main+```++Resolve only conflicts in this request worktree. Then follow the repository’s local-main merge and cleanup procedure. Do not push unless the user explicitly asks.diff --git a/docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.md b/docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.mdnew file mode 100644index 000000000..3dedb5484--- /dev/null+++ b/docs/superpowers/plans/2026-09-17-host-rendered-scenic-settings.md@@ -0,0 +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/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.diff --git a/docs/superpowers/specs/2026-09-15-renderer-plugin-settings-surfaces-design.md b/docs/superpowers/specs/2026-09-15-renderer-plugin-settings-surfaces-design.mdnew file mode 100644index 000000000..194b14a5a--- /dev/null+++ b/docs/superpowers/specs/2026-09-15-renderer-plugin-settings-surfaces-design.md@@ -0,0 +1,114 @@+# Renderer Plugin Settings Surfaces Design++## Problem++`contributes.settingsDestinations` currently opens each plugin page in an+Electron `WebContentsView`. On Windows and Linux that child native surface is+always composited above the main renderer and has an opaque backing canvas.+Even when the plugin document and its CSS are transparent, it cannot reveal a+scenic backdrop painted by the main renderer. The result is the black rectangle+visible behind Nexus Scenic Themes.++The rectangle cannot be corrected with plugin theme CSS: it is outside the+document's compositor. Making the BrowserWindow transparent would risk native+resize, drag, and Windows/Linux window-control behaviour, and duplicating the+backdrop inside the child view would create an unsynchronised second canvas.++## Decision++Settings destinations will become renderer-composited sandboxed iframe+surfaces. The host renderer owns their location in the existing Settings layout;+plugins supply only their page files and communicate through a host-controlled+message bridge.++The existing native `PluginViewHost` remains the implementation for work-panel+views. It is not used for Settings destinations.++## Resource model++The main process will register a secure, standard `plugin-settings:` protocol+before `app.whenReady()`. A URL has the shape:++```+plugin-settings://<plugin-id>/<plugin-relative-entry-or-resource>+```++The handler resolves a resource only when all of the following hold:++1. `<plugin-id>` is currently loaded and has the granted `ui.settings`+ permission.+2. The requested path remains inside that plugin's package.+3. The package has a declared Settings destination whose resolved entry is in+ the same package.+4. The resource extension is one of the host's static page formats (HTML, CSS,+ JavaScript, image, font, or media) and has a known MIME type.++The handler answers with `no-store`, `nosniff`, and a host-authored CSP. The CSP+permits only same-origin scripts/styles/images/fonts plus declared+`plugin-asset:` images; it denies network connection, framing of other pages,+objects, workers, form submission, and navigation. This preserves the no-egress+contract even though an iframe shares the app BrowserWindow's Electron session.++The HTML entry receives one host-authored bridge script before plugin scripts.+It does not receive Node, Electron, the main renderer's preload bridge, or a+same-origin relationship with the host page.++## Bridge model++The embedded page receives `window.pluginBridge` with the same public shape as+today's panel bridge:++```ts+window.pluginBridge.invoke(channel, payload?)+window.pluginBridge.on(event, handler)+```++The bridge is implemented by an injected host script and `postMessage`, not by+a preload. The host React component accepts messages only from its own iframe+window, validates the message envelope and generated request id, and forwards+the call through a new main-process IPC endpoint. Main validates the active+plugin/destination, then calls the existing `PluginRuntime.invokePanelBridge`.+Consequently the existing fixed channel, permission, auditing, and plugin+identity checks remain authoritative. A plugin cannot invoke renderer IPC,+touch the Settings React tree, choose another plugin/destination, or send a+cross-plugin request.++Host appearance and locale arrive in a one-way initial bridge message. Existing+sanctioned bridge events, including `appearance:changed`, are forwarded only to+the matching active destination.++## Lifecycle and layout++`PluginSettingsDestination` renders a single iframe in the existing+`.settings-content-inner` flow. It has no native bounds IPC and cannot cover+the titlebar, Windows/Linux controls, resize edges, sidebar, or Settings rail.+The iframe expands with its normal Settings content region; the outer renderer+keeps scroll ownership and normal Settings geometry.++Core navigation, plugin disable/uninstall/reload, an absent entry, and a failed+load remove the iframe and return the user to General. No `WebContentsView` is+created, cached, or attached for a Settings destination. The Settings page+therefore stays on the one renderer compositing plane as `.app-scenic-backdrop`.++## Security and compatibility++- `sandbox` is present on every Settings iframe. It includes only+ `allow-scripts`; it deliberately excludes `allow-same-origin`, popups,+ downloads, top navigation, forms, and pointer-lock.+- Plugin destination pages remain package-local. Remote requests, dynamic+ resource URLs, and arbitrary CSS/DOM injection remain unavailable.+- Plugin panels and work-panel views retain their isolated `WebContentsView`+ architecture; their geometry and bridge contracts do not change.+- Ordinary Settings and all non-plugin themes retain their existing DOM,+ layout, native control handling, and styling.+- The host does not make the BrowserWindow transparent and does not add a+ second scenic background to a plugin surface.++## Verification++Contract tests will demonstrate protocol registration and strict CSP, sandboxed+iframe ownership, absence of Settings `WebContentsView` calls, message source+and destination validation, lifecycle cleanup, and protected native geometry.+Focused build/type checks will accompany existing plugin-theme tests. Manual+verification will cover switching between core Settings and Nexus Scenic Themes+while each scenic theme is active, plus native title controls on Windows/Linux.diff --git a/docs/superpowers/specs/2026-09-17-host-rendered-scenic-settings-design.md b/docs/superpowers/specs/2026-09-17-host-rendered-scenic-settings-design.mdnew file mode 100644index 000000000..a851582b4--- /dev/null+++ b/docs/superpowers/specs/2026-09-17-host-rendered-scenic-settings-design.md@@ -0,0 +1,52 @@+# Host-rendered Scenic Settings Design++## Status++Approved for implementation on 2026-09-17.++## Problem++Plugin-provided HTML Settings pages cannot meet the scenic compositing requirement. An Electron `WebContentsView` is an opaque native child surface; a sandboxed iframe is a separate Chromium document surface. Both introduce a solid rectangle between the host-owned scenic backdrop and the Settings controls.++## Decision++Replace generic plugin Settings HTML destinations with a host-rendered declarative `scenicThemes` destination. The host renders all DOM, styling, layout, focus behavior, selection state, slider, and Apply action in the normal React Settings tree. A plugin contributes only validated metadata and declared theme assets.++The first implementation supports the Nexus Scenic Themes pack. It is a deliberately narrow contract, not a general plugin Settings UI language.++## Manifest contract++`contributes.scenicThemes` is an optional object requiring a stable id, localized label, description, keywords, a host-supported icon token, and one to twelve theme cards in presentation order. Every card carries a plugin-owned declared theme id, localized name and description, and one preview asset declared by that theme.++The host verifies `ui.settings`, `ui.theme`, card ids, localization values, asset containment, ownership, and the declared typed `--nexus-backdrop-blur` length variable with whole-number `0..20` bounds. Other variables and plugin settings are not editable by this destination.++Generic `settingsDestinations` HTML entries are retired from the appearance extension capability. The plugin's `settings/` directory is removed; there is no iframe, custom page protocol, bridge, or second document canvas.++## Host surface and visual ownership++The host places the scenic destination under Extensions and renders it directly inside `.settings-content-inner`. The host canvas, content wrapper, and scenic destination wrapper are transparent under a scenic plugin theme so the one root backdrop remains visible throughout Settings.++- Preview cards use declared local `plugin-asset://` images, readable overlays, selected outline/checkmark, and host-owned focus behavior.+- Only individual cards and the blur control own material surfaces; the destination has no outer panel or full-page background.+- The host owns responsive grid layout, narrow-window reflow, native titlebar/control protection, drag regions, and reduced-transparency fallbacks.++## Behavior and data flow++1. Main validates scenic metadata from each loaded plugin.+2. The host renders cards and resolves the selected theme's persisted blur value.+3. Selecting a card immediately invokes the restricted plugin-owned theme selection API.+4. The range input accepts integer values from 0 to 20 and changes only local draft state plus its `npx` output.+5. Apply invokes the existing typed variable API for only `--nexus-backdrop-blur` on the selected owned theme.+6. The host refreshes active theme CSS after successful save; failures restore confirmed value and show a host toast.+7. Switching cards restores each theme's confirmed blur; base/other plugin themes follow existing theme cleanup.++## Security and lifecycle++Plugins cannot provide HTML, CSS, JavaScript, selectors, components, event handlers, arbitrary actions, or iframe content. They cannot change Settings geometry, navigation, drag regions, native controls, or the work panel. Unknown paths, URLs, variables, theme ids, and cross-plugin references fail closed. Disable, uninstall, or invalid metadata removes the destination and returns the active Settings view to General.++## Tests and validation++- SDK validation rejects malformed objects, unknown/cross-plugin theme ids, undeclared assets, duplicates, non-localized strings, unsupported variables, and card counts outside 1–12.+- Main/IPC tests prove eligible loaded plugins only, declared asset rewriting, typed variable ownership, and lifecycle cleanup.+- Renderer tests prove the host renders cards/range/Apply, transparent outer ownership, responsive layout, selected accessibility, no iframe, and no outer panel.+- Interaction tests prove immediate selection, draft-only slider updates, Apply-only persistence, restoration, failures, base/plugin isolation, reduced transparency, and native controls.diff --git a/packages/plugin-sdk/src/index.test.ts b/packages/plugin-sdk/src/index.test.tsindex 0f6311e7c..aad967901 100644--- a/packages/plugin-sdk/src/index.test.ts+++ b/packages/plugin-sdk/src/index.test.ts@@ -135,7 +135,7 @@ describe("validateManifest", () => {).toMatch(/duplicate session source/);});- it("validates typed theme variables and sandboxed settings destinations", () => {+ it("validates typed theme variables and data-only scenic Settings contributions", () => {expect(validateContributions({themes: [{@@ -144,12 +144,18 @@ describe("validateManifest", () => {path: "themes/scenic.css",variables: [{ name: "--nexus-backdrop-blur", type: "length", unit: "px", min: 0, max: 20, default: 6 }],}],- settingsDestinations: [{+ scenicThemes: {id: "scenic-themes",label: { en: "Scenic themes", "zh-CN": "风景主题" },+ description: { en: "Scenic cards", "zh-CN": "风景卡片" },icon: "palette",- entry: "settings/index.html",- }],+ themes: [{+ themeId: "scenic",+ label: { en: "Scenic", "zh-CN": "风景" },+ description: { en: "Scenic card", "zh-CN": "风景卡片" },+ previewAsset: "assets/scenic.png",+ }],+ },}),).toBeUndefined();expect(@@ -158,6 +164,26 @@ describe("validateManifest", () => {}),).toMatch(/variable declaration/);});++ it("validates host-rendered scenic Settings contributions", () => {+ const scenicThemes = {+ id: "nexus-scenic-themes",+ label: { en: "Nexus Scenic Themes", "zh-CN": "Nexus 风景主题" },+ description: { en: "Four scenic themes", "zh-CN": "四款风景主题" },+ icon: "palette" as const,+ themes: [{+ themeId: "twilight-mountains",+ label: { en: "Twilight Mountains", "zh-CN": "暮光山脉" },+ description: { en: "Twilight glass", "zh-CN": "暮光玻璃" },+ previewAsset: "assets/twilight-mountains.png",+ }],+ };+ expect(validateContributions({ scenicThemes })).toBeUndefined();+ expect(validateContributions({ scenicThemes: { ...scenicThemes, themes: [] } })).toMatch(/1 to 12 cards/);+ expect(validateContributions({ scenicThemes: { ...scenicThemes, themes: [{ ...scenicThemes.themes[0], previewAsset: "../escape.png" }] } })).toMatch(/previewAsset/);+ expect(validateContributions({ scenicThemes: { ...scenicThemes, themes: [{ ...scenicThemes.themes[0], label: "Twilight" as unknown as typeof scenicThemes.themes[number]["label"] }] } })).toMatch(/localized label/);+ expect(validateContributions({ scenicThemes: { ...scenicThemes, keywords: ["scenic" as unknown as { en: string; "zh-CN": string }] } })).toMatch(/keywords/);+ });});describe("validateContributions", () => {@@ -359,7 +385,7 @@ describe("planSafeActions contract (ADR 0211)", () => {});describe("contributed theme assets and window appearance", () => {- it("accepts a whitelisted absolute asset list", () => {+ it("accepts whitelisted package-relative and absolute asset lists", () => {expect(validateContributions({themes: [@@ -367,17 +393,15 @@ describe("contributed theme assets and window appearance", () => {id: "midnight",label: "Midnight",path: "a.css",- assets: ["C:/art/bg.png", "file:///C:/font/ui.woff2", "/art/sheen.svg"],+ assets: ["assets/bg.png", "fonts/ui.woff2", "assets/sheen.svg", "C:/art/external.png"],},],}),).toBeUndefined();});- it("rejects a relative path, an escape, an unknown scheme or a wrong extension", () => {+ it("rejects an escape, an unknown scheme or a wrong extension", () => {for (const asset of [- "art/bg.png",- "./art/bg.png","../bg.png","art/../bg.png","C:/art/../bg.png",@@ -401,7 +425,7 @@ describe("contributed theme assets and window appearance", () => {id: "m",label: "M",path: "a.css",- assets: ["C:/art/bg.png", "file:///C:/art/bg.png"],+ assets: ["assets/bg.png", "./assets/bg.png", "C:/art/external.png", "file:///C:/art/external.png"],},],}),diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.tsindex d23a088bc..ce5bed130 100644--- a/packages/plugin-sdk/src/index.ts+++ b/packages/plugin-sdk/src/index.ts@@ -126,8 +126,8 @@ export type PluginManifest = {providers?: PluginProviderContrib[];settings?: PluginSettingContrib[];themes?: PluginThemeContrib[];- /** Sandboxed pages placed exclusively in Settings' host-owned Extensions group. */- settingsDestinations?: PluginSettingsDestinationContrib[];+ /** A host-rendered, image-card theme selector in Settings → Extensions. */+ scenicThemes?: PluginScenicThemesContrib;/** Native window background for this plugin's themes (ADR 0248). */windowAppearance?: PluginWindowAppearanceContrib;mcpServers?: PluginMcpServerContrib[];@@ -365,7 +365,7 @@ export type PluginThemeContrib = {/** Base palette the overrides are layered on. Defaults to `dark`. */base?: "light" | "dark";/**- * Relative paths (extension whitelist, 4 MB summed) this theme's CSS may+ * Package-relative or absolute paths (extension whitelist, 4 MB summed) this theme's CSS may* reference with `url()`. The host rewrites each matching reference to its own* `plugin-asset://` scheme; anything not declared here is still refused.*/@@ -374,12 +374,24 @@ export type PluginThemeContrib = {variables?: PluginThemeVariableContrib[];};-export type PluginSettingsDestinationContrib = {+/**+ * Data only: the host owns every DOM node, style, and interaction for this+ * Settings destination so a scenic canvas never sits behind a plugin document.+ */+export type PluginScenicThemesContrib = {id: string;- label: PluginLocalizedString | string;- icon: "sliders" | "sparkles" | "palette" | "plug" | "settings";- keywords?: Array<PluginLocalizedString | string>;- entry: string;+ label: PluginLocalizedString;+ description: PluginLocalizedString;+ keywords?: PluginLocalizedString[];+ icon: "palette";+ themes: PluginScenicThemeCardContrib[];+};++export type PluginScenicThemeCardContrib = {+ themeId: string;+ label: PluginLocalizedString;+ description: PluginLocalizedString;+ previewAsset: string;};/** Wire format a contributed provider may declare. Absent means `chat_completions`. */@@ -1576,7 +1588,7 @@ export function validateContributions(const assetPaths = new Set<string>();for (const asset of theme.assets) {if (typeof asset !== "string" || !isThemeAssetPath(asset)) {- return `theme "${theme.id}" asset must be an absolute ${THEME_ASSET_EXTENSIONS.join(+ return `theme "${theme.id}" asset must be a package-relative or absolute ${THEME_ASSET_EXTENSIONS.join("/",)} path`;}@@ -1601,17 +1613,26 @@ export function validateContributions(}}- const settingsDestinationIds = new Set<string>();- for (const destination of contributes.settingsDestinations ?? []) {- if (!destination || typeof destination !== "object") return "contributes.settingsDestinations entries must be objects";- if (typeof destination.id !== "string" || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(destination.id)) return "contributes.settingsDestinations id must match [a-zA-Z][a-zA-Z0-9_-]{0,63}";- if (settingsDestinationIds.has(destination.id)) return `duplicate settings destination id "${destination.id}"`;- settingsDestinationIds.add(destination.id);- if (typeof destination.entry !== "string" || !destination.entry.endsWith(".html")) return `settings destination "${destination.id}" entry must be an .html file`;- const pathError = relativePathError(destination.entry, `settings destination "${destination.id}" entry`);- if (pathError) return pathError;- if (!destination.label || (typeof destination.label !== "string" && typeof destination.label !== "object")) return `settings destination "${destination.id}" requires a label`;- if (!["sliders", "sparkles", "palette", "plug", "settings"].includes(destination.icon)) return `settings destination "${destination.id}" has an unsupported icon`;+ const scenicThemes = contributes.scenicThemes;+ if (scenicThemes !== undefined) {+ if (!scenicThemes || typeof scenicThemes !== "object" || Array.isArray(scenicThemes)) return "contributes.scenicThemes must be an object";+ if (typeof scenicThemes.id !== "string" || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(scenicThemes.id)) return "contributes.scenicThemes id must match [a-zA-Z][a-zA-Z0-9_-]{0,63}";+ const localized = (value: unknown) => Boolean(value && typeof value === "object" && typeof (value as PluginLocalizedString).en === "string" && typeof (value as PluginLocalizedString)["zh-CN"] === "string");+ if (!localized(scenicThemes.label)) return "contributes.scenicThemes requires a localized label";+ if (!localized(scenicThemes.description)) return "contributes.scenicThemes requires a localized description";+ if (scenicThemes.keywords !== undefined && (!Array.isArray(scenicThemes.keywords) || !scenicThemes.keywords.every(localized))) return "contributes.scenicThemes keywords must be localized";+ if (scenicThemes.icon !== "palette") return "contributes.scenicThemes has an unsupported icon";+ if (!Array.isArray(scenicThemes.themes) || scenicThemes.themes.length < 1 || scenicThemes.themes.length > 12) return "contributes.scenicThemes themes must contain 1 to 12 cards";+ const themeIds = new Set<string>();+ for (const card of scenicThemes.themes) {+ if (!card || typeof card !== "object") return "contributes.scenicThemes theme cards must be objects";+ if (typeof card.themeId !== "string" || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(card.themeId)) return "contributes.scenicThemes card themeId must be valid";+ if (themeIds.has(card.themeId)) return `contributes.scenicThemes duplicates themeId "${card.themeId}"`;+ themeIds.add(card.themeId);+ if (!localized(card.label)) return "contributes.scenicThemes card requires a localized label";+ if (!localized(card.description)) return "contributes.scenicThemes card requires a localized description";+ if (typeof card.previewAsset !== "string" || !isThemeAssetPath(card.previewAsset)) return "contributes.scenicThemes card previewAsset must be an image path";+ }}const windowAppearance = contributes.windowAppearance;diff --git a/packages/plugin-sdk/src/theme-css.test.ts b/packages/plugin-sdk/src/theme-css.test.tsindex c2366f29e..383680097 100644--- a/packages/plugin-sdk/src/theme-css.test.ts+++ b/packages/plugin-sdk/src/theme-css.test.ts@@ -168,13 +168,13 @@ describe("maskNonCodeCss", () => {});describe("theme assets", () => {- const ASSET = "C:/art/bg.png";+ const ASSET = "assets/bg.png";const resolveAsset: ThemeCssAssetResolver = (target) => {const normalized = normalizeThemeAssetPath(target);return normalized === ASSET ? themeAssetUrl("demo.hello", normalized) : null;};- it("rewrites an absolute reference to the host scheme", () => {+ it("rewrites a package-relative reference to the host scheme", () => {const result = sanitizeThemeCss(`.a { background: url("${ASSET}") no-repeat; }`,undefined,@@ -182,15 +182,15 @@ describe("theme assets", () => {);expect(result).toEqual({ok: true,- css: `.a { background: url("plugin-asset://demo.hello/${encodeURIComponent(ASSET)}") no-repeat; }`,+ css: `.a { background: url("plugin-asset://demo.hello/${ASSET}") no-repeat; }`,});});- it("accepts the file: URL spelling of the same absolute path", () => {- const result = sanitizeThemeCss(".a { background: url(file:///C:/art/bg.png); }", undefined, resolveAsset);+ it("accepts the normalized package-relative spelling of the same asset", () => {+ const result = sanitizeThemeCss(".a { background: url(./assets/bg.png); }", undefined, resolveAsset);expect(result.ok).toBe(true);if (result.ok) {- expect(result.css).toContain(`plugin-asset://demo.hello/${encodeURIComponent(ASSET)}`);+ expect(result.css).toContain(`plugin-asset://demo.hello/${ASSET}`);}});@@ -219,20 +219,18 @@ describe("theme assets", () => {expect(sanitizeThemeCss(css, undefined, resolveAsset)).toEqual({ ok: true, css });});- it("accepts absolute paths only — package-relative ones are no longer assets", () => {+ it("accepts normalized package-relative and absolute paths", () => {expect(isThemeAssetPath(ASSET)).toBe(true);- expect(normalizeThemeAssetPath("C:\\art\\bg.png")).toBe(ASSET);- expect(normalizeThemeAssetPath("file:///C:/art/bg.png")).toBe(ASSET);+ expect(normalizeThemeAssetPath("assets\\bg.png")).toBe(ASSET);+ expect(normalizeThemeAssetPath("./assets/bg.png")).toBe(ASSET);+ expect(normalizeThemeAssetPath("C:\\art\\bg.png")).toBe("C:/art/bg.png");+ expect(normalizeThemeAssetPath("file:///C:/art/bg.png")).toBe("C:/art/bg.png");expect(normalizeThemeAssetPath("/art/bg.png")).toBe("/art/bg.png");- expect(normalizeThemeAssetPath("file:///art/bg.png")).toBe("/art/bg.png");for (const refused of [- "art/bg.png",- "./art/bg.png",- "art\\bg.png","../escape.png","art/../../x.png","art//bg.png",- "C:/art/bg.gif",+ "assets/bg.gif","C:/art/../bg.png","https://x/y.png","",@@ -242,9 +240,12 @@ describe("theme assets", () => {}});- it("builds the host url with the absolute path percent-encoded", () => {+ it("builds host urls for package-relative and absolute paths", () => {expect(themeAssetUrl("demo.hello", ASSET)).toBe(- `plugin-asset://demo.hello/${encodeURIComponent(ASSET)}`,+ `plugin-asset://demo.hello/${ASSET}`,+ );+ expect(themeAssetUrl("demo.hello", "C:/art/bg.png")).toBe(+ `plugin-asset://demo.hello/${encodeURIComponent("C:/art/bg.png")}`,);});});diff --git a/packages/plugin-sdk/src/theme-css.ts b/packages/plugin-sdk/src/theme-css.tsindex 4ad49d984..fad722f57 100644--- a/packages/plugin-sdk/src/theme-css.ts+++ b/packages/plugin-sdk/src/theme-css.ts@@ -44,68 +44,58 @@ const THEME_ASSET_EXTENSION_PATTERN = new RegExp(/*** `plugin-asset://<pluginId>/<assetPath>` — how a theme reaches its bytes.*- * The key is an absolute filesystem path; see the encoding note below.+ * Package-relative keys are written directly. Absolute filesystem keys are+ * percent-encoded so drive colons and URL delimiters cannot change the lookup.*/export function themeAssetUrl(pluginId: string, assetPath: string): string {- // Asset keys are always absolute paths, so they are always percent-encoded:- // a path may contain a space, `?`, `#` or a drive colon that the URL parser- // would otherwise re-read as something other than a path segment. The- // `plugin-asset:` handler decodes it back.- return `${THEME_ASSET_SCHEME}://${pluginId}/${encodeURIComponent(assetPath.trim())}`;+ const normalized = normalizeThemeAssetPath(assetPath);+ const key = isExternalThemeAssetPath(normalized) ? encodeURIComponent(normalized) : normalized;+ return `${THEME_ASSET_SCHEME}://${pluginId}/${key}`;}/**- * Whether a normalized asset key is an absolute filesystem path.- *- * Windows drive paths (`C:/art/bg.png`) and POSIX absolute paths (`/art/bg.png`)- * both count; the host serves them straight from the filesystem.+ * Whether a normalized asset key names an external filesystem path.*/export function isExternalThemeAssetPath(key: string): boolean {return key.startsWith("/") || /^[a-zA-Z]:\//.test(key);}/**- * Normalize an asset reference to a canonical absolute key: forward slashes, no- * `file:` prefix, no trailing `./`.+ * Normalize a theme asset reference to either a package-relative forward-slash+ * path or an absolute filesystem path. The host distinguishes both forms at+ * load time and keeps package-local files contained inside the plugin root.*- * A theme asset is **always an absolute path** — `C:/art/bg.png`, `/art/bg.png`, or- * either spelled as a `file:` URL. Package-relative references are rejected: the- * host serves theme bytes straight from the filesystem.+ * Both the declaration in the manifest and the `url()` target inside the sheet+ * go through this, so `./art/bg.png` and `art/bg.png` are one package asset.*- * Returns an empty string when the value cannot name an asset: a relative path, an- * unknown scheme, a `.`/`..` segment, or an extension off the whitelist.+ * Returns an empty string when the value cannot name one: an unknown scheme,+ * empty or `.`/`..` segment, or an extension off the whitelist.*/export function normalizeThemeAssetPath(value: string): string {let raw = value.trim();if (/^file:/i.test(raw)) {- // Parsed by hand: this module is bundled for the renderer too, and it must not- // reach for `node:url`.const stripped = raw.replace(/^file:\/\//i, "").replace(/^file:/i, "");- const decoded = decodeUriComponentSafe(stripped);- raw = /^\/[a-zA-Z]:\//.test(decoded) ? decoded.slice(1) : decoded;+ try {+ raw = decodeURIComponent(stripped);+ } catch {+ return "";+ }+ if (/^\/[a-zA-Z]:\//.test(raw)) raw = raw.slice(1);}const path = raw.replace(/\\/g, "/").replace(/^\.\//, "");if (!path) return "";- if (!isExternalThemeAssetPath(path)) return "";- if (path.split("/").some((segment) => segment === "." || segment === "..")) return "";+ if (path.includes(":" ) && !isExternalThemeAssetPath(path)) return "";+ const segments = isExternalThemeAssetPath(path) ? path.split("/").filter(Boolean) : path.split("/");+ if (segments.some((segment) => !segment || segment === "." || segment === "..")) return "";return THEME_ASSET_EXTENSION_PATTERN.test(path) ? path : "";}-/** `decodeURIComponent` that returns the input unchanged when it is not valid. */-function decodeUriComponentSafe(value: string): string {- try {- return decodeURIComponent(value);- } catch {- return value;- }-}-/**- * `contributes.themes[].assets` entries name the absolute paths a theme may- * reference, on the extension whitelist. The host serves them from the filesystem;- * this only rejects the obviously unusable before anything is read.+ * `contributes.themes[].assets` entries may be package-relative or absolute+ * filesystem paths, but must be on the extension whitelist. The host contains+ * package-relative paths inside the plugin root before serving them.*/export function isThemeAssetPath(value: string): boolean {return normalizeThemeAssetPath(value) !== "";diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.tsindex 19f1018d3..93e5f649a 100644--- a/packages/shared/src/protocol.ts+++ b/packages/shared/src/protocol.ts@@ -191,16 +191,14 @@ export const IPC = {pluginLauncherToggle: "pi-desktop/pluginLauncher/toggle",pluginLauncherDismiss: "pi-desktop/pluginLauncher/dismiss",pluginThemes: "pi-desktop/plugin/themes",- pluginSettingsDestinations: "pi-desktop/plugin/settings/destinations",+ pluginScenicThemesDestinations: "pi-desktop/plugin/scenicThemes/destinations",+ pluginScenicThemesSetBlur: "pi-desktop/plugin/scenicThemes/setBlur",pluginServices: "pi-desktop/plugin/services",pluginViews: "pi-desktop/plugin/views",pluginViewOpen: "pi-desktop/plugin/view/open",pluginViewClose: "pi-desktop/plugin/view/close",pluginViewSetBounds: "pi-desktop/plugin/view/setBounds",pluginViewSetVisible: "pi-desktop/plugin/view/setVisible",- pluginSettingsViewOpen: "pi-desktop/plugin/settings/view/open",- pluginSettingsViewSetBounds: "pi-desktop/plugin/settings/view/setBounds",- pluginSettingsViewSetVisible: "pi-desktop/plugin/settings/view/setVisible",mcpList: "pi-desktop/mcp/list",mcpUpsert: "pi-desktop/mcp/upsert",mcpRemove: "pi-desktop/mcp/remove",diff --git a/packages/shared/src/types/plugins.ts b/packages/shared/src/types/plugins.tsindex ba049a0a9..1078fb4b7 100644--- a/packages/shared/src/types/plugins.ts+++ b/packages/shared/src/types/plugins.ts@@ -138,15 +138,27 @@ export type PluginViewMeta = {order: number;};-/** A host-resolved, sandboxed plugin Settings destination. */-export type PluginSettingsDestinationMeta = {+/** A data-only scenic Settings destination rendered by the host React tree. */+export type PluginScenicThemesDestinationMeta = {pluginId: string;destinationId: string;ref: string;label: string;+ description: string;pluginName: string;- icon: "sliders" | "sparkles" | "palette" | "plug" | "settings";+ icon: "palette";keywords: string[];+ themes: PluginScenicThemeCardMeta[];+};++/** One host-validated preview card belonging to a scenic destination. */+export type PluginScenicThemeCardMeta = {+ themeId: string;+ label: string;+ description: string;+ previewUrl: string;+ blur: number;+ blurDefault: number;};/**