Fix several issues with multi-workspace serialization and restoration that caused sidebar workspaces to not fully restore after Zed restart. ## Changes ### 1. Resilient restoration — don't let one failing workspace kill the rest In `restore_multiworkspace`, the loop restoring each workspace in a group used `?` on every `.await`. If any single workspace failed (e.g. a DB read error, item deserialization failure), all remaining workspaces were silently abandoned. Changed to log-and-continue so each workspace is attempted independently. `restore_multiworkspace` now returns a `MultiWorkspaceRestoreResult` containing both the window handle and a list of errors, which the caller logs individually. ### 2. Proper serialization at lifecycle events - **`create_workspace`** now assigns a database ID (via `next_id()`) and writes a `session_id`/`window_id` binding so newly-created workspaces can be persisted and restored. - **`remove_workspace`** now deletes the removed workspace from the DB (preventing zombie restoration) and serializes the updated multi-workspace state. - **`activate`** now only serializes when the active workspace actually changes, and uses the new `set_active_workspace` helper to keep the ordering correct (set index *then* serialize, not the other way around). - The `serialize` method now stores its task in `_serialize_task` instead of fire-and-forget detaching, enabling `flush_serialization` to await it. ### 3. Flush serialization on quit The quit handler now calls `flush_serialization` on every workspace and multi-workspace before `cx.quit()`, bypassing the 200ms throttle to ensure all `session_id`/`window_id` values are written to the database before the process exits. ### 4. Await pending tasks on app quit `MultiWorkspace` now registers an `on_app_quit` handler that awaits all in-flight serialization, creation, and removal tasks within GPUI's shutdown timeout. The existing `on_release` handler continues to detach tasks as a safety net for non-quit window closes, matching the pattern used by `Room`. ### 5. Track workspace serialization task `Workspace::serialize_workspace` now stores the actual serialization task in `_serialize_workspace_task` instead of detaching it, so `flush_serialization` can cancel any pending throttle *and* await the in-flight write. ### 6. New persistence helper Added `set_session_binding` query to update a workspace's `session_id` and `window_id` in one shot, used by `create_workspace` to bind newly-created workspaces to the current session. ### 7. Tests Added tests covering: - `flush_serialization` completing before quit - `create_workspace` assigning a DB ID and serializing the active workspace ID - Removal of a workspace deleting it from the DB and updating multi-workspace state - Restoration resilience when individual workspaces fail Closes AI-37 (No release notes because this is still feature-flagged.) Release Notes: - N/A --------- Co-authored-by: Anthony Eid <anthony@zed.dev>
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 issue)
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
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.