Skip to content

fix(docs): nav first paint - #52679

Merged
antlio merged 3 commits into
masterfrom
antlio/fix-docs-nav-first-paint
Nov 4, 2026
Merged

antlio merged 3 commits into
masterfrom
antlio/fix-docs-nav-first-paint

Conversation

@antlio

@antlio antlio commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem

Solution

  • changes the docs nav to show the server links on first paint, so most visitors do not wait for the flags
  • adds a cache of the experiment value from the last visit, so a returning visitor gets their variant at hydration
  • adds a head script that hides the nav only for visitors cached on option-1, so the control menu does not flash
  • fixes the nav swap when the posthog request fails, because the nav keeps the cached variant
  • fixes the stale option-1 cache after the flag is deleted, because the cache saves false when posthog returns no flag
  • changes the experiment exposure to wait for loaded flags, so a stale cached variant is never recorded

Review instructions

  1. open /docs/guides/auth on desktop and reload the page
  2. make sure that the top bar links and the sidebar nav show on first paint
  3. open /docs/guides/auth?docs-ia-mvp-v1=option-1 and make sure that the top bar shows "Develop and deploy" and "Run and manage"
  4. at a mobile width, open the menu and make sure that the menu sections show
  5. run pnpm --filter docs exec vitest run features/IaNav and make sure that all 18 tests pass

Checklist

Check all before review:

  • I have read CONTRIBUTING.md
  • If I wrote a new docs topic or edited an existing topic, I used the /write-the-docs or /edit-the-docs skill, which applies the docs style guide

@antlio antlio self-assigned this Nov 3, 2026
@antlio
antlio requested a review from a team as a code owner November 3, 2026 08:10
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
design-system Ready Ready Preview Nov 4, 2026 7:45am UTC
docs Ready Ready Preview, v0 Nov 4, 2026 7:45am UTC
kb Ready Ready Preview Nov 4, 2026 7:45am UTC
studio-self-hosted Ready Ready Preview Nov 4, 2026 7:45am UTC
studio-staging Ready Ready Preview Nov 4, 2026 7:45am UTC
ui-library Ready Ready Preview Nov 4, 2026 7:45am UTC
zone-www-dot-com Ready Ready Preview, v0 Nov 4, 2026 7:45am UTC
1 Skipped Deployment
Project Deployment Actions Updated
studio Ignored Ignored Nov 4, 2026 7:45am UTC

Request Review

@supabase

supabase Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The docs IA navigation now caches its variant in local storage, uses cached state for readiness, and applies a shared pending class to navigation elements. A head script sets the document’s IA navigation attribute when the cached value is option-1.

Changes: IA navigation first paint

Layer / File(s) Summary
Cache and resolve the IA variant
packages/common/constants/local-storage.ts, apps/docs/features/IaNav/useIaNavVariant.ts, apps/docs/features/IaNav/useIaNavVariant.test.ts, apps/docs/features/IaNav/useNavItems.test.ts
The IA flag now has a local-storage key. The variant hook uses cached state while flags load or are unavailable, updates the cache when flags load, and captures exposure only when flags are available and no valid URL override is present. Tests cover cached and loaded flag cases.
Bootstrap cached state and determine readiness
apps/docs/features/IaNav/constants.ts, apps/docs/features/IaNav/constants.test.ts, apps/docs/app/layout.tsx, apps/docs/features/IaNav/useIaNavReady.ts, apps/docs/features/IaNav/useIaNavReady.test.ts
The head script sets the document attribute when the cached value is option-1. The readiness hook now reports ready when a cached IA flag exists. Tests cover the cache script and readiness behavior.
Apply pending state to navigation items
apps/docs/features/IaNav/index.ts, apps/docs/components/Navigation/NavigationMenu/GlobalMobileMenu.tsx, apps/docs/components/Navigation/NavigationMenu/GlobalNavigationMenu.tsx, apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
The shared pending class is exported and applied to navigation elements when navigation is not ready. The global menu applies it to dropdown items and direct links rather than the root menu.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant IA_NAV_CACHE_SCRIPT
  participant useIaNavVariant
  participant useIaNavReady
  participant NavigationMenu
  Browser->>IA_NAV_CACHE_SCRIPT: Load head script
  IA_NAV_CACHE_SCRIPT->>Browser: Read local storage and set data-ia-nav for option-1
  useIaNavVariant->>Browser: Read cached IA flag
  useIaNavVariant->>Browser: Store loaded IA flag
  useIaNavReady->>useIaNavVariant: Read cached IA flag
  useIaNavReady->>NavigationMenu: Provide readiness state
  NavigationMenu->>Browser: Apply pending class when not ready
Loading

Possibly related PRs

  • supabase/supabase#52551: Implements the same docs navigation cache, readiness handling, head script, and pending class.
  • supabase/supabase#52191: Introduced IA navigation readiness and hidden-until-ready behavior that this change updates.
  • supabase/supabase#52049: Introduced IA flag selection and useNavItems, which the variant and readiness hooks use.

Suggested labels: documentation

Suggested reviewers: czenko

Merge Risk: Moderate · up to fffa9

Some returning visitors may retain obsolete navigation, and fallback tabs may not immediately observe cache changes from another tab.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(docs): nav first paint" names the main change. The PR makes the docs navigation render on first paint instead of waiting for feature flags after hydration, and the changed files (IaNav …
Description check Passed The description follows the template's Problem and Solution sections, and both are filled in with specific content. The Problem section explains that the docs nav experiment hides the top bar links an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(docs): nav first paint" names the main change. The PR makes the docs navigation render on first paint instead of waiting for feature flags after hydration, and the changed files (IaNav hooks, nav menu components, head script) match that aim. The title is short and uses the conventional prefix. It is brief, so it does not name the cache or the head script, but it does not need to cover every detail.

Full details: Description check

Explanation

The description follows the template's Problem and Solution sections, and both are filled in with specific content. The Problem section explains that the docs nav experiment hides the top bar links and sidebar until feature flags load, which adds up to a 1s wait after hydration. The Solution section lists the concrete changes: first-paint server links, a cached experiment value, a head script, a fallback for failed PostHog requests, a fix for stale option-1 caches, and exposure recorded only after flags load. The Review instructions section has a numbered procedure with URLs and a test command. The Checklist is present, with the CONTRIBUTING.md item checked. The docs style-guide item is unchecked, which is acceptable because the PR does not add a new docs topic or edit one. The Preview links section is an unfilled template comment, which is optional. The Additional context section is also an unfilled comment, which is optional.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 13 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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.

Share
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 03fb2d7 and 9feffd8.

Files selected for processing: 3
  • apps/docs/features/IaNav/useIaNavReady.test.ts
  • apps/docs/features/IaNav/useIaNavReady.ts
  • apps/docs/features/IaNav/useIaNavVariant.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@antlio antlio mentioned this pull request Nov 3, 2026
1 of 2 tasks

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@antlio
antlio force-pushed the antlio/fix-docs-nav-first-paint branch from 04c836f to 03fb2d7 Compare November 3, 2026 08:42

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread apps/docs/features/IaNav/constants.ts Resolved
@antlio
antlio force-pushed the antlio/fix-docs-nav-first-paint branch from 03fb2d7 to 9feffd8 Compare November 3, 2026 08:57

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@czenko czenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Comment thread apps/docs/features/IaNav/constants.ts Resolved
@antlio
antlio force-pushed the antlio/fix-docs-nav-first-paint branch from 9feffd8 to fffa99d Compare November 4, 2026 07:40
@antlio
antlio enabled auto-merge (squash) November 4, 2026 07:41
@antlio
antlio merged commit 2182a91 into master Nov 4, 2026
51 of 52 checks passed
@antlio
antlio deleted the antlio/fix-docs-nav-first-paint branch November 4, 2026 07:45
@alexisintech alexisintech mentioned this pull request Nov 5, 2026
1 of 2 tasks
czenko added a commit that referenced this pull request Nov 6, 2026
…52735)

Closes DOCS-1520

## Problem

The original PR was only client-side. This is adding server-side
integration.

The docs-nav evals fetch each page's HTML with no JavaScript and add
`?docs-ia-mvp-v1=option-1` to every request. The option-1 arm gets the
control navigation anyway.

Guide pages are statically generated, so the server can't read the query
parameter. `useIaNavVariant` reads the override from the URL after the
page loads, so the fetched HTML always has today's nav, hidden with an
`invisible` class.

The top nav dropdowns have a second gap. Their panels mount on the
client, so their links are not in the server HTML for either variant.
Every eval case starts at `/docs`, where those links are the only way
into the Option 1 groups.

## Solution

- **Rewrite option-1 requests:** `proxy.ts` sends `/docs` and guide
pages with `?docs-ia-mvp-v1=option-1` to `/docs/ia/option-1/…`. Pages
there render on the first request and are then cached, so nothing is
added to the build. Requests without the parameter, and `.md` requests,
are not rewritten.
- **Read the variant from the route:** `IaNavRouteProvider`, in the root
layout, reads the variant from the layout segments. `useIaNavVariant`
returns it on the server and records no PostHog exposure for it.
`useIaNavReady` is ready at once, so the nav has no `invisible` class.
- **Strip the route prefix:** on the server, `usePathname` returns the
rewritten path. The nav components, breadcrumbs, and `AiTools` use
`useDocsPathname`, which strips the `/ia/option-1` prefix.
- **Breadcrumbs follow the variant:** they resolve from the visitor's
nav config, not always today's.
- **Top nav subheads in the HTML:** a `<noscript>` block next to the top
nav lists the dropdown links for the visitor's variant, inside an
`sr-only` nav. Browsers with JavaScript ignore it.
- **No index for the route:** direct visits to `/docs/ia/option-1/…` get
`noindex`. Canonical URLs point to the real guide.

**Not changed:**

- **Reference pages:** they keep today's nav, even with the parameter.
- **Config pages:** the five generated config pages under `self-hosting`
and `local-development/cli` are not in the markdown manifest, so they
keep today's nav too.
- **Links:** they don't carry the query parameter, so a click in the
browser leaves the forced variant. This was already the case before this
PR.
- **Conflicts with #52679:** it changes the same hooks. Whichever PR
merges second needs a rebase.

## Review instructions

`grep -c` counts the lines of server HTML that contain the text. A count
of 1 or more means the text is in the HTML that an agent fetches without
JavaScript. A count of 0 means it is not.

1. Run `curl -s
"https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth/sessions?docs-ia-mvp-v1=option-1"
| grep -c "Run and manage"`. The count is 1 or more. "Run and manage" is
an Option 1 top nav label, so this checks that the parameter gets Option
1's nav from the server.
2. Run `curl -s
"https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth/sessions"
| grep -c "Run and manage"`. The count is 0. This checks that a request
without the parameter still gets today's nav.
3. Run `curl -s
"https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs?docs-ia-mvp-v1=option-1"
| grep -c "guides/platform/ssl-enforcement"`. The count is 1 or more.
The home page has no sidebar, and this link sits only in the "Run and
manage" dropdown, so this checks that the top nav subhead links are in
the server HTML.
4. Run `curl -s -o /dev/null -w "%{http_code}"
"https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth.md?docs-ia-mvp-v1=option-1"`.
It returns `200`. This checks that the markdown version still loads with
the parameter.
5. Open
[/docs/guides/auth](https://docs-git-docs-ia-option-1-server-render-supabase.vercel.app/docs/guides/auth)
in a browser and hover over the top nav. You see today's nav and
dropdowns.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants