Skip to content

fix: window on missing display#1133

Open
Llandy3d wants to merge 1 commit intomainfrom
window_outof_bound
Open

fix: window on missing display#1133
Llandy3d wants to merge 1 commit intomainfrom
window_outof_bound

Conversation

@Llandy3d
Copy link
Copy Markdown
Collaborator

@Llandy3d Llandy3d commented Mar 24, 2026

Description

Fix #1086

  • Add isWindowOnScreen helper that checks if saved window bounds overlap any available display using Electron's
    screen.getDisplayMatching() API
  • When the window would be off-screen, omit the saved x/y coordinates so Electron auto-centers the window on the primary display

How to Test

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)


Note

Low Risk
Low risk: small, isolated change to window creation logic plus unit tests; main risk is incorrect bounds overlap logic causing windows to not restore to the intended position on some multi-monitor setups.

Overview
Prevents the app from restoring its main window to coordinates that are no longer visible (e.g., after monitor configuration changes).

Adds isWindowOnScreen() (tested in window.test.ts) to detect whether saved window bounds overlap the current display work area, and in main.ts only applies saved x/y when the window would be on-screen; otherwise Electron falls back to default placement.

Written by Cursor Bugbot for commit 91d6f78. This will update automatically on new commits. Configure here.

Comment on lines 114 to 115
width,
height,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the window's dimensions were saved when it was on a bigger screen and the width/height are now greater than what's available? Should there also be a check or is this handled automatically?

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.

When I disconnect an external monitor and launch k6 Studio, it opens the window off-screen and crashes

3 participants