Skip to content

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

fix(plugins): notify the renderer after the startup plugin restore

mai-ming046a49c3a8c4
diff --git a/apps/desktop/electron/main/runtime/lifecycle.ts b/apps/desktop/electron/main/runtime/lifecycle.ts
index d2afdd4cc..b8bd6ac80 100644
--- a/apps/desktop/electron/main/runtime/lifecycle.ts
+++ b/apps/desktop/electron/main/runtime/lifecycle.ts
@@ -277,6 +277,11 @@ export function createRuntimeLifecycle({
}
}
}
+ // Renderer-side plugin surfaces — the Extensions page and every plugin
+ // `renderer` module — re-read the plugin list only when this event
+ // arrives, and the window has already fetched the list by now. Without it
+ // a restored plugin keeps no renderer UI until something else changes.
+ sendToRenderer(IPC.event.pluginChanged, { reason: "restore" });
} catch (error) {
logger.app("plugin", "error", "plugin list failed", {
data: String(error),
diff --git a/docs/spec/07-plugins/05-plugin-lifecycle.md b/docs/spec/07-plugins/05-plugin-lifecycle.md
index b994fc32e..5e43e8b03 100644
--- a/docs/spec/07-plugins/05-plugin-lifecycle.md
+++ b/docs/spec/07-plugins/05-plugin-lifecycle.md
@@ -146,6 +146,8 @@ On app startup:
2. Read the enabled state
3. Load only enabled plugins
4. Skip a single failed plugin without affecting other plugins or the main app
+5. Emit `pluginChanged` (`reason: "restore"`) once the pass is done, so the
+ renderer re-reads a plugin list it may have fetched before the restore
## 6. Developer mode
diff --git a/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md b/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md
index 8618062c3..47a59d8d8 100644
--- a/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md
+++ b/docs/spec/07-plugins/12-plugin-ipc-and-host-services.md
@@ -81,10 +81,11 @@ PluginManager
The shipped `pluginChanged` event carries a `reason` so the renderer can decide
what to refetch: `install`, `loadDev`, `enable`, `disable`, `uninstall`, `crash`,
-`service`, `market.install`, `market.applyUpdates`, `themes` (runtime
+`service`, `restore`, `market.install`, `market.applyUpdates`, `themes` (runtime
`themes.upsert` / `themes.remove`). `service` fires on every
supervision transition and is the cheapest of them — only the service list needs
-a reload.
+a reload. `restore` fires once when startup recovery has loaded the enabled
+plugins, so a surface that listed them earlier still sees them.
`settingsChanged` (`pi-desktop/app/event/settingsChanged`) carries a settings
patch when the **host** writes app settings outside the renderer path — today
diff --git a/docs/zh-CN/spec/07-plugins/05-plugin-lifecycle.md b/docs/zh-CN/spec/07-plugins/05-plugin-lifecycle.md
index 78cc96dd1..472326ac5 100644
--- a/docs/zh-CN/spec/07-plugins/05-plugin-lifecycle.md
+++ b/docs/zh-CN/spec/07-plugins/05-plugin-lifecycle.md
@@ -137,6 +137,8 @@ discovered
2. 读取使能状态
3.仅加载已启用的插件
4. 跳过单个失败的插件而不影响其他插件或主应用程序
+5. 这一步跑完后发出 `pluginChanged`(`reason: "restore"`),让渲染器重新读取
+ 它可能在恢复完成之前就取过的插件清单
## 6. 开发者模式
diff --git a/docs/zh-CN/spec/07-plugins/12-plugin-ipc-and-host-services.md b/docs/zh-CN/spec/07-plugins/12-plugin-ipc-and-host-services.md
index 142483336..4141cc02d 100644
--- a/docs/zh-CN/spec/07-plugins/12-plugin-ipc-and-host-services.md
+++ b/docs/zh-CN/spec/07-plugins/12-plugin-ipc-and-host-services.md
@@ -77,9 +77,10 @@ PluginManager
附带的 `pluginChanged` 事件带有 `reason`,以便渲染器可以决定
重新获取的内容:`install`、`loadDev`、`enable`、`disable`、`uninstall`、`crash`、
-`service`、`market.install`、`market.applyUpdates`。 `service` 在每个
+`service`、`restore`、`market.install`、`market.applyUpdates`。 `service` 在每个
监管过渡是其中最便宜的——只需要服务列表
-重新加载。
+重新加载。`restore` 在启动恢复把已启用的插件加载完之后发出一次,
+让早于它取过清单的界面仍能看到这些插件。
## 4. 1 事件(主机→插件进程)