Skip to content

Precompute install-audience flag for the hero switcher#366

Merged
dferber90 merged 2 commits intomainfrom
ck/precompute-install-audience
Apr 18, 2026
Merged

Precompute install-audience flag for the hero switcher#366
dferber90 merged 2 commits intomainfrom
ck/precompute-install-audience

Conversation

@christopherkindl
Copy link
Copy Markdown
Contributor

@christopherkindl christopherkindl commented Apr 17, 2026

Summary

The home hero's "For humans / For agents" tab was held in useState, so every reload snapped back to the default tab. This PR models the tab as a precomputed flag like the other hero flags.

Changes

  • flags.ts — new `installAudienceFlag` (`'humans' | 'agents'`, cookie key `install-audience`, default `'agents'`), added to `rootFlags` so `generatePermutations` covers both variants (2× permutations, cheap).
  • `page.tsx` — awaits the flag alongside the others, publishes it via `FlagValues`, and renders the new `` in place of the inline client component. Removed the now-unused `CommandPrompt*` imports and `COMMAND_FOR_*` constants.
  • `install-command.tsx` (new) — client wrapper around `CommandPromptRoot`. On click: writes the cookie, sets an optimistic override, calls `router.refresh()` — same pattern as `FlagToggle`.

The home hero's "For humans / For agents" tab was tracked in React
state, so every reload snapped back to the default tab and broke the
"page is static without layout shift" promise. Model it as a
precomputed flag like the other hero flags:

- Add `installAudienceFlag` (`'humans' | 'agents'`, cookie key
  `install-audience`, default `'agents'`) and include it in
  `rootFlags` so `generatePermutations` covers both variants
- Read the flag on the server and publish it via `FlagValues`
- New `InstallCommand` client wrapper renders `CommandPromptRoot`
  with the server value and, on click, writes the cookie + calls
  `router.refresh()` (optimistic override pattern mirroring
  `FlagToggle`)

Result: the proxy's `precompute(rootFlags)` reads the cookie, rewrites
to the matching `[code]`, and SSR renders the correct tab from the
start — reloads stay on the user's choice with no client-only state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 17, 2026

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

Project Deployment Actions Updated (UTC)
flags-playground Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
flags-sdk-dev Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
flags-sdk-next-15 Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
flags-sdk-next-16 Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
flags-sdk-snippets Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
flags-sdk-sveltekit-snippets Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
shirt-shop Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am
shirt-shop-api Ready Ready Preview, Comment, Open in v0 Apr 18, 2026 0:20am

@dferber90 dferber90 merged commit 44ba55f into main Apr 18, 2026
19 checks passed
@dferber90 dferber90 deleted the ck/precompute-install-audience branch April 18, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants