Repository navigation
Prime own-echo baseline on node hydration to stop false conflict toasts (#1586) - #1587
Merged
mstomar125 merged 1 commit intoJul 9, 2026
Merged
Conversation
The skip-while-editing guard raises a "Your edit conflicted with a remote change" version-mismatch notification whenever a database broadcast for an actively-edited node is not recognised as this client's own echo. Recognition depends on lastPersistedContent, which was only populated after the first local edit. So a node's first daemon echo after the WatchNodes subscription opens (the daemon streaming the node's current state) had no baseline and was misclassified as a foreign write, firing a spurious toast on effectively every edit of a freshly loaded node. Prime lastPersistedContent with the server-confirmed content whenever a node is accepted from the daemon broadcast or hydrated from the backend — the setNode and batchSetNodes accept paths, gated on shouldMarkAsPersisted (true iff the content equals the backend's). The first echo of unchanged content now matches and stays silent; a genuinely different foreign write still fails the equality check and correctly raises the conflict. The guarded, actively-edited early return is deliberately left un-primed so it can never adopt a foreign write as the baseline. Add regression tests that drive the real hydration path with no __test_ backdoor: a load-echo of a backend-hydrated node raises no notification, and a real foreign write after priming still does. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closed
6 tasks
Contributor
Author
|
APPROVE Verified against
CI green ( |
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
Editing a freshly-loaded node in a single-writer session reliably fired a "Your edit conflicted with a remote change" toast even with no other writer. This fixes the false positive at its root.
Root cause
setNode's skip-while-editing guard raises aversion-mismatchconflict notification whenever adatabase-source broadcast for an actively-edited node is not recognised as this client's own echo. Recognition (isPlausibleOwnEcho) compares the incoming content againstlastPersistedContent, which was only populated after the first local edit. So a node's first daemon echo after theWatchNodessubscription opens — the daemon streaming the node's current (unchanged) state — had no baseline, was misclassified as a foreign write, and fired a spurious toast. The function's own doc comment already flagged this "no last-sent record ⇒ reports false for all broadcasts, including legitimate own-echoes after load" trade-off; in practice it fired on effectively every edit of a loaded node.Fix
Prime
lastPersistedContentwith the server-confirmed content whenever a node is accepted from the daemon broadcast or hydrated from the backend — thesetNodeandbatchSetNodesaccept paths (initial tree load goes throughbatchSetNodes), gated onshouldMarkAsPersisted(true iff the content equals the backend's). Factored into a singleprimeOwnEchoBaseline()helper so the rationale lives in one place.On the hypothesised broadcast-vs-persistence race
Investigated and dismissed for a node's own edits:
lastPersistedContent.set()on the persistence path runs synchronously right before theUpdateNodeRPC, which strictly precedes the daemon's echo — so a node's ownC1echo always findslastPersistedContent = C1. The false positives came from unprimed (never-locally-edited) nodes, which this change addresses.Tests
Added two regression tests that drive the real hydration path (no
__test_setLastPersistedContentbackdoor):does NOT notify on a load-echo of a backend-hydrated node (real path, no backdoor)still notifies on a genuine foreign write after real-path priming (no backdoor)Verification:
shared-node-store-skip-while-editing: 20/20 pass (18 existing + 2 new; existing foreign-write/own-echo/dedup tests unchanged).shared-node-storesuites: 251/251.bun run --cwd packages/desktop-app quality:fix: eslint 0 errors, svelte-check 0 errors/0 warnings.Acceptance criteria
quality:fixclean; no new frontend test failuresCloses #1586