Skip to content

workspace: Support hot-exit for empty workspaces and single files#46557

Merged
SomeoneToIgnore merged 8 commits intozed-industries:mainfrom
shfc:hot-exit-empty-workspaces
Jan 23, 2026
Merged

workspace: Support hot-exit for empty workspaces and single files#46557
SomeoneToIgnore merged 8 commits intozed-industries:mainfrom
shfc:hot-exit-empty-workspaces

Conversation

@shfc
Copy link
Contributor

@shfc shfc commented Jan 11, 2026

Enables restoration of empty workspaces (without folders) that contain unsaved items like drafts or single files. Empty workspaces are now identified by workspace_id rather than paths, allowing multiple empty workspaces to coexist and be properly restored on startup. This ensures users don't lose work when closing Zed with unsaved files in empty workspaces.

Closes #15098

Release Notes:

  • Improved: Empty workspaces with unsaved files now restore on startup (hot-exit)

@cla-bot
Copy link

cla-bot bot commented Jan 11, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @shfc on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@shfc
Copy link
Contributor Author

shfc commented Jan 11, 2026

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 11, 2026
@cla-bot
Copy link

cla-bot bot commented Jan 11, 2026

The cla-bot has been summoned, and re-checked this pull request!

Enables restoration of empty workspaces (without folders) that contain unsaved
items like drafts or single files. Empty workspaces are now identified by
workspace_id rather than paths, allowing multiple empty workspaces to coexist
and be properly restored on startup.
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the attempt: it's amazing to see that now all the files I've edited in empty workspaces come back.

Yet, no unsaved changes are restored according to my testing:

no_changes.mov

I have merged main in to re-trigger the CI and fix the merge commits, but not sure how to help and fix the logic.
Do you have any clues?

@shfc
Copy link
Contributor Author

shfc commented Jan 23, 2026

Thank you for the attempt: it's amazing to see that now all the files I've edited in empty workspaces come back.

Yet, no unsaved changes are restored according to my testing:

no_changes.mov
I have merged main in to re-trigger the CI and fix the merge commits, but not sure how to help and fix the logic. Do you have any clues?

Thanks for letting me know. I've resolved the data loss when working without a worktree by adding logic to restore the missing content to the None branch, and also added a test. Could you please review again?

test.mp4

@shfc shfc requested a review from SomeoneToIgnore January 23, 2026 08:11
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm now, amazing.

Thank you for finding a way to adjust the code, let's make it a bit more easy to approach for future changes and merge.

@shfc
Copy link
Contributor Author

shfc commented Jan 23, 2026

Works like a charm now, amazing.

Thank you for finding a way to adjust the code, let's make it a bit more easy to approach for future changes and merge.

Updated. Thanks for your suggestions, please let me know what you think now.

@shfc shfc requested a review from SomeoneToIgnore January 23, 2026 11:45
@shfc
Copy link
Contributor Author

shfc commented Jan 23, 2026

@SomeoneToIgnore fixed the formatting issue, please run the CI again

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

@shfc shfc requested a review from SomeoneToIgnore January 23, 2026 14:45
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change, thank you a lot!

@SomeoneToIgnore SomeoneToIgnore enabled auto-merge (squash) January 23, 2026 14:48
@SomeoneToIgnore SomeoneToIgnore merged commit e1c80f4 into zed-industries:main Jan 23, 2026
27 checks passed
@disbolog
Copy link

disbolog commented Jan 23, 2026

Does this new functionality mean I can have Zed save non-persisted files (e.g. newly created, and not existing edited) without even having a workspace = akin to default on VSCode?

@fuzenco
Copy link

fuzenco commented Jan 31, 2026

This is a huge update! Just now, I wished Zed would re-open unsaved files, as I had lost a document I was working on last month that wasn’t yet saved. Before scanning the release notes, I tested an unsaved file, hoping I had missed something and that the feature might have been added. To my surprise, I found out it’s actually here! I was blown away by this news. Thank you, Zed and the community, for continuing to make this editor amazing.

@fuzenco
Copy link

fuzenco commented Jan 31, 2026

Does this new functionality mean I can have Zed save non-persisted files (e.g. newly created, and not existing edited) without even having a workspace = akin to default on VSCode?

If you mean unsaved files not in a workspace, the answer is yes. I just tested it. My prayers have been answered.

@tdkl
Copy link

tdkl commented Feb 2, 2026

Does this new functionality mean I can have Zed save non-persisted files (e.g. newly created, and not existing edited) without even having a workspace = akin to default on VSCode?

If you mean unsaved files not in a workspace, the answer is yes. I just tested it. My prayers have been answered.

How can you get it to work? I currently have it set to Restore On Startup: Last Session, but when I create new files and close the Zed editor, it prompts to save the files or discard them all.

@fuzenco
Copy link

fuzenco commented Feb 2, 2026

How can you get it to work? I currently have it set to Restore On Startup: Last Session, but when I create new files and close the Zed editor, it prompts to save the files or discard them all.

I don’t know as I have never messed with my configs, besides the setting you said you have on, there are all enabled in my Zed:

When Closing With No Tabs = Platform Default
On Last Window Closed = Platform Default

@bitbonk
Copy link

bitbonk commented Feb 3, 2026

It is probably not fully fixed yet. As #48255 demonstrates.

@shfc
Copy link
Contributor Author

shfc commented Feb 3, 2026

Does this new functionality mean I can have Zed save non-persisted files (e.g. newly created, and not existing edited) without even having a workspace = akin to default on VSCode?

If you mean unsaved files not in a workspace, the answer is yes. I just tested it. My prayers have been answered.

How can you get it to work? I currently have it set to Restore On Startup: Last Session, but when I create new files and close the Zed editor, it prompts to save the files or discard them all.

Did you use the version released after v0.222.0-pre? This feature hasn't been released on the current stable version yet.

@tdkl
Copy link

tdkl commented Feb 3, 2026

Does this new functionality mean I can have Zed save non-persisted files (e.g. newly created, and not existing edited) without even having a workspace = akin to default on VSCode?

If you mean unsaved files not in a workspace, the answer is yes. I just tested it. My prayers have been answered.

How can you get it to work? I currently have it set to Restore On Startup: Last Session, but when I create new files and close the Zed editor, it prompts to save the files or discard them all.

Did you use the version released after v0.222.0-pre? This feature hasn't been released on the current stable version yet.

Thank you, you're absolutely right, my bad. I was expecting it to be the part of stable release already. Now I see that it was merged only in the preview release.

@tdkl
Copy link

tdkl commented Feb 7, 2026

It works great now in stable, thank you again for the work. But when I had various non-saved files opened which were re-opening fine after closure, I noticed that when a new update was downloaded and I clicked on "Update Zed and restart", after restart of Zed those non-saved files were gone.

@jankkm
Copy link

jankkm commented Feb 9, 2026

I noticed too that it usually works well but there is at least one situation where the unsaved files get lost:
If I close the current empty workspace but not the application (red button on macOS) the window closes without a warning. This might be technically similar to what happens on update like @tdkl described.

The same is true for non-empty workspaces but in that case I can reopen the workspace and the unsaved work comes back.

@shfc
Copy link
Contributor Author

shfc commented Feb 9, 2026

It works great now in stable, thank you again for the work. But when I had various non-saved files opened which were re-opening fine after closure, I noticed that when a new update was downloaded and I clicked on "Update Zed and restart", after restart of Zed those non-saved files were gone.

Hi, could you please create a new issue for this? Since this PR is already done, it'll be easier to track that way.

@SomeoneToIgnore
Copy link
Contributor

I believe we have one now: #48468 and it is a nice one to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serialize the unsaved changes of files not associated with a worktrees

7 participants