feat(ui): dual-read/write libraries↔workspaces account-sync key (LIB-6 A5)#158
Merged
Conversation
…LIB-6) The account-sync blob carried the library list under the legacy wire key `workspaces`; LIB-5 renamed the values to Library[] but missed the key itself. Dual-write the list under BOTH `libraries` (new canonical) and `workspaces` (legacy) — always equal — and dual-read incoming blobs as `libraries ?? workspaces` (prefer new). An account server on either side of the rename now interoperates with no data loss: an old server storing the blob verbatim still exposes `workspaces` to old clients, and the new server mirrors both keys. Adds 4 interop tests (new↔new dual-write, new↔old-server fallback read, prefer-new when both present, old-write round-trip through a mirroring server). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
Author
|
Paired server half (open.book.pub): https://github.com/eliotlim/open.book.pub/pull/29 — the two coordinate but each is independently back-compatible. |
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.
Problem
AccountProvidersyncs the page-container roster to the account under the JSON keyworkspaces. The product-wide rename of that container noun to library (epic LIB) requires the sync key to becomelibraries. A hard rename would break settings sync during rollout: a new client writinglibrariesagainst a not-yet-deployed server (which still readsworkspaces) would silently drop the roster, and vice versa. The rename must land with zero data loss across any old/new client-server pairing.Solution
Dual-read/write back-compat in
packages/ui/src/providers/AccountProvider.tsx:libraries ?? workspaces— prefer the new canonical key, fall back to the legacy one so an old server (or old locally-stored blob) still hydrates.librariesandworkspacesso an old server that only readsworkspaceskeeps working, while a new server preferslibraries.The server half lives in the paired open.book.pub PR (
mirrorLibraryKeyscopies present→both on GET and PUT).Non-visual change — sync/persistence only.
Before / After
workspaceslibraries ?? workspacesworkspacesonlylibrariesandworkspacesworkspaces)librariesTest procedure
pnpm --filter @book.dev/ui run typecheck→ exit 0 (afterbuild:libsbuilds the@book.dev/sdkdist thatverifybuilds first; bare typecheck against a stale dist fails identically on untouchedmainand is unrelated to this change — none of those errors touchAccountProvider).pnpm --filter @book.dev/ui exec vitest run src/providers/__tests__/AccountProvider.test.tsx→ 13 pass / 0 fail (covers read-fallback and dual-write both directions).Operational notes
workspaces, so nothing breaks if the account deploy hasn't landed.