Skip to content

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

feat(plugin-panel): add a transparent floating widget placement

vastsa930e6b93eaed
diff --git a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
index 290659a10..e8c568a2a 100644
--- a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
+++ b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
@@ -55,6 +55,9 @@ export function registerPluginUiIpc({
title: resolvePluginLocalizedString(manifest.ui.title, getUpdaterLocale(), manifest.name),
locale: getUpdaterLocale(),
theme: getPluginPanelTheme(),
+ shape: manifest.ui.shape,
+ alwaysOnTop: manifest.ui.alwaysOnTop,
+ resizable: manifest.ui.resizable,
width: manifest.ui.width ?? 480,
height: manifest.ui.height ?? 360,
htmlPath,
diff --git a/apps/desktop/electron/main/plugin-panel-host.ts b/apps/desktop/electron/main/plugin-panel-host.ts
index 43026e7fe..66dc45900 100644
--- a/apps/desktop/electron/main/plugin-panel-host.ts
+++ b/apps/desktop/electron/main/plugin-panel-host.ts
@@ -1,10 +1,14 @@
-import { BrowserWindow, ipcMain, session } from "electron";
+import { BrowserWindow, ipcMain, Menu, session } from "electron";
import { pathToFileURL } from "node:url";
import { join, resolve } from "node:path";
+import { catalogs, resolveLocale } from "@pi-desktop/i18n";
import { isNetUrlAllowed, THEME_ASSET_SCHEME } from "@pi-desktop/plugin-sdk";
import { builtinWindowBackground } from "@pi-desktop/shared";
import {
isPluginPanelWindowControlAction,
+ PLUGIN_PANEL_MIN_SIZE,
+ PLUGIN_PANEL_WIDGET_MIN_SIZE,
+ PLUGIN_PANEL_WIDGET_ARGUMENT,
PLUGIN_PANEL_WINDOW_CONTROL_CHANNEL,
PLUGIN_PANEL_WINDOW_STATE_CHANNEL,
PLUGIN_PANEL_LOCALE_ARGUMENT_PREFIX,
@@ -20,6 +24,18 @@ export type PluginPanelOpenRequest = {
width: number;
height: number;
htmlPath: string;
+ /**
+ * `"panel"` (default) keeps the 46px host drag band and its three-control
+ * capsule. `"widget"` opens the same sandboxed page as a transparent floating
+ * surface with neither, so a plugin can be a small orb the user keeps on
+ * screen. The plugin surface itself is unchanged: same preload bridge, same
+ * partition, same egress policy.
+ */
+ shape?: "panel" | "widget";
+ /** Floating widget placement only: keep the surface above other windows. */
+ alwaysOnTop?: boolean;
+ /** Overrides the per-shape default: panels are resizable, widgets are not. */
+ resizable?: boolean;
/**
* Egress allowlist from `manifest.net.domains`. A panel is a full web page:
* `sandbox: true` removes Node, not the network, so without this the panel is
@@ -141,6 +157,12 @@ export class PluginPanelHost {
private senderResolvers: Array<(senderId: number) => string | null> = [];
/** Observer for failures of the fire-and-forget legacy sync bridge. */
private onBridgeError?: (pluginId: string, channel: string, error: unknown) => void;
+ /**
+ * Locale per floating-widget web contents. Presence in this map is also what
+ * makes a window a widget for `showWidgetMenu`, so a panel never gets a
+ * context menu it did not ask for.
+ */
+ private widgetLocales = new Map<number, string>();
constructor(
bridge: BridgeHandler,
@@ -299,12 +321,55 @@ export class PluginPanelHost {
if (window.isMaximized()) window.unmaximize();
else window.maximize();
break;
+ case "contextMenu":
+ this.showWidgetMenu(window);
+ break;
case "close":
window.close();
break;
}
}
+ /**
+ * A floating widget has no capsule, so its own context menu opens the host's
+ * window menu instead. Without it the only way out of a widget would be a
+ * plugin-authored close button, and a plugin that never added one would leave
+ * a window the user cannot dismiss.
+ *
+ * Only a widget is registered in `widgetLocales`; a panel or docked view that
+ * asks for this action gets nothing, because panels keep the capsule.
+ */
+ private showWidgetMenu(window: BrowserWindow): void {
+ if (window.isDestroyed() || window.webContents.isDestroyed()) return;
+ const locale = this.widgetLocales.get(window.webContents.id);
+ if (locale === undefined) return;
+ const labels = catalogs[resolveLocale(locale)].pluginPanelWidget;
+ const menu = Menu.buildFromTemplate([
+ {
+ label: labels.alwaysOnTop,
+ type: "checkbox",
+ checked: window.isAlwaysOnTop(),
+ click: (item) => {
+ if (!window.isDestroyed()) window.setAlwaysOnTop(item.checked);
+ },
+ },
+ { type: "separator" },
+ {
+ label: labels.minimize,
+ click: () => {
+ if (!window.isDestroyed()) window.minimize();
+ },
+ },
+ {
+ label: labels.close,
+ click: () => {
+ if (!window.isDestroyed()) window.close();
+ },
+ },
+ ]);
+ menu.popup({ window });
+ }
+
/**
* Confine everything the panel's web contents can reach to the plugin's
* declared domains. See `applyPluginEgressPolicy`, which the docked work-panel
@@ -335,18 +400,32 @@ export class PluginPanelHost {
const ses = session.fromPartition(partition, { cache: true });
this.applyEgressPolicy(ses, request);
+ const widget = request.shape === "widget";
+ const minSize = widget ? PLUGIN_PANEL_WIDGET_MIN_SIZE : PLUGIN_PANEL_MIN_SIZE;
const win = new BrowserWindow({
- width: Math.max(360, request.width || 480),
- height: Math.max(280, request.height || 360),
+ width: Math.max(minSize.width, request.width || (widget ? 220 : 480)),
+ height: Math.max(minSize.height, request.height || (widget ? 220 : 360)),
title: request.title,
show: false,
autoHideMenuBar: true,
// The host theme is only a fallback; the preload samples the actual
// plugin page colors after it has loaded and paints the chrome from them.
- backgroundColor: builtinWindowBackground(request.theme),
- // Every platform uses the same frameless surface. The preload owns the
- // only visible window controls: a fixed three-button capsule.
+ backgroundColor: widget ? "#00000000" : builtinWindowBackground(request.theme),
+ // Every platform uses the same frameless surface. A panel's visible window
+ // controls are the preload's three-button capsule; a floating widget has
+ // no chrome of its own — the plugin draws its silhouette edge to edge.
frame: false,
+ transparent: widget,
+ // A transparent window would otherwise carry a rectangular native shadow
+ // around an orb that is round; a widget draws its own glow instead.
+ hasShadow: !widget,
+ resizable: request.resizable ?? !widget,
+ alwaysOnTop: widget && request.alwaysOnTop === true,
+ // A floating widget is a desktop companion, not a taskbar entry, and it
+ // has no capsule to restore from a maximized state.
+ skipTaskbar: widget,
+ maximizable: !widget,
+ ...(widget ? { fullscreenable: false } : {}),
webPreferences: {
session: ses,
preload: join(__dirname, "../preload/plugin-panel.js"),
@@ -357,6 +436,7 @@ export class PluginPanelHost {
additionalArguments: [
`${PLUGIN_PANEL_LOCALE_ARGUMENT_PREFIX}${encodeURIComponent(request.locale)}`,
`--pi-plugin-panel-theme=${request.theme}`,
+ ...(widget ? [PLUGIN_PANEL_WIDGET_ARGUMENT] : []),
...(request.development
? ["--pi-plugin-panel-development=1"]
: []),
@@ -385,8 +465,10 @@ export class PluginPanelHost {
// while the window is still alive; reading `webContents` later throws
// "Object has been destroyed" and surfaces an uncaught main-process dialog.
const webContentsId = win.webContents.id;
+ if (widget) this.widgetLocales.set(webContentsId, request.locale);
win.on("closed", () => {
this.pendingDrops.delete(webContentsId);
+ this.widgetLocales.delete(webContentsId);
this.windows.delete(request.pluginId);
});
diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.ts
index 50758dc5a..6e7049e02 100644
--- a/apps/desktop/electron/main/plugin-runtime.ts
+++ b/apps/desktop/electron/main/plugin-runtime.ts
@@ -195,6 +195,16 @@ export type PluginPanelRequest = {
htmlPath: string;
locale?: string;
theme?: "light" | "dark";
+ /**
+ * `"panel"` (default) keeps the 46px host drag band and its capsule.
+ * `"widget"` is the transparent floating placement: no band, no capsule, a
+ * whole-window drag map, and a host context menu instead of the capsule.
+ */
+ shape?: "panel" | "widget";
+ /** Floating widget placement only: keep the surface above other windows. */
+ alwaysOnTop?: boolean;
+ /** Overrides the per-shape default: panels are resizable, widgets are not. */
+ resizable?: boolean;
/** The plugin's egress allowlist; the panel session is confined to it. */
netDomains?: readonly string[];
/** Allows the isolated panel to request microphone audio, never camera access. */
@@ -4438,6 +4448,9 @@ export class PluginRuntime {
this.services.getLocale?.(),
loaded.manifest.name,
),
+ shape: loaded.manifest.ui?.shape,
+ alwaysOnTop: loaded.manifest.ui?.alwaysOnTop,
+ resizable: loaded.manifest.ui?.resizable,
width: loaded.manifest.ui?.width ?? 480,
height: loaded.manifest.ui?.height ?? 360,
htmlPath,
diff --git a/apps/desktop/electron/preload/plugin-panel.ts b/apps/desktop/electron/preload/plugin-panel.ts
index 4cb677760..8bf78d64f 100644
--- a/apps/desktop/electron/preload/plugin-panel.ts
+++ b/apps/desktop/electron/preload/plugin-panel.ts
@@ -5,6 +5,7 @@ import {
PLUGIN_PANEL_CHROME_VERSION,
PLUGIN_PANEL_CHROME_PAINT_THROUGH_VERSION,
PLUGIN_PANEL_EMBEDDED_ARGUMENT,
+ PLUGIN_PANEL_WIDGET_ARGUMENT,
PLUGIN_PANEL_LOCALE_ARGUMENT_PREFIX,
PLUGIN_PANEL_WINDOW_CONTROL_CHANNEL,
PLUGIN_PANEL_WINDOW_STATE_CHANNEL,
@@ -71,6 +72,14 @@ function isEmbeddedPanel(): boolean {
return process.argv.includes(PLUGIN_PANEL_EMBEDDED_ARGUMENT);
}
+/**
+ * True when this surface is a floating widget: a transparent, frameless window
+ * whose whole rectangle belongs to the plugin — no titlebar band, no capsule.
+ */
+function isWidgetPanel(): boolean {
+ return process.argv.includes(PLUGIN_PANEL_WIDGET_ARGUMENT);
+}
+
function panelTheme(): PluginPanelTheme {
const prefix = "--pi-plugin-panel-theme=";
const raw = process.argv.find((argument) => argument.startsWith(prefix));
@@ -111,12 +120,14 @@ function pageSurface(theme: PluginPanelTheme): string {
function publishTitlebarHeight(): void {
document.documentElement?.style.setProperty(
"--pi-plugin-titlebar-height",
- `${isEmbeddedPanel() ? 0 : PLUGIN_PANEL_TITLEBAR_HEIGHT}px`,
+ `${isEmbeddedPanel() || isWidgetPanel() ? 0 : PLUGIN_PANEL_TITLEBAR_HEIGHT}px`,
);
}
function pluginOwnsTitlebarSpacing(): boolean {
- return pluginChromeMode() !== "legacy";
+ // A floating widget publishes a titlebar height of 0 and draws edge to edge,
+ // so the host must not add the legacy 46px offset either.
+ return isWidgetPanel() || pluginChromeMode() !== "legacy";
}
/**
@@ -365,6 +376,81 @@ function installPaintThroughDragMap(dragRegion: HTMLElement): void {
sync();
}
+/**
+ * A floating widget drags through its whole window: the plugin owns every pixel
+ * and normally paints a silhouette far smaller than the rectangle it lives in,
+ * so the segment map covers the full surface and only interactive elements
+ * punch holes in it. Same mechanics as the panel's paint-through band, one
+ * rectangle taller.
+ */
+function installWidgetDragMap(dragRegion: HTMLElement): void {
+ const sync = () => {
+ const width = Math.max(
+ 1,
+ window.innerWidth,
+ document.documentElement?.clientWidth ?? 0,
+ );
+ const height = Math.max(
+ 1,
+ window.innerHeight,
+ document.documentElement?.clientHeight ?? 0,
+ );
+ const segments = paintThroughDragSegments(
+ width,
+ height,
+ paintThroughNoDragRects(),
+ );
+ dragRegion.replaceChildren(
+ ...segments.map((segment) => {
+ const element = document.createElement("div");
+ element.className = "drag-segment";
+ element.setAttribute("aria-hidden", "true");
+ element.style.left = `${segment.left}px`;
+ element.style.top = `${segment.top}px`;
+ element.style.width = `${segment.right - segment.left}px`;
+ element.style.height = `${segment.bottom - segment.top}px`;
+ return element;
+ }),
+ );
+ };
+
+ let frame = 0;
+ const schedule = () => {
+ if (frame) return;
+ frame = window.requestAnimationFrame(() => {
+ frame = 0;
+ sync();
+ });
+ };
+
+ const observer = new MutationObserver(schedule);
+ observer.observe(document.body, {
+ subtree: true,
+ childList: true,
+ attributes: true,
+ attributeFilter: [
+ "aria-hidden",
+ "class",
+ "data-pi-plugin-no-drag",
+ "hidden",
+ "style",
+ ],
+ });
+ window.addEventListener("resize", schedule, { passive: true });
+ window.addEventListener("scroll", schedule, { capture: true, passive: true });
+ sync();
+}
+
+/**
+ * Tells the page which placement it renders in — `panel`, `widget`, or a docked
+ * `view` — before page scripts run, so CSS can branch on it without a bridge
+ * round trip.
+ */
+function publishPanelShape(): void {
+ const shape = isWidgetPanel() ? "widget" : isEmbeddedPanel() ? "view" : "panel";
+ document.documentElement?.setAttribute("data-pi-plugin-panel-shape", shape);
+}
+
function chromeLabels(input = panelLocale()): ChromeLabels {
const locale = input.replaceAll("_", "-").toLowerCase();
const traditionalChinese =
@@ -484,6 +570,7 @@ function installPanelChrome(): void {
// plugin CSS can resolve its variable without an extra reflow or a second
// 46px offset.
publishTitlebarHeight();
+ publishPanelShape();
// A docked view has no window controls and no drag band, so it gets the full
// surface. The variable is still published — at 0 — so a plugin's fixed
@@ -493,6 +580,66 @@ function installPanelChrome(): void {
return;
}
+ // A floating widget has no host chrome at all: the page owns the whole
+ // rectangle and draws its own silhouette. Drag comes from a whole-window
+ // segment map, and right-click asks the host for the widget menu instead of
+ // the capsule a panel would show.
+ if (isWidgetPanel()) {
+ const widgetTheme = panelTheme();
+ const host = document.createElement("pi-plugin-panel-chrome");
+ host.dataset.theme = widgetTheme;
+ host.dataset.chromeMode = "widget";
+ host.setAttribute("aria-hidden", "true");
+ const style = document.createElement("style");
+ style.textContent = `
+ :host {
+ color-scheme: light dark;
+ pointer-events: none;
+ position: fixed;
+ inset: 0;
+ z-index: 2147483647;
+ display: block;
+ user-select: none;
+ }
+ .drag-region {
+ -webkit-app-region: no-drag;
+ app-region: no-drag;
+ pointer-events: none;
+ position: absolute;
+ inset: 0;
+ }
+ .drag-segment {
+ -webkit-app-region: drag;
+ app-region: drag;
+ pointer-events: auto;
+ position: absolute;
+ z-index: 0;
+ user-select: none;
+ }
+ `;
+ const chrome = document.createElement("div");
+ chrome.className = "chrome";
+ const dragRegion = document.createElement("div");
+ dragRegion.className = "drag-region";
+ dragRegion.setAttribute("aria-hidden", "true");
+ chrome.append(dragRegion);
+ const shadow = host.attachShadow({ mode: "closed" });
+ shadow.append(style, chrome);
+ document.documentElement.append(host);
+ installWidgetDragMap(dragRegion);
+ // The capsule is the panel's only close affordance; a widget has none, so
+ // the host owns an equivalent menu behind the surface's context menu.
+ window.addEventListener("contextmenu", (event) => {
+ event.preventDefault();
+ void ipcRenderer
+ .invoke(PLUGIN_PANEL_WINDOW_CONTROL_CHANNEL, "contextMenu")
+ .catch(() => {
+ // Closing destroys the sender before the invocation resolves.
+ });
+ });
+ return;
+ }
+
// v2 pages use `padding-top: var(--pi-plugin-titlebar-height, 0px)` (or
// their own calc from it), so preserving the original body padding is what
// keeps their content tight. Legacy pages do not know about the variable;
@@ -819,6 +966,8 @@ function installPanelChrome(): void {
// The install path repeats this defensively for pages that replace their root.
publishTitlebarHeight();
+publishPanelShape();
+
if (document.readyState === "loading") {
window.addEventListener("DOMContentLoaded", installPanelChrome, { once: true });
} else {
diff --git a/apps/desktop/electron/shared/plugin-panel-chrome.ts b/apps/desktop/electron/shared/plugin-panel-chrome.ts
index 26c12e589..a682a9fc7 100644
--- a/apps/desktop/electron/shared/plugin-panel-chrome.ts
+++ b/apps/desktop/electron/shared/plugin-panel-chrome.ts
@@ -50,6 +50,23 @@ export const PLUGIN_PANEL_LOCALE_ARGUMENT_PREFIX = "--pi-plugin-panel-locale=";
*/
export const PLUGIN_PANEL_EMBEDDED_ARGUMENT = "--pi-plugin-panel-embedded=1";
+/**
+ * Marks a plugin surface as a floating widget: a transparent, frameless window
+ * with no 46px titlebar band and no host control capsule. The preload publishes
+ * a titlebar height of 0, installs a drag map over the whole window, and routes
+ * right-click to the host's widget menu. `window.pluginBridge` is identical to
+ * a panel, so one HTML entry can serve both placements.
+ */
+export const PLUGIN_PANEL_WIDGET_ARGUMENT = "--pi-plugin-panel-widget=1";
+
+/**
+ * Smallest surface each placement may ask for. A panel is sized around
+ * plugin-drawn content; a widget draws its own silhouette — a floating orb —
+ * and may shrink far below that.
+ */
+export const PLUGIN_PANEL_MIN_SIZE = { width: 360, height: 280 } as const;
+export const PLUGIN_PANEL_WIDGET_MIN_SIZE = { width: 120, height: 120 } as const;
+
export const PLUGIN_PANEL_WINDOW_CONTROL_CHANNEL =
"pi-plugin-panel-window-control";
export const PLUGIN_PANEL_WINDOW_STATE_CHANNEL =
@@ -59,6 +76,10 @@ export const PLUGIN_PANEL_WINDOW_CONTROL_ACTIONS = [
"getState",
"minimize",
"toggleMaximize",
+ // A floating widget has no capsule, so right-click on the surface asks the
+ // host for its widget menu: close, minimize, always on top. A panel answers
+ // the same action with a no-op — panels keep the capsule.
+ "contextMenu",
"close",
] as const;
diff --git a/apps/desktop/test/plugin-panel-window.test.mjs b/apps/desktop/test/plugin-panel-window.test.mjs
index 9942afc73..fd458f5a2 100644
--- a/apps/desktop/test/plugin-panel-window.test.mjs
+++ b/apps/desktop/test/plugin-panel-window.test.mjs
@@ -29,7 +29,10 @@ const bundledPanelSources = [
test("plugin panels match the cross-platform main-window chrome contract", () => {
assert.match(hostSource, /frame: false/);
assert.doesNotMatch(hostSource, /titleBarStyle|trafficLightPosition/);
- assert.match(hostSource, /backgroundColor: builtinWindowBackground\(request\.theme\)/);
+ assert.match(
+ hostSource,
+ /backgroundColor: widget \? "#00000000" : builtinWindowBackground\(request\.theme\)/,
+ );
assert.match(hostSource, /win\.setMenu\(null\)/);
assert.match(hostSource, /pi-plugin-panel-development=1/);
assert.match(chromeSource, /PLUGIN_PANEL_TITLEBAR_HEIGHT = 46/);
@@ -84,7 +87,9 @@ test("plugin panels expose host-owned dropped-file authorization", () => {
test("plugin panel close does not read destroyed webContents", () => {
assert.match(
hostSource,
- /const webContentsId = win\.webContents\.id;\s*win\.on\("closed", \(\) => \{\s*this\.pendingDrops\.delete\(webContentsId\);/,
+ /const webContentsId = win\.webContents\.id;\s*if \(widget\) this\.widgetLocales\.set\(webContentsId, request\.locale\);\s*win\.on\("closed", \(\) => \{\s*this\.pendingDrops\.delete\(webContentsId\);/,
+ // The widget locale is cleared with the same captured id, never through a
+ // destroyed webContents object.
);
const closedHandler = hostSource.slice(
hostSource.indexOf('win.on("closed"'),
@@ -165,3 +170,57 @@ test("checked-in plugin panels follow the host chrome contract", () => {
assert.doesNotMatch(panelSource, /top:\s*0/);
}
});
+
+test("floating widgets are transparent, chromeless, and still dismissible", () => {
+ // The manifest field has to reach the window: transparent surface, no band,
+ // no capsule, and a smaller minimum than a panel's.
+ assert.match(chromeSource, /PLUGIN_PANEL_WIDGET_ARGUMENT = "--pi-plugin-panel-widget=1"/);
+ assert.match(
+ chromeSource,
+ /PLUGIN_PANEL_WIDGET_MIN_SIZE = \{ width: 120, height: 120 \} as const/,
+ );
+ assert.match(chromeSource, /PLUGIN_PANEL_MIN_SIZE = \{ width: 360, height: 280 \} as const/);
+ assert.match(hostSource, /const widget = request\.shape === "widget";/);
+ assert.match(hostSource, /transparent: widget,/);
+ assert.match(hostSource, /backgroundColor: widget \? "#00000000"/);
+ assert.match(hostSource, /hasShadow: !widget,/);
+ assert.match(hostSource, /skipTaskbar: widget,/);
+ assert.match(hostSource, /maximizable: !widget,/);
+ assert.match(hostSource, /resizable: request\.resizable \?\? !widget,/);
+ assert.match(hostSource, /alwaysOnTop: widget && request\.alwaysOnTop === true,/);
+ assert.match(hostSource, /\.\.\.\(widget \? \[PLUGIN_PANEL_WIDGET_ARGUMENT\] : \[\]\),/);
+
+ // The preload owns the placement: titlebar height 0, no capsule, and a drag
+ // map over the whole window instead of the 46px band.
+ assert.match(preloadSource, /function isWidgetPanel\(\): boolean/);
+ assert.match(
+ preloadSource,
+ /isEmbeddedPanel\(\) \|\| isWidgetPanel\(\) \? 0 : PLUGIN_PANEL_TITLEBAR_HEIGHT/,
+ );
+ assert.match(preloadSource, /isWidgetPanel\(\) \|\| pluginChromeMode\(\) !== "legacy"/);
+ assert.match(preloadSource, /data-pi-plugin-panel-shape/);
+ assert.match(preloadSource, /function installWidgetDragMap\(dragRegion: HTMLElement\): void/);
+ assert.match(preloadSource, /host\.dataset\.chromeMode = "widget"/);
+ assert.match(preloadSource, /installWidgetDragMap\(dragRegion\);/);
+ const widgetBranch = preloadSource.slice(
+ preloadSource.indexOf("if (isWidgetPanel()) {"),
+ preloadSource.indexOf("let labels = chromeLabels();"),
+ );
+ assert.ok(widgetBranch.length > 0, "the widget branch must return before the capsule exists");
+ assert.doesNotMatch(widgetBranch, /className = "capsule"/);
+ // The segment map is the only drag route, so its holes must come from the
+ // same no-drag selector the panel band uses.
+ assert.match(preloadSource, /paintThroughDragSegments\(/);
+ assert.match(preloadSource, /paintThroughNoDragRects\(\)/);
+
+ // A widget has no capsule to close it, so the host menu is the way out.
+ assert.match(chromeSource, /"contextMenu",/);
+ assert.match(preloadSource, /invoke\(PLUGIN_PANEL_WINDOW_CONTROL_CHANNEL, "contextMenu"\)/);
+ assert.match(hostSource, /private showWidgetMenu\(window: BrowserWindow\): void/);
+ assert.match(hostSource, /catalogs\[resolveLocale\(locale\)\]\.pluginPanelWidget/);
+ assert.match(hostSource, /private widgetLocales = new Map<number, string>\(\);/);
+ assert.match(hostSource, /if \(widget\) this\.widgetLocales\.set\(webContentsId, request\.locale\);/);
+ assert.match(hostSource, /this\.widgetLocales\.delete\(webContentsId\);/);
+ // A panel that asks for the widget menu gets nothing: only widgets register.
+ assert.match(hostSource, /if \(locale === undefined\) return;/);
+});
diff --git a/apps/desktop/test/window-background-theme.test.mjs b/apps/desktop/test/window-background-theme.test.mjs
index 77648a97d..fac75e5cb 100644
--- a/apps/desktop/test/window-background-theme.test.mjs
+++ b/apps/desktop/test/window-background-theme.test.mjs
@@ -33,7 +33,12 @@ test("theme changes synchronize the native non-macOS window background", () => {
// That fallback is the shared built-in theme table, not a literal per call
// site, so window-ipc, window creation, and the panel host cannot drift.
assert.match(mainSource, /: builtinWindowBackground\(theme\)/);
- assert.match(mainSource, /backgroundColor: builtinWindowBackground\(request\.theme\)/);
+ assert.match(
+ mainSource,
+ // A floating widget paints its own silhouette, so the host leaves that
+ // window fully transparent instead of pouring a theme colour behind it.
+ /backgroundColor: widget \? "#00000000" : builtinWindowBackground\(request\.theme\)/,
+ );
assert.match(
mainSource,
/builtinWindowBackground\(\s*nativeTheme\.shouldUseDarkColors \? "dark" : "light",?\s*\)/,
diff --git a/crates/host-core/src/plugins/model.rs b/crates/host-core/src/plugins/model.rs
index d6af92975..43a03d2f2 100644
--- a/crates/host-core/src/plugins/model.rs
+++ b/crates/host-core/src/plugins/model.rs
@@ -238,6 +238,18 @@ pub struct PluginUiMeta {
pub height: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<Value>,
+ /// `"panel"` (default) or `"widget"`. A widget is a transparent, frameless
+ /// floating surface: no 46px host titlebar band, no window-control capsule,
+ /// a drag map over the whole window, and a host context menu (close,
+ /// minimize, always on top).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub shape: Option<String>,
+ /// Widget placement only: keep the floating surface above other windows.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub always_on_top: Option<bool>,
+ /// Overrides the per-shape default (panels are resizable, widgets are not).
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub resizable: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/crates/host-core/src/plugins/tests.rs b/crates/host-core/src/plugins/tests.rs
index 98b583748..3b2270a33 100644
--- a/crates/host-core/src/plugins/tests.rs
+++ b/crates/host-core/src/plugins/tests.rs
@@ -1967,3 +1967,27 @@ fn market_cards_and_details_read_the_catalog_i18n_block() {
Some("Reads nothing else")
);
}
+
+#[test]
+fn plugin_ui_meta_parses_the_floating_widget_placement() {
+ let widget: PluginUiMeta = serde_json::from_value(json!({
+ "panel": "renderer/index.html",
+ "width": 200,
+ "height": 200,
+ "shape": "widget",
+ "alwaysOnTop": true,
+ "resizable": false
+ }))
+ .unwrap();
+ assert_eq!(widget.shape.as_deref(), Some("widget"));
+ assert_eq!(widget.always_on_top, Some(true));
+ assert_eq!(widget.resizable, Some(false));
+
+ // A manifest that never heard of widgets keeps deserializing untouched, and
+ // the camelCase keys stay the wire contract.
+ let panel: PluginUiMeta =
+ serde_json::from_value(json!({ "panel": "renderer/index.html" })).unwrap();
+ assert!(panel.shape.is_none());
+ assert!(panel.always_on_top.is_none());
+ assert!(panel.resizable.is_none());
+}
diff --git a/docs/adr/0273-plugin-panel-floating-widget.md b/docs/adr/0273-plugin-panel-floating-widget.md
new file mode 100644
index 000000000..8c8080579
--- /dev/null
+++ b/docs/adr/0273-plugin-panel-floating-widget.md
@@ -0,0 +1,76 @@
+# ADR 0273: A floating widget placement for plugin panels
+
+- Status: Accepted for implementation
+- Date: 2026-09-17
+- Deciders: PI-Desktop core
+- Related: [ADR 0081](0081-host-owned-plugin-panel-chrome.md) ·
+ [ADR 0092](0092-plugin-owned-panel-surface.md) ·
+ [ADR 0093](0093-plugin-panel-strict-drag-band.md) ·
+ [ADR 0110](0110-plugin-panel-chrome-spacing-contract.md) ·
+ [07-plugins/03-plugin-api](../spec/07-plugins/03-plugin-api.md)
+
+## Context
+
+Every plugin panel is a frameless `BrowserWindow` that reserves a 46px host drag
+band and carries one three-control capsule in its top-right corner (ADR 0092,
+ADR 0093, ADR 0110). That grammar suits a panel that shows content, and does not
+suit a plugin whose whole interface is a small round companion — a voice orb, a
+timer, a status light.
+
+Such a plugin cannot exist today. The host paints an opaque background, forces a
+360×280 minimum, and draws the capsule over the top of the page. What an author
+gets is a rectangle with a toolbar strip, not a floating sphere; the transparent
+strip that makes the panel chrome work reads as a seam around a shape that is not
+a rectangle at all. Electron can already host a transparent window, and the
+plugin surface itself — preload bridge, session partition, permission gate, egress
+policy — needs no change to allow it.
+
+## Decision
+
+1. A manifest may declare `"ui": { "shape": "widget" }`. `"panel"` stays the
+ default; an absent or `"panel"` value keeps today's behavior unchanged.
+2. A widget window is `transparent: true` with a fully transparent
+ `backgroundColor`, `hasShadow: false`, `frame: false`, `maximizable: false`,
+ `fullscreenable: false`, and `skipTaskbar: true`. The plugin draws its own
+ silhouette, shadow, and glow.
+3. A widget has no 46px band and no capsule. The preload publishes
+ `--pi-plugin-titlebar-height: 0px`, never applies the legacy additive offset,
+ and instead installs a drag map over the whole window: empty space drags,
+ while standard controls and every element marked `data-pi-plugin-no-drag`
+ stay clickable. The mechanics are the paint-through segment map of ADR 0093,
+ applied to the full rectangle.
+4. The capsule is the panel's only close affordance (ADR 0093 §4), so the host
+ owns an equivalent menu behind the widget surface's own context menu: close,
+ minimize, and an always-on-top toggle. It travels on the existing
+ sender-validated window-control channel as one new `contextMenu` action, so
+ `window.pluginBridge` still gains no window primitive.
+5. `ui.width` / `ui.height` are honoured down to 120×120 for a widget (a panel's
+ minimum stays 360×280). `ui.alwaysOnTop` defaults to `false`; `ui.resizable`
+ defaults to `false` for a widget and `true` for a panel.
+6. The preload publishes the placement as
+ `document.documentElement.dataset.piPluginPanelShape` (`panel` | `widget` |
+ `view`) before page scripts run, so one HTML entry can serve every placement
+ without a bridge round trip.
+7. The plugin surface is otherwise unchanged: same preload, same
+ `pluginBridge` channels, same permission gate, same per-plugin session
+ partition, same egress policy, same localization rules. A widget needs no new
+ permission.
+8. `manifest.ui.shape`, `ui.alwaysOnTop`, and `ui.resizable` are validated at
+ install by the Plugin SDK, carried in the shared manifest type, and parsed by
+ host-core's `PluginUiMeta`, so the Rust catalog and the TypeScript host agree
+ on the contract.
+
+## Consequences
+
+- A plugin can be a floating orb: transparent, small, always-on-top when it asks
+ for it, draggable from its empty space, and closable from a host menu even when
+ the plugin never drew a close button.
+- The 46px band, the capsule, and the v2 spacing contract stay exactly as they
+ are for panels and docked views; existing plugins and installed packages are
+ unaffected.
+- Placement is a per-plugin manifest choice, not a per-page one: the same HTML
+ entry may serve a panel, a widget, and a docked view by reading the published
+ placement and the titlebar variable.
+- A widget surface has one more pointer rule to document: an element that must
+ receive clicks is either a standard control or carries
+ `data-pi-plugin-no-drag`; everything else drags the window.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 27917774a..b59a68209 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -299,3 +299,4 @@ Each ADR includes:
| 0269 | [Move capability documents between the global and project levels](0269-capability-level-transfer.md) | Accepted for implementation (amends ADR 0112) |
| 0268 | Remove quotes, annotations, and side chats | Accepted (supersedes message-quotes-and-side-chats / response-annotations / floating-annotation-index) |
| 0272 | [Judge a public-network address on the route the request will dial](0272-connection-time-public-network-route.md) | Accepted for implementation (amends ADR 0243; issue #419 / PR #473) |
+| 0273 | [A floating widget placement for plugin panels](0273-plugin-panel-floating-widget.md) | Accepted for implementation (amends ADR 0093 §4; ADR 0092 / ADR 0110) |
diff --git a/docs/plugin-development.md b/docs/plugin-development.md
index b793a8d9d..a4898f214 100644
--- a/docs/plugin-development.md
+++ b/docs/plugin-development.md
@@ -13,6 +13,7 @@ A plugin can contribute one or more of these capabilities:
|---|---|---|
| Command | An explicit action in global search | `contributes.commands`, `pi.commands.register` |
| Panel | A small isolated HTML interface | `ui.panel`, `ui.panel` permission, `window.pluginBridge` |
+| Floating widget | A transparent, frameless companion window — a round orb, not a rectangle | `ui.panel` permission, `"ui": { "shape": "widget" }`, `window.pluginBridge` |
| Work panel view | An interface docked in the app's right work panel | `contributes.views`, `ui.view` permission, `window.pluginBridge` |
| Agent tool | A function the Agent can call | `contributes.agentTools`, `pi.agent.registerTool` |
| One-shot completion | A host-owned completion against the user's models | `pi.models.list`, `pi.session.getLlmContext`, `pi.agent.complete` |
@@ -218,6 +219,27 @@ The host does not inject a panel title. Keep the 46px drag band in mind for
viewport-height calculations as well:
`height: calc(100dvh - var(--pi-plugin-titlebar-height, 46px))`.
+### Floating widgets
+
+A plugin whose whole interface is a small floating shape — a voice orb, a timer,
+a status light — declares `"ui": { "shape": "widget" }` in its manifest instead
+of accepting a rectangle with a toolbar strip. The panel then opens as a
+transparent, frameless window:
+
+- no 46px drag band and no capsule; `--pi-plugin-titlebar-height` is `0px`
+- empty space drags the window, while a standard control — or any element marked
+ `data-pi-plugin-no-drag` — stays clickable
+- right-click on the surface opens the host menu: close, minimize, always on top
+- `ui.width` / `ui.height` are honoured down to 120×120, and `ui.alwaysOnTop`
+ pins the widget above other windows
+- the page can read `document.documentElement.dataset.piPluginPanelShape`
+ (`panel` | `widget` | `view`) to style one HTML entry for every placement
+
+Draw the silhouette yourself — `border-radius: 50%`, your own shadow, a glow that
+bleeds past the shape — and keep the page background transparent outside it, so
+the window disappears behind the shape. Everything else, `window.pluginBridge`,
+permissions, settings, is identical to a panel.
+
```html
<!doctype html>
<html lang="en">
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index 975cd9c2d..10593010b 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -916,6 +916,32 @@ Detached panel pages using the current chrome contract declare
for normal-flow top spacing. The host preserves that page-owned spacing. A
page without the marker remains supported through the legacy additive offset.
+### 6.1 Floating widgets
+
+A manifest may declare `"ui": { "shape": "widget" }`. The panel then opens as a
+floating widget: the same sandboxed, permission-gated page in a transparent,
+frameless window with no 46px drag band, no control capsule, and no rectangular
+native shadow. The page owns its whole rectangle and normally paints a
+silhouette smaller than it — a round orb, for instance — so the host must not
+draw a frame around that silhouette.
+
+- `--pi-plugin-titlebar-height` is `0px`, and the legacy additive top offset is
+ not applied either, whatever chrome marker the page declares.
+- The placement is published before page scripts run as
+ `document.documentElement.dataset.piPluginPanelShape`: `panel`, `widget`, or
+ `view`.
+- Dragging uses a whole-window drag map: empty space moves the window, while
+ standard controls (`button`, `input`, `a`, `[tabindex]`, …) and every element
+ marked `data-pi-plugin-no-drag` stay clickable.
+- A widget has no capsule, so the host owns an equivalent menu behind the
+ surface's own context menu: close, minimize, and always on top. A plugin may
+ still close its own widget through `ui.closePanel()`.
+- `ui.width` / `ui.height` are honoured down to 120×120 (a panel's minimum stays
+ 360×280). `ui.alwaysOnTop` pins a widget above other windows, and
+ `ui.resizable` defaults to `false` for a widget and `true` for a panel.
+- Nothing else changes: same preload, same `pluginBridge` channels, same
+ permission gate, same session partition and egress policy.
+
A docked view may also be given one subject to show. The `location` a work-panel
tab already carries is delivered to any contributed view — not only
`pi.browser`, whose address bar keeps its own navigation channel: on creation it
diff --git a/docs/zh-CN/plugin-development.md b/docs/zh-CN/plugin-development.md
index 77d87ebda..fdd5e2da6 100644
--- a/docs/zh-CN/plugin-development.md
+++ b/docs/zh-CN/plugin-development.md
@@ -16,6 +16,7 @@
|---|---|---|
| 命令 | 全局搜索中的显式操作 | `contributes.commands`、`pi.commands.register` |
| 面板 | 一个小的独立的 HTML 界面 | `ui.panel`、`ui.panel` 权限、`window.pluginBridge` |
+| 悬浮挂件 | 透明无边框的小挂件窗口——例如一个圆形球体 | `ui.panel` 权限、`"ui": { "shape": "widget" }`、`window.pluginBridge` |
| Agent 工具 | Agent 可以调用的函数 | `contributes.agentTools`、`pi.agent.registerTool` |
| 技能 | Agent 按需加载指令 | `contributes.skills`、`agent.prompt.inject` 权限 |
| 主题 | 设计令牌覆盖 | `contributes.themes`、`ui.theme` 权限 |
@@ -217,6 +218,23 @@ PI-Desktop 在 macOS、Windows 和 Linux 上都使用无边框窗口承载面板
计算视口高度时也要扣除同一个 46px:
`height: calc(100dvh - var(--pi-plugin-titlebar-height, 46px))`。
+### 悬浮挂件
+
+如果一个插件的全部界面就是一个小小的悬浮形状——语音球、计时器、状态灯——
+就在清单里声明 `"ui": { "shape": "widget" }`,而不是接受一个带工具栏条的矩形。
+面板此时会以透明、无边框的窗口打开:
+
+- 没有 46px 拖拽带,也没有胶囊;`--pi-plugin-titlebar-height` 为 `0px`
+- 空白处拖动窗口;标准控件或任何带 `data-pi-plugin-no-drag` 标记的元素保持可点击
+- 在挂件上右键打开宿主菜单:关闭、最小化、始终置顶
+- `ui.width` / `ui.height` 最小可到 120×120,`ui.alwaysOnTop` 让挂件浮在其他窗口之上
+- 页面可读取 `document.documentElement.dataset.piPluginPanelShape`
+ (`panel` | `widget` | `view`),让同一份 HTML 适配三种位置
+
+自己绘制轮廓——`border-radius: 50%`、自定义阴影、溢出到形状之外的辉光——并让
+页面背景在轮廓之外保持透明,窗口就会隐没在形状之后。其余部分(`window.pluginBridge`、
+权限、设置)与面板完全一致。
+
```html
<!doctype html>
<html lang="en">
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index abe0e5357..a7792a00f 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1233,6 +1233,15 @@ sklm: {
"skipped": "Frage {{number}} übersprungen"
}
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ "pluginPanelWidget": {
+ "alwaysOnTop": "Immer im Vordergrund",
+ "minimize": "Minimieren",
+ "close": "Widget schließen"
+ },
"panel": {
"title": "Arbeitsfenster",
"subagent": "Unteragent",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 9ecfce98f..b648bc1a2 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1249,6 +1249,15 @@ sklm: {
skipped: "Question {{number}} skipped",
},
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ pluginPanelWidget: {
+ alwaysOnTop: "Always on top",
+ minimize: "Minimize",
+ close: "Close widget",
+ },
panel: {
title: "Work panel",
subagent: "Subagent",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index cfccb4d81..c8833dce6 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1233,6 +1233,15 @@ sklm: {
"skipped": "Pregunta {{number}} omitida"
}
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ "pluginPanelWidget": {
+ "alwaysOnTop": "Siempre visible",
+ "minimize": "Minimizar",
+ "close": "Cerrar el widget"
+ },
"panel": {
"title": "Panel de trabajo",
"subagent": "Subagente",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 85cedac5d..60496a5a1 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1233,6 +1233,15 @@ sklm: {
"skipped": "Question {{number}} ignorée"
}
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ "pluginPanelWidget": {
+ "alwaysOnTop": "Toujours au-dessus",
+ "minimize": "Réduire",
+ "close": "Fermer le widget"
+ },
"panel": {
"title": "Panneau de travail",
"subagent": "Sous-agent",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index d334df6c8..0378d702c 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1250,6 +1250,15 @@ sklm: {
skipped: "질문 {{number}} 건너뜀",
},
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ pluginPanelWidget: {
+ alwaysOnTop: "항상 위에 표시",
+ minimize: "최소화",
+ close: "위젯 닫기",
+ },
panel: {
title: "작업 패널",
subagent: "서브에이전트",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index c3ec41dbb..506c7a95c 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1250,6 +1250,15 @@ sklm: {
skipped: "Soru {{number}} atlandı",
},
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ pluginPanelWidget: {
+ alwaysOnTop: "Her zaman üstte",
+ minimize: "Küçült",
+ close: "Widget'ı kapat",
+ },
panel: {
title: "Çalışma paneli",
subagent: "Alt ajan",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 9ecf66072..b64f22fe1 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1236,6 +1236,15 @@ sklm: {
skipped: "第 {{number}} 题已跳过",
},
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ pluginPanelWidget: {
+ alwaysOnTop: "始终置顶",
+ minimize: "最小化",
+ close: "关闭挂件",
+ },
panel: {
title: "工作面板",
subagent: "子智能体",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 8c4fecea1..1c3c52cca 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1236,6 +1236,15 @@ sklm: {
skipped: "第 {{number}} 題已跳過",
},
},
+ /**
+ * Host-owned window menu of a floating plugin widget (`ui.shape: "widget"`).
+ * A widget has no control capsule, so its context menu carries these.
+ */
+ pluginPanelWidget: {
+ alwaysOnTop: "永遠置頂",
+ minimize: "最小化",
+ close: "關閉小工具",
+ },
panel: {
title: "工作面板",
subagent: "子智慧體",
diff --git a/packages/plugin-sdk/src/index.test.ts b/packages/plugin-sdk/src/index.test.ts
index 825e6c712..0f6311e7c 100644
--- a/packages/plugin-sdk/src/index.test.ts
+++ b/packages/plugin-sdk/src/index.test.ts
@@ -40,6 +40,33 @@ describe("validateManifest", () => {
).toMatch(/zh-CN is required/);
});
+ it("validates the floating widget placement fields", () => {
+ expect(validateManifest({ ...base, ui: { shape: "widget" } }).ok).toBe(true);
+ expect(validateManifest({ ...base, ui: { shape: "panel" } }).ok).toBe(true);
+ expect(validateManifest({ ...base, ui: { shape: "orb" } }).error).toMatch(
+ /manifest\.ui\.shape/,
+ );
+ expect(
+ validateManifest({ ...base, ui: { alwaysOnTop: "yes" } }).error,
+ ).toMatch(/manifest\.ui\.alwaysOnTop must be a boolean/);
+ expect(validateManifest({ ...base, ui: { resizable: 1 } }).error).toMatch(
+ /manifest\.ui\.resizable must be a boolean/,
+ );
+ const widget = validateManifest({
+ ...base,
+ ui: {
+ panel: "renderer/index.html",
+ shape: "widget",
+ alwaysOnTop: true,
+ resizable: false,
+ },
+ });
+ expect(widget.ok).toBe(true);
+ expect(widget.manifest?.ui?.shape).toBe("widget");
+ expect(widget.manifest?.ui?.alwaysOnTop).toBe(true);
+ expect(widget.manifest?.ui?.resizable).toBe(false);
+ });
+
it("accepts the new contribution shapes", () => {
const result = validateManifest({
...base,
diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.ts
index 2b80144eb..d23a088bc 100644
--- a/packages/plugin-sdk/src/index.ts
+++ b/packages/plugin-sdk/src/index.ts
@@ -74,6 +74,19 @@ export type PluginManifest = {
width?: number;
height?: number;
title?: PluginLocalizedString | string;
+ /**
+ * Panel placement. `"panel"` (default) keeps the host-owned 46px titlebar
+ * band and its three-control capsule. `"widget"` opens the same sandboxed
+ * page as a transparent, frameless floating surface: no band, no capsule,
+ * a drag map over the whole window, and a host context menu that closes,
+ * minimizes, or pins it. A widget may be smaller than a panel — see
+ * `PLUGIN_PANEL_MIN_SIZE` / `PLUGIN_PANEL_WIDGET_MIN_SIZE` in the host.
+ */
+ shape?: "panel" | "widget";
+ /** Floating widget placement only: keep the surface above other windows. */
+ alwaysOnTop?: boolean;
+ /** Overrides the per-shape default: panels are resizable, widgets are not. */
+ resizable?: boolean;
};
contributes?: {
commands?: Array<{
@@ -1202,7 +1215,13 @@ export function validateManifest(raw: unknown): {
const i18nError = manifestI18nError((m as Record<string, unknown>).i18n);
if (i18nError) return { ok: false, error: i18nError };
const ui = m.ui as
- | { title?: unknown; panel?: unknown }
+ | {
+ title?: unknown;
+ panel?: unknown;
+ shape?: unknown;
+ alwaysOnTop?: unknown;
+ resizable?: unknown;
+ }
| null
| undefined;
if (ui !== undefined) {
@@ -1218,6 +1237,15 @@ export function validateManifest(raw: unknown): {
const panelError = relativePathError(ui.panel, "manifest.ui.panel");
if (panelError) return { ok: false, error: panelError };
}
+ if (ui.shape !== undefined && ui.shape !== "panel" && ui.shape !== "widget") {
+ return { ok: false, error: "manifest.ui.shape must be \"panel\" or \"widget\"" };
+ }
+ for (const key of ["alwaysOnTop", "resizable"] as const) {
+ const value = ui[key];
+ if (value !== undefined && typeof value !== "boolean") {
+ return { ok: false, error: `manifest.ui.${key} must be a boolean` };
+ }
+ }
}
const contributesError = validateContributions(m.contributes);
if (
diff --git a/packages/shared/src/types/plugins.ts b/packages/shared/src/types/plugins.ts
index 61d9e520a..3cda7f4a7 100644
--- a/packages/shared/src/types/plugins.ts
+++ b/packages/shared/src/types/plugins.ts
@@ -70,6 +70,17 @@ export type PluginUiMeta = {
width?: number;
height?: number;
title?: string | PluginLocalizedString;
+ /**
+ * Panel placement. `"panel"` (default) keeps the host-owned 46px drag band
+ * and its three-control capsule. `"widget"` is a transparent, frameless
+ * floating surface with neither, sized from the inside: the page owns its
+ * whole rectangle and drags the window through a host-provided drag map.
+ */
+ shape?: "panel" | "widget";
+ /** Floating widget placement only: keep the surface above other windows. */
+ alwaysOnTop?: boolean;
+ /** Overrides the per-shape default: panels are resizable, widgets are not. */
+ resizable?: boolean;
};
/**