workspace: Fix opening closed projects randomly when Zed restarts#50961
Conversation
|
Seems like this probably works to fix it, but before we commit it I'd like to understand why the workspace session id is being used in the wrong way deeper in the. code. |
when a user quits zed:
when we close a window
when we open a diff project in same window
the bug when we close proj
my fixbasically adds 2 lines before let remove_task = workspace.remove_from_session(window, cx); // clear session_id in db
remove_task.await; // wait for db write |
|
tldr : we never call
cx.spawn_in(window, async move |_this, cx| {
let should_continue = workspace
.update_in(cx, |workspace, window, cx| {
workspace.prepare_to_close(crate::CloseIntent::ReplaceWindow, window, cx) // <-- cleans up DB
})?
.await?;
if should_continue {
workspace
.update_in(cx, |workspace, window, cx| {
workspace.open_workspace_for_paths(true, paths, window, cx)
})?
.await
} else {
Ok(())
}
})hope this helps a lil bit :)) |
|
Interesting. Should we call |
call remove_from_session to immediately remove session_id from memory, spawns task that awaits db write, calls open_new to replace window with empty workssapce
uses `prepare_to_close(CloseIntent::ReplaceWindow)` on the current worksapce, this clears session_id, serializes unsaved buffer state adn handles active call cleanup. matches the pattern we have in `MultiWorkspace::open_project` in `multi_workspace.rs`
@ConradIrwin |
ed6d11c to
95d488d
Compare
|
THanks! |
…d-industries#50961) Closes zed-industries#49854 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] No UI changes Video for the fix: in the video i open a project -> close the project -> quit out of zed -> reopen zed -> zed opens to an empty workspace which was not the case before https://github.com/user-attachments/assets/1afb44a1-932b-4dab-8228-9d9d65750b6e Release Notes: - Fixed closed projects re-opening erroneously
Closes #49854
Before you mark this PR as ready for review, make sure that you have:
Video for the fix:
in the video i open a project -> close the project -> quit out of zed -> reopen zed -> zed opens to an empty workspace which was not the case before
projectfix.mp4
Release Notes: