Skip to content

workspace: Prompt to save dirty buffers when close would orphan them#55889

Merged
agu-z merged 2 commits into
mainfrom
prompt-before-orphaning-dirty-buffers
May 6, 2026
Merged

workspace: Prompt to save dirty buffers when close would orphan them#55889
agu-z merged 2 commits into
mainfrom
prompt-before-orphaning-dirty-buffers

Conversation

@agu-z
Copy link
Copy Markdown
Contributor

@agu-z agu-z commented May 6, 2026

The hot-exit shortcut in save_all_internal silently serializes dirty buffers instead of prompting. It assumes the workspace will still be reachable, but that's not true for ReplaceWindow, or for CloseWindow of an empty workspace on macOS — both detach the workspace and orphan its serialized buffers in the DB with no UI path back to them.

Only allow the shortcut when the workspace is actually recoverable (Quit, save_last_workspace, or has visible worktrees). Otherwise prompt.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #55726

Release Notes:

  • Fixed unsaved untitled buffers being silently lost when opening a file or project from an empty window

The hot-exit shortcut in `save_all_internal` silently serializes dirty
buffers to the editor DB instead of prompting. That assumes the
workspace will be reachable later — true for `Quit` and for workspaces
with worktrees (recoverable by path), but not for `ReplaceWindow` or
`CloseWindow` of an empty workspace on macOS, where the session binding
is removed and the serialized buffer is orphaned with no UI path back.

Now we only allow the shortcut when the workspace is actually
recoverable, and prompt otherwise.

Closes #55726
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 6, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 6, 2026
@agu-z agu-z force-pushed the prompt-before-orphaning-dirty-buffers branch from 62e7c20 to 043adc6 Compare May 6, 2026 14:14
On Linux/Windows, closing the last window sets `save_last_workspace`,
which preserves the session (same as `Quit`), so hot-exit is safe there.
@agu-z agu-z force-pushed the prompt-before-orphaning-dirty-buffers branch from 043adc6 to 165d596 Compare May 6, 2026 14:15
Copy link
Copy Markdown
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

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

has the desired effect on the issue

@agu-z agu-z added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 00d8d45 May 6, 2026
31 checks passed
@agu-z agu-z deleted the prompt-before-orphaning-dirty-buffers branch May 6, 2026 15:17
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening a file or project loses unsaved file

2 participants