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.
Local-first, dids, wasm + OPFS, flutter, iroh, dht #1148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Local-first, dids, wasm + OPFS, flutter, iroh, dht #1148
Changes from 1 commit
5e622fe64a1cd96fa444228ec9fc40638982c0ff1b4766c3353a5d65612e22936c494f0af475d5b85b420ce229956a0a452da27e7a60cef6c5f7c563724a8ea7262b6bf4aa8fc4e11d6508d0af4cc72439a3cc9582c925041ed23c66bca67fbea72ea1cf93420fb07a47bbe7badbbc6c0ee4501e20d0ecc2b513c4780afb981884cbcf51e45d38bfd38d077898325f6e83fa39d110524ac7c729bb052569f0a4f69538b953dbb23096a0f814d430c417aa0e467a7ca0b727a7a4b2017d052ba0d2e9cdee05fcc6e3567f665278b608336f8866864e88bc26cfa7801ceb2c8b195c25c19bd7bd1207dae7cb1f627651a156bb56a4b3ae3a177185460d06382e09d35dfe1e0a0cd9b9fa1241a7d891458e4562ab776e7abbd3ad7d275da73e516c0ae9b72b6bf1e13e6812cfe184d4ccea8602cdfe60db06ffa886dcc59a7b1bc1283141de4997003b55e5ee25dec20a9d6fe859666ce3dd1d532ed23e0d71cf6becd0c022fa44118a99b2d1bec92ea2b3a4e14eb4cab804998b7bed43aa96b3829c13afec1ac16b285a6d8264dbe83b4d64736d7169350c598cbea9a5573018767a59593e8ee9e0f5c1085d0e774f4f161cc0b64fd70849220e9d1f480a93ac8875d5d8ebba1994bd1355feada0f5e7ae6918e24470854656885bc6e7906d84cac2799b14d44469af13073be8881aab151e47b4f3029ef751e7ecb8f03e411295b821e3da3b25c1aa17ef178b87a1bcb01857164800174a5ad2dbc50299f36190080f816cd42872b83db1043d5c9f824c81f3b3f329a4f245d78b449839d67d0222f5996935b9e4718be34899c7a73e71d915f7ae520d286587ec23bb62be0ac57969767a7dc7eb54a7b3ff667bc064e5717427be2e8852faf29fe1c4652f58392416cdf6e81654e99abf567321e95d8db031b01f2327ee35e20d4a5e0ca7e8e68a6e406868c36722ab21e48c2fa82c9ddfd1107c7c875a58d26e927398dd749c6db6a9b2cf5ab8879aa2281d187dd771c258f62b32c44b1a2cbd6d44118aeb80a503338b9ab0e961d09ac47c01bb7b2c7b8c1c21f985691caacbf5be9f341abae32f39200a88e4e5e0cf2c3c232db13415495b17435a2758664e837062d4e69a2369390155957256024a866c547f6a81449c31da1650264f77a7d199553dfbd4fc5832a7677b3cace36c903ee3b11e7d0774342d4ddbc9fdae412befb3fa7d657b5a9feead098e35656f31File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Before: every WS handler had its own bespoke setup for "new state for a resource arrived": const resource = this.store.resources.get(subject) ?? this.store.getResourceLoading(subject); resource.importLoroUpdate(msg.loroBytes); if (msg.commitId) resource.setLastCommitValue(msg.commitId); resource.source = 'server-ws' (or 'ws-commit', or ...); resource.sourceTimestamp = Date.now(); resource.loading = false; // ad-hoc echo detection (only in UPDATE sub-push): const prevCommit = ...; const isEcho = isExisting && prevCommit === newCommit; if (!isEcho) { this.store.addResources(resource, { skipCommitCompare: true }); } this.checkForMissingBlobs(resource); 77 lines for \`Tag.UPDATE\`, 46 for \`Tag.SYNC_PUSH\`. Each branch remembered \`skipCommitCompare\` and \`sourceTimestamp\` differently, and the echo-detection logic only existed in the sub-push branch even though the same race exists everywhere. After: every ingress goes through the new \`Store.applyIncoming(change: IncomingChange)\`. The function performs subject normalisation, commit-id dedup (replaces the hand-rolled \`isEcho\` block), Loro/JSON-AD hydration, and routes to the existing \`addResource\` flow with \`skipCommitCompare\` always set (we already deduped at the top). \`IncomingChange.source\` is a small enum (\`'ws-pending-get' | 'ws-sub-push' | 'ws-sync-push' | 'ws-query-update' | 'http-fetch' | 'local-pre-push' | 'local-acked' | 'offline-replay'\`); a private mapping function projects it onto the existing \`ResourceSource\` field on \`Resource\` so consumers see no change. Migrated this commit: - \`Tag.UPDATE\` → \`applyIncoming\` (both pending-GET branch and sub-push branch). The 77-line block becomes ~30 lines. - \`Tag.SYNC_PUSH\` → \`applyIncoming\` (per-entry). The 46-line block becomes ~20 lines. Still to migrate (Phase 3 follow-ups): - \`Tag.QUERY_UPDATE\` (currently calls \`fetchResourceFromServer\` per added subject — that path stays). - HTTP fetch (\`Client.fetchResourceHTTP\`) — the JSON-AD ingress branch in \`applyIncoming\` is wired but not yet used. - Local commit pre-/post-POST \`addResources\` calls in \`Resource.pushCommits\`. - Offline replay path (\`Resource.applyPendingCommitsLocally\`). The remaining sites still use \`addResources({skipCommitCompare: true})\`. They keep working — \`addResource\` is unchanged. They'll collapse onto \`applyIncoming\` in subsequent commits, then \`addResource\` becomes a private helper of \`applyIncoming\`, then it's deleted. Validation: - \`pnpm test\` — 37/37 unit tests pass - \`pnpm test:integration\` — 6/6 integration tests pass - \`ATOMIC_TEST_CPU_THROTTLE=6 pnpm test-e2e\` against a 7-test flake set including multi-context — 7/7 pass Net diff for this commit: store.ts: +163 (mostly the new applyIncoming + types) websockets.ts: +40 -83 = −43 (UPDATE + SYNC_PUSH branches collapsed) The websockets.ts shrinkage is the visible part; the structural delta is "9 ingress paths with 4 echo-detection schemes" → "one ingress with one dedup". This is partial Phase 3 of UNIFIED_DATA_LAYER.md. Subsequent commits finish the migration and remove \`addResource\` / \`addResources\` from the public surface.Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing