Skip to content

feat: restore window position and size from Rust before frame creation#88

Merged
j4rviscmd merged 4 commits intomainfrom
feat/window-restore
Mar 27, 2026
Merged

feat: restore window position and size from Rust before frame creation#88
j4rviscmd merged 4 commits intomainfrom
feat/window-restore

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

Replace tauri-plugin-window-state with self-managed window geometry persistence in Rust. The setup hook now reads config.json before creating the main window, applying saved position and size when the user setting is enabled. This eliminates the visual jump that occurred when the frontend restored geometry after the window was already visible.

Changes

Rust backend

  • New module window.rs — Handles window creation, geometry save/restore, and off-screen detection
  • lib.rs — Removed tauri-plugin-window-state plugin; window is now created programmatically in the setup hook with on_window_event(CloseRequested) to persist geometry on close
  • Cargo.toml — Removed tauri-plugin-window-state dependency
  • tauri.conf.json — Cleared the windows array (window creation is now programmatic)
  • capabilities/default.json — Removed window-state:default permission

Frontend

  • store-provider.tsx — Removed restoreStateCurrent() call and @tauri-apps/plugin-window-state import
  • windowStateConfig.ts — Updated JSDoc to reflect Rust-side restore
  • package.json — Removed @tauri-apps/plugin-window-state dependency

Behavior

Setting Startup behavior
Restore ON (default) Window opens at saved position & size
Restore OFF Window opens at default 1200×800, centred by OS
Saved position off-screen Falls back to default 1200×800, centred by OS

Testing

  • App starts at default size on fresh install
  • Window position/size persisted across restarts
  • Settings toggle works (takes effect on next launch)
  • Splash screen renders correctly
  • cargo build / cargo clippy / tsc --noEmit pass

j4rviscmd and others added 2 commits March 28, 2026 00:58
Replace tauri-plugin-window-state with self-managed geometry
persistence. The Rust setup hook now reads config.json to check
whether restoration is enabled and, if so, creates the main window
at the saved position and size. On close, geometry is saved back to
config.json in logical coordinates with off-screen detection fallback.

- Add src-tauri/src/window.rs for window lifecycle management
- Remove tauri-plugin-window-state from Rust and frontend deps
- Remove frontend restoreStateCurrent() call in store-provider
- Clear windows array in tauri.conf.json (now programmatic)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Mar 27, 2026
@j4rviscmd j4rviscmd merged commit 3a4674c into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the feat/window-restore branch March 27, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant