incremental collaboration sync with targeted bootstrap#1081
Open
incremental collaboration sync with targeted bootstrap#1081
Conversation
b95f4aa to
fff5e76
Compare
495dbf5 to
359fa23
Compare
4d12410 to
b1c380a
Compare
Merged
d665eb6 to
abe90f6
Compare
5b07050 to
d819a0c
Compare
aa9ffb8 to
5e63350
Compare
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
5e63350 to
619af97
Compare
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.
Main Code Changes
This PR changes the collaboration sync path so we stop treating every edit like a full-scene replacement.
src/utils/syncSceneData.tsThis is the diff/merge layer. It selects only the elements whose versions changed for outbound websocket updates, and it merges incoming remote element updates incrementally into the current scene.
src/hooks/useSync.tsThis is the persistence and broadcast scheduler. It lets the designated syncer own persisted scene sync, and it runs server/websocket sync from the latest settled scene snapshot instead of an earlier intermediate state.
src/hooks/useCollaboration.tsThis is the room bootstrap path. A newly joined client requests a targeted full-scene init (
SCENE_INIT_REQUEST->SCENE_INIT) instead of relying on room-wide full-scene rebroadcasts. Full-scene replacement is still kept for bootstrap, recovery, and explicit replacement paths.In Plain Terms
Proof / Safety
tests/integration/syncSceneData.spec.mjs: changed-element-only selection, new-element incremental send, remote version merge without downgrade, remote-only sync-marker advance, and "unsent local edits only" after remote merges.tests/integration/useSyncScheduling.spec.tsx: trailing-edge sync uses the settled scene snapshot, and readiness transitions reschedule pending work instead of flushing stale intermediate state.tests/integration/socket.spec.mjsandtests/integration/multinode-redis.spec.mjs: direct scene bootstrap reaches only the targeted socket, including across nodes.playwright/e2e/collaboration.spec.tsasserts direct bootstrap on join and one-elementSCENE_UPDATEdelivery during a real two-session collaboration flow.Benchmark
This branch now includes a rerunnable full-stack benchmark instead of a helper-only microbench:
npm run bench:incremental-syncnpm run bench:incremental-sync -- --scenario planning-flow --mutation selection-dragnpm run bench:incremental-sync -- --output-json tools/benchmarks/incremental-sync-results.jsontools/benchmarks/runIncrementalSyncBenchmark.mjsplaywright/bench/incremental-sync-benchmark.spec.tsplaywright/support/incrementalSyncBenchmarkFixtures.ts,playwright/support/incrementalSyncBenchmarkHooks.tsWhat it does:
PUT /apps/whiteboard/{fileId}save pathSCENE_UPDATEpayloadsLocal output on April 2, 2026 (default 3x3 matrix,
scale=1,runs=1):Across the full 3x3 matrix:
84.27%to99.66%898 msto1429 ms535 msto578 ms537 msto579 msDependency and prerequisite CI updates for this work are tracked separately in #1116.