Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
Merge branch 'fix/plugin-labels-follow-app-locale'
vastsab24d3cd2892d
diff --cc docs/adr/0268-plugin-labels-follow-the-app-language.mdindex 000000000,4bb31665d..b0208cdc2mode 000000,100644..100644--- a/docs/adr/0268-plugin-labels-follow-the-app-language.md+++ b/docs/adr/0268-plugin-labels-follow-the-app-language.md@@@ -1,0 -1,81 +1,81 @@@-# ADR 0267: Plugin Labels Follow the App Language++# ADR 0268: Plugin Labels Follow the App Language++ - **Status**: Accepted+ - **Date**: 2026-09-16+ - **Related**: [ADR 0009](0009-english-first-globalization.md) ·+ [ADR 0160](0160-shipped-locale-registry-and-language-picker.md) ·+ [ADR 0182](0182-traditional-chinese-shell-locale.md) ·+ [07-plugins/02-plugin-manifest-schema](../spec/07-plugins/02-plugin-manifest-schema.md) ·+ [07-plugins/07-plugin-marketplace](../spec/07-plugins/07-plugin-marketplace.md)++ ## Context++ A plugin's display name and description come from its manifest, and a+ marketplace card's from its catalog entry. Both are single strings written in+ whatever language the author used, so the Extensions page, the plugin launcher,+ and the marketplace drew Chinese names under an English shell and English names+ under a Chinese one. The plugin repository's own validator had been requiring a+ top-level `i18n` block — `{ "en": { name, description, safetyNotes }, "zh-CN": {+ … } }` — since its first release, and the catalog ships the same block on every+ entry. The desktop shell read none of it: rows rendered `name` and+ `description` verbatim, so a plugin translated by its author into the user's+ language still arrived in the wrong one.++ The shell already has every piece the fix needs: `@pi-desktop/i18n` owns the+ shipped locale registry, the app language is resolved in the main process+ (`settings.language`, or the OS locale while it is `auto`), and localized+ manifest fields (`ui.title`, view titles, command and destination labels) are+ already resolved by the host through `resolvePluginLocalizedString` with English+ fallback.++ ## Decision++ 1. `manifest.i18n` and the same block on a marketplace catalog entry become part+ of the plugin contract, with `name`, `description`, and `safetyNotes`.+ `en` and `zh-CN` are the contract locales; a plugin is not required to+ translate itself into the other shipped shell locales.+ 2. Every Chinese shell locale reads `zh-CN`; every other locale reads `en`.+ `zh-TW` therefore reads English rather than a half-shared `zh-CN` guess,+ matching `resolvePluginLocalizedString` (ADR 0182).+ 3. Resolution happens in the **host**, not the renderer: rows leave the process+ 3. Resolution happens in the **host**, not the renderer: rows leave the process+ as finished strings, exactly like a plugin view title. A missing locale, a+ missing field, or an empty string falls back per field to the other contract+ locale, and from there to the author's flat `name` / `description`, so a+ partial translation never blanks a row.+ 4. The desktop shell pushes the app language down (`plugins.setLocale`) whenever+ it changes and then emits `pluginChanged`, so the surfaces re-read. The+ registry keeps the author's own strings: a language change never rewrites+ persisted rows, and the `i18n` block is neither persisted nor sent over RPC.+ 5. A malformed block (not an object of locale → object, or a non-string+ `name`/`description`/`safetyNotes`) fails `validateManifest`. Unknown locales+ and unknown fields inside an entry are ignored, so a publisher may carry more+ than the contract requires.++ ## Consequences++ - A translated plugin now reads in the user's language on the Extensions page,+ the plugin launcher, and the marketplace, and its `safetyNotes` — the text+ that explains what an install can touch — reads in that language too.+ - Catalog search matches every locale's name and description, so a user who+ types what they saw in one language still finds the entry after switching.+ - Plugin authors keep shipping a single-language manifest if they want to: the+ flat fields remain the fallback, and no field of the block is mandatory to+ load.+ - The host holds one more piece of state (the display locale). It is pushed by+ the shell rather than read per request, so a row does not depend on which RPC+ happens to carry a locale.++ ## Alternatives++ - **Resolve in the renderer**: the renderer knows `i18n.language` and would+ switch instantly, but it would have to receive every manifest's `i18n` block,+ which contradicts the rule that the renderer never reads a manifest, and it+ would duplicate the fallback rules the host already owns.+ - **Per-request locale parameter on every plugin RPC**: works for `plugins.list`+ but leaves the summaries the host itself returns (install results, permission+ changes, marketplace update checks) unlocalized, and adds a locale to every+ call site.+ - **Leave names to the author's language**: the plugin repository already+ requires the block, so the shell would keep ignoring data its ecosystem+ publishes — the reported bug.diff --cc docs/adr/README.mdindex 5b14e4e01,69f967352..dcf2b7c94--- a/docs/adr/README.md+++ b/docs/adr/README.md@@@ -293,4 -293,4 +293,5 @@@ Each ADR includes| session-content-search | [Discover sessions by indexed message text](session-content-search.md) | Accepted || transcript-reading-ownership | [Share renderer history and search views](transcript-reading-ownership.md) | Accepted || 0266 | [Plugin fs roots follow the calling session](0266-plugin-fs-root-follows-the-calling-session.md) | Accepted (D093) |-| 0267 | [Plugin labels follow the app language](0267-plugin-labels-follow-the-app-language.md) | Accepted (amends 0160; ADR 0182) |+| 0267 | [Move capability documents between the global and project levels](0267-capability-level-transfer.md) | Accepted for implementation (amends ADR 0112) |++| 0268 | [Plugin labels follow the app language](0268-plugin-labels-follow-the-app-language.md) | Accepted (amends 0160; ADR 0182) |diff --cc docs/spec/07-plugins/07-plugin-marketplace.mdindex 3f5bc95f0,f6ccaf7c1..67d5e3238--- a/docs/spec/07-plugins/07-plugin-marketplace.md+++ b/docs/spec/07-plugins/07-plugin-marketplace.md@@@ -218,6 -218,15 +218,15 @@@ type MarketPluginSummary =verified?: booleaninstallable?: boolean}+ `i18n` is display metadata, not a summary field: the host resolves a card's+ `name` / `description` and a detail view's `safetyNotes` against the app+ language and falls back per field to the entry's own values, so a translated-plugin reads in the user's language (ADR 0267). A catalog entry declares the++plugin reads in the user's language (ADR 0268). A catalog entry declares the+ same block as a manifest — `{ en: { name, description, safetyNotes }, "zh-CN":+ { … } }`. Search matches every locale, not only the one currently displayed; a+ malformed block fails the catalog parse, while unknown locales and unknown+ fields inside an entry are ignored.+```### MarketPluginDetaildiff --cc docs/zh-CN/adr/index.mdindex 0a45c4b8e,6fba453c2..b9e956c89--- a/docs/zh-CN/adr/index.md+++ b/docs/zh-CN/adr/index.md@@@ -284,6 -284,7 +284,7 @@@ ADR 记录那些不应被静默改变�| 0251 | [删除项目会一并删除其拥有的会话](/adr/0251-project-delete-with-owned-sessions) | 已接受 || 0253 | [移除子智能体轮次上限](/adr/0253-remove-subagent-turn-limit) | 已接受(取代 0062 / 0063 / 0119 / 0126 / 0166 / 0210 中关于 `maxTurns` 的条款) || 0265 | [排队队列的优先区块与行内操作](/adr/0265-turn-queue-priority-block-and-row-actions) | 已接受待实现(修订 ADR 0213 / 0118) |- | 0267 | [插件标签跟随应用语言](/adr/0267-plugin-labels-follow-the-app-language) | 已接受(修订 ADR 0160;ADR 0182) |++ | 0268 | [插件标签跟随应用语言](/adr/0268-plugin-labels-follow-the-app-language) | 已接受(修订 ADR 0160;ADR 0182) |## 什么时候看 ADR