persist flag state and boot from last-known values#1193
Open
bpapillon wants to merge 1 commit into
Open
Conversation
bpapillon
commented
Apr 30, 2026
dontlaugh
reviewed
Apr 30, 2026
| }); | ||
| }); | ||
|
|
||
| describe("Persistent flag state cache", () => { |
Contributor
There was a problem hiding this comment.
We'll need to break up this test file at some point.
c1ae3d5 to
77655cb
Compare
9a67ae5 to
2dfdc63
Compare
Hydrate this.checks/planChecks from the StoragePersister at construction and persist on every WS update so subsequent page loads can render with cached values instead of fallbacks while the network reconciles. On setContext, if the new context already has values in memory (e.g. just hydrated from storage), pre-resolve isPending and notify listeners synchronously rather than entering the pending state. In-memory remains the source of truth for reads — storage is a hydration source on boot and a durable mirror on writes. Resolution is still gated on setContext/identify; nothing is exposed without a context. New persistFlagState option (default true) opts out. LRU-capped at 10 contexts; storage failures degrade gracefully.
2dfdc63 to
949057e
Compare
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.
Adds a persistent, context-keyed cache for flag check results (and plan) on top of the existing
StoragePersisterinterface. For clients with a "pending" hook (e.g. schematic-react's useSchematicIsPending), the hook will resolve immediately if values are found in local storage rather than waiting for a response from the websocket connection, resulting in faster initial renders for subsequent loads.