Repository navigation
Coalesce Pro reconnect-replay node bursts into one render (frontend half of sync #188) - #1423
Conversation
…alf of sync #188) On reconnect the Pro daemon flushes a caught-up batch of node events as one burst (sync #194). The incoming-event listener applied them one at a time — each node:created/updated does an async getNode + setNode → one re-render per node. When sync is active (proSync.isPro), collect the burst's node ids over a short window (~16ms), fetch them together, then apply them in a synchronous setNode loop so Svelte coalesces the reactive updates into a single render. Deletes still apply immediately (a queued update for a since-deleted node resolves to null and is skipped, so the delete wins). Gated on proSync.isPro — reconnect replay is a Pro-only flow, so the community build never enters this path and its per-event behavior is byte-for-byte unchanged. Tests: a Pro burst defers then applies every node in one pass; the community path still applies each event immediately. Frontend half of NodeSpaceAI/nodespace-sync#188 (pairs with sync PR #194). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
REQUEST CHANGES The coalescing approach is sound and the free-user gating is correct ( The PR says: "a queued update for a since-deleted node resolves to null and is skipped, so the delete wins." That only holds if
This is precisely the failure class in the freshly-filed sync#193 ("node delete dropped under concurrent edit, deleted node kept on peer"), and this PR opens a new window for it inside the reconnect-replay burst — the exact scenario (interleaved deletes + upserts) the coalescer is built for. Fix (one line): in the pendingNodeIds.delete(event.payload.id);
sharedNodeStore.deleteNode(event.payload.id, { type: 'database', reason: 'domain-event' }, true);That closes the larger pre-flush window. A narrower residual remains — a delete landing during the Minor (non-blocking): Tests are otherwise good (deferral + one-pass apply, community-immediate path). Re-request once the delete eviction lands. |
The coalescer claimed a delete during the window wins, but node:deleted didn't evict the queued re-fetch — so the flush's getNode could re-add a just-deleted node and resurrect it (the sync#193 failure class, reopened inside the burst). - node:deleted now calls cancelPendingNodeFetch(id): removes the id from pendingNodeIds, and if a flush is mid-fetch, tombstones it so the apply loop skips it. Closes both the pre-flush window and the during-Promise.all window. - resetNodeFetchCoalescer() on (re)init clears a stale in-flight timer/state so a prior listener registration can't fire into fresh state (the non-blocking note). - Test: an update queued then deleted within the window stays deleted. Suite 3873 (+1); eslint + svelte-check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Addressed the delete-wins finding (thanks — real bug). |
|
APPROVE (re-review @ f752871) Thorough fix — closes both windows from the prior review plus the teardown leak:
Free-user path stays inert: the coalescer sets are only populated on the Pro ( Good to merge with sync#194. Nice turnaround. |
…alf of sync #188) (#1423) * Coalesce Pro reconnect-replay node bursts into one render (frontend half of sync #188) On reconnect the Pro daemon flushes a caught-up batch of node events as one burst (sync #194). The incoming-event listener applied them one at a time — each node:created/updated does an async getNode + setNode → one re-render per node. When sync is active (proSync.isPro), collect the burst's node ids over a short window (~16ms), fetch them together, then apply them in a synchronous setNode loop so Svelte coalesces the reactive updates into a single render. Deletes still apply immediately (a queued update for a since-deleted node resolves to null and is skipped, so the delete wins). Gated on proSync.isPro — reconnect replay is a Pro-only flow, so the community build never enters this path and its per-event behavior is byte-for-byte unchanged. Tests: a Pro burst defers then applies every node in one pass; the community path still applies each event immediately. Frontend half of NodeSpaceAI/nodespace-sync#188 (pairs with sync PR #194). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Enforce delete-wins in the replay coalescer (address review on #1423) The coalescer claimed a delete during the window wins, but node:deleted didn't evict the queued re-fetch — so the flush's getNode could re-add a just-deleted node and resurrect it (the sync#193 failure class, reopened inside the burst). - node:deleted now calls cancelPendingNodeFetch(id): removes the id from pendingNodeIds, and if a flush is mid-fetch, tombstones it so the apply loop skips it. Closes both the pre-flush window and the during-Promise.all window. - resetNodeFetchCoalescer() on (re)init clears a stale in-flight timer/state so a prior listener registration can't fire into fresh state (the non-blocking note). - Test: an update queued then deleted within the window stays deleted. Suite 3873 (+1); eslint + svelte-check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Mayank Tomar <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Frontend half of NodeSpaceAI/nodespace-sync#188 (pairs with sync PR #194)
On reconnect the Pro daemon flushes a caught-up batch of node events as one burst (sync #194). The frontend listener (
tauri-sync-listener) applied them one at a time — eachnode:created/node:updateddoes an asyncgetNode+setNode→ one re-render per node.Change
When sync is active (
proSync.isPro), collect the burst's node ids over a short window (~16ms), fetch them together, then apply them in a synchronoussetNodeloop so Svelte coalesces the reactive updates into a single render. Deletes still apply immediately (a queued update for a since-deleted node resolves tonulland is skipped, so the delete wins).Free-user safety
Gated on
proSync.isPro. Reconnect replay is a Pro-only flow, so the community build never enters this path and its per-event behavior is byte-for-byte unchanged. Verified: the full frontend suite stays green and the existing per-event tests (which run with the default non-Pro tier) are untouched.Tests
node:createdevents is deferred (not applied synchronously) then applied in one pass (all nodes land after the window).proSync.tier !== 'pro') still applies each event immediately.eslint+svelte-checkclean.Together with sync #194 (daemon-side event coalescing), this closes the render-trickle described in #188.