fix(journal): flush autosave on dismiss, import reload, and midnight rollover - #620
Draft
cursor[bot] wants to merge 4 commits into
Draft
fix(journal): flush autosave on dismiss, import reload, and midnight rollover#620cursor[bot] wants to merge 4 commits into
cursor[bot] wants to merge 4 commits into
Conversation
…ter import Past journal sheets and backgrounding could dismiss before the 400ms debounce completed, dropping unsaved edits. Settings import wrote on a background ModelContext while Today kept stale in-memory state; a queued autosave could overwrite imported rows for the current day. - persistImmediately on JournalScreen disappear and scene background - Import on the main ModelContext and post journalStoreDidChangeExternally - Reload Today from store with autosave epoch to drop stale debounced saves - Commit inline chip drafts before midnight day rollover Co-authored-by: Kip <kipyin@users.noreply.github.com>
Midnight or resume calls refreshTodayIfStale, which persisted then loaded today even when context.save() failed. That replaced in-memory edits with a new day and could discard unsaved work. Gate loadEntry on a successful persist and add a regression test. Co-authored-by: Kip <kipyin@users.noreply.github.com>
Co-authored-by: Kip <kipyin@users.noreply.github.com>
Commit pending chip drafts to the stale journal day before refreshTodayIfStale advances the ViewModel, then clear all inline editing UI state so stale indices cannot write into the new day. Adds a ViewModel test locking the commit-before-advance contract. Co-authored-by: Kip <kipyin@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-applies validated journal autosave fixes still missing from
main(same class as open PR #619). Three concrete data-loss paths:ModelContextwhile Today held stale in-memory state; a pending debounced autosave could overwrite freshly imported today row.Root cause
scenePhasebackground/inactive oronDisappear.Fix
persistImmediately()+commitActiveInlineChipEdit()on background/inactive and disappear.autosaveEpochinvalidates stale debounced saves;reloadFromStoreAfterExternalChangeafter import.modelContext+journalStoreDidChangeExternallynotification.Validation
swiftlint lint(Linux)JournalViewModelTests,JournalViewModelExternalReloadTestsgrace test)