Add offline queue utility and live-sync tests#8
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
liva | 43cac87 | Feb 08 2026, 09:30 PM |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43cac87b40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (remaining.length === 0) { | ||
| this.clear(); | ||
| } else { | ||
| this.writeQueue(remaining); |
There was a problem hiding this comment.
Preserve enqueues that happen during flush
Because flush snapshots the queue once at the start, then later writeQueue(remaining) overwrites storage, any updates enqueued while the async send loop is running are lost. This can happen if the UI continues to enqueue local edits while a reconnect flush is in progress, leading to dropped offline changes. Consider re-reading and merging at the end (or locking/enqueueing into a separate buffer) so concurrent enqueues are preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43cac87b40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (remaining.length === 0) { | ||
| this.clear(); | ||
| } else { | ||
| this.writeQueue(remaining); |
There was a problem hiding this comment.
Preserve enqueues that happen during flush
Because flush snapshots the queue once at the start, then later writeQueue(remaining) overwrites storage, any updates enqueued while the async send loop is running are lost. This can happen if the UI continues to enqueue local edits while a reconnect flush is in progress, leading to dropped offline changes. Consider re-reading and merging at the end (or locking/enqueueing into a separate buffer) so concurrent enqueues are preserved.
Useful? React with 👍 / 👎.
Motivation
Description
OfflineUpdateQueuewithOfflineStorageAdapterplusLocalStorageAdapterandMemoryStorageAdapterto persist ordered updates (libs/excalidraw-live-sync/src/offline/OfflineQueue.ts).src/index.tsso consumers can opt into offline-first behavior viaOfflineUpdateQueue.README.mdoutlining enqueueing, flush/merge, conflict guardrails and extensibility points.FakeWebSocketforLiveSyncClientand tests for queue semantics (tests/excalidraw-live-sync/LiveSyncClient.test.ts,tests/excalidraw-live-sync/OfflineQueue.test.ts).Testing
npm test -- tests/excalidraw-live-syncand all tests passed: 8 tests, 8 passed (including connection/connect, ephemeral filtering, reconnect scheduling, disconnect behavior, sendUpdate, and offline queue flush/failure cases).Codex Task