Repository navigation
Conversation
…s with the page On first visits the banner's paragraph out-sizes the landing H1 at 360, 412 and 430px, and because ConsentBanner rendered nothing until the post-hydration consent effect, it became the final LCP entry about 1.9s after FCP on a throttled phone. The banner now renders during SSR and the first client render, marked data-consent-banner="pending". A rule in globals.css hides that pending copy unless <html> carries data-consent-undecided. A small inline script right after the banner sets the attribute only when resolveConsent() would return null (no GPC/DNT signal, no stored choice), and only once the banner's web font is ready, so the banner never paints in the fallback face and then reflows at the swap. It stays fixed and keeps zero CLS. The buttons work before hydration: the script records a click and hides the banner, and ConsentBanner applies it through setConsent() when React takes over, so every write still goes through one place. Returning, GPC/DNT and no-JS visitors never paint the banner. Tests: an int spec holds the inline script to resolveConsent() across 90 visitor shapes and pins the font wait and the click hand-off. consent.e2e covers the pre-hydration banner and click, the hidden copy for decided and GPC visitors, and no-JS visitors. The axe specs wait for the hydrated banner. contributing.mdx records the new rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (9)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: Ducksss/payload-components/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe consent banner is now included in static HTML and revealed by an inline script when consent is undecided. Pre-hydration choices are queued and applied after hydration. Integration and end-to-end tests cover reveal conditions, choice handoff, and hydrated-banner checks. ChangesConsent Banner Lifecycle
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
actor Visitor
participant Browser
participant consentBannerRevealScript
participant ConsentBanner
participant setConsent
Visitor->>Browser: Clicks the decline button
Browser->>consentBannerRevealScript: Dispatches the click event
consentBannerRevealScript->>Browser: Queues denied and hides the banner
Browser->>ConsentBanner: Hydrates the component
ConsentBanner->>ConsentBanner: Reads the queued choice
ConsentBanner->>setConsent: Applies denied
Merge Risk: ⚪ Minimal · up to The consent banner now ships in static HTML and is revealed only for undecided visitors. Choices made before hydration are applied afterward. No concrete merge-blocking risk was identified. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to A consent choice recorded before hydration can overwrite a later opt-out from another tab, allowing consent-gated tracking to resume. The impact is limited to the visitor’s browser, and active browser privacy signals still block tracking. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 7 files. (2 skipped: 2 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolve the move of tests/e2e/consent.ts to tests/e2e/support/consent.ts from #592: carry this branch's expectConsentBannerReady helper and its expect/Page imports onto the moved file, and point the a11y, templates-a11y, and consent specs at the new path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Superseded by #598. Tightening the banner's description keeps the H1 as the mobile LCP element, so LCP equals first paint: 1.36–1.47 s at 360–430 px on a throttled-phone profile. That beats the ~2.6 s here, and it needs neither the inline reveal script nor the duplicated consent-read logic. The branch stays up for reference, and the measurement method from this PR was reused. |
…bile LCP (#598) On a first visit at 360-430px, the consent banner's description paragraph could out-size the landing H1. Because the banner paints after hydration, it then became the final LCP entry, about 3.4s on a throttled phone. Since #583 the H1 is opaque from first paint. A tighter description keeps the banner below the H1's area, so LCP stays at first contentful paint. The new copy keeps all four disclosures: which tools, why, what Decline does, and what runs regardless. It replaces the static-HTML banner approach in #590, which reached about 2.6s with 576 added lines. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Follow-up to the finding in #583 (issue #523). On a first visit to the landing page, the consent banner's description
<p>was the final LCP entry at 360, 412 and 430px. Its LCP area is slightly larger than the H1's there, andConsentBannerrendered nothing until the post-hydration consent effect, so on a throttled phone it painted about 1.9s after FCP.This PR puts the banner in the static HTML so it no longer waits for hydration:
ConsentBanneralso renders during SSR and the first client render, while consent is still unread (undefined). That copy is markeddata-consent-banner="pending". Once React reads consent, behaviour is unchanged:nullfor a stored choice or a privacy signal, the live banner otherwise.globals.csshides the pending copy unless<html>carriesdata-consent-undecided. A late, failed or missing script can only delay the banner; it can never flash it at someone who already chose. Visitors without JavaScript never see it.resolveConsent()would returnnull: no GPC/DNT signal and no stored choice. It first waits for the banner's web font (immediately if it is already loaded), so the banner never paints in the fallback face and reflows at the swap. It reads storage but never writes it.ConsentBannerapplies the choice throughsetConsent()when React takes over, so every write still goes through one place. If the bundle never arrives, the banner can still be dismissed, and nothing is stored.No copy, layout, role, label or DOM-order change. The banner stays fixed and keeps zero CLS.
First-visit LCP at 360/412/430px drops by about 0.7s on a Lighthouse-like throttled phone (3.36–3.39s → 2.63–2.67s on the final commit, on
mainand on #583), with CLS unchanged at every width. Returning visitors are unchanged.Two decisions for the maintainer
i18n:checkgates stay green with it.consentBannerRevealScriptif you'd rather take the LCP.Options evaluated
text-xs(12/16px) gets the paragraph under the H1 at every widthWhy layout alone can't fix it: a paragraph's LCP area is roughly its widest line × line count × line height. Changing width or padding just reflows the text into more, shorter lines (or fewer, longer ones). Only the font size, the line height or the text itself moves the area. B and C also only change which element is largest. On
mainwithout #583, the faded H1 isn't an LCP candidate at all, so a smaller banner would still be the late LCP entry there. A works with or without #583.Measurements
Method. Production builds (
E2E_PORT=<port> pnpm build:e2e), each served by its ownnext startand loaded side by side:main(ac916f5)mainEach load used Playwright 1.62.1 and Chromium 151.0.7922.34, with one cold browser context per load, and the build order rotated every iteration. The profile approximated Lighthouse mobile: 4× CPU, 150 ms RTT, 1.6 Mbps down / 750 Kbps up, DPR 1.75, a mobile UA and touch, at viewports 360×800, 390×844, 412×823 and 430×932. Analytics origins were blocked through CDP.
Buffered
PerformanceObservers forlargest-contentful-paint,paintandlayout-shiftwere installed by an init script. The final LCP entry is reported with the region its element belongs to. "First visit" means a clean profile; "returning visitor" meanslocalStorage.pc_consent = 'denied'was set by an init script before load. Δ is the median of per-iteration paired differences, with a bootstrap 95% CI.Final commit (6 paired iterations, 192 loads, 0 console errors, run while the machine was busier, so absolute times sit about 0.2s above the run below):
main→ this PR, first visit (banner shown)<p><p><p>main→ this PR, returning visitor (pc_consentstored)#583 → #583 + this PR, first visit (banner shown)
<p><p><p>#583 → #583 + this PR, returning visitor (
pc_consentstored)This PR vs variant A1 (12 paired iterations on #583, first visits; 480 loads). This run used the revision just before the pre-hydration click hand-off. At load time that hand-off only attaches one listener, and the final-commit run above reproduces the same deltas. One load was dropped: a JS chunk failed with
net::ERR_NETWORK_CHANGED, the host's network changing, so that page never hydrated.Why the font wait costs time on this profile. At 412px the 94 KB document finishes at 1.94s, and Geist (68 KB) and Geist Mono (70 KB, also preloaded) both finish at about 2.2–2.4s. FCP is at ~1.2s and the banner's own bytes arrive before it, so A1 can paint at FCP but only in the fallback face.
Side effect, observed but not a goal. First-visit FCP is ~90 ms earlier with this PR (1,170 vs 1,262 ms, 12-iteration run), so at 390px on #583, where the H1 is LCP, LCP improves by ~80 ms too. Returning visitors, whose script exits early, show no change. My unverified guess is that
document.fonts.load()during parsing starts Geist's font-display timer before the first layout.Options B and C: the paragraph's text area against the H1's (Range-based probe on the live DOM, reduced motion; Chrome's LCP size for the banner runs ~2% above this probe, the H1's ~0.5%):
text-xs(12/16px) belowsmleading-snug(19.25px)p-3Width sweep, 320–767px in 1px steps:
Candidate copy for your review:
Both candidates keep all four disclosures: which tools, why, what Decline does, and what runs regardless.
Tighter rewrite, measured. A scratch build of #583 + this PR + the tighter copy, throttled, 4 paired iterations, first visits:
Accessibility and consent semantics
regionlabelled by its title), accessible names, focus styles and DOM position (last in<body>), and stillposition: fixed.setConsent()applies it when React runs. GPC/DNT visitors and stored choices never see the banner, and neither do visitors without JavaScript, who have nothing to consent to.a11y.e2eandtemplates-a11y.e2estill run without consent. They now wait for the hydrated banner (expectConsentBannerReady), because a visible banner no longer implies hydration./docshydration recovery. Onmain,/docspages throw React fix(privacy,test): expire every parent cookie domain, correct two stale test claims #418 (fixed by frontend(fix): give Fumadocs the public pathname so docs pages hydrate #585). React's recovery re-renders the root, which clears attributes on<html>. Sampled every animation frame, the banner still went straight from pending to live with no hidden frame, in 6 of 6 throttled runs and 2 unthrottled ones.Tradeoffs
<body>.resolveConsent()'s read logic as a string.tests/int/consent-reveal.int.spec.tsruns both against the same stubbed browser for 90 visitor shapes, and also pins the font wait, the font-failure fallbacks and the click hand-off.Test plan
pnpm lint,pnpm format:check,pnpm i18n:check,pnpm exec tsc --noEmitpnpm run test:int: 894 passed, 1 skipped, across 65 files. The newtests/int/consent-reveal.int.spec.ts(100 tests) was mutation-checked: dropping the GPC check fails 6 parity cases, and dropping the font wait fails the wait test.E2E_PORT=3182 PLAYWRIGHT_SERVER_MODE=production pnpm test:e2ewith consent, a11y, frontend, templates-a11y and webkit-landing: 251 passed, 1 skipped (the Linux-only visual baseline). After the last test edit,consent.e2ewas re-run: 14/14.consent.e2e: 13/14. The one failure, "withdrawing deletes the GA cookies the opt-in created", fails the same way onmain(ac916f5) in dev mode, so it is not from this PR. The_gavalues it finds are real GA-issued ones, becausemain's suite still loads the real gtag.js; frontend(fix): keep GA4 on the production hosts and the e2e suite offline #586 stubs it. It passes in production mode.release-gate(the full e2e run, including visual baselines). Not run locally. The banner never appears in the visual specs, which either grant consent or render chrome-free previews, and every CSS chunk except theglobals.cssone is byte-identical tomain.Interactions with open PRs
globals.css, in different hunks; this commit cherry-picks cleanly onto frontend(fix): let the hero H1 rise without fading so it counts as LCP #583, and both stacks are measured above.tests/e2e/consent.tsandconsent.e2e.spec.ts. Whichever merges second keeps both sides (mountGoogleTagOfflineplusexpectConsentBannerReady). The new tests here assert nothing about GA.'unsafe-inline'for script elements, and it uses no inline event-handler attributes, soscript-src-attr 'none'is fine./docsfix(privacy,test): expire every parent cookie domain, correct two stale test claims #418 described above.Refs #523
🤖 Generated with Claude Code
Summary by CodeRabbit