Repository navigation
Closed
Description
Phase 6 of the octane/data RFC (#2362): one store per account, shared by every tab of compatible builds.
Where things stand
Phases 1–5 have landed:
- contracts, the store and SSR hydration;
- views, pages and forms;
- the encrypted persistent cache and the durable write journal;
- realtime feeds (feat(data): realtime feeds that keep loaded reads current #2506, feat(data): WebSocket and broker feed listeners, and feed cursors across restarts #2524, feat(data): carry feed positions in a server render's seed #2530).
Today each tab opens its own createDataStore. So two tabs of one account each load the same reads, hold their own feed connections, and keep their own copy of the write journal. They share only what the persistent cache and the journal partition hold, and that sharing is not coordinated.
Goal
A SharedWorker owns the account's store across tabs. Each tab renders read-only snapshots from it and sends its writes to it. One load, one feed connection and one rollback then serve every tab, and a write journaled in one tab is never recovered twice.
Parts
- Shared owner. The worker holds reads, the cache, feed connections and the journal. Tabs subscribe to snapshots and dispatch validated writes.
useRead,useReadState,usePages,useFeedanduseFormkeep their current behavior in both bindings, including synchronous snapshots for hydration. - Compatibility handshake. Tabs share a worker only when their build's contracts and protocol match. A tab on an incompatible build keeps its own store and never reads the worker's state.
- Account fencing. Every snapshot and reply carries the account generation. After an account switch, or while the device is locked, a tab that was frozen shows nothing until it has read the current account decision. Late replies for a retired generation are dropped.
- Fallback and crash recovery. Where SharedWorker is unavailable, each tab keeps its own store, as today. A tab or worker crash does not lose a journaled write, does not send one twice, and does not reveal another account's data.
Acceptance (from the RFC)
- Two compatible builds share one read and observe the same rollback.
- Freeze a tab, switch accounts while it is locked, time out the acknowledgement, and crash the initiator and the worker. On resume, the tab reveals data only after reading the durable account decision.
- An incompatible build falls back to its own store with no access to the shared one.
- The same scenarios pass in the Octane and React bindings.
Open design questions
To settle in a short design note before code:
- Ownership split: what the worker owns, and what stays in the tab. For example: view evaluation, optimistic projections, form drafts and focus.
- Snapshot protocol: whole snapshots or patches per read, and how a tab keeps
getSnapshotsynchronous across the worker boundary, during hydration in particular. - Compatibility: what "compatible build" means. One option is a hash of contract names, schema shapes and protocol version.
- The server render's seed: how it reaches the worker when the worker already holds newer values.
- Testing: how to run SharedWorker scenarios in CI. Browser tests are likely, with a fallback-only path under jsdom.
- Bundle cost: a tab that uses the worker should not also ship the full store.
Metadata
Metadata
Assignees
Labels
No labels
Activity
trueadm commentedon Nov 12, 2026
Status: none of the cross-tab work here has started yet. The PRs linked from this issue (#2540, #2541, #2542, #2545, #2546, #2547 and #2548) are correctness fixes to the phases that have already landed: write lifetime, refresh ordering, recovery durability, feed disconnects, seed snapshots, form identity and read keys. They aren't the shared-worker owner, the handshake or account fencing described above. Each one has review feedback posted. #2541 currently adds a request per write in apps with a feed, which is why Shelf's e2e fails on it.
trueadm commentedon Nov 18, 2026
Phase 6 is complete on main. It landed in #2559 (owner/replica protocol), #2560 (SharedWorker host and the
dataWorkerplugin option), #2572 (account fencing), #2583 (compatibility handshake, fallback and crash recovery), #2594 and #2625 (the owner as the only writer of the cache and journal, and settling writes in flight after a crash) and #2629 (reconciling the server's seed across tabs, with the shared-tab test also run on the React page). Later fixes are in #2940, #2941 and #2997. The acceptance cases have tests: the Shelf e2e covers the frozen-tab account switch, anddata-owner.test.tscovers freeze, resume, handshake and crash. The design is indocs/data-cross-tab-plan.md.