feat: persist window size, position, and full screen state across launches#1083
Merged
feat: persist window size, position, and full screen state across launches#1083
Conversation
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
…-persistence # Conflicts: # CHANGELOG.md
…roApp/TablePro into worktree-window-state-persistence # Conflicts: # CHANGELOG.md
This was referenced May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
visibleFrame) instead of a fixed default.Why
The editor always opened at the same default size, even after the user resized or full screened it. Three bugs combined to defeat persistence: a
viewWillAppearupsize floor that silently discarded any restored frame smaller than 1200x800, aWindowManager.openTabwindow.center()call that wiped autosave-restored origins, and no full screen tracking at all (isRestorable = falseopts out of Cocoa Resume).How
Native macOS APIs only. No Cocoa Resume /
NSWindowRestoration, which would race withAppLaunchCoordinator's custom session restore.WindowFramePolicy(new): per-window-class value type (autosaveName,fullScreenStateKey, first-run sizing rules). Static instances for.editor,.jsonViewer,.integrationsActivity,.feedback.WindowStateController(new):@MainActorsingleton that callssetFrameAutosaveName+setFrameUsingName, computes first-run size, observeswillEnterFullScreen/didExitFullScreenfor full screen bool, and queues a one-shotdidBecomeKeyobserver to calltoggleFullScreenwhen the saved bool is true. Per-window observer lifetime managed by a privateWindowStateBinding.WindowChromeConfiguratorgains an optionalstatePolicyso SwiftUI Window scenes (Integrations Activity) get persistence through the sameNSViewRepresentableused for chrome config.viewWillAppearupsize floor and the unconditionalwindow.center(). Centering only happens on first run.NSWindow+FrameAutosavehelper, replaced by the controller.Off-screen handling uses Apple default behavior:
setFrameUsingNameclamps to the current main screen when the saved screen is gone.Files
New:
TablePro/Core/Services/Infrastructure/WindowFramePolicy.swiftTablePro/Core/Services/Infrastructure/WindowStateController.swiftTableProTests/Services/WindowFramePolicyTests.swiftModified:
TabWindowController.swift,WindowManager.swift,MainSplitViewController.swift,JSONViewerWindowController.swift,FeedbackWindowController.swift,WindowChromeConfigurator.swift,TableProApp.swift,CHANGELOG.mdDeleted:
TablePro/Extensions/NSWindow+FrameAutosave.swiftTest plan
window.minSizeof 720x480 still enforced).NSScreen.main.visibleFrame, centered.xcodebuild test -only-testing:TableProTests/WindowFramePolicyFirstRunSizingTestspasses.