Repository navigation
fix(desktop): archive unsaved edits instead of dropping a parked conflict #1451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
30427e6
9e2b52e
c486530
2bfe040
9f00d82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -506,6 +506,14 @@ export function createNoteSession(options: NoteSessionOptions): NoteSession { | |
| // reads the (now frozen) buffer, so pending edits persist to this | ||
| // session's path even after the UI moves on. | ||
| if (!discarded) { | ||
| if (conflict !== null && dirty && io.archiveUnsaved !== undefined) { | ||
| // A parked conflict pauses saves, so the flush below writes nothing | ||
| // and the buffer would die with the session. Keep it recoverable | ||
| // instead; the user chooses a side (or merges by hand) later. | ||
| void io.archiveUnsaved(path, header + buffer).catch((cause: unknown) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewed by GPT-6. [P1] Retain the buffer when archival fails. If the archive write rejects, for example because Please keep the archive snapshot owned by a recovery queue or another live owner until persistence succeeds. Surface a visible failure with retry/export recovery, and make teardown callers able to await preservation. Add a rejecting
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partly, in 9e2b52e. Done: a failed archive sets the session
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exit path is covered in 2bfe040, without a queue: a failed archive now rejects |
||
| console.error('failed to archive unsaved edits:', cause) | ||
| }) | ||
| } | ||
| void flush() | ||
| } | ||
| disposed = true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed by GPT-6.
[P1] Include parked-buffer archival in the awaited exit/background flush. Reproduce by editing a note, parking an external conflict, and pressing Cmd-Q without navigating away.
installQuitFlush()awaitsflushOpenDocuments(), which only callssession.flush().save()returns immediately for a parked conflict, so the app then confirms quit without ever calling this new archive hook. React cleanup does not run on that exit path. Closing a secondary note window has the same gap; iOS background flush also only callsflush().Please expose an awaited preservation operation through the existing flush lifecycle, with deduplication for unchanged buffers. Both navigation teardown and exit/background flushing must wait for the archive write. Add coverage that parks a conflict, calls the exit-facing flush without
dispose(), and verifies that it waits for archival.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and that path is the one in the user report. In 9e2b52e archival moves into
flush(): under a parked conflict it returnspreserve()instead of the no-op save chain, deduplicated on the buffer bytes, so ⌘Q, window close, and iOS backgrounding await it throughflushOpenDocuments(), anddispose()needs no special case. Test:flush archives a parked buffer once, without dispose (the quit path).