All jobs

Remember Window Size and Position Between Launches in a Tauri App

Yes. An agent adds the Tauri window-state plugin, restores size, position and maximised state on launch, checks the Rust and frontend builds and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the app and reads how its windows are made. In an app like Uninen/tauri-vue-template, src-tauri/tauri.conf.json declares one window titled tauri-app at 800 by 600 and nothing else about it, so every launch opens the same size in the platform's default position. src-tauri/Cargo.toml depends on tauri 2 with tauri-plugin-shell and tauri-plugin-prevent-default, and src-tauri/src/lib.rs builds the app with those two plugins, a setup closure that opens devtools in debug builds through get_webview_window(_app, "main"), and one greet command. The frontend is Vue 3 with Pinia; package.json scripts run vitest for tests and cargo check --manifest-path src-tauri/Cargo.toml as pnpm check, and .github/workflows/test-build.yml installs the webkit and appindicator packages and runs pnpm tauri build on Ubuntu 24.04 for every pull request. There is no src-tauri/capabilities/ directory, so the frontend has no plugin permissions beyond the defaults.

It then adds the plugin on the Rust side, which is where restoring state belongs. Cargo.toml gains tauri-plugin-window-state at the 2 line, and lib.rs registers tauri_plugin_window_state::Builder::default().build() ahead of the existing plugins, inside a #[cfg(desktop)] block so a mobile build of the same crate compiles. With that in place the plugin restores each window's size, position and maximised state when the window is created and saves them when the app closes, with no frontend code and no permission needed. The agent keeps the 800 by 600 in tauri.conf.json as the first-launch default and adds a comment there saying the plugin overrides it afterwards.

It then decides whether the frontend needs the JavaScript API, and in this app it does not: nothing in src/ creates windows or saves state by hand. The pull request still shows what a caller would add if it did, @tauri-apps/plugin-window-state with saveWindowState and restoreStateCurrent, and the window-state:default permission that would go in a capability file, so the next person does not have to look it up. A denylist is mentioned for any splash or settings window that should always open fresh. The README's project structure section gets two lines on where the state is stored and how to reset it by deleting the file.

It proves the change with the project's own checks. It installs the Linux build dependencies the workflow lists, runs pnpm install, pnpm check for the Rust side, pnpm test for the Vue unit tests and pnpm build for the frontend, and then cargo build --manifest-path src-tauri/Cargo.toml so the plugin's native dependencies are compiled on the same distribution the workflow uses. It cannot open a window in the sandbox, so the pull request says what a reviewer should see: resize and move the window, quit, relaunch, same frame.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Make this Tauri app remember each window's size, position and maximised state between launches. Read tauri.conf.json, Cargo.toml, the Rust entry files, package.json and the CI workflows first, and note how windows are created and which plugins are registered. Add the Tauri window-state plugin on the Rust side, registered for desktop targets only, keep the configured window size as the first-launch default, and document in the README where the state file lives and how to reset it. Only add the frontend package and a capability permission if the app creates windows or saves state from JavaScript; otherwise show in the pull request what that would look like. Install the build dependencies the workflow uses, run the Rust check, the frontend tests, the frontend build and a cargo build, and open a pull request with the changes, the command output and the manual check a reviewer should do.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that changes src-tauri/Cargo.toml, src-tauri/Cargo.lock, src-tauri/src/lib.rs, a comment in tauri.conf.json and the README, with a description that says which window properties are restored, that the frontend was left untouched and why, and the three-step manual check for the reviewer.

The run's record keeps the cargo check, vitest, vite build and cargo build output from the same Ubuntu packages the workflow installs, so a reviewer knows the plugin compiled against this app's Tauri version before the CI build even starts.

Before merging, a reviewer builds the app on one desktop platform, resizes and moves the window, quits and relaunches, and confirms the frame comes back. On macOS they also check that a window closed while maximised reopens maximised, which is the case users notice first.

Run it on every Linear issue labelled desktop

An automation in the app's Project with a linear trigger on linear.issue.labeled and the label desktop starts one run per labelled issue, with the issue added after the prompt. The issue that asks for window memory and the later one that asks to exclude a settings window each get their own run and pull request, and the run reads the app's current plugins rather than assuming an earlier change landed.

A run whose cargo check or cargo build fails ends needs_review with the compiler output in its record instead of opening a pull request that cannot build, so the fix is a comment on the issue and a follow-up, not a fresh investigation.

The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.

Why run it on Rush?

The change itself is a dependency and one line, and the risk is everything around it: a plugin registered on a target where it does not compile, a permission the frontend did not need, a window that should always open fresh. The agent reads how the app creates windows, registers the plugin for desktop only, and compiles the Rust crate with the native libraries the workflow uses before a person looks at the diff.

On Rush the compile output and the test runs are in the run's record beside the pull request, and the same request serves every Tauri app a team ships. What the sandbox cannot do, open a window and move it, the pull request turns into a short check a reviewer does once.

Frequently asked questions

Does the frontend need to change?

Not for the default behaviour. The Rust plugin restores state when a window is created and saves it on close. The JavaScript package and the window-state:default permission are only needed if your frontend creates windows itself or wants to save state at a moment of its choosing, and the pull request shows that code without adding it.

What about a window that should always open at its default size?

The plugin builder takes a denylist of window labels. The agent adds one if the app has a splash, about or settings window that should not remember its frame, and otherwise mentions the option in the README so the next window gets the right choice.

Where is the state stored, and how do I reset it?

In a small file the plugin writes under the app's per-user application directory when the app closes. Deleting that file returns every window to the size in tauri.conf.json. The README section the pull request adds names the path for each platform.

Will this break the mobile build of the same crate?

No. The plugin is registered inside a #[cfg(desktop)] block, so the Android and iOS targets compile without it, which matches the plugin's own supported platforms.

More Tauri jobs

More jobs like this: Turn a Linear label into a PR

Keep reading