Skip to content

Add offline queue utility and live-sync tests#8

Open
shivamd20 wants to merge 1 commit into
mainfrom
codex/fix-live-sync-engine-and-add-tests
Open

Add offline queue utility and live-sync tests#8
shivamd20 wants to merge 1 commit into
mainfrom
codex/fix-live-sync-engine-and-add-tests

Conversation

@shivamd20

Copy link
Copy Markdown
Owner

Motivation

  • The live-sync engine exhibited intermittent issues (duplicate elements, missed syncs), so groundwork for an offline-first approach and comprehensive tests were added to harden connection/reconnect and queuing behavior.

Description

  • Add an OfflineUpdateQueue with OfflineStorageAdapter plus LocalStorageAdapter and MemoryStorageAdapter to persist ordered updates (libs/excalidraw-live-sync/src/offline/OfflineQueue.ts).
  • Export the offline utility from the package by updating src/index.ts so consumers can opt into offline-first behavior via OfflineUpdateQueue.
  • Document a detailed offline-first sync plan in the package README.md outlining enqueueing, flush/merge, conflict guardrails and extensibility points.
  • Add unit tests for connection lifecycle and message handling using a FakeWebSocket for LiveSyncClient and tests for queue semantics (tests/excalidraw-live-sync/LiveSyncClient.test.ts, tests/excalidraw-live-sync/OfflineQueue.test.ts).

Testing

  • Ran the package tests with npm test -- tests/excalidraw-live-sync and 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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 8, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
liva 43cac87 Feb 08 2026, 09:30 PM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +85 to +88
if (remaining.length === 0) {
this.clear();
} else {
this.writeQueue(remaining);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +85 to +88
if (remaining.length === 0) {
this.clear();
} else {
this.writeQueue(remaining);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant