Skip to content

Persist window position and size across sessions#313

Merged
sbertix merged 3 commits into
supabitapp:mainfrom
tamarazuk:fix/268-persist-window-frame
May 12, 2026
Merged

Persist window position and size across sessions#313
sbertix merged 3 commits into
supabitapp:mainfrom
tamarazuk:fix/268-persist-window-frame

Conversation

@tamarazuk
Copy link
Copy Markdown
Contributor

Summary

Fixes #268 — the main window now remembers its position and size across app launches, including when placed on a secondary display.

Problem

Supacode had no window frame persistence. Every launch reset the window to fill the primary display, which is especially annoying on multi-monitor setups.

Solution

Set NSWindow.setFrameAutosaveName("main") on the main window in WindowTabbingView.disallowTabbing(), which already configures the main NSWindow (tabbing mode, identifier, delegate).

Once an autosave name is set, macOS automatically:

  • Saves the window frame to UserDefaults on every move/resize
  • Restores the frame on next launch, including the correct display

A guard (frameAutosaveName.rawValue != WindowID.main) ensures the call is idempotent across repeated updateNSView cycles.

Testing

  • Single display: window position/size persists across quit & relaunch
  • Multi-display: window moved to secondary display stays there after relaunch
  • Display disconnected: macOS constrains the window to a visible display (built-in behavior)

Note: make build-app could not run in CI-like env (no Xcode installation), but the change is a single standard NSWindow API call with no new imports.

Set NSWindow.frameAutosaveName on the main window so macOS
automatically saves and restores the window frame (position + size)
across app launches, including on secondary displays.

The autosave name is set in WindowTabbingView.disallowTabbing(), which
already configures the main NSWindow (tabbing mode, identifier,
delegate). A guard ensures setFrameAutosaveName is only called once.

Fixes supabitapp#268
Copy link
Copy Markdown
Collaborator

@sbertix sbertix left a comment

Choose a reason for hiding this comment

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

Thanks 💪

Comment thread supacode/App/WindowTabbingDisabler.swift Outdated
@sbertix sbertix enabled auto-merge (squash) May 12, 2026 21:56
@sbertix sbertix disabled auto-merge May 12, 2026 22:02
@sbertix sbertix enabled auto-merge (squash) May 12, 2026 22:02
@sbertix sbertix merged commit 66b300d into supabitapp:main May 12, 2026
2 checks passed
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.

Window doesn't persist position and size on macOS between sessions on a multi display setup

2 participants