Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): keep window controls above the work panel
hui4550be54c5e255a
diff --git a/apps/desktop/src/components/WindowControls.tsx b/apps/desktop/src/components/WindowControls.tsxindex aaf7049e8..839e39fa6 100644--- a/apps/desktop/src/components/WindowControls.tsx+++ b/apps/desktop/src/components/WindowControls.tsx@@ -9,15 +9,10 @@ import { TooltipButton } from "./ui";** macOS keeps native inset traffic lights; other platforms run a frameless* window, so minimize/maximize/close live here — flat Codex-style glyph- * buttons pinned to the top-right of the 46px titlebar band. The main shell- * can contain the controls in the conversation pane while Settings keeps them- * fixed to the full window.+ * buttons pinned to the top-right of the 46px titlebar band. AppShell owns a+ * single control band outside the conversation and work-panel stacking contexts.*/-export function WindowControls({- contained = false,-}: {- contained?: boolean;-} = {}) {+export function WindowControls() {const { t } = useTranslation();const platform = window.piDesktop?.platform ?? "darwin";const [maximized, setMaximized] = useState(false);@@ -41,9 +36,7 @@ export function WindowControls({return (<div- className={`window-controls no-drag${- contained ? " window-controls-in-pane" : ""- }`}+ className="window-controls no-drag"><TooltipButtontype="button"diff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsxindex 20be3b699..f82e0ebd6 100644--- a/apps/desktop/src/features/app/AppShell.tsx+++ b/apps/desktop/src/features/app/AppShell.tsx@@ -88,7 +88,6 @@ export function AppShell() {if (page === "settings") {shell = (<>- <WindowControls /><Suspense fallback={<RoutePending />}><SettingsPage /></Suspense>@@ -144,13 +143,11 @@ export function AppShell() {</TooltipButton>)}<div className="window-chrome-drag" aria-hidden />- <WindowControls contained /></div>)}{!workPanelMaximized && (<section className="main-pane">- <WindowControls contained />{page === "chat" ? (<ConversationTopbarsidebarCollapsed={sidebarCollapsed}@@ -311,6 +308,8 @@ export function AppShell() {><div className="app-scenic-backdrop" aria-hidden />{shell}+ {/* Keep native-window actions outside pane stacking contexts. */}+ {ready && <WindowControls />}<ProjectCreateDialog />{splash}</div>diff --git a/apps/desktop/src/styles/chrome.css b/apps/desktop/src/styles/chrome.cssindex ae36daaee..46f72dd5b 100644--- a/apps/desktop/src/styles/chrome.css+++ b/apps/desktop/src/styles/chrome.css@@ -1001,13 +1001,6 @@/* Continuous with the adjacent titlebar: no side seam (D297). */}-/* The main shell keeps one control band mounted inside MainPane, but its- * viewport-fixed position must not follow MainPane while the work panel reflows. */-.window-controls.window-controls-in-pane {- position: fixed;- isolation: isolate;-}-/* Electron resolves app-region hit testing across siblings. The controls must* be a later compositor layer than Settings, plugin content, or a work-panel* drag header. */@@ -1015,6 +1008,11 @@z-index: 1100;}+/* Follow the adjacent titlebar surface when the dock occupies the right edge. */+.app-shell:has(> .work-panel) > .window-controls {+ background: var(--ds-bg-dock-raised);+}+.window-control-btn {-webkit-app-region: no-drag;app-region: no-drag;@@ -1132,7 +1130,9 @@--preview-chrome-inset: var(--ds-window-lead-inset);}-.window-chrome-row {+/* Match the scenic backdrop's child-layer specificity so preview navigation+ * stays above the work panel while non-control pixels remain pass-through. */+.app-shell > .window-chrome-row {position: absolute;top: 0;right: 0;diff --git a/apps/desktop/test/plugin-settings-renderer-surface.test.mjs b/apps/desktop/test/plugin-settings-renderer-surface.test.mjsindex 8d94ea623..fc26e5492 100644--- a/apps/desktop/test/plugin-settings-renderer-surface.test.mjs+++ b/apps/desktop/test/plugin-settings-renderer-surface.test.mjs@@ -36,6 +36,5 @@ test("scenic blur persists only after the host-owned Apply action", () => {test("window controls have a compositor layer above Settings destinations", () => {const chrome = read("src/styles/chrome.css");assert.match(chrome, /\.window-controls\s*\{[\s\S]*?z-index:\s*1000/s);- assert.match(chrome, /\.window-controls\.window-controls-in-pane\s*\{[\s\S]*?isolation:\s*isolate/s);assert.match(chrome, /\.app-shell\s*>\s*\.window-controls\s*\{[\s\S]*?z-index:\s*1100/s);});diff --git a/apps/desktop/test/window-menu.test.mjs b/apps/desktop/test/window-menu.test.mjsindex eae46b1f4..cff800b6a 100644--- a/apps/desktop/test/window-menu.test.mjs+++ b/apps/desktop/test/window-menu.test.mjs@@ -165,15 +165,8 @@ test("Windows and Linux use menu-free frameless chrome with window controls", ()assert.match(controlsSource, /windowControl\("getState"\)/);assert.match(controlsSource, /ariaLabel=\{t\("window\.minimize"/);assert.match(controlsSource, /ariaLabel=\{t\("window\.close"/);- assert.match(controlsSource, /window-controls-in-pane/);- assert.match(- appSource,- /<section className="main-pane">[\s\S]*?<WindowControls contained \/>/,- );- assert.match(- stylesSource,- /\.window-controls\.window-controls-in-pane\s*\{[^}]*position:\s*fixed;/s,- );+ assert.equal((appSource.match(/<WindowControls\s*\/>/g) ?? []).length, 1);+ assert.match(appSource, /\{shell\}[\s\S]*?\{ready && <WindowControls \/>\}/);assert.match(stylesSource,/\.window-control-btn\s*\{[^}]*-webkit-app-region:\s*no-drag;[^}]*pointer-events:\s*auto;/s,diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 403189001..0ab162f0d 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -607,7 +607,7 @@ test("preview mode keeps shell actions and restores routes before navigation", (assert.match(appSource, /className=\{cx\([\s\S]*?"window-chrome-row"/);assert.match(appSource, /data-nav="new-task"/);assert.match(appSource, /<CollapsedTitlebarActions[\s\S]*?onNewTask=/);- assert.match(appSource, /<WindowControls contained \/>/);+ assert.match(appSource, /\{ready && <WindowControls \/>\}/);assert.match(appSource, /const workPanelMaximizedRef = useRef\(false\)/);assert.match(appSource,diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.mdindex d677b96ed..4fed80673 100644--- a/docs/spec/04-ux/01-ui-ia.md+++ b/docs/spec/04-ux/01-ui-ia.md@@ -73,7 +73,13 @@ destination, chat as the home surface, tools and permissions inline.left and accessible minimize / maximize-or-restore / close controls at theright edge of the conversation pane when the panel is closed (D129). Whenthe work panel is open, those controls stay viewport-fixed over the panel- header rather than travelling with MainPane. Destination history is+ header rather than travelling with MainPane. One window-level control band+ stays outside pane stacking contexts across panel open, preview, restore,+ and Settings transitions. Its background follows the adjacent titlebar surface+ (dock header when open, conversation surface when closed) in both themes.+ Preview navigation must also remain above the panel;+ macOS keeps native traffic lights and its existing fullscreen insets.+ Destination history isshortcut-first (`Cmd/Ctrl+[` and `Cmd/Ctrl+]`) with no dedicated back/forwardchrome; while Extensions is active, the footer Plugins button performs oneBack step as the only pointer affordance. The main titlebar has nodiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 3a3e219ca..0d3825862 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -13515,3 +13515,27 @@ frames must produce no further renders or pending callbacks. Card geometry isread at press time, and move/release/cancel/unmount paths must clear transienttransforms and queued frames. Release before the scheduled frame must still savethe latest destination. These assertions measure work counts, not device FPS.++### E2E-CHROME-window-controls-survive-work-panel++- **Preconditions:** A built desktop and matching host-core binary; isolated+ profile and data directory with one local session; no real provider calls.+- **Steps:** Open the work panel from the titlebar, toggle the sidebar, maximize+ and restore the panel, maximize and restore the native window, close the panel,+ visit Settings and return, reopen the panel, minimize/restore the window, then+ click Close with close-to-tray configured in the disposable profile. Also+ enter and leave native fullscreen with the panel open. Check the three controls+ with Chromium hit testing throughout, including light/dark Windows/Linux CSS.+- **Expected:** Windows/Linux minimize, maximize/restore, and close stay visible+ and hit-testable at the window edge. Native actions work with the panel open.+ Preview sidebar navigation remains clickable. On macOS no duplicate renderer+ window controls appear; the native traffic-light and fullscreen contracts stay+ unchanged. CSS emulation does not qualify another operating system's native UI.+- **Specs:** `04-ux/01-ui-ia.md` titlebar; ADR 0021 and ADR 0025.+- **Acceptance:** Window actions remain accessible independently of pane state.+- **Milestone:** Post-MVP regression coverage.+- **Automation:** `pnpm test:e2e:window-controls`; macOS traffic-light geometry+ also has `apps/desktop/test/traffic-light-reserve.test.mjs` contract coverage.+- **Status:** Automated for the executing native platform; run on macOS/Linux+ runners for native qualification. Optional screenshots are written only to+ `PI_DESKTOP_CHROME_ARTIFACT_DIR`.diff --git a/docs/zh-CN/spec/04-ux/01-ui-ia.md b/docs/zh-CN/spec/04-ux/01-ui-ia.mdindex 80744f765..c3394bb61 100644--- a/docs/zh-CN/spec/04-ux/01-ui-ia.md+++ b/docs/zh-CN/spec/04-ux/01-ui-ia.md@@ -77,6 +77,12 @@The main process uses the same geometry from `@pi-desktop/shared`.Right native-control exclusion is unchanged; header-height background paintfills the left lane without an opaque overlay covering panel controls.+ One window-level control band stays outside pane stacking contexts across+ panel open, preview, restore, and Settings transitions. Its background follows+ the adjacent titlebar surface (dock header when open, conversation surface when+ closed) in both themes. Preview navigation+ must also remain above the panel; macOS keeps native traffic lights and its+ existing fullscreen insets.Windows/Linux 使用无菜单的无框架 46px 行,并在左侧和可访问的最小化/最大化或恢复/关闭控件右(D129)。目的地历史以快捷键为主(`Cmd/Ctrl+[` 和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.mdindex ff6c2155f..8055087af 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@@ -8031,3 +8031,27 @@ frames must produce no further renders or pending callbacks. Card geometry isread at press time, and move/release/cancel/unmount paths must clear transienttransforms and queued frames. Release before the scheduled frame must still savethe latest destination. These assertions measure work counts, not device FPS.++### E2E-CHROME-window-controls-survive-work-panel++- **Preconditions:** A built desktop and matching host-core binary; isolated+ profile and data directory with one local session; no real provider calls.+- **Steps:** Open the work panel from the titlebar, toggle the sidebar, maximize+ and restore the panel, maximize and restore the native window, close the panel,+ visit Settings and return, reopen the panel, minimize/restore the window, then+ click Close with close-to-tray configured in the disposable profile. Also+ enter and leave native fullscreen with the panel open. Check the three controls+ with Chromium hit testing throughout, including light/dark Windows/Linux CSS.+- **Expected:** Windows/Linux minimize, maximize/restore, and close stay visible+ and hit-testable at the window edge. Native actions work with the panel open.+ Preview sidebar navigation remains clickable. On macOS no duplicate renderer+ window controls appear; the native traffic-light and fullscreen contracts stay+ unchanged. CSS emulation does not qualify another operating system's native UI.+- **Specs:** `04-ux/01-ui-ia.md` titlebar; ADR 0021 and ADR 0025.+- **Acceptance:** Window actions remain accessible independently of pane state.+- **Milestone:** Post-MVP regression coverage.+- **Automation:** `pnpm test:e2e:window-controls`; macOS traffic-light geometry+ also has `apps/desktop/test/traffic-light-reserve.test.mjs` contract coverage.+- **Status:** Automated for the executing native platform; run on macOS/Linux+ runners for native qualification. Optional screenshots are written only to+ `PI_DESKTOP_CHROME_ARTIFACT_DIR`.diff --git a/package.json b/package.jsonindex 76ee605ed..87aaafad2 100644--- a/package.json+++ b/package.json@@ -34,6 +34,7 @@"test:e2e:oauth-retry": "node --test apps/desktop/test/anthropic-oauth-retry.test.mjs","test:e2e:boot": "node scripts/e2e-electron-boot.mjs","test:e2e:layout": "node scripts/e2e-three-column-layout.mjs",+ "test:e2e:window-controls": "node scripts/e2e-window-controls.mjs","test:e2e:supervision": "node scripts/e2e-supervision.mjs","test:e2e:subagents": "node scripts/e2e-subagents.mjs","test:e2e:subagent-models": "node scripts/e2e-subagent-models.mjs",diff --git a/scripts/e2e-window-controls.mjs b/scripts/e2e-window-controls.mjsnew file mode 100644index 000000000..8378c9ea1--- /dev/null+++ b/scripts/e2e-window-controls.mjs@@ -0,0 +1,224 @@+#!/usr/bin/env node+/** Window controls must remain hit-testable through the real work-panel flow.+ * Uses a throwaway profile, production preload/IPC and the built application.+ * Platform CSS emulation is explicitly not native macOS/Linux qualification.+ */+import assert from "node:assert/strict";+import { spawn } from "node:child_process";+import { once } from "node:events";+import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join, resolve } from "node:path";+import { setTimeout as delay } from "node:timers/promises";+import { assertDesktopBuild, repositoryRoot, resolveElectronBinary } from "./e2e/boot.mjs";+import { Host, resolveHostBinary } from "./e2e/host.mjs";++const root = repositoryRoot();+const { appDir } = assertDesktopBuild(root);+const { electronBinary } = resolveElectronBinary(root);+const binary = resolveHostBinary();+const temp = await mkdtemp(join(tmpdir(), "pi-window-controls-"));+const port = Number(process.env.PI_DESKTOP_CHROME_CDP_PORT || 9347);+const pending = new Map();+let sequence = 0;+let socket;+let child;+let output = "";+let failed = false;++async function waitFor(predicate, label) {+ const end = Date.now() + 30_000;+ while (Date.now() < end) {+ if (await predicate()) return;+ await delay(100);+ }+ throw new Error(`Timed out: ${label}`);+}+function send(method, params = {}) {+ const id = ++sequence;+ return new Promise((resolve, reject) => {+ const timer = setTimeout(() => {+ pending.delete(id);+ reject(new Error(`CDP timeout: ${method}`));+ }, 15_000);+ pending.set(id, { resolve, reject, timer });+ socket.send(JSON.stringify({ id, method, params }));+ });+}+async function evaluate(expression) {+ const result = await send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true });+ if (result.exceptionDetails) throw new Error(JSON.stringify(result.exceptionDetails));+ return result.result.value;+}+async function settle() {+ await evaluate(`(async () => {+ await new Promise(requestAnimationFrame);+ await Promise.all(document.getAnimations().filter(a => a.effect?.getTiming().iterations !== Infinity)+ .map(a => a.finished.catch(() => {})));+ await new Promise(requestAnimationFrame);+ })()`);+}+async function click(selector, waitForPaint = true) {+ const point = await evaluate(`(() => {+ const el = document.querySelector(${JSON.stringify(selector)});+ if (!el) throw new Error('Missing target: ' + ${JSON.stringify(selector)});+ const r = el.getBoundingClientRect();+ const x = r.x + r.width / 2, y = r.y + r.height / 2;+ if (!el.contains(document.elementFromPoint(x, y))) throw new Error('Obscured target: ' + ${JSON.stringify(selector)} + ' by ' + document.elementFromPoint(x, y)?.className);+ return { x, y };+ })()`);+ for (const type of ["mousePressed", "mouseReleased"]) {+ await send("Input.dispatchMouseEvent", { type, ...point, button: "left", clickCount: 1 });+ }+ if (waitForPaint) await settle();+}+async function checkControls(label) {+ const result = await evaluate(`(() => {+ const buttons = [...document.querySelectorAll('.window-control-btn')];+ const band = document.querySelector('.window-controls');+ const header = document.querySelector('.work-panel-header');+ if (band && header && getComputedStyle(band).backgroundColor !== getComputedStyle(header).backgroundColor)+ throw new Error('Window-control background differs from the adjacent panel header');+ return buttons.map(el => {+ const r = el.getBoundingClientRect();+ const x = r.x + r.width / 2, y = r.y + r.height / 2;+ return { label: el.getAttribute('aria-label'), visible: r.width > 0 && r.height > 0 &&+ x >= 0 && x < innerWidth && y >= 0 && y < innerHeight,+ reachable: el.contains(document.elementFromPoint(x, y)) };+ });+ })()`);+ const ok = process.platform === "darwin"+ ? result.length === 0+ : result.length === 3 && result.every(r => r.visible && r.reachable);+ console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${JSON.stringify(result)}`);+ if ((!ok || label === "panel opened") && process.env.PI_DESKTOP_CHROME_ARTIFACT_DIR) {+ const dir = resolve(process.env.PI_DESKTOP_CHROME_ARTIFACT_DIR);+ await mkdir(dir, { recursive: true });+ const shot = await send("Page.captureScreenshot");+ await writeFile(join(dir, ok ? "window-controls-fixed.png" : "window-controls-failure.png"), Buffer.from(shot.data, "base64"));+ }+ assert.ok(ok, label);+}++try {+ const host = new Host(binary, join(temp, "data"));+ let sessionId;+ try {+ await host.start();+ await host.call("workspace.set", { path: temp });+ const { session } = await host.call("session.create", { title: "Window controls regression" });+ sessionId = session.id;+ } finally {+ await host.stop();+ }+ const env = { ...process.env, PI_DESKTOP_DATA_DIR: join(temp, "data"),+ PI_DESKTOP_HOST_BIN: binary, PI_DESKTOP_START_MAXIMIZED: "0", ELECTRON_RENDERER_URL: "" };+ delete env.ELECTRON_RUN_AS_NODE;+ child = spawn(electronBinary, [`--remote-debugging-port=${port}`, `--user-data-dir=${join(temp, "profile")}`, "."],+ { cwd: appDir, env, stdio: ["ignore", "pipe", "pipe"] });+ child.stdout.on("data", data => { output = (output + data).slice(-4000); });+ child.stderr.on("data", data => { output = (output + data).slice(-4000); });+ let target;+ await waitFor(async () => {+ try {+ const response = await fetch(`http://127.0.0.1:${port}/json/list`, { signal: AbortSignal.timeout(1000) });+ target = (await response.json()).find(t => t.type === "page" && t.url.includes("out/renderer/index.html") && !t.url.includes("surface="));+ return !!target;+ } catch { return false; }+ }, "renderer target");+ socket = new WebSocket(target.webSocketDebuggerUrl);+ await new Promise((resolve, reject) => { socket.onopen = resolve; socket.onerror = reject; });+ socket.onmessage = event => {+ const message = JSON.parse(event.data);+ const entry = pending.get(message.id);+ if (!entry) return;+ clearTimeout(entry.timer);+ pending.delete(message.id);+ if (message.error) entry.reject(new Error(JSON.stringify(message.error)));+ else entry.resolve(message.result);+ };+ await waitFor(() => evaluate(`!!document.querySelector('.main-pane') && !document.querySelector('.startup-splash')`), "ready shell");+ await evaluate(`window.__PI_DESKTOP__.selectSession(${JSON.stringify(sessionId)})`);+ await waitFor(() => evaluate(`document.querySelector('.app-work-panel-toggle')?.disabled === false`), "active session");+ await settle();+ await checkControls("panel closed");+ await click(".app-work-panel-toggle");+ await waitFor(() => evaluate(`!!document.querySelector('.work-panel')`), "panel opened");+ await settle();+ await checkControls("panel opened");+ if (process.platform !== "darwin") {+ for (const platform of ["win32", "linux"]) {+ for (const theme of ["light", "dark"]) {+ await evaluate(`document.documentElement.dataset.platform = ${JSON.stringify(platform)};+ window.__PI_DESKTOP__.setThemeAttr(${JSON.stringify(theme)})`);+ await settle();+ await checkControls(`${platform}/${theme} CSS with panel open (emulated)`);+ }+ }+ await evaluate(`document.documentElement.dataset.platform = ${JSON.stringify(process.platform)}`);+ }+ await click('[data-nav="toggle-sidebar"]');+ await checkControls("sidebar toggled with panel open");+ await click(".work-panel-maximize");+ await waitFor(() => evaluate(`!!document.querySelector('.work-panel-maximized')`), "panel maximized");+ await checkControls("panel maximized");+ await click('[data-nav="toggle-sidebar"]');+ await checkControls("sidebar toggled with panel maximized");+ await click(".work-panel-maximize");+ await checkControls("panel restored");+ await evaluate(`window.piDesktop.invoke('pi-desktop/menu/nativeAction', {action:'toggleFullScreen'})`);+ await waitFor(() => evaluate(`window.piDesktop.invoke('pi-desktop/menu/nativeAction', {action:'restoreMainWindow'}).then(s => s.ok && s.data.fullScreen)`), "native fullscreen");+ await settle();+ await checkControls("native fullscreen with panel open");+ await evaluate(`window.piDesktop.invoke('pi-desktop/menu/nativeAction', {action:'toggleFullScreen'})`);+ await waitFor(() => evaluate(`window.piDesktop.invoke('pi-desktop/menu/nativeAction', {action:'restoreMainWindow'}).then(s => s.ok && !s.data.fullScreen)`), "leave native fullscreen");+ await settle();+ if (process.platform !== "darwin") {+ await click(".window-control-btn:nth-child(2)");+ await waitFor(() => evaluate(`window.piDesktop.invoke('pi-desktop/window/control', {action:'getState'}).then(s => s.ok && s.data.maximized)`), "native window maximized");+ await checkControls("native window maximized with panel open");+ await click(".window-control-btn:nth-child(2)");+ await waitFor(() => evaluate(`window.piDesktop.invoke('pi-desktop/window/control', {action:'getState'}).then(s => s.ok && !s.data.maximized)`), "native window restored");+ }+ await click(".app-work-panel-toggle");+ await waitFor(() => evaluate(`!document.querySelector('.work-panel')`), "panel closed again");+ await checkControls("panel closed again");+ await evaluate(`window.__PI_DESKTOP__.setPage('settings')`);+ await waitFor(() => evaluate(`!!document.querySelector('.settings-mode')`), "settings opened");+ await settle();+ await checkControls("settings route");+ await evaluate(`window.__PI_DESKTOP__.setPage('chat')`);+ await settle();+ await click(".app-work-panel-toggle");+ await settle();+ await checkControls("panel reopened after settings");+ if (process.platform !== "darwin") {+ await click(".window-control-btn:first-child", false);+ await waitFor(() => evaluate(`document.visibilityState === 'hidden'`), "native minimize");+ await evaluate(`window.piDesktop.invoke('pi-desktop/menu/nativeAction', {action:'toggleMainWindow'})`);+ await waitFor(() => evaluate(`document.visibilityState === 'visible'`), "native window shown");+ await settle();+ await checkControls("restored after native minimize");+ // Configure only the disposable profile so close-to-tray can be observed+ // without leaving a blocking native confirmation dialog on the test runner.+ await evaluate(`window.piDesktop.invoke('pi-desktop/window/closeBehavior/set', {behavior:'tray'})`);+ await click(".window-control-close", false);+ await waitFor(() => evaluate(`document.visibilityState === 'hidden'`), "native close-to-tray");+ console.log("PASS native minimize and close actions");+ }+ console.log(`PASS native ${process.platform} window-control flow`);+} catch (error) {+ failed = true;+ console.error(error);+ console.error(output);+} finally {+ socket?.close();+ for (const entry of pending.values()) clearTimeout(entry.timer);+ if (child && child.exitCode === null) {+ const exited = once(child, "exit");+ child.kill();+ await exited;+ }+ await rm(temp, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });+}+process.exitCode = failed ? 1 : 0;