Skip to content

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

fix(plugins): complete panel load timeout contract

vastsadee29c60c374
diff --git a/apps/desktop/test/plugin-panel-invoker.test.mjs b/apps/desktop/test/plugin-panel-invoker.test.mjs
index 357d827f9..0d38abb0f 100644
--- a/apps/desktop/test/plugin-panel-invoker.test.mjs
+++ b/apps/desktop/test/plugin-panel-invoker.test.mjs
@@ -357,7 +357,7 @@ test("a panel page that fails its own load keeps the original error", async () =
});
test("the panel load budget is a generous, seconds-scale default", () => {
- assert.ok(PLUGIN_PANEL_LOAD_SETTLE_MS >= 10_000);
+ assert.equal(PLUGIN_PANEL_LOAD_SETTLE_MS, 15_000);
});
test("the open path races the page load against that budget (#998)", () => {
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index a8508fce2..71ae131c9 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -3329,6 +3329,11 @@ identify the platform validation still needed.
- **Acceptance**: G (isolated panel)
- **Status**: Documented
+Initial-load timeout check: Open a fixture panel from Extensions → Installed
+whose page load remains pending. After 15 seconds, the open request must report
+`PANEL_LOAD_TIMEOUT` through the initiating action and destroy the hidden
+window; opening a normal panel afterward must still work.
+
#### E2E-024AA: Plugin-owned UI follows the host locale
- **Preconditions**: A loaded plugin with a panel or settings destination, and a plugin process subscribed to `pi.events.on("appearance:changed")`.
diff --git a/docs/spec/07-plugins/01-plugin-system.md b/docs/spec/07-plugins/01-plugin-system.md
index fc8c36673..c855b3434 100644
--- a/docs/spec/07-plugins/01-plugin-system.md
+++ b/docs/spec/07-plugins/01-plugin-system.md
@@ -220,6 +220,10 @@ are reachable there) and CPU/memory limits.
### 6.3 Plugin Panel UI
- Load the plugin page in a dedicated sandboxed `BrowserWindow` and isolated
per-plugin session partition
+- Keep a newly created panel hidden until its initial page load settles. Bound
+ that wait to 15 seconds; if it does not settle, destroy the hidden window and
+ reject the open request with `PANEL_LOAD_TIMEOUT`. Preserve the original error
+ when the page load fails on its own.
- Closing a panel (capsule close, disable, uninstall, or crash teardown) must
not read a destroyed `BrowserWindow` or its `webContents`. The host copies
any contents identity needed for drop-record cleanup while the window is
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index ba38e8c94..ea0d2eca1 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -1509,11 +1509,11 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备
#### E2E-024D:隔离插件面板主桥
- **先决条件**:启用 `ui.panel` 的插件。
-- **步骤**: 1) 打开插件面板。 2) 调用面板桥 API(`ui.showToast`、可选的 fs/net(带授权))。 3) 通过胶囊关闭面板,以及通过禁用或卸载插件关闭面板。
-- **预期**:面板在沙盒 window/partition 中运行;桥接调用经过许可检查;主机在面板关闭时保持稳定,主进程不得抛出 `TypeError: Object has been destroyed` 或弹出未捕获异常对话框。
+- **步骤**: 1) 打开插件面板。 2) 调用面板桥 API(`ui.showToast`、可选的 fs/net(带授权))。 3) 通过胶囊关闭面板,以及通过禁用或卸载插件关闭面板。4) 从「扩展 → 已安装」打开一个初始页面加载一直 pending 的测试面板;等待 15 秒后再打开正常面板。
+- **预期**:面板在沙盒 window/partition 中运行;桥接调用经过许可检查;主机在面板关闭时保持稳定,主进程不得抛出 `TypeError: Object has been destroyed` 或弹出未捕获异常对话框。初始加载持续 pending 达 15 秒的面板以 `PANEL_LOAD_TIMEOUT` 失败,通过发起操作显示错误,并销毁隐藏窗口;页面自行加载失败时保留原始错误,超时后仍可正常打开其他面板。
- **链接规格**:`07-plugins/01-plugin-system.md`、`07-plugins/03-plugin-api.md`、`07-plugins/04-plugin-security.md`、`07-plugins/12-plugin-ipc-and-host-services.md`
- **验收**:G(隔离面板)
-- **状态**:已记录
+- **状态**:已记录;初始加载超时及打开路径接线由单元/契约测试覆盖
#### E2E-024AA:插件自有界面跟随宿主语言
diff --git a/docs/zh-CN/spec/07-plugins/01-plugin-system.md b/docs/zh-CN/spec/07-plugins/01-plugin-system.md
index 953a1bafa..44e13ef1e 100644
--- a/docs/zh-CN/spec/07-plugins/01-plugin-system.md
+++ b/docs/zh-CN/spec/07-plugins/01-plugin-system.md
@@ -222,6 +222,9 @@ Host Main (PI-Desktop)
### 6. 3 插件面板用户界面
- 在专用的沙盒 `BrowserWindow` 中加载插件页面,并为每个插件使用隔离的会话分区
+- 新建面板的初始页面加载完成前保持窗口隐藏,等待上限为 15 秒;若仍未完成,
+ 宿主销毁隐藏窗口,并以 `PANEL_LOAD_TIMEOUT` 拒绝打开请求。若页面加载自行失败,
+ 则保留原始错误。
- 关闭面板(胶囊关闭、禁用、卸载或崩溃拆除)不得读取已销毁的 `BrowserWindow` 或其 `webContents`。宿主必须在窗口仍存活时复制清理拖拽记录所需的 contents id,避免 `closed` 处理程序抛出 `Object has been destroyed`。
- 在 macOS、Windows 和 Linux 上都使用无边框窗口。preload 精确保留透明的
46px 拖拽带,并只在右上角渲染最简胶囊:最小化、最大化/还原和关闭。