Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(window): leave fullscreen before hide-on-close — no more stranded black Space
enes9c8f3bcfb8c1
diff --git a/src/main/index.ts b/src/main/index.tsindex ca775cdee..2adaeab82 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -58,7 +58,7 @@ import {isValidPendingId,syntheticAnsweredEvent} from '../core/agents/pending-approvals'-import { setMainWindow, getMainWindow, sendToMain, shouldHideOnClose, createCrashReloadPolicy } from './main-window'+import { setMainWindow, getMainWindow, sendToMain, closeAction, createCrashReloadPolicy } from './main-window'import { installKeydownIntercepts } from './keydown-intercept'import {initNotchHud,@@ -611,10 +611,24 @@ function createWindow(): BrowserWindow {// outlives its window (tmux sessions, hook server, updater); destroying the window// would leave every window-bound subsystem (agent-status forwarding, tails, updater,// license events) pointing at a dead webContents after a dock-reopen.+ // A fullscreen window must LEAVE fullscreen before it hides: hiding in place strands the+ // window's empty Space as a black screen (issue #78 / electron/electron#20263). The+ // transition is async, so the hide waits for `leave-full-screen`; `leavingFullScreen`+ // keeps a second ⌘W during the transition from stacking another listener.+ let leavingFullScreen = falsewin.on('close', (e) => {- if (shouldHideOnClose(process.platform, quitting)) {- e.preventDefault()+ const action = closeAction(process.platform, quitting, win.isFullScreen())+ if (action === 'default') return+ e.preventDefault()+ if (action === 'hide') {win.hide()+ } else if (!leavingFullScreen) {+ leavingFullScreen = true+ win.once('leave-full-screen', () => {+ leavingFullScreen = false+ if (!win.isDestroyed() && !quitting) win.hide()+ })+ win.setFullScreen(false)}})diff --git a/src/main/main-window.test.ts b/src/main/main-window.test.tsindex fa99cc754..80027ba43 100644--- a/src/main/main-window.test.ts+++ b/src/main/main-window.test.ts@@ -5,6 +5,7 @@ import {sendToMain,mainWindowClientIds,shouldHideOnClose,+ closeAction,createCrashReloadPolicy,type MainWindowLike} from './main-window'@@ -158,3 +159,20 @@ describe('shouldHideOnClose', () => {expect(shouldHideOnClose('linux', false)).toBe(false)})})++describe('closeAction', () => {+ it('hides a windowed macOS close', () => {+ expect(closeAction('darwin', false, false)).toBe('hide')+ })+ it('leaves fullscreen before hiding — hiding in place strands a black Space (issue #78)', () => {+ expect(closeAction('darwin', false, true)).toBe('leave-fullscreen-then-hide')+ })+ it('lets the close through when quitting, fullscreen or not', () => {+ expect(closeAction('darwin', true, true)).toBe('default')+ expect(closeAction('darwin', true, false)).toBe('default')+ })+ it('never intercepts on other platforms, fullscreen included', () => {+ expect(closeAction('linux', false, true)).toBe('default')+ expect(closeAction('win32', false, true)).toBe('default')+ })+})diff --git a/src/main/main-window.ts b/src/main/main-window.tsindex d5271d0da..8988ae837 100644--- a/src/main/main-window.ts+++ b/src/main/main-window.ts@@ -73,3 +73,21 @@ export function createCrashReloadPolicy(export function shouldHideOnClose(platform: NodeJS.Platform | string, quitting: boolean): boolean {return platform === 'darwin' && !quitting}++export type CloseAction = 'default' | 'hide' | 'leave-fullscreen-then-hide'++/**+ * What the close-event handler should do. Hiding a FULLSCREEN window without leaving fullscreen+ * first strands its empty Space as a black screen the user can still swipe to (issue #78, the+ * known Electron behavior electron/electron#20263) — so fullscreen must be exited, the async+ * `leave-full-screen` transition awaited, and only THEN the window hidden. The quit path is not+ * affected: there the window really closes and the app (and its Space) goes away with it.+ */+export function closeAction(+ platform: NodeJS.Platform | string,+ quitting: boolean,+ isFullScreen: boolean+): CloseAction {+ if (!shouldHideOnClose(platform, quitting)) return 'default'+ return isFullScreen ? 'leave-fullscreen-then-hide' : 'hide'+}