fix: eliminate FOUC on cookie accept and custom font load#4999
Open
woohyeokk-choi wants to merge 1 commit intofastrepl:mainfrom
Open
fix: eliminate FOUC on cookie accept and custom font load#4999woohyeokk-choi wants to merge 1 commit intofastrepl:mainfrom
woohyeokk-choi wants to merge 1 commit intofastrepl:mainfrom
Conversation
Remove the isInitialized state from PostHogProvider so the wrapper type stays stable (always PostHogReactProvider in prod) and React never unmounts/remounts children when analytics consent is given. Verified safe against posthog-js v1.367.0 source: all capture/identify calls are no-ops before init() via the __loaded guard. Add font-display: swap to all @font-face rules so custom fonts (Redaction, SF Pro) swap in without blocking render. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
👷 Deploy request for hyprnote pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for char-cli-web canceled.
|
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.
Summary
isInitializedstate fromPostHogProviderso the React wrapper type stays stable (PostHogReactProviderin prod with an API key). Previously, accepting cookie consent triggered aFragment → PostHogReactProviderwrapper swap that unmounted and remounted the entire page, causing a brief flash of unstyled content.font-display: swapto all@font-facerules (Redaction, SF Pro) so custom fonts swap in without blocking render.Root cause
PostHogProviderconditionally rendered<>{children}</>or<PostHogReactProvider>based on anisInitializedstate that started asfalse. On consent accept, React saw a component type change and remounted all children — visible as FOUC.Safety verification
Verified against
posthog-jsv1.367.0 source: allcapture()/identify()calls are silent no-ops beforeinit()via the!this.__loadedguard. RenderingPostHogReactProviderwith an uninitialized client sets no cookies, makes no network requests, and queues no events.Test plan
🤖 Generated with Claude Code
Note
Low Risk
Low risk UI/perf changes: adjusts PostHog wrapper rendering and font loading behavior, with limited blast radius beyond analytics initialization timing.
Overview
Prevents a full subtree remount (and resulting FOUC) when analytics consent is toggled by making
PostHogProvideralways renderPostHogReactProviderin production when an API key is present, while guardingposthog.init()to run only once viadidInitRef.Improves perceived loading by adding
font-display: swapto all custom@font-facedeclarations so text renders immediately with fallback fonts and swaps when Redaction/SF Pro are ready.Reviewed by Cursor Bugbot for commit 5258d01. Bugbot is set up for automated code reviews on this repo. Configure here.