[Bug]: Main Window Position (x, y) Is Not Persisted on Launch (Only Size & Maximized State)
Nobody has claimed this yet.
- 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:
- Window Close Event: The close/blur listener calls
window.getNormalBounds()(which yields{x, y, width, height}), but only stores{width, height, maximized}. - Config Schema Definition: The
desktopWindowSizeconfiguration schema definition is strictly typed to{width, height, maximized}withoutxandyattributes. - Window Instantiation:
createBrowserWindow()constructs the primary window passing onlywidthandheight, completely ignoring saved screen coordinates. Consequently, macOS window management places it at the default cascade position.
Proposed Fix
- Update
desktopWindowSizestate schema to include optionalxandyproperties:{width, height, maximized, x?, y?}. - In the window bounds persistence handler, store
xandyreturned fromgetNormalBounds(). - In
createBrowserWindow(), passxandyasBrowserWindowConstructorOptions. - Add display bounds clamping using Electron's
screen.getDisplayMatching(bounds)to prevent off-screen spawning if an external monitor was disconnected.
Environment
- App Version: ZCode 3.11.2 (3.11.2.6792)
- OS: macOS 26.6.2 (Apple Silicon)
- Reported by:
Jotaon Z.ai Community Discord - Discord Thread: https://discord.com/channels/1346756824233148527/1549363209474150411
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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