Skip to content

Ship a reusable browser ownership coordinator (currently only in the example app) #38

Description

@lucas-barake

packages/local-browser exports ReplicaClient, ReplicaOwner (the RPC handler layer), SessionManager, Presence, BrowserReplica, BrowserSqlite (index.ts) - but NO reusable tab/worker ownership coordinator. The election/handoff/takeover logic that decides which tab owns the durable replica lives entirely in the test-browser example apps; a consumer building a multi-tab app must hand-roll it.

For a package that documents browser ownership as a feature, the coordinator is the load-bearing piece and it is not shipped. The confirmed correctness defects in that hand-rolled logic (stranded tabs on takeover, wrong health-check target, leaked sessions - filed separately) are exactly what a well-tested shipped coordinator would prevent.

Direction: extract a reusable, tested ownership coordinator (Web Locks or leader-election over BroadcastChannel/SharedWorker) into packages/local-browser/src with an explicit Layer, covering election, takeover, handoff to existing tabs, DB-worker liveness, and session cleanup on tab close.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions