Remember the window's size and position - #99
Merged
Merged
Conversation
`tauri-plugin-window-state`, with explicit flags rather than its default `all()`: that set carries `VISIBLE`, and quitting from the tray saves a hidden window — the next launch would restore it hidden, an application that starts with nothing on screen. A unit test holds the flag out. The size in `tauri.conf.json` is now only a first launch, and 800x600 was narrow for a grid of cards: 1100x720, with a 640x480 floor so no saved geometry can come back unusable.
The plugin restores the geometry from `on_webview_ready`, which runs after the window is already on screen: it appeared at the config's size and then jumped. Measured through startup, that was 1116x720 at +172 ms and the remembered 900x600 at +359 ms. The window is now created hidden and shown from `setup`, once the restore has run — one rectangle, no jump. `backgroundColor` is the dark `--bg-0` so the WebView's white does not take the flash's place.
vmillet-dev
force-pushed
the
feat/window-remembers-its-geometry
branch
from
September 13, 2026 18:42
5945dcb to
b74cb29
Compare
This was referenced Sep 14, 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.
Closes #11.
tauri-plugin-window-state— the plugin, not a hand-rolled persistence throughPreferencesService. It brought one crate with it and no transitive dependency, which is well under "more than it is worth"; and doing it in the front end would mean restoring the geometry after Angular boots, so the window would visibly jump on every launch.The flags are the whole ticket
The plugin's default is
StateFlags::all(), andall()includesVISIBLE. WithcloseToTrayon — which is the default — quitting from the tray saves a window that is hidden, and the next launch restores it hidden: an application that starts with nothing on screen and only a tray icon to be found by. That is the trap the ticket warns about, and taking the plugin's default would have walked straight into it.So
WINDOW_STATE_FLAGSisSIZE | POSITION | MAXIMIZED, named and commented, with a unit test that holdsVISIBLEout — a comment cannot fail a build.DECORATIONSandFULLSCREENare left out for the opposite reason: nothing in DevBox changes either, so saving them stores noise.The other half of the ticket's warning needs nothing from us. A minimized window on Windows reports itself at -32000, and the plugin already guards it: both its
Movedand itsResizedhandlers skip a minimized window, andupdate_stateskips size and position when minimized or maximized. Confirmed by reading the plugin rather than by hoping.Worth knowing: the file is written on
RunEvent::Exit, not on every move. The tray's "Quitter" isapp.exit(0), so it goes through; a force-kill writes nothing and leaves the previous geometry standing, which is the right answer for a crash.First launch
tauri.conf.jsonis now only a first launch. 800×600 was the ticket's own complaint — narrow for a grid ofminmax(220px, 1fr)cards — so it is 1100×720, withminWidth/minHeightof 640×480. The floor is not decoration: it is what stops a saved geometry, or a drag, from bringing the window back at a size nothing fits in.Verified on the assembled application
This is not reachable from the e2e suite —
reopenSession()is explicitly not a restart, the process hosts the WebDriver server and must stay up, so "quit and launch again" cannot be expressed there. Same reason15-preferences-on-diskreads its file from Node. So it was checked by hand, against the real binary:.window-state.jsonwritten:964×601 at 240,130(client area)"visible": falseforced into the state file, then launchedThat last row is the trap, demonstrated rather than argued.
Checked
cargo test— 169 + 34 + 83 + 14 + 10 passing, including the new flag guard.cargo clippy --all-targets -- -D warnings,cargo fmt --check— clean.npm test— 937 passing.npm run lint— clean.docs/architecture.mdgains a "Window geometry" section next to the tray;CLAUDE.mdgains theVISIBLEtrap.