Skip to content

Choosing Save in the unsaved-changes prompt deletes a new untitled note #23688

Closed

Description

@brennanb2025

What happens

  1. Create a new untitled markdown note and type some text.
  2. Close its tab without saving.
  3. In the unsaved-changes prompt, choose Save.

Actual: the note's file is deleted from disk and the typed text is lost.
Expected: the note is saved and kept.

The opposite choice is inverted too: Don't Save on the same kind of note leaves an empty untitled.md behind.

Reproduced in the main window of a folder workspace and in the floating panel on a dev build. The same code path is on current main (verified by reading it), but it has not yet been reproduced on a release build.

Why

  • handleSaveAndClose in src/renderer/src/components/editor/editor-autosave-controller.ts saves the draft, which clears the draft and the dirty flag, and then calls closeFile.
  • closeFile runs the untitled-note cleanup. shouldDeleteUntouchedUntitledFile in src/renderer/src/store/slices/editor/tabs/untitled-file-cleanup.ts deletes any file that is untitled, not dirty, has no draft, and does not have deleteUntouchedOnClose: false.
  • A note that was just saved matches all of those. Nothing on the save path clears isUntitled or sets deleteUntouchedOnClose: false. Only renaming the note clears isUntitled, and only notes created from a template set the flag.
  • Don't Save keeps the draft, so the cleanup skips the note and the empty file survives.

Suggested direction

Fix it in the untitled-note lifecycle rather than in one close path: once a note has been saved, it is no longer "untouched" and must never be cleaned up on close. Patching only handleSaveAndClose would leave other close paths exposed.

Also decide what Don't Save should do for a never-saved untitled note. Most likely it should remove the empty file, as closing an untouched note already does.

Acceptance

  • Save in the prompt keeps the note and its text on disk.
  • Don't Save on a never-saved untitled note leaves no stray empty file.
  • Covered for both local and SSH/remote workspaces, since the cleanup deletes through the runtime file client.
  • A test that fails if the fix is reverted.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. self-assigned this
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions