Repository navigation
feat(id-web): wire the IndexedDB store adapter as the production draft store (#16808) - #16810
Merged
Merged
Conversation
…t store (#16808) First wiring slice for #14774 slice 4 (offline drafts): pkgs/id/web now imports the port-contract-v2 IndexedDB adapter from pkgs/id/browser and puts it to work as the editor draft store. - New src/draft-store.ts: DraftStore over the adapter (drafts namespace, one atomic commitBatch per write under a fresh operation ID), plus draftSyncDecision — a draft may sync only over the server version it was written against; otherwise it conflicts and is kept. - main.ts: a failed save (server error or network failure) persists the edited doc as a local draft; a successful save clears it; at editor open a stored draft is synced through the normal /api/save path when its base version is still current. All draft operations are best-effort and can never break editing or saving. The service worker stays a cache and never sees a draft. - tsconfig: rootDir widened to the pkgs/id parent so the cross-package adapter import typechecks (noEmit; bun does the bundling). Tests: draft-store.test.ts (6 tests, in-memory port) pins the record, dedupe, listing, and sync-decision semantics. Typecheck clean.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This was referenced Nov 29, 2026
Merged
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.
Refs #16808, #14774 (slice 4), #13918.
What this is
The first production-wiring slice for the IndexedDB store adapter. The adapter (
pkgs/id/browser, port contract v2) was prototype-only;pkgs/id/webnever imported it, so a failed editor save lost the edited document. Now the web product chooses this store, as the adapter header anticipated.pkgs/id/web/src/draft-store.ts(new):DraftStoreover the adapter — one draft per document name in thedraftsnamespace, every write a single atomiccommitBatchunder a fresh operation ID (retries dedupe through the port contract). PlusdraftSyncDecision: a draft may sync only over the server version it was written against; otherwise it conflicts and is kept (the design record: conflicts surface in the store layer, never as silent overwrites).main.ts: failed saves (server error / network failure) persist the edited doc as a local draft; a successful save clears it; at editor open, a stored draft is synced through the normal/api/savepath when its base version is still current, and kept on conflict or failure. Every draft operation is best-effort and cannot break editing or saving. The service worker stays a cache and never sees a draft.tsconfig.json:rootDirwidened to thepkgs/idparent so the cross-package import typechecks (noEmit; bun does the bundling).Verification
draft-store.test.ts: 6 tests against an in-memory port with the adapter's batch shape — record round-trip, replace/clear, per-write operation IDs, ordered listing with malformed values skipped, parse validation, and the sync-decision oracle. All pass.tsc --noEmitonpkgs/id/web: clean.Remainder on #16808
Draft restore is sync-through-save only; a conflicted draft is kept and logged but has no resolution UI yet, and the browser conformance suite does not yet run against the web wiring. #14774 slice 4 stays open until #16808 completes.
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-29T13:51:24Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch/workspace/github-work/w0647-l17", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch/workspace/github-work/w0647-l17", "repo": "developing-today/code", "branch": "xaltha/16808-idb-web-wiring", "sha": "05673de17ea2c0078c1ca9357a7183a468148378" }, "auth_subject": "xaltha", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.