You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Choosing Save in the unsaved-changes prompt deletes a new untitled note #23688
Create a new untitled markdown note and type some text.
Close its tab without saving.
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.
Activity