Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
docs(plugins): describe unified tiles, the pin cap, and the content-sized panel
v_wyxgwang834739bb9f16
diff --git a/docs/adr/0339-plugin-launcher-local-apps.md b/docs/adr/0339-plugin-launcher-local-apps.mdindex 00f6226b9..20206e89e 100644--- a/docs/adr/0339-plugin-launcher-local-apps.md+++ b/docs/adr/0339-plugin-launcher-local-apps.md@@ -57,8 +57,11 @@ app data directory, not host-core user data.discovered and the user can already see, and nothing else.4. Discovery is bounded and non-invasive. Main reads only well-known locations,never spawns a program to probe, caches the scan for 5 minutes, caps the list- at 600 entries, extracts icons for the first 200 entries (≤4 KiB each), and- drops an entry whose target is gone.+ at 600 entries, asks the platform for a `large` icon for the first 200 entries+ (each data URL ≤32 KiB, reused across scans through an id-keyed cache), and+ drops an entry whose target is gone. A plugin tile never has a platform icon:+ the launcher draws a letter tile for plugin panels, because `manifest.icon` is+ author-declared but not consumed by the host.5. The launcher's size and position live in main-process shell state(`<data dir>/plugin-launcher-state.json`), not in host-core. It follows the`window-state.json` precedent from ADR 0090: best-effort, debounced,diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex fa3ca0f53..39091b6aa 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -19516,26 +19516,30 @@ their separate platform acceptance.9. Pin an application, quit, restart, and reopen the launcher with an emptyinput.- **Expected**: Step 1 shows `Recently used` with two rows of eight tiles and- `Pinned` with one row of eight; the recents header reports the true number of- remembered items and the pinned header offers `All →`. Step 2 lists the- trigger plugin as the **first** tile with a `receives 1+1` detail line, ahead- of name matches, and the panel shows `1+1` exactly once (a second read returns- `null`). Step 3 reaches the same application through all three spellings with- a `pinyin`/`initials` detail line. Step 4 lists `PI-Desktop` once by name.- Step 5 keeps eight columns per row at every width between the minimum and- maximum, and the dragged size is restored after the restart. Step 6 keeps the- window at its current size, reports the dropped count in the header, and asks- the user to keep typing. Step 7 removes the disabled plugin from recents,- pins, and matches while every other tile still opens. Step 8 keeps the panel- responsive (no frozen input, no unhandled error) and reports no match, because- input longer than 256 characters is never matched against a trigger. Step 9- still shows the pinned application in the `Pinned` row.+ `Pinned` with one row of eight once the user has pins; the recents header+ reports the true number of remembered items and offers `Show all {count} →`+ plus `All plugins →`. Step 2 lists the trigger plugin as the **first** tile,+ ahead of name matches and without a detail line, and the panel shows `1+1`+ exactly once (a second read returns `null`). Step 3 reaches the same+ application through all three spellings. Step 4 lists `PI-Desktop` once by+ name. Step 5 keeps eight columns per row at every width, the panel height+ always matches what it renders, and the dragged width is restored after the+ restart. Step 6 keeps the window at its height cap, reports the dropped count+ in the header, and asks the user to keep typing. Step 7 removes the disabled+ plugin from recents, pins, and matches while every other tile still opens.+ Step 8 keeps the panel responsive (no frozen input, no unhandled error) and+ reports no match, because input longer than 256 characters is never matched+ against a trigger. Step 9 still shows the pinned application in the `Pinned`+ row.- **Automation**: `pnpm --filter @pi-desktop/desktop test` runs the offlinecoverage for these rules: `launcher-search.test.mjs` (ranking order, section- caps, overflow total, trigger whole-input matching and the 256-character- limit), `launcher-store.test.mjs` (pins, aliases, recents, legacy migration- and pruning), `local-apps.test.mjs` (discovery, bounds, dropped targets,- opaque-id launch) and `plugin-launcher-state.test.mjs` (clamping and- re-centring). Rust `plugins` tests cover the manifest rules. The rendered- Electron journey above — grouped grid, resize, restart, and the panel payload- round trip — is Draft until a launcher E2E script exists.+ caps, overflow total, trigger whole-input matching, the 256-character limit+ and the all-plugins view), `launcher-store.test.mjs` (pins and the eight-pin+ cap, recents, legacy migration, retired fields read without error, and+ pruning), `plugin-launcher-height.test.mjs` (content-height arithmetic and+ clamping), `local-apps.test.mjs` (discovery, bounds, icon budget and icon+ cache, dropped targets, opaque-id launch) and `plugin-launcher-state.test.mjs`+ (clamping and re-centring). Rust `plugins` tests cover the manifest rules. The+ rendered Electron journey above — grouped grid, content height, resize,+ restart, and the panel payload round trip — is Draft until a launcher E2E+ script exists.diff --git a/docs/spec/07-plugins/18-plugin-launcher.md b/docs/spec/07-plugins/18-plugin-launcher.mdindex 47904938a..1e8e8503a 100644--- a/docs/spec/07-plugins/18-plugin-launcher.md+++ b/docs/spec/07-plugins/18-plugin-launcher.md@@ -46,46 +46,68 @@ ADR 0086.## 3. Layout-The panel renders one search field at the top, a results region, and a footer of-keyboard hints. The search field carries the shortcut hint (`⌥ Space` /-`Alt + Space`).+The panel renders one search field at the top, a scrolling results region, and a+footer of keyboard hints. The search field carries the shortcut hint+(`⌥ Space` / `Alt + Space`).Grid geometry (`apps/desktop/src/lib/launcher-search.ts`):-| Region | Rows | Tiles | Header action |+| Region | Rows | Tiles | Header actions ||---|---|---|---|-| `Recently used` (empty input) | 2 | 16 | `Show all {count} →` — `count` is the true number of remembered items |-| `Pinned` (empty input) | 1 | 8 | `All →` — expands both sections to their full lists |+| `Recently used` (empty input) | 2 | 16 | `Show all {count} →` — `count` is the true number of remembered items; `All plugins →` — the full plugin list |+| `Pinned` (empty input) | 1 | 8 | none || Matches (non-empty input) | 3 | 24 | `{count} more — keep typing to narrow it down` |+| All plugins (view) | — | every installed plugin | none |Every row is eight columns; the column count does not change with the number ofresults, so the grid does not reflow as the user types or resizes.-`Show all {count} →` / `All →` set an expanded view whose action becomes-`Collapse`. While the input is non-empty the panel shows the hit view only: the-total number of matches is reported in the header action so a query that had to-drop tiles still says so, instead of silently truncating.+`Show all {count} →` sets an expanded view whose action becomes `Collapse`. The+pinned section renders nothing at all — not even its header — while the user has+no pins, and it never carries a header action: it is always exactly one row.++`All plugins →` replaces the recent and pinned sections with one grid of every+installed **plugin** in the same results region; local applications are not+included. Recently opened plugins come first and the rest keep catalog order. The+grid stays scrollable once the window reaches its height cap, and every tile in+it can be opened with `Enter` or pinned. Typing returns to the hit view, and `Esc`+leaves the view before it dismisses the panel.++While the input is non-empty the panel shows the hit view only: the total number+of matches is reported in the header action so a query that had to drop tiles+still says so, instead of silently truncating.Empty states: `Loading plugins…` while the catalog is loading, `Looking forinstalled applications…` while the background application scan is still-running, `No plugins with panels are ready to open.` when nothing is-launchable, and `No matching plugins` for a query with no hit.+running, `No plugins with panels are ready to open.` when nothing is launchable,+and `No matching plugins` for a query with no hit. A query with no hit — and a+panel with neither recents nor pins — offers `Browse the plugin market`, which+closes the panel, focuses the main window, and opens the plugin market page+(§12).## 4. Tiles-Every tile shows an icon, a name, and one detail line:+Every tile shows the same three parts:++- the icon — an application's platform icon, or a monogram for a plugin and for+ an application whose icon could not be read; an `<img>` that fails to load+ falls back to the monogram instead of leaving a hole;+- the name, ellipsized when it does not fit;+- a type badge on the same line as the name — `Plugin` or `App`.-- the reason it matched — `name {value}`, `pinyin {value}`,- `initials {value}`, `alias {value}`, `about {value}`, `pinned`, `recent`, or- `receives {value}` for a declared trigger (the text the plugin will receive);-- a source tag: `Plugin` or `App`.+A tile does not explain why it matched: there is no second line, so every tile is+the same height and the eight-column grid stays aligned. The `title` tooltip+carries `name · type` (plus the executable name for an application) and never the+launcher payload.-Plugins render a square tile and applications a circular one, each with its-monogram or icon. A plugin and an application that share a name are therefore-both listed and visually distinguishable rather than deduplicated.+Plugins render a square tile and applications a circular one. A plugin and an+application that share a name are therefore both listed and visually+distinguishable rather than deduplicated.-Each tile has a per-item menu button whose accessible label is-`More actions for {name}` (§8).+Each tile carries a pin toggle in its corner (§8) with `aria-pressed` and the+`Pin to panel` / `Unpin` label. It is hidden until the tile is hovered, active,+or focused, stays visible on an already pinned tile, and is not part of the tab+order — the panel is driven from the search field.## 5. Matching and ranking@@ -96,14 +118,16 @@ Score order, best first:1. whole-input declared trigger match (§6)2. exact name-3. exact alias-4. name prefix (an alias prefix shares this rank)-5. pinyin prefix-6. initials prefix-7. name substring-8. pinyin / initials substring-9. alias substring-10. description substring+3. name prefix+4. pinyin prefix+5. initials prefix+6. name substring+7. pinyin / initials substring+8. description substring++The rank is internal: it orders the tiles and is never rendered, because a tile+has no detail line. A trigger match wins the whole item, so a plugin that matches+both by pattern and by name appears exactly once, ahead of every name match.Ties break on recency (most recently opened first), then plugins beforeapplications, then name, then catalog order, so a given catalog and store always@@ -130,10 +154,10 @@ Rules enforced on the declaration:- a pattern that does not compile is inert — it matches nothing and does notbreak the panel.-A trigger hit ranks above every name match and shows the text the plugin will-receive as its detail line (`receives {value}`). This is what lets a plugin-declare an arithmetic or command-like shape (`1+1`) without competing with every-name that merely contains `1`.+A trigger hit ranks above every name match. This is what lets a plugin declare an+arithmetic or command-like shape (`1+1`) without competing with every name that+merely contains `1`. The panel does not print the text the plugin will receive —+the payload travels with the open request only (§7).## 7. Payload delivery@@ -159,7 +183,7 @@ tile click / Enter- Payloads longer than `LAUNCHER_PAYLOAD_MAX_LENGTH` (512) are dropped: the panelopens with no payload instead of failing the open.-## 8. Pins, aliases, and recents+## 8. Pins and recentsPer-item preferences live in the renderer's `localStorage` under`pi.desktop.launcher.state` (`apps/desktop/src/lib/launcher-store.ts`). The first@@ -169,18 +193,27 @@ upgrade keeps the existing recency order.| Item | Limit ||---|---|| Recents | one entry per item, capped at 60 |-| Pins | 24 |-| Aliases | 6 per item, 32 characters each |--Every read is defensive: an unreadable record is dropped, and stored ids are-pruned against the live catalog, so a plugin that was disabled or uninstalled-disappears from recents, pins, and matches. Hiding a plugin from the launcher is-a launcher-scope preference only — the plugin keeps loading and its commands keep+| Pins | 8 (one row) |++Pinning is one click on the tile's pin toggle; the panel has no per-item menu.+There is no way to rename an item either: a tile shows the name the plugin or the+operating system declares.++A full pin row refuses the next pin instead of silently evicting an older one.+The footer reports `All 8 pin slots are taken`, and the pinned row shakes once+(suppressed under `prefers-reduced-motion: reduce`). Unpinning frees the slot.++Every read is defensive: an unreadable record is dropped, stored ids are pruned+against the live catalog, and unknown fields written by an older or newer build —+for example the retired `aliases` map — are ignored and left in place, never+rewritten on read. A plugin that was disabled or uninstalled therefore disappears+from recents, pins, and matches. Hiding a plugin from the launcher is a+launcher-scope preference only — the plugin keeps loading and its commands keepworking.The store is per renderer origin, which the launcher window and the main window-share, so pins and aliases written in one window are visible in the other-through the ordinary `storage` event.+share, so pins written in one window are visible in the other through the+ordinary `storage` event.## 9. Local applications@@ -193,12 +226,14 @@ through the ordinary `storage` event.- Linux: freedesktop `.desktop` entries under `/usr/share/applications`,`/usr/local/share/applications`, and `~/.local/share/applications`.-Bounds: the scan result is cached for 5 minutes, holds at most 600 entries,-extracts icons for the first 200 entries only (each data URL capped at 4 KiB),-and drops an entry whose target no longer exists.+Bounds: the scan result is cached for 5 minutes, holds at most 600 entries and+extracts icons for the first 200 of them. Each icon is the platform's `large`+variant, capped at 32 KiB, and cached across scans keyed by item id and icon+path; an entry that disappears prunes its cached icon, so a rescan does not pay+for a lookup it already has. An entry whose target no longer exists is dropped.The renderer receives a display name, an executable name, a source tag-(`start-menu` / `app-bundle` / `desktop-entry`), a small icon, and an opaque+(`start-menu` / `app-bundle` / `desktop-entry`), an icon, and an opaque`app:<slug>` id — never a path. Opening a tile sends that id;`pi-desktop/pluginLauncher/openApp` resolves it against the host's own scan andre-checks that the target still exists before launching, so the surface cannot be@@ -207,12 +242,19 @@ ADR [0339](../../adr/0339-plugin-launcher-local-apps.md) records this decision.## 10. Window size, position, and state-- The window is resizable between 560×380 and 1280×940 DIP. The minimum width is- the smallest width at which eight columns still fit without squeezing; the+- The window is resizable between 560 and 1280 DIP wide; the minimum width is the+ smallest width at which eight columns still fit without squeezing, and themaximum keeps eight tiles scannable.-- Size and position persist in `<data dir>/plugin-launcher-state.json`, written+- Height always fits the content. The renderer measures the search row, the+ natural height of the results content, the footer, and the panel padding and+ reports the total through `pi-desktop/pluginLauncher/contentHeight`; the host+ clamps it to 120–940 DIP and sets the content size, so the panel never opens+ with empty space and never clips a row.+- Width and position persist in `<data dir>/plugin-launcher-state.json`, writtenbest-effort and debounced by the main process- (`apps/desktop/electron/main/plugin-launcher-state.ts`).+ (`apps/desktop/electron/main/plugin-launcher-state.ts`). Height is not a user+ preference: a persisted height is only a starting point until the first+ measurement arrives.- A remembered position is applied only when the whole panel still fits insidethe work area it is opening on; otherwise the panel re-centres there.- This is main-process shell state, following ADR@@ -226,7 +268,7 @@ ADR [0339](../../adr/0339-plugin-launcher-local-apps.md) records this decision.| `↑` / `↓` | move one grid row || `←` / `→` | move one tile || `Enter` | open the active tile |-| `Esc` | close the panel |+| `Esc` | leave the all-plugins view, otherwise close the panel |While an IME composition is active (`event.isComposing` or `keyCode === 229`) nokey is acted on, so a Chinese IME's candidate Enter or arrow keys never open or@@ -238,19 +280,30 @@ move a tile.|---|---|---|| `pi-desktop/pluginLauncher/catalog` | renderer → main | plugins + applications + `appsScanning` || `pi-desktop/pluginLauncher/openApp` | renderer → main | opaque `app:<slug>` id only |+| `pi-desktop/pluginLauncher/contentHeight` | renderer → main | measured content height; finite positive numbers only, clamped to 120–940 DIP |+| `pi-desktop/pluginLauncher/openMarket` | renderer → main | hide the panel, focus the main window, open the plugin market page || `pi-desktop/pluginLauncher/dismiss` | renderer → main | hide the panel || `pi-desktop/pluginLauncher/toggle` | main → renderer | show/hide request || `pi-desktop/pluginLauncher/event/shown` | main → renderer | reset the panel for a fresh open || `pi-plugin-panel-event:launcher:payload` | main → panel page | §7 |-The catalog and `openApp` handlers verify that the sender is the launcher-window's own `webContents`; any other sender is rejected with-`PERMISSION_DENIED`. Both are main-only capabilities:+Every launcher handler verifies that the sender is the launcher window's own+`webContents`; any other sender is rejected with `PERMISSION_DENIED`. They are+main-only capabilities:- no plugin bridge exposes these channels, and no application-launch API existsin the plugin runtime;- the launcher window itself runs with `contextIsolation`, `sandbox`, and no- Node integration, like every other renderer surface.+ Node integration, like every other renderer surface;+- `contentHeight` accepts only a finite positive number and clamps it into the+ supported range, so a compromised renderer can ask for a smaller or larger+ panel but never for a window the user cannot recover.++`openMarket` does not navigate the shell itself. It hides the panel and asks the+orchestrator for the `openPluginMarket` application-menu command, which brings+the main window forward and lands on the plugin market page+(`apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts`,+`apps/desktop/src/features/app/useAppShellRuntime.tsx`).The catalog contains only plugins that are enabled, `ready`, declare`ui.panel`, and hold the `ui.panel` permission, so a disabled plugin cannot be@@ -277,31 +330,40 @@ the command list inside global search; this document describes the launcher.|---|---|| Window, accelerator, bounds persistence, prewarm | `apps/desktop/electron/main/bootstrap/launcher.ts` || Bounds parsing/clamping (pure) | `apps/desktop/electron/main/plugin-launcher-state.ts`, `apps/desktop/test/plugin-launcher-state.test.mjs` |-| Catalog + `openApp` IPC, sender check, trigger sanitizing | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |-| Application discovery and launch | `apps/desktop/electron/main/local-apps.ts`, `local-apps-platform.ts`, `local-app-parse.ts`, `apps/desktop/test/local-apps.test.mjs` |-| Matching, ranking, sections | `apps/desktop/src/lib/launcher-search.ts`, `apps/desktop/test/launcher-search.test.mjs` |-| Pins, aliases, recents, migration | `apps/desktop/src/lib/launcher-store.ts`, `apps/desktop/test/launcher-store.test.mjs` |-| Surface rendering and keyboard | `apps/desktop/src/components/PluginLauncher.tsx`, `apps/desktop/src/components/launcher/` |+| Catalog, `openApp`, `contentHeight`, `openMarket` IPC, sender check, trigger sanitizing | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |+| Application discovery, icon budget and icon cache | `apps/desktop/electron/main/local-apps.ts`, `local-apps-platform.ts`, `local-app-parse.ts`, `apps/desktop/test/local-apps.test.mjs` |+| Matching, ranking, sections, all-plugins view | `apps/desktop/src/lib/launcher-search.ts`, `apps/desktop/test/launcher-search.test.mjs` |+| Pins, recents, migration | `apps/desktop/src/lib/launcher-store.ts`, `apps/desktop/test/launcher-store.test.mjs` |+| Content height arithmetic and clamping (pure) | `apps/desktop/src/lib/launcher-height.ts`, `apps/desktop/electron/main/plugin-launcher-state.ts`, `apps/desktop/test/plugin-launcher-height.test.mjs` |+| Surface rendering and keyboard | `apps/desktop/src/components/PluginLauncher.tsx`, `apps/desktop/src/components/launcher/LauncherTileButton.tsx`, `apps/desktop/src/styles/plugin-launcher.css` || Payload transport | `apps/desktop/electron/main/plugin-panel-host.ts`, `apps/desktop/electron/preload/plugin-panel.ts` || Trigger validation (host) | `crates/host-core/src/plugins/validation/launcher_triggers.rs` || Shared contract | `packages/shared/src/types/launcher.ts` |## 15. Acceptance-1. Opening the launcher with an empty input shows `Recently used` (two rows) and- `Pinned` (one row) with eight tiles per row, and the recents header reports- the real number of remembered items.+1. Opening the launcher with an empty input shows `Recently used` (two rows) and,+ when the user has pins, `Pinned` (one row) with eight tiles per row; the+ recents header reports the real number of remembered items.2. A plugin that declares a trigger receives the typed input as the first tile,- and its panel shows the same text.+ appears exactly once, and its panel shows the same text.3. `wx`, `weixin`, and `微信` all reach the same application.4. A plugin and an application with the same name both appear as separate tiles.5. `pi` finds PI-Desktop by name, and the same item through pinyin andinitials.-6. Dragging the window to resize keeps eight columns per row, and the new size- survives an application restart.-7. A query with more than 24 matches does not grow the window; the header- reports the dropped count and asks the user to keep typing.+6. Dragging the window wider keeps eight columns per row and survives a restart;+ the height always matches what the panel renders.+7. A query with more than 24 matches does not grow the window past its cap; the+ header reports the dropped count and asks the user to keep typing.8. Disabling or uninstalling a plugin removes it from recents, pins, andmatches without leaving a broken tile.9. A 500-character pasted input neither hangs the panel nor matches a trigger.10. A pinned application is still pinned after a restart.+11. Pinning eight items fills the row; a ninth pin reports that the slots are+ taken, shakes the row, and does not evict an existing pin.+12. `All plugins →` lists every installed plugin (no applications), keeps+ recently used plugins first, and `Esc` returns to the previous view.+13. A query with no hit offers `Browse the plugin market`, which closes the panel+ and opens the plugin market page in the main window.+14. A tile never shows a second text line, and no surface in the launcher can+ rename a plugin or an application.diff --git a/docs/zh-CN/spec/07-plugins/18-plugin-launcher.md b/docs/zh-CN/spec/07-plugins/18-plugin-launcher.mdindex 6259ca9fc..801e91a6b 100644--- a/docs/zh-CN/spec/07-plugins/18-plugin-launcher.md+++ b/docs/zh-CN/spec/07-plugins/18-plugin-launcher.md@@ -31,26 +31,34 @@| 区域 | 行数 | 磁贴数 | 头部动作 ||---|---|---|---|-| `Recently used`(空输入) | 2 | 16 | `Show all {count} →`——`count` 是真实的已记住条目数 |-| `Pinned`(空输入) | 1 | 8 | `All →`——把两个区域都展开为完整列表 |+| `Recently used`(空输入) | 2 | 16 | `Show all {count} →`——`count` 是真实的已记住条目数;`All plugins →`——全部插件列表 |+| `Pinned`(空输入) | 1 | 8 | 无 || 匹配结果(有输入) | 3 | 24 | `{count} more — keep typing to narrow it down` |+| 全部插件(视图) | — | 所有已安装插件 | 无 |每行都是八列;列数不随结果数量变化,因此网格不会在输入或缩放时重排。-`Show all {count} →` / `All →` 会进入展开视图,此时该动作变为 `Collapse`。输入非空时只显示命中视图:头部动作报告匹配总数,因此被裁掉的磁贴会被明确说明,而不是静默截断。+`Show all {count} →` 会进入展开视图,此时该动作变为 `Collapse`。没有任何固定项时固定区整块不渲染(连标题也不显示),且它从不带头部动作——固定区始终只有一行。-空状态:目录加载中显示 `Loading plugins…`;后台应用扫描未结束时显示 `Looking for installed applications…`;没有可启动项时显示 `No plugins with panels are ready to open.`;查询无命中时显示 `No matching plugins`。+`All plugins →` 会用单个网格替换最近使用与固定两区,列出所有已安装**插件**(不含本机应用)。最近使用过的插件排在前面,其余按目录顺序;窗口达到高度上限后网格继续滚动,且其中每个磁贴都能用 `Enter` 打开或固定。继续输入会回到命中视图,`Esc` 先退出该视图再关闭面板。++输入非空时只显示命中视图:头部动作报告匹配总数,因此被裁掉的磁贴会被明确说明,而不是静默截断。++空状态:目录加载中显示 `Loading plugins…`;后台应用扫描未结束时显示 `Looking for installed applications…`;没有可启动项时显示 `No plugins with panels are ready to open.`;查询无命中时显示 `No matching plugins`。查询无命中——以及既无最近使用也无固定项时——还会提供 `Browse the plugin market`,点击后关闭面板、聚焦主窗口并打开插件市场页(§12)。## 4. 磁贴-每个磁贴显示图标、名称和一行详情:+每个磁贴都只有同样的三部分:++- 图标——应用使用平台图标;插件、以及读不到图标的应用使用首字母色块;`<img>` 加载失败也回退到色块,不会留下空洞;+- 名称,放不下时以省略号截断;+- 与名称同一行的类型徽标——`Plugin` 或 `App`。-- 命中原因——`name {value}`、`pinyin {value}`、`initials {value}`、`alias {value}`、`about {value}`、`pinned`、`recent`,或声明触发器时的 `receives {value}`(插件将收到的文本);-- 来源标签:`Plugin` 或 `App`。+磁贴不再解释命中的原因:没有第二行,因此每个磁贴高度一致,八列网格保持对齐。`title` 提示为 `名称 · 类型`(应用还会附上可执行文件名),绝不包含启动载荷。-插件使用方形磁贴,应用使用圆形磁贴,各自显示字母组合或图标。因此同名插件与应用会同时列出并且在视觉上可区分,而不是被去重。+插件使用方形磁贴,应用使用圆形磁贴。因此同名插件与应用会同时列出并且在视觉上可区分,而不是被去重。-每个磁贴有一个条目菜单按钮,其无障碍标签为 `More actions for {name}`(§8)。+每个磁贴右上角有一个图钉,带 `aria-pressed` 与 `Pin to panel` / `Unpin` 标签。它只在悬停、激活或聚焦时显示,已固定的磁贴常显,且不进入 Tab 序列——面板只由搜索框驱动。## 5. 匹配与排序@@ -60,14 +68,14 @@1. 整段输入命中声明触发器(§6)2. 名称完全一致-3. 别名完全一致-4. 名称前缀(别名前缀与该档同级)-5. 拼音前缀-6. 首字母前缀-7. 名称子串-8. 拼音/首字母子串-9. 别名子串-10. 描述子串+3. 名称前缀+4. 拼音前缀+5. 首字母前缀+6. 名称子串+7. 拼音/首字母子串+8. 描述子串++排序档位是内部的:它只决定磁贴顺序,从不渲染,因为磁贴没有详情行。触发器命中独占该条目,因此同时按模式与名称命中的插件只出现一次,并排在所有名称匹配之前。同分时依次比较:最近使用(越新越前)、插件先于应用、名称、目录顺序,因此同一份目录与状态每次都会产生相同顺序。@@ -84,7 +92,7 @@- 长于 200 字符的模式永不被编译;- 无法编译的模式是惰性的——它不匹配任何内容,也不会破坏面板。-触发器命中排在所有名称匹配之前,并把插件将收到的文本作为详情行(`receives {value}`)显示。这正是插件可以声明算术或类命令形状(`1+1`)而不与任何只是包含 `1` 的名称竞争的原因。+触发器命中排在所有名称匹配之前。这正是插件可以声明算术或类命令形状(`1+1`)而不与任何只是包含 `1` 的名称竞争的原因。面板不再显示插件将收到的文本——载荷只随打开请求投递(§7)。## 7. 载荷投递@@ -103,19 +111,22 @@- `consumeLauncherPayload()` 读取即清空,第二次调用返回 `null`。载荷绝不会投递给第二个插件,也绝不会重放。- 长于 `LAUNCHER_PAYLOAD_MAX_LENGTH`(512)的载荷会被丢弃:面板以无载荷方式打开,而不是让打开失败。-## 8. 固定、别名与最近使用+## 8. 固定与最近使用条目级偏好存放在渲染端的 `localStorage` 中,键为 `pi.desktop.launcher.state`(`apps/desktop/src/lib/launcher-store.ts`)。首次读取会迁移旧面板的 `pi.desktop.pluginLaunchHistory` 键,因此升级后仍保留原有顺序。| 条目 | 上限 ||---|---|| 最近使用 | 每项一条,最多 60 条 |-| 固定 | 24 |-| 别名 | 每项 6 个,每个 32 字符 |+| 固定 | 8(恰好一行) |++固定就是点击磁贴上的图钉,面板没有条目菜单。也不存在重命名能力:磁贴显示插件或操作系统声明的名称。++固定位已满时会拒绝新的固定,而不是静默挤掉较早的固定:底部提示 `All 8 pin slots are taken`,固定区抖动一次(`prefers-reduced-motion: reduce` 时不动画)。取消固定即可腾出位置。-每次读取都是防御性的:无法解析的记录被丢弃,存储的 id 会按实时目录裁剪,因此被禁用或卸载的插件会从最近使用、固定和匹配结果中消失。把插件从启动器隐藏只是启动器范围的偏好——插件仍会加载,其命令仍然可用。+每次读取都是防御性的:无法解析的记录被丢弃,存储的 id 会按实时目录裁剪;旧版本或新版本写入的未知字段——例如已废弃的 `aliases`——会被忽略并保留原样,读取时绝不回写。因此被禁用或卸载的插件会从最近使用、固定和匹配结果中消失。把插件从启动器隐藏只是启动器范围的偏好——插件仍会加载,其命令仍然可用。-存储按渲染端 origin 隔离,而启动器窗口与主窗口共享同一 origin,因此在一个窗口中写入的固定和别名会通过普通 `storage` 事件同步到另一个窗口。+存储按渲染端 origin 隔离,而启动器窗口与主窗口共享同一 origin,因此在一个窗口中写入的固定项会通过普通 `storage` 事件同步到另一个窗口。## 9. 本机应用@@ -125,14 +136,15 @@- macOS:`/Applications`、`/System/Applications` 及其 `Utilities` 子目录下的应用包。- Linux:`/usr/share/applications`、`/usr/local/share/applications` 与 `~/.local/share/applications` 下的 freedesktop `.desktop` 条目。-上限:扫描结果缓存 5 分钟,最多 600 条,只为前 200 条提取图标(每个 data URL 不超过 4 KiB),目标已不存在的条目会被丢弃。+上限:扫描结果缓存 5 分钟,最多 600 条,只为前 200 条提取图标。图标取平台的 `large` 变体,每个 data URL 不超过 32 KiB,并按条目 id 与图标路径缓存跨扫描复用;条目消失时其缓存图标也会被清理,因此重复扫描不会重复付出同一次查询。目标已不存在的条目会被丢弃。-渲染端只会收到显示名称、可执行文件名、来源标签(`start-menu` / `app-bundle` / `desktop-entry`)、小图标和不透明的 `app:<slug>` id——永远没有路径。打开磁贴时发送该 id;`pi-desktop/pluginLauncher/openApp` 会在宿主自己的扫描结果中解析它,并在启动前重新检查目标仍然存在,因此该界面无法被变成“启动我指定的任意程序”。ADR 0339 记录了这个决定。+渲染端只会收到显示名称、可执行文件名、来源标签(`start-menu` / `app-bundle` / `desktop-entry`)、图标和不透明的 `app:<slug>` id——永远没有路径。打开磁贴时发送该 id;`pi-desktop/pluginLauncher/openApp` 会在宿主自己的扫描结果中解析它,并在启动前重新检查目标仍然存在,因此该界面无法被变成“启动我指定的任意程序”。ADR 0339 记录了这个决定。## 10. 窗口尺寸、位置与状态-- 窗口可在 560×380 与 1280×940 DIP 之间缩放。最小宽度是八列仍能完整排布的最小宽度;最大值保证八列磁贴仍可扫读。-- 尺寸与位置持久化在 `<data dir>/plugin-launcher-state.json`,由主进程尽力写入并做防抖(`apps/desktop/electron/main/plugin-launcher-state.ts`)。+- 窗口宽度可在 560 与 1280 DIP 之间缩放;最小宽度是八列仍能完整排布的最小宽度,最大值保证八列磁贴仍可扫读。+- 高度始终贴合内容。渲染端测量搜索行、结果内容的自然高度、底部栏以及面板内边距,并通过 `pi-desktop/pluginLauncher/contentHeight` 上报总高度;主进程将其钳制在 120–940 DIP 后设置内容尺寸,因此面板既不会带着空白打开,也不会裁掉一行。+- 宽度与位置持久化在 `<data dir>/plugin-launcher-state.json`,由主进程尽力写入并做防抖(`apps/desktop/electron/main/plugin-launcher-state.ts`)。高度不是用户偏好:记住的高度只是首次测量到达前的起点。- 只有整个面板仍能落在即将打开的工作区内时,才会采用记住的位置;否则在該工作区重新居中。- 这是主进程的 shell 状态,遵循 ADR 0090 与 `window-state.json`:不涉及 host-core schema、迁移或用户数据。@@ -143,7 +155,7 @@| `↑` / `↓` | 移动一行 || `←` / `→` | 移动一个磁贴 || `Enter` | 打开当前磁贴 |-| `Esc` | 关闭面板 |+| `Esc` | 先退出全部插件视图,否则关闭面板 |输入法合成进行中(`event.isComposing` 或 `keyCode === 229`)时任何按键都不生效,因此中文输入法的候选回车或方向键不会打开或移动磁贴。@@ -153,17 +165,20 @@|---|---|---|| `pi-desktop/pluginLauncher/catalog` | 渲染端 → 主进程 | 插件 + 应用 + `appsScanning` || `pi-desktop/pluginLauncher/openApp` | 渲染端 → 主进程 | 只接受不透明的 `app:<slug>` id |+| `pi-desktop/pluginLauncher/contentHeight` | 渲染端 → 主进程 | 测量出的内容高度;只接受有限正数,并钳制到 120–940 DIP |+| `pi-desktop/pluginLauncher/openMarket` | 渲染端 → 主进程 | 隐藏面板、聚焦主窗口、打开插件市场页 || `pi-desktop/pluginLauncher/dismiss` | 渲染端 → 主进程 | 隐藏面板 || `pi-desktop/pluginLauncher/toggle` | 主进程 → 渲染端 | 显示/隐藏请求 || `pi-desktop/pluginLauncher/event/shown` | 主进程 → 渲染端 | 每次打开时重置面板 || `pi-plugin-panel-event:launcher:payload` | 主进程 → 面板页面 | 见 §7 |-目录与 `openApp` 处理器会校验发送方是启动器窗口自己的 `webContents`;其他发送方一律以 `PERMISSION_DENIED` 拒绝。二者都是仅主进程可用的能力:+启动器的每个处理器都会校验发送方是启动器窗口自己的 `webContents`;其他发送方一律以 `PERMISSION_DENIED` 拒绝。它们都是仅主进程可用的能力:- 没有任何插件桥暴露这些通道,插件运行时也不存在启动应用的 API;-- 启动器窗口自身与其他渲染界面一样启用 `contextIsolation`、`sandbox`,且不启用 Node 集成。+- 启动器窗口自身与其他渲染界面一样启用 `contextIsolation`、`sandbox`,且不启用 Node 集成;+- `contentHeight` 只接受有限正数并钳制到支持区间,因此被攻破的渲染端最多只能要求更大或更小的面板,无法要求一个用户救不回来的窗口。-目录中只包含已启用、状态为 `ready`、声明了 `ui.panel` 并持有 `ui.panel` 权限的插件,因此即使某个插件的 id 仍留在本地历史里,被禁用的插件也无法从这里打开。+`openMarket` 不自己导航 shell:它隐藏面板,并向编排层请求应用菜单的 `openPluginMarket` 命令,由后者把主窗口带到前台并落到插件市场页(`apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts`、`apps/desktop/src/features/app/useAppShellRuntime.tsx`)。## 13. 与全局搜索的关系@@ -182,24 +197,29 @@|---|---|| 窗口、快捷键、边界持久化、预热 | `apps/desktop/electron/main/bootstrap/launcher.ts` || 边界解析/钳制(纯函数) | `apps/desktop/electron/main/plugin-launcher-state.ts`、`apps/desktop/test/plugin-launcher-state.test.mjs` |-| 目录与 `openApp` IPC、发送方校验、触发器净化 | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |-| 应用发现与启动 | `apps/desktop/electron/main/local-apps.ts`、`local-apps-platform.ts`、`local-app-parse.ts`、`apps/desktop/test/local-apps.test.mjs` |-| 匹配、排序、区域划分 | `apps/desktop/src/lib/launcher-search.ts`、`apps/desktop/test/launcher-search.test.mjs` |-| 固定、别名、最近使用、迁移 | `apps/desktop/src/lib/launcher-store.ts`、`apps/desktop/test/launcher-store.test.mjs` |-| 界面渲染与键盘 | `apps/desktop/src/components/PluginLauncher.tsx`、`apps/desktop/src/components/launcher/` |+| 目录、`openApp`、`contentHeight`、`openMarket` IPC、发送方校验、触发器净化 | `apps/desktop/electron/main/ipc/plugin-launcher-ipc.ts` |+| 应用发现、图标预算与图标缓存 | `apps/desktop/electron/main/local-apps.ts`、`local-apps-platform.ts`、`local-app-parse.ts`、`apps/desktop/test/local-apps.test.mjs` |+| 匹配、排序、区域划分、全部插件视图 | `apps/desktop/src/lib/launcher-search.ts`、`apps/desktop/test/launcher-search.test.mjs` |+| 固定、最近使用、迁移 | `apps/desktop/src/lib/launcher-store.ts`、`apps/desktop/test/launcher-store.test.mjs` |+| 内容高度换算与钳制(纯函数) | `apps/desktop/src/lib/launcher-height.ts`、`apps/desktop/electron/main/plugin-launcher-state.ts`、`apps/desktop/test/plugin-launcher-height.test.mjs` |+| 界面渲染与键盘 | `apps/desktop/src/components/PluginLauncher.tsx`、`apps/desktop/src/components/launcher/LauncherTileButton.tsx`、`apps/desktop/src/styles/plugin-launcher.css` || 载荷传输 | `apps/desktop/electron/main/plugin-panel-host.ts`、`apps/desktop/electron/preload/plugin-panel.ts` || 触发器校验(宿主) | `crates/host-core/src/plugins/validation/launcher_triggers.rs` || 共享契约 | `packages/shared/src/types/launcher.ts` |## 15. 验收-1. 空输入打开启动器时显示 `Recently used`(两行)与 `Pinned`(一行),每行八个磁贴,最近使用头部报告真实的已记住条目数。-2. 声明了触发器的插件以第一个磁贴的形式收到输入,其面板显示相同文本。+1. 空输入打开启动器时显示 `Recently used`(两行),若用户有固定项则显示 `Pinned`(一行),每行八个磁贴,最近使用头部报告真实的已记住条目数。+2. 声明了触发器的插件以第一个磁贴的形式收到输入,只出现一次,其面板显示相同文本。3. `wx`、`weixin` 和 `微信` 都能到达同一个应用。4. 同名插件与应用都作为独立磁贴出现。5. `pi` 能按名称找到 PI-Desktop,也能按拼音和首字母找到同一项。-6. 拖动窗口缩放时每行仍是八列,且新尺寸在重启后保留。-7. 匹配超过 24 项的查询不会撑大窗口;头部报告被裁掉的数量并提示继续输入。+6. 拖动加宽窗口时每行仍是八列并在重启后保留;高度始终匹配面板实际渲染的内容。+7. 匹配超过 24 项的查询不会把窗口撑过上限;头部报告被裁掉的数量并提示继续输入。8. 禁用或卸载插件后,它从最近使用、固定和匹配中消失,且不会留下失效磁贴。9. 粘贴 500 字符的输入既不会卡住面板,也不会命中任何触发器。10. 固定的应用在重启后仍然处于固定状态。+11. 固定满 8 项后,第 9 次固定会提示固定位已满、抖动固定区,且不会挤掉已有的固定项。+12. `All plugins →` 列出所有已安装插件(不含应用),最近使用的插件在前,`Esc` 返回上一个视图。+13. 查询无命中时提供 `Browse the plugin market`,点击后关闭面板并在主窗口打开插件市场页。+14. 磁贴不再显示第二行文字,启动器内任何界面都不能重命名插件或应用。