Skip to content

fix(shell): size the initial main window within the work area - #1274

Closed
130rockirt wants to merge 1 commit into
KunAgent:developfrom
130rockirt:codex/fix-main-window-initial-bounds
Closed

fix(shell): size the initial main window within the work area#1274
130rockirt wants to merge 1 commit into
KunAgent:developfrom
130rockirt:codex/fix-main-window-initial-bounds

Conversation

@130rockirt

Copy link
Copy Markdown
Contributor

Summary

Fixes the title-bar restore button appearing to do nothing on small or high-DPI-scaled displays.

  • Root cause: the main window always opened at a fixed 1280x840. On displays whose work area is smaller than that (e.g. a 1280x800 panel at 150% scaling, work area 1280x752), Windows clamps the new window to fill the work area. The window therefore opens effectively full-screen, and restoring from maximize returns to bounds that match the maximized size — the window visibly never shrinks.
  • Fix: derive the initial window bounds from the primary display work area. Large screens keep the 1280x840 default; smaller work areas get at most 85% of the work area (never below the 960x640 minimum), centered, so restore-from-maximize always shrinks visibly.

Changes

  • src/main/main-window-initial-bounds.ts (new): pure resolveMainWindowInitialBounds(workArea) helper plus the exported min/default size constants.
  • src/main/main-window.ts: createWindow now positions and sizes the window from the primary display work area instead of hardcoding width: 1280, height: 840.
  • src/main/main-window-initial-bounds.test.ts (new): unit tests for large, small/scaled, tiny, and offset work areas.

Tests

  • npx vitest run src/main/main-window-initial-bounds.test.ts src/main/main-window.auxiliary.test.ts — 6 passed
  • npx vitest run on adjacent main-window suites (activation, renderer-recovery, storage-relocation, runtime-data-recovery) — 12 passed
  • npm run typecheck — passed
  • Real Electron verification on a 1280x800 @150% display (work area 1280x752), simulating createWindow then maximize → restore:
    • before: restored bounds 1284x753 vs maximized 1296x768 (Δ 12x15 px — invisible, the reported bug)
    • after: restored bounds 1091x643 vs maximized 1296x768 (Δ 205x125 px — clearly visible)

The main window always opened at a fixed 1280x840. On small or
high-DPI-scaled displays whose work area is smaller than that (for
example a 1280x800 panel at 150% scaling with a 1280x752 work area),
Windows clamps the new window to fill the work area, so restoring from
maximize returns to bounds that match the maximized size and the
restore button looks like a no-op.

Derive the initial bounds from the primary display work area: keep the
1280x840 default on large screens, cap at 85% of the work area (never
below the 960x640 minimum), and center the window.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants