feat(tauri): persist window size/position/maximized state under AppData with monitor clamping - #4
Draft
crazyrob425 with Copilot wants to merge 2 commits into
Draft
crazyrob425 with Copilot wants to merge 2 commits into
crazyrob425 with Copilot wants to merge 2 commits into
Conversation
…r clamping Agent-Logs-Url: https://github.com/crazyrob425/KDP-E-Book-Generator/sessions/d8c55547-b16d-4421-8d12-7a62d9e51fde Co-authored-by: crazyrob425 <247058665+crazyrob425@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Ensure Tauri v2 wrapper persists window state on Windows
feat(tauri): persist window size/position/maximized state under AppData with monitor clamping
Mar 26, 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.
Tauri v2 wrapper had no window state persistence — every launch reopened at the default size/position with no memory of the previous session. Adds full save/restore of window geometry and maximized state stored under the OS
app_data_dir, with off-screen clamping on restore.Changes
src-tauri/src/lib.rsWindowState— serialisable struct (x, y, width, height, maximized); defaults to 1200×800 at (100, 100)window-state.jsonfromapp_data_dir; silently falls back to defaults on first run or corrupt fileclamp_to_monitors) — finds the monitor containing the saved top-left corner (falls back to first monitor); clamps size to monitor bounds and enforces ≥ 50 px title-bar visibility to prevent off-screen windows after display layout changesapply_window_state) — sets size/position, maximises if flagged, then callswindow.show()after geometry is appliedsetup_state_persistence) —Arc<Mutex<WindowState>>+mpsc::channel; background thread absorbs rapid move/resize events and flushes afterDEBOUNCE_MS(500 ms) of quiet;CloseRequestedtriggers an immediate synchronous savesrc-tauri/tauri.conf.json"visible": falseon the main window — prevents the position-flicker that would occur if the window appeared at the default position before Rust applies the restored geometryREADME.mdwindow-state.jsonpaths on Windows (%APPDATA%\com.tauri.dev\), macOS, and Linux, and describes restore/maximized/clamping/debounce behaviourOriginal prompt
In crazyrob425/KDP-E-Book-Generator (ref main), ensure the Tauri v2 wrapper persists window size/position and maximized state on Windows, stores the window state and all app data under the OS AppData directory, and clamps/restores window bounds to the current monitor work area so it never opens off-screen. Implement minimal Rust changes using Tauri v2 APIs: load state on startup and apply to main window; listen to window move/resize/maximize/unmaximize events with debounce and save state to a JSON settings file in app_data_dir. Update README to document AppData paths and behavior. Open a PR targeting main.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: @copilot Accepted Confirmation: Are you sure?
Assistant: GitHub is just where the code lives. Building a Tauri desktop app can’t happen “inside GitHub” by itself—you need either:
Right now I can’t directly push the Tauri wrapper into your
blacklistedrob-prog/KDP-E-Book-Generatorrepo from this chat (GitHub is blocking write access for this session), so I can’t “just do it” in-place for you yet.Two paths forward (pick one)
Path A (no local setup): GitHub Actions builds the Windows installer for you
This is the closest to what you want: you click “Run workflow” (or push a commit) and GitHub produces a
.msiinstaller you download.To do that, we still need one of these:
Path B (local once): you generate the wrapper with one command, then everything else can be GitHub-built
You’d do one local step to create the wrapper; then we add Actions and you never build locally again.
Quick questions (so I give you the exact minimal-click instructions)
If you answer those, I’ll tell you the lowest-effort route and exactly what to click/do—aiming for “one-time setup, then GitHub builds the installer forever.”
User: can you fork the repo and do it??
Assistant: We’re waiting for your response to the “Are you sure?” confirmation dialog so I can proceed with forking Blacklisted-Binary/demo-repository and applying the Tauri + SQLite + Windows CI changes in the fork.
User: @copilot Accepted Confirmation: Are you sure?
Assistant: Yes—forking is a good workaround if you can’t (or don’t want to) fight the permission issue on the original repo.
What I can do vs. what I can’t do
blacklistedrob-prog/KDP-E-Book-Generatorfrom here right now because this session doesn’t have the necessary write privileges on that repo, and forking itself may also be blocked depending on what GitHub allows the integration to do in your account.If forking is available on your side, this is the fastest path
You do one click:
blacklistedrob-prog/KDP-E-Book-Generatorcrazyrob425/KDP-E-Book-Generator(or whatever name you pick), send me the fork repo name.Then I can work against the fork and you’ll get:
src-tauri/recreatedWhat I need from you
Reply with either:
crazyrob425/KDP-E-Book-Generator” (best), orOnce you give me the fork repo path, I’ll proceed with the full rebuild there and keep it as close as possible to your current project structure and vibe.
User: i forked it: crazyrob425/KDP-E-Book-Generator
Assistant: I’ve started the Copilot coding agent work on your fork
crazyrob425/KDP-E-Book-Generatorto add the full Tauri v2 wrapper, Rust-only SQLite backend, job progress events, and a Windows MSI GitHub Actions build workflow; you can track progress at the task link below.