Skip to content

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

fix(work-panel): detach plugin views on renderer reload

liujinsheng2ccb3a404b10
diff --git a/apps/desktop/electron/main/bootstrap/window.ts b/apps/desktop/electron/main/bootstrap/window.ts
index 0b5044e88..962b25872 100644
--- a/apps/desktop/electron/main/bootstrap/window.ts
+++ b/apps/desktop/electron/main/bootstrap/window.ts
@@ -760,6 +760,17 @@ export async function createWindow({
browserHost.setWindow(window);
pluginViews.setWindow(window);
+ // A renderer reload (⌘R) drops the React tree that drives plugin-view
+ // visibility, leaving the native view compositing above the fresh renderer
+ // as an orphan overlay no surviving control can hide. Detach it here so a
+ // reload always starts from "no plugin view shown"; the reloaded renderer
+ // re-attaches on demand. Same-document navigations keep the tree alive.
+ window.webContents.on(
+ "did-start-navigation",
+ (_event, _url, isInPlace, isMainFrame) => {
+ if (isMainFrame && !isInPlace) pluginViews.hideVisibleView();
+ },
+ );
window.on("closed", () => {
screen.removeListener("display-metrics-changed", reconcileDisplayTopology);
screen.removeListener("display-added", reconcileDisplayTopology);
diff --git a/apps/desktop/electron/main/plugin-view-host.ts b/apps/desktop/electron/main/plugin-view-host.ts
index a4976d3d1..3cd4c506d 100644
--- a/apps/desktop/electron/main/plugin-view-host.ts
+++ b/apps/desktop/electron/main/plugin-view-host.ts
@@ -368,6 +368,20 @@ export class PluginViewHost {
if (!entry.view.webContents.isDestroyed()) entry.view.webContents.close();
}
+ /**
+ * Detach the on-screen view without closing its page (renderer reload path).
+ *
+ * A renderer reload drops the React tree that owns plugin-view visibility.
+ * The native view would keep compositing above the fresh renderer as an
+ * orphan layer nothing can hide or close — its owning tab is gone and the
+ * new tree starts with an empty panel. Main therefore detaches on every
+ * main-frame navigation; the reloaded renderer re-attaches a view through
+ * the normal open/setVisible path when the user opens the tab again.
+ */
+ hideVisibleView(): void {
+ this.detachVisible();
+ }
+
private detachVisible(): void {
const entry = this.visibleKey ? this.views.get(this.visibleKey) : null;
this.visibleKey = null;