## Summary Closes #65166 When launching `Zed.exe` on Windows while an instance is already open, the second process spawns `Session::new`, which immediately writes a fresh session ID to `kv_store`, before hitting the single-instance check and exiting. As the issue traces, on the next cold start Zed looks up workspaces under that orphaned ID and restores nothing. This moves `Session::new` below the single-instance check so only the primary instance records a session ID. Nothing before the check uses `session` or `session_id` (both the crash handler and `app.run` come after). *(Note: This only fixes the secondary-launch overwrite, not the `app_will_quit` timeout in the issue logs.)* ## Testing No unit test added since the ordering is inline in `main()` behind the instance mutex (happy to factor out the startup sequence for a test if you'd like). Tested manually on Windows 11 (debug build with `ZED_RELEASE_CHANNEL=nightly` so the single-instance check runs, `ZED_UPDATE_EXPLANATION` set, and a temp `--user-data-dir`): 1. Opened a workspace, launched `zed.exe` 3 more times, and checked `kv_store.session_id` in `db/0-nightly/db.sqlite` after each. - **Before:** Overwritten on every extra launch while the active workspace kept the initial ID. - **After:** Stayed `b09be725-a782-4231-9686-90b43ba1c2a1` across all 3 launches. 2. Force-killed the instance (`taskkill /F`) and relaunched: wrote a new ID (`91a430ae-3040-472c-b8cb-e873867d0ffe`) and restored the workspace as expected. I haven't tested an orderly quit (Ctrl+Q) and relaunch. Not run on Linux or macOS, which go through the same check block. Local `cargo fmt --all -- --check` and debug `cargo clippy -p zed --all-targets -- --deny warnings` pass. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [ ] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). (No UI changes.) - [ ] Tests cover the new or changed behavior. (See Testing.) Release Notes: - Fixed launching Zed on Windows while it was already running causing the previous session not to be restored.
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.