a tool for shared writing and social publishing forked from leaflet.pub/leaflet

split mirror readiness from sync-engine initialization

The mirror tracked the sync engine's "initialized" key by latching a boolean off the watch diff stream, and useMirrorQuery gated on it. That conflated two separate questions and made a transient wrong diff permanent: state derived from deltas cannot correct itself, so one bad del froze every consumer on the initialFacts fallback until the next pull. Split them. The mirror now exposes `populated` — whether the watch has delivered its first diff, which with initialValuesInFirstDiff carries every key already in the store. It is set by a diff's arrival, never from its contents, so no diff can unset it. Keeping it on the mirror preserves the property that the buckets and readiness land in the same callback, which a bare subscription would race. Whether the store holds real data is answered by reading "initialized" through useSubscribe, which re-queries on invalidation and therefore self-heals — the same pattern useEntity already uses. The gate is now populated && initialized. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>


Author
Co-author Claude Opus 5 (1M context) Date Commit Parent d3639efb
+34 -20
3 changed files
+34 -20
3 changed files