feat(desktop): persist and restore window state

Fixes #1223
This commit is contained in:
Éverton Toffanetto
2026-06-01 12:04:58 +00:00
committed by GitHub
parent a5c2f39f65
commit 1ede1bccf7
5 changed files with 608 additions and 3 deletions
@@ -3,12 +3,15 @@ import { describe, expect, it, vi } from "vitest";
import {
applyWindowControlsOverlayUpdate,
createWindowControlsOverlayState,
DEFAULT_WINDOW_HEIGHT,
DEFAULT_WINDOW_WIDTH,
getMainWindowChromeOptions,
getTitleBarOverlayOptions,
readBadgeCount,
readWindowControlsOverlayUpdate,
readWindowTheme,
resolveRuntimeTitleBarOverlayOptions,
resolveWindowBounds,
} from "./window-manager";
describe("window-manager", () => {
@@ -186,4 +189,26 @@ describe("window-manager", () => {
});
});
});
describe("resolveWindowBounds", () => {
it("falls back to the default size when no state is saved", () => {
expect(resolveWindowBounds(null)).toEqual({
width: DEFAULT_WINDOW_WIDTH,
height: DEFAULT_WINDOW_HEIGHT,
});
});
it("restores the full size and position", () => {
expect(
resolveWindowBounds({ x: 120, y: 80, width: 1024, height: 720, isMaximized: false }),
).toEqual({ width: 1024, height: 720, x: 120, y: 80 });
});
it("omits the position when only the size was persisted", () => {
expect(resolveWindowBounds({ width: 1024, height: 720, isMaximized: true })).toEqual({
width: 1024,
height: 720,
});
});
});
});