Repository navigation
Ink written before a save survives the file changing on disk (#273) - #279
Merged
Merged
Conversation
Since 2.10.0 the notebook view is not plain text to Obsidian (#246), so a modify event while the view had unsaved ink replaced the notebook with the file: the newest strokes vanished and, with the history cleared, undo could not bring them back. Obsidian's loadFileInternal also reads lastSavedData only after its awaited read, so a save starting meanwhile made the view's own previous save look like a change from elsewhere. A reread of a text this view loaded or wrote is now skipped (history kept), and a real change from elsewhere is merged three ways, by id, with the unsaved ink (src/model/reload-merge.ts). The diagnostics export and the debug HUD count what happened (diskReloads). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A copy of the notebook arriving late from another device made ink this device had already saved look erased over there, and the merge dropped it. It also did so with nothing unsaved here, and for a page with no unsaved changes, which was taken whole from the file. - Anything this device has that the file lacks is kept, saved or not, and saved back. Price: an erase made on another device while this one holds the notebook open comes back. - Pages are looked inside even when unchanged here, and a list the file stores as absent (no pictures) counts as empty, not as removed. - Two devices that counted on from the same highest id gave different new strokes one id; the merge kept only this device's. Both are kept now, the other renumbered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks Oskar, this landed in #286 as a merge, so your commit is in main as it was. On top of it:
|
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.
Closes #273.
Cause (proven in the real-Obsidian rig with Obsidian 1.15.1; not yet seen on an iPad)
2.10.0's #246 fix set
isPlaintext = falseon the notebook view. Obsidian 1.15.1'sTextFileView.loadFileInternal(read fromobsidian-1.15.1.asar) runs on everymodifyof the open file:Before, the text was merged and then held. Now it is a plain replace. FineNotes keeps the view dirty for a long time: the write-hold puts saves off while the pen writes, then the background encode runs. Any
modifyin that window swaps the notebook for the file, which drops the newest strokes.InkSurface.setDocumentclears the history, so undo cannot bring them back. That matches the report.What fires the
modifyon the reporter's iPad is unproven. It can be:lastSavedDatais read after the awaited read, and the mobile adapter queues reads and writes, so a save that starts during the read makes the view's own previous save look like an outside change.Repro in the rig, build without the fix: stroke A, wait for the save, stroke B, then append a line to the file from outside → the notebook holds only A, and undo is empty. With the fix: every stroke is kept, the appended text is kept,
diskReloads.merged = 1, and the file equals the view after the next save.Fix
src/model/reload-merge.ts(pure):OwnTextsremembers the last three texts this view loaded or wrote.mergeReload(base, local, remote)is a three-way merge by id on the stored form.InkView.loadViewData, on a reread of the same file:diskReloads: {own, merged, carried, replaced}.disk=own…/merged…+…/replaced….Ruled out from the code: pen rejoin's
History.withdraw, Scribble to erase and joined-page mirrors. None of them changed since 2.8.x.Tested
tests/model/reload-merge.test.ts(13 cases) and 4 new view cases intests/view/ink-view-file.test.ts. The first view case fails on the old code.Nothing visible changed, so there is no review page.
🤖 Generated with Claude Code