Skip to content

Grace period for inaccessible workspaces#50829

Merged
ConradIrwin merged 3 commits intozed-industries:mainfrom
ojpro:grace-period-for-inaccessible-workspaces
Mar 13, 2026
Merged

Grace period for inaccessible workspaces#50829
ConradIrwin merged 3 commits intozed-industries:mainfrom
ojpro:grace-period-for-inaccessible-workspaces

Conversation

@ojpro
Copy link
Copy Markdown
Contributor

@ojpro ojpro commented Mar 5, 2026

Closes #49603

Release Notes:

  • Added a 7-day grace period to prevent recently used local workspaces from being deleted when their paths are temporarily unavailable. Session workspaces are always preserved on restart.

ojpro added 2 commits March 5, 2026 14:33
Paths that are temporarily unavailable (e.g. external drives, network
mounts) were being deleted from recent and session workspaces
immediately.

Recent workspaces now get a grace period based on their last-used
timestamp.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 5, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 5, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Mar 5, 2026

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 3d5d2aa

@ConradIrwin
Copy link
Copy Markdown
Member

Thanks for this! Instead of passing a bool to that function, should we just short-circuit and only check the old ones?

I think the other caller should pass false to preserve existing behavior (not true) and it might be clearer if the bool wasn't there

@ConradIrwin ConradIrwin self-assigned this Mar 6, 2026
@ojpro
Copy link
Copy Markdown
Contributor Author

ojpro commented Mar 6, 2026

Hey @ConradIrwin,

I have updated all_paths_exist_with_a_directory to accept a timestamp instead of boolean.
With that recent_workspaces_on_disk only delete the workplace if it's not available and it's been more than 7 days long.

@ConradIrwin
Copy link
Copy Markdown
Member

Thanks, that's much clearer!

@ConradIrwin ConradIrwin merged commit 07cfa81 into zed-industries:main Mar 13, 2026
29 checks passed
@yeskunall
Copy link
Copy Markdown
Member

@ojpro congratulations on your first contribution to Zed! A great QoL improvement, at that! 💖

Have a great weekend!

tommyming pushed a commit to tommyming/zed that referenced this pull request Mar 15, 2026
Closes zed-industries#49603

Release Notes:
- Added a 7-day grace period to prevent recently used local workspaces
from being deleted when their paths are temporarily unavailable. Session
workspaces are always preserved on restart.
@maxbrunsfeld
Copy link
Copy Markdown
Collaborator

maxbrunsfeld commented Mar 18, 2026

@ojpro I believe this PR is causing non-existent directories to appear in the recent project picker. Was that your intent?

I think the correct behavior would be to allow a grace period before deleting the rows from Sqlite, but to still avoid showing inaccessible directories in the picker. Am I missing something there?

If you get a chance, could you follow up and fix that?

@ojpro
Copy link
Copy Markdown
Contributor Author

ojpro commented Mar 18, 2026

Hey @maxbrunsfeld

Actually the intent is to only delete non-existence directories after a period (7 days by default), but if that project opened before that period end it should reset the grace period, and so on.

The use case is, if I have a project A, but on an external drive | Network, I open a project B (on device), Zed remove the reference to that project A because the drive is not mounted during that session.

@maxbrunsfeld
Copy link
Copy Markdown
Collaborator

maxbrunsfeld commented Mar 18, 2026

I understand that we want to keep the directories in the database for seven days. But your change caused them to still show up in the recent projects picker (where they will then fail to open). I don't think that is a good behavior.

/cc @ojpro

@ojpro
Copy link
Copy Markdown
Contributor Author

ojpro commented Mar 23, 2026

Hey @maxbrunsfeld

Okay. I will make it show the projects on the picker only if they exist.

@injust
Copy link
Copy Markdown
Contributor

injust commented Mar 25, 2026

But your change caused them to still show up in the recent projects picker (where they will then fail to open)

The behaviour actually seems weirder than that. I deleted a project, restarted Zed, and opened that project from the picker. Zed opened it as an unsaved file in my current workspace.

Agree that non-existent projects should just be hidden.

@ojpro
Copy link
Copy Markdown
Contributor Author

ojpro commented Mar 28, 2026

Hey @maxbrunsfeld , @ConradIrwin

I have updated the logic to hide nonexisting workspaces from the picker if it within the grace period, instead of it being an empty file

#52638

@injust
Copy link
Copy Markdown
Contributor

injust commented Apr 3, 2026

If you open a workspace, then close it and delete it from disk, restarting Zed will cause this error:

ERROR [worktree] root path could not be canonicalized: canonicalizing "~/foo": No such file or directory (os error 2)

And it seems like Zed does not restart cleanly -- previously open workspaces are not reopened.

@ojpro
Copy link
Copy Markdown
Contributor Author

ojpro commented Apr 3, 2026

unable to produce the error

Cap.2026-04-03.at.22.16.44.mp4

@injust
Copy link
Copy Markdown
Contributor

injust commented Apr 3, 2026

Hmm, I couldn't reproduce it again. Not sure if it's directly related then.

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 first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent deletion of inaccessible project

6 participants