feat(admin): add IndexedDB offline cache and optimistic mutation sync#1156
Closed
bhubbard wants to merge 19 commits into
Closed
feat(admin): add IndexedDB offline cache and optimistic mutation sync#1156bhubbard wants to merge 19 commits into
bhubbard wants to merge 19 commits into
Conversation
… (Phases 3 & 4) - Optimistic delete/update helpers for instant UI feedback with rollback on error - Background sync manager with visibility-aware polling (pauses when tab hidden) - Multi-tab cache coordination via BroadcastChannel - Sync status indicator in header (shows syncing/offline/error states) - "Clear Local Cache" button in General Settings - Convert content/media delete, publish/unpublish to optimistic mutations - Convert menus and sections to use optimistic delete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CacheProvider calls useQueryClient(), so it needs QueryClientProvider as an ancestor. The reversed nesting caused the dashboard to hang on load. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 tests across 6 test files covering: - db.ts: database setup, schema creation, connection lifecycle - cache-store.ts: CRUD operations, TTL expiry, pruning, index queries - cache-warmup.ts: singleton pre-loading from IndexedDB - broadcast.ts: BroadcastChannel multi-tab coordination - sync.ts: background sync manager lifecycle and status - optimistic-mutation.ts: optimistic delete/update/rollback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 5169ebf The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Scope checkThis PR changes 5,206 lines across 32 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
Contributor
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
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.
What does this PR do?
This PR implements a robust offline caching and synchronization layer in the Admin UI using IndexedDB. It enables instant page rendering by serving cached data as
placeholderDatabefore fresh data resolves from the network. It also introduces multi-tab cache invalidation coordination, offline background sync, and resilient optimistic mutations that automatically roll back on error.Specifically, this includes:
db.ts,cache-store.ts) for caching singletons, detail records, and list content, with pre-warmup.useCachedQueryhook that falls back to the cache instantly and refreshes from the network in the background.optimisticDelete,optimisticUpdate,optimisticListItemUpdate) to immediately update the local query and IndexedDB states, handling query rollbacks on failure.BroadcastChannel-based communication to invalidate and sync cache stores across multiple open browser tabs.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.Note: If you are going to publish these changes, please run
pnpm changesetlocally before opening the PR to generate the changeset file.AI-generated code disclosure