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
shared-node-store: updateTaskNode()'s OCC direct-hydration path also needs the skip-while-editing guard #2072
The same unguarded direct-hydration pattern exists in updateTaskNode()
updateTaskNode()'s OCC-conflict catch handler (packages/desktop-app/src/lib/services/shared-node-store.svelte.ts, around line 2390 as of #2071) has the identical shape updateNode() had before #2071:
if(currentNode){this.nodesSet(nodeId,currentNode);this.versions.set(nodeId,currentNode.version??1);this.persistedNodeIds.add(nodeId);this.pendingUpdates.delete(nodeId);this.notifySubscribers(nodeId,currentNode,{type: 'database',reason: 'occ-resync'});}else{this.resyncNodeFromServer(nodeId).catch((resyncError)=>{log.error(`Failed to resync after OCC error for task node ${nodeId}:`,resyncError);});}
The direct-hydration branch (currentNode truthy) writes straight into the store via the guard-free nodesSet(), with no decideRemoteUpdate skip-while-editing check — same clobber class #2071 just closed for updateNode()'s sibling handler.
Fix
Apply the same fix #2071 applied to updateNode(): route the direct-hydration branch through decideRemoteUpdate with hasPending: false (same self-referential-race reasoning), skip the nodesSet/version overwrite when the decision says not to apply, but still mark the node persisted. Mirror #2071's structure and test pattern (see the OCC direct-hydration guard (#2068) block in shared-node-store-skip-while-editing.test.ts, adapted for the task-node path — likely needs store.updateTaskNode(...) + a mocked backendAdapter.updateTaskNode rejection instead of backendAdapter.updateNode).
Scope note
Kept out of #2068/#2071 to keep that PR's diff to the specific method the issue named. Genuine OCC conflicts on task-property updates (status/priority/due date drags, etc.) while a node is also being actively text-edited are a narrower window than the generic content-editing case, but the failure mode is identical: a daemon conflict response that embeds current_node can silently overwrite in-progress edits.
Note for whoever picks this up: #2069 (merged in #2076) added `SimplePersistenceCoordinator.isQueued(nodeId)` and the pattern of capturing `hadQueuedWrite` BEFORE calling `clearQueued(nodeId)` (which otherwise erases the evidence a second write was ever queued). `updateTaskNode()`'s OCC handler already computes `hadQueuedWrite` this way and passes it to its `resyncNodeFromServer` fallback call — when adding the `decideRemoteUpdate` guard to its direct-hydration branch here, reuse that same already-computed `hadQueuedWrite` for `hasPending` rather than hardcoding `false` or recomputing it, to avoid re-introducing the self-referential-hasPending bug #2069 fixed.
Fixed in #2089 — mirrors #2071's fix exactly, using `hadQueuedWrite` for `hasPending` (matching the current, more-evolved state of `updateNode()`'s branch, not the older hardcoded-`false` version from #2071's original diff).
While writing the regression tests I found a real behavioral nuance: `updateTaskNode()`'s catch handler unconditionally reverts to the pre-edit snapshot on ANY failure (OCC or not) before this guard runs, unlike `updateNode()`'s no-op-on-content rollback — so the guard here protects against the daemon's conflicting snapshot landing on the already-reverted state, not the specific optimistic edit surviving. That same unconditional rollback can also clobber a later queued write's result, a separate pre-existing bug filed as #2088 rather than folded into this PR.
Activity
Wire hadQueuedWrite into the OCC direct-hydration branch's hasPending…
shared-node-store: fix resyncNodeFromServer's direct-call hasPending …
mstomar125 commentedon Aug 14, 2026
Note for whoever picks this up: #2069 (merged in #2076) added `SimplePersistenceCoordinator.isQueued(nodeId)` and the pattern of capturing `hadQueuedWrite` BEFORE calling `clearQueued(nodeId)` (which otherwise erases the evidence a second write was ever queued). `updateTaskNode()`'s OCC handler already computes `hadQueuedWrite` this way and passes it to its `resyncNodeFromServer` fallback call — when adding the `decideRemoteUpdate` guard to its direct-hydration branch here, reuse that same already-computed `hadQueuedWrite` for `hasPending` rather than hardcoding `false` or recomputing it, to avoid re-introducing the self-referential-hasPending bug #2069 fixed.
mstomar125 commentedon Aug 14, 2026
Fixed in #2089 — mirrors #2071's fix exactly, using `hadQueuedWrite` for `hasPending` (matching the current, more-evolved state of `updateNode()`'s branch, not the older hardcoded-`false` version from #2071's original diff).
While writing the regression tests I found a real behavioral nuance: `updateTaskNode()`'s catch handler unconditionally reverts to the pre-edit snapshot on ANY failure (OCC or not) before this guard runs, unlike `updateNode()`'s no-op-on-content rollback — so the guard here protects against the daemon's conflicting snapshot landing on the already-reverted state, not the specific optimistic edit surviving. That same unconditional rollback can also clobber a later queued write's result, a separate pre-existing bug filed as #2088 rather than folded into this PR.
shared-node-store: apply skip-while-editing guard to updateTaskNode's…
shared-node-store: fix updateTaskNode()'s unconditional failure-rollb…