Skip to content

feat(id-web): wire the IndexedDB store adapter as the production draft store (#16808) - #16810

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/16808-idb-web-wiring
Nov 29, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/16808-idb-web-wiring

Conversation

@dezren39

@dezren39 dezren39 commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

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/web never 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): DraftStore over the adapter — one draft per document name in the drafts namespace, every write a single atomic commitBatch under a fresh operation ID (retries dedupe through the port contract). Plus draftSyncDecision: 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/save path 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: rootDir widened to the pkgs/id parent 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 --noEmit on pkgs/id/web: clean.
  • Full-diff read against the issue and the ID: service-worker offline / local-first web app — design and first slice #13918 record by the landing lane; a fleet-command run for the package suite is dispatched at this head as an aid.

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-bot with what you need.

…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.
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7d3edcc5-a09a-4fed-a1ad-22389d8ad30e
Commits

Reviewing files that changed from the base of the PR and between 8354544 and 05673de.

Files selected for processing: 4

  • pkgs/id/web/src/draft-store.test.ts
  • pkgs/id/web/src/draft-store.ts
  • pkgs/id/web/src/main.ts
  • pkgs/id/web/tsconfig.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant