feat: add window state persistence with settings toggle#47
Merged
Conversation
Add tauri-plugin-window-state to save and restore window position and size across app restarts. The plugin always saves state on close, but restoration is controlled by a toggle in Settings. - Register window-state plugin with skip_initial_state to defer restore - Add StateFlags::POSITION | SIZE for selective state tracking - Pre-fetch toggle value in store-provider initPromise (no visual flash) - Add WindowStateOption switch component in Settings dialog - Default: restore enabled (ON) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Add window position and size persistence using
tauri-plugin-window-state.The plugin always saves window state on close, but restoration is controlled by a toggle in the Settings dialog (default: ON). When disabled, the app opens with the default 1200×800 centered window.
Changes
Backend (Rust)
tauri-plugin-window-statedependencyskip_initial_state("main")to defer restore to frontendStateFlags::POSITION | StateFlags::SIZE(excludes maximized/fullscreen)window-state:defaultcapability permissionFrontend (TypeScript/React)
@tauri-apps/plugin-window-statedependencystore-provider.tsxinitPromise (no visual flash)restoreStateCurrent()with try-catch for error resilienceWindowStateOptionswitch component in Settings dialoguseWindowStatehook following existing toggle patternindex.ts)Architecture
Uses Option A: Plugin + skip_initial_state approach:
skip_initial_stateprevents auto-restore on startuprestoreStateCurrent()before React rendersinitPromise(before Suspense resolves)