zai-org / zai-org/feedback

[Bug]: Main Window Position (x, y) Is Not Persisted on Launch (Only Size & Maximized State)

Open
#664 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Bug Description

On ZCode Desktop (tested on macOS Apple Silicon), the application window fails to restore its previous screen position (x, y) upon restart. It always opens at the macOS OS default placement, forcing the user to reposition the window on every launch.


Root Cause Analysis (Verified via app.asar v3.11.2)

Analysis of the Electron main process bundle in app.asar (v3.11.2) pinpoints the exact omission:

  1. Window Close Event: The close/blur listener calls window.getNormalBounds() (which yields {x, y, width, height}), but only stores {width, height, maximized}.
  2. Config Schema Definition: The desktopWindowSize configuration schema definition is strictly typed to {width, height, maximized} without x and y attributes.
  3. Window Instantiation: createBrowserWindow() constructs the primary window passing only width and height, completely ignoring saved screen coordinates. Consequently, macOS window management places it at the default cascade position.

Proposed Fix
  1. Update desktopWindowSize state schema to include optional x and y properties: {width, height, maximized, x?, y?}.
  2. In the window bounds persistence handler, store x and y returned from getNormalBounds().
  3. In createBrowserWindow(), pass x and y as BrowserWindowConstructorOptions.
  4. Add display bounds clamping using Electron's screen.getDisplayMatching(bounds) to prevent off-screen spawning if an external monitor was disconnected.

Environment

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Electron main-process code that defines the desktopWindowSize schema, handles getNormalBounds() persistence, and constructs the BrowserWindow. Trace how saved bounds are loaded and run the existing desktop or window tests, if present. Done means x and y are persisted, restored on launch, and clamped when the saved display is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.