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): read getBounds while un-maximized, for Linux WMs without getNormalBounds
Shogun605c34855a6f
diff --git a/CLAUDE.md b/CLAUDE.mdindex a1369d56a..f5ff741a5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -3590,9 +3590,14 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord measomeone with two monitors — `screen.getAllDisplays()` is called at the seam in `index.ts` and its**work areas** (not full display bounds) are passed in. The refusals ARE the feature, because eachis a way the naive version is worse than the fixed size it replaces:- - **`getNormalBounds()`, never `getBounds()`.** While maximized the latter returns the MAXIMIZED- rectangle, so saving it makes the next un-maximize hand back a screen-sized window — state that- looks right and behaves wrong, and only for the users who maximize.+ - **While MAXIMIZED the size comes from `getNormalBounds()`, never `getBounds()`.** The latter+ returns the MAXIMIZED rectangle, so saving it makes the next un-maximize hand back a+ screen-sized window — state that looks right and behaves wrong, and only for the users who+ maximize. **Un-maximized it is `getBounds()`**, which is the same rectangle wherever both work:+ Electron documents `getNormalBounds()` as supported only on some Linux desktop environments, and+ the common case must not depend on the window manager. The maximized case still does and cannot+ be helped from here, but it matters less, because that record restores by re-maximizing rather+ than by its size.- **A position that is no longer reachable is DROPPED, not clamped.** A laptop undocked from themonitor its window was on would otherwise reopen the app off-screen: running, focusable from thedock, visible nowhere, with no gesture that rescues it. Reachable means a real overlap with somediff --git a/src/main/window-state.test.ts b/src/main/window-state.test.tsindex f70af8ede..f90494811 100644--- a/src/main/window-state.test.ts+++ b/src/main/window-state.test.ts@@ -28,13 +28,24 @@ const ONE_SCREEN: Rect[] = [{ x: 0, y: 27, width: 1920, height: 1053 }]const TWO_SCREENS: Rect[] = [...ONE_SCREEN, { x: -2560, y: 0, width: 2560, height: 1440 }]const DEFAULTS = { width: 1400, height: 900 }-function source(over: Partial<{ destroyed: boolean; minimized: boolean; fullScreen: boolean; maximized: boolean; bounds: Rect }> = {}) {+function source(+ over: Partial<{+ destroyed: boolean+ minimized: boolean+ fullScreen: boolean+ maximized: boolean+ bounds: Rect+ currentBounds: Rect+ }> = {}+) {+ const normal = over.bounds ?? { x: 100, y: 200, width: 1000, height: 700 }return {isDestroyed: () => over.destroyed ?? false,isMinimized: () => over.minimized ?? false,isFullScreen: () => over.fullScreen ?? false,isMaximized: () => over.maximized ?? false,- getNormalBounds: () => over.bounds ?? { x: 100, y: 200, width: 1000, height: 700 }+ getNormalBounds: () => normal,+ getBounds: () => over.currentBounds ?? normal}}@@ -225,6 +236,24 @@ describe('captureWindowState', () => {})})+ it('reads getBounds while un-maximized, so Linux WMs without getNormalBounds still save', () => {+ // Electron documents getNormalBounds() as supported only on some Linux desktop environments.+ // The un-maximized case is the common one and must not depend on the window manager; the two+ // calls return the same rectangle wherever both work, so nothing changes elsewhere.+ const win = source({+ maximized: false,+ bounds: { x: 0, y: 0, width: 1, height: 1 },+ currentBounds: { x: 300, y: 120, width: 1280, height: 800 }+ })+ expect(captureWindowState(win)).toEqual({+ x: 300,+ y: 120,+ width: 1280,+ height: 800,+ maximized: false+ })+ })+it('uses getNormalBounds, so un-maximizing later restores the pre-maximize size', () => {// getBounds() on a maximized window returns the MAXIMIZED rect. Saving that would make the// next un-maximize hand back a screen-sized window — right-looking state, wrong behaviour,diff --git a/src/main/window-state.ts b/src/main/window-state.tsindex df0fc16fe..ae869fb3b 100644--- a/src/main/window-state.ts+++ b/src/main/window-state.ts@@ -173,6 +173,8 @@ export interface WindowStateSource {isMaximized(): boolean/** The RESTORED bounds — see the note in `captureWindowState`. */getNormalBounds(): Rect+ /** The CURRENT bounds. Read only while un-maximized — see the note in `captureWindowState`. */+ getBounds(): Rect}/**@@ -192,21 +194,28 @@ export interface WindowStateSource {* In both cases the previously saved record stands, which is the honest outcome: "we could not* observe a new preference", never "the preference is gone".*- * The bounds come from `getNormalBounds()`, never `getBounds()`. While maximized the latter returns- * the MAXIMIZED rectangle, so saving it would make the next un-maximize restore to a window the+ * While MAXIMIZED the bounds come from `getNormalBounds()`, never `getBounds()`: the latter returns+ * the maximized rectangle, so saving it would make the next un-maximize restore to a window the* size of the screen — the state would look right and behave wrong, and only for the users who* maximize.+ *+ * While un-maximized it is `getBounds()`, and the two are the same rectangle wherever both work.+ * The split exists for Linux, where Electron documents `getNormalBounds()` as supported only on+ * some desktop environments; `getBounds()` has no such caveat, so the common case stops depending+ * on the window manager. The maximized case still does, and cannot be helped from here — but it+ * also matters less, because that record restores by re-maximizing rather than by its size.*/export function captureWindowState(win: WindowStateSource): WindowState | null {if (win.isDestroyed() || win.isMinimized() || win.isFullScreen()) return null- const b = win.getNormalBounds()+ const maximized = win.isMaximized()+ const b = maximized ? win.getNormalBounds() : win.getBounds()if (!Number.isFinite(b.width) || !Number.isFinite(b.height) || b.width <= 0 || b.height <= 0) {return null}const state: WindowState = {width: Math.round(b.width),height: Math.round(b.height),- maximized: win.isMaximized()+ maximized}if (Number.isFinite(b.x) && Number.isFinite(b.y)) {state.x = Math.round(b.x)