Skip to content

Foundation + Instant Shell for IndexedDB Admin Caching - #82

Closed
bhubbard wants to merge 11 commits into
emdash-cms:mainfrom
bhubbard:indexedDB
Closed

bhubbard wants to merge 11 commits into
emdash-cms:mainfrom
bhubbard:indexedDB

Conversation

@bhubbard

@bhubbard bhubbard commented Apr 2, 2026

Copy link
Copy Markdown

What this achieves:

  • On repeat visits, the admin shell renders instantly (sidebar, header, navigation) from cached manifest data
  • The currentUser is also cached, so permission-dependent UI renders immediately
  • Background fetches update the cache transparently
  • If IndexedDB is unavailable (private browsing), everything degrades gracefully to standard useQuery

Next phases (not yet implemented):

  • Phase 2: Cache content lists, media, users, bylines, taxonomies, menus, sections
  • Phase 3: Optimistic mutations with conflict resolution
  • Phase 4: Delta sync, sync status indicator, "Clear cache" button

@changeset-bot

changeset-bot Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e97af39

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@bhubbard

bhubbard commented Apr 2, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Apr 2, 2026
@bhubbard

bhubbard commented Apr 2, 2026

Copy link
Copy Markdown
Author

recheck

bhubbard and others added 4 commits April 2, 2026 12:41
… (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 <[email protected]>
@bhubbard
bhubbard marked this pull request as draft April 2, 2026 22:28
bhubbard and others added 3 commits April 2, 2026 22:22
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 <[email protected]>
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 <[email protected]>
@bhubbard
bhubbard marked this pull request as ready for review April 3, 2026 05:43
@bhubbard

bhubbard commented Apr 3, 2026

Copy link
Copy Markdown
Author

All 4 phases from the plan are complete:

Phase 1: Foundation + Instant Shell ✅ — IDB schema, cache-store, useCachedQuery, warmup, CacheProvider
Phase 2: Entity Caching ✅ — All major list/detail views cached (content, media, menus, sections, taxonomies, bylines, users)
Phase 3: Optimistic Mutations ✅ — optimisticDelete, optimisticUpdate, optimisticListItemUpdate helpers, applied to content/media/menu/section deletes and publish/unpublish
Phase 4: Delta Sync + Polish ✅ — Background sync manager, multi-tab BroadcastChannel, sync indicator in header, "Clear Local Cache" in settings

@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@pkg-pr-new

pkg-pr-new Bot commented Apr 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@82

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@82

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@82

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@82

emdash

npm i https://pkg.pr.new/emdash@82

create-emdash

npm i https://pkg.pr.new/create-emdash@82

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@82

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@82

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@82

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@82

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@82

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@82

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@82

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@82

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@82

commit: e97af39

@BenjaminPrice

Copy link
Copy Markdown
Contributor

This is a large PR. Could you please update the PR description to reflect the state of the PR (all phases completed, as per your comment) and use the template provided?

https://github.com/emdash-cms/emdash/blob/main/.github/PULL_REQUEST_TEMPLATE.md

@ascorbic

Copy link
Copy Markdown
Member

This is a useful addition, but can you rebase it on the latest main and use the PR template. If you've used an agent you can just ask it to do that.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity.

If you're still working on this, please push an update or leave a comment.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants