Skip to content

feat(header): reflect signed-in state in the marketing header - #52

Merged
sweetmantech merged 3 commits into
mainfrom
feat/marketing-header-signed-in
Jul 28, 2026
Merged

feat(header): reflect signed-in state in the marketing header#52
sweetmantech merged 3 commits into
mainfrom
feat/marketing-header-signed-in

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

The marketing site header always rendered Sign In + Sign Up, even for a user who is already signed in. This makes the header reflect the signed-in state: once Privy resolves and the user is authenticated, the header shows a single "Open app" CTA (→ siteConfig.appUrl) instead of the sign-in/sign-up pair. The mobile menu's auth link swaps to "Open app" too.

Changes

  • components/layout/Header.tsx
    • Read auth state via usePrivy() (ready, authenticated).
    • signedIn = ready && authenticated — gated on ready so the server render and first client render both show the signed-out CTAs, avoiding a hydration mismatch; the header then swaps in place once Privy resolves.
    • Desktop: signed-in → one primary "Open app" pill; signed-out → existing Sign In (outline) + Sign Up (primary).
    • Mobile menu: the auth link reads "Open app" when signed in.
  • app/layout.tsx
    • Move <Header /> inside <PrivyAuthProvider> so the header can consume Privy context (it previously sat outside the provider). The provider is documented SSR-safe — it renders a plain context on the server — so pages stay statically prerenderable.

Achromatic chrome preserved (no new color); reuses the existing pill styles per DESIGN.md.

Verification

  • pnpm exec tsc --noEmit — clean for both changed files.
  • pnpm buildcompilation + TypeScript pass (✓ Compiled successfully, Running TypeScript ...).
  • Full static export could not complete locally: prerender throws Cannot initialize the Privy provider with an invalid Privy app ID because there is no real NEXT_PUBLIC_PRIVY_APP_ID secret in this environment (Privy rejects placeholder IDs at init). This is pre-existing and env-drivenPrivyAuthProvider already wraps every page on main, so any static page throws the identical error without the production secret; it is not introduced by this change. Vercel builds/previews with the real app id prerender normally.
  • Visual confirmation of the signed-in swap on a Vercel Preview (with the real Privy app id) recommended before merge.

Scope

Implements only the "marketing header signed-in state" slice of the P3 long tail in chat#1885. Explicitly out of scope (remaining P3 follow-ups): bash/skill tool components, and "Unknown artist" rows (needs song_artists ingestion).

Targets main. Part of chat#1885.

🤖 Generated with Claude Code


Summary by cubic

Update the marketing header to reflect the signed-in state and add logout. After @privy-io/react-auth resolves, show a single “Open app” CTA; provide logout on desktop and mobile.

  • New Features

    • Use useSignedIn (built on usePrivy ready/authenticated) to gate initial render, then swap to “Open app” → siteConfig.appUrl.
    • Logout: desktop icon-only button with accessible label/title, hidden on mobile (hidden sm:inline-flex); mobile menu adds a “Log out” row that closes the menu and calls logout().
  • Refactors

    • Extracted auth UI into HeaderAuthActions (desktop) and HeaderMobileAuthLinks (menu) with shared useSignedIn; Header no longer imports usePrivy or owns auth logic.
    • Wrapped <Header />, <Footer />, and ViewModeBar inside PrivyAuthProvider in app/layout.tsx so the header can consume Privy context (SSR-safe).

Written for commit eeade36. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added authentication-aware navigation in the header.
    • Signed-in users can open the app or log out directly from desktop and mobile menus.
    • Signed-out users continue to see Sign In and Sign Up options.
  • Bug Fixes

    • Improved authentication state handling to prevent incorrect initial header displays.

The marketing header always showed Sign In + Sign Up, even for a
signed-in user. Read Privy auth state (`usePrivy`) and, once resolved,
show a single "Open app" CTA instead. Gated on `ready` so the server and
first client render both show the signed-out CTAs (no hydration
mismatch), then swap in place.

Moves `<Header />` inside `<PrivyAuthProvider>` in the root layout so the
header can consume Privy context; the provider is SSR-safe (plain context
on the server) so pages stay statically prerenderable.

Refs chat#1885.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
marketing Ready Ready Preview Jul 28, 2026 2:32am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The root layout now provides Privy authentication context to shared layout components. The header uses Privy state to conditionally render desktop and mobile sign-in, sign-up, open-app, and logout actions.

Changes

Privy authentication layout

Layer / File(s) Summary
Provider wiring for shared layout
app/layout.tsx
PrivyAuthProvider now wraps Header, main content, Footer, and ViewModeBar.
Authentication-aware header actions
components/layout/Header.tsx
Header derives signed-in state after Privy is ready and conditionally renders authentication actions for desktop and mobile menus, including logout behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: sidneyswift

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: the marketing header now reflects the signed-in state.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/marketing-header-signed-in

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

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@sweetmantech

Copy link
Copy Markdown
Contributor Author

Preview verification — 2026-07-27

Preview: https://marketing-4bbca0fux-recoup.vercel.app — built from 5f0e1930 (PR head, sha-filtered deployment 5571473385, state success).

Results

# Check Expected Actual Result
1 Server-rendered HTML, signed out Sign In + Sign Up, no "Open app" exactly that — curl on the raw HTML returns 1× Sign In, 1× Sign Up, 0× Open app
2 After hydration, signed out unchanged still Sign In + Sign Up, both → https://chat.recoupable.dev
3 Signed in single Open app CTA Open apphttps://chat.recoupable.dev; both sign-out CTAs gone
4 Mobile menu variant Open app replaces Sign In DOM shows two nodes: the desktop CTA and the sm:hidden menu link, both reading Open app
5 Footer + ViewModeBar inside the widened Privy boundary render normally full footer (nav columns, socials, legal) + theme toggle render on every page checked
6 Privy modal on the marketing origin opens, brand-themed opens with the light-mode wordmark and email-only login

Signed out

marketing header signed out

Signed in

marketing header signed in — Open app

Row 1 is the one worth calling out: the ready && authenticated guard does what its comment claims. The server render and the first client render both produce the signed-out CTAs, so there's no hydration mismatch — the swap happens in place once Privy resolves.

How the signed-in state was reached (and the caveat that comes with it)

The marketing header has no login control of its own — it only links out to chat. The single login() trigger in the whole app is inside useCatalogValuation, so signing in on this origin required running the valuation flow.

I first tried the zero-side-effect route: reusing a browser context already authenticated against a chat preview. It stayed signed out. localStorage is origin-scoped and the two previews are unrelated domains (marketing-*.vercel.app vs chat-*.vercel.app), so no session carries over — even though both use the same preview Privy app (cmc52us2g…).

That means this preview cannot reproduce the production condition this PR actually targets: a session established on chat.recoupable.dev being read by recoupable.dev, which works only because they share a parent domain. What's verified here is that the component logic is correct given an authenticated Privy session on the same origin. The cross-subdomain half — the chat#1801 gap — still wants a confirmation on prod after merge: sign in at chat.recoupable.dev, then load recoupable.dev and check the header reads Open app.

To keep the forced valuation cheap I picked the smallest artist I could find — Sound of Fractures StemsDAO, 5 followers. The run returned $389 (range $267–$547) across 6 measured tracks, and it also confirms the flow still works end-to-end under the reparented provider.

Note on the app/layout.tsx reparenting

Header, Footer, and ViewModeBar all move inside PrivyAuthProvider. Row 5 covers the render check. Worth a reviewer's eye on prerendering specifically: PrivyAuthProvider's docstring says it "renders a plain context on the server, so pages stay statically prerenderable (chat#1798, chat#1814)" — that property is what makes this move safe, and it held on every page I loaded here, but it's the thing to watch if a future change makes the provider client-only.

The signed-in header shipped an entry point with no exit: marketing has
no logout anywhere (grep for logout/signout across the repo returned
zero), so a visitor who signs in through the valuation flow — the only
login trigger on the site — was stuck showing 'Open app' with no way to
sign out or switch accounts without going to chat.

Desktop gets an icon-only button matching the theme toggle, since the
header chrome is achromatic and text-free and 'Open app' should stay the
only CTA with weight. It carries aria-label and title because a bare
glyph has no accessible name. The mobile menu gets a labelled row
instead — an icon-only entry reads as decoration in a text list.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread components/layout/Header.tsx Outdated
Comment thread components/layout/Header.tsx Outdated
Sign Up
</Link>
</>
)}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OCP

  • actual: signed in button set defined in Header component inline
  • required: new component for logged in header button set

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in eeade36. The desktop button set now lives in components/layout/HeaderAuthActions.tsx — it owns its own auth state rather than taking a signedIn prop, so Header carries no auth logic at all: no usePrivy import, no signedIn, no branching. Adding another auth-dependent action now touches only that file, not the header shell.

The ready && authenticated guard moved to a shared useSignedIn() hook so it isn't duplicated across the desktop and mobile components.

Header went 134 → 98 lines.

Comment thread components/layout/Header.tsx Outdated
Comment on lines +142 to +153
{signedIn && (
<button
onClick={() => {
setMobileOpen(false);
void logout();
}}
className="flex w-full items-center gap-2 px-3 py-2.5 text-sm font-ui font-medium text-(--foreground)/70 sm:hidden"
>
<LogOut size={16} />
Log out
</button>
)}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OCP - new inline components / logic should be abstracted to a new component file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in eeade36. The mobile menu's auth rows are now components/layout/HeaderMobileAuthLinks.tsx, taking a single onNavigate callback to close the menu. Same pattern as the desktop counterpart — it resolves its own auth state, so the inline {signedIn && ...} logic is gone from Header.

Addresses review on #52.

OCP/SRP (sweetmantech): the signed-in and signed-out button sets were
branching inline inside Header, so every new auth-dependent action meant
editing the header shell. They now live in HeaderAuthActions (desktop)
and HeaderMobileAuthLinks (menu), each owning its own auth state via a
shared useSignedIn hook. Header carries no auth logic at all — it went
from 134 to 98 lines and no longer imports usePrivy.

P2 (cubic): the desktop log-out icon had no breakpoint class, so on
phone widths it rendered alongside the labelled menu row — two log-out
controls at once. It is now 'hidden sm:inline-flex', mirroring how
'Sign In' has always been hidden below sm in favour of its menu row.

useSignedIn also de-duplicates the 'ready && authenticated' guard, which
would otherwise be repeated in both components.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sweetmantech
sweetmantech merged commit e1a67c7 into main Jul 28, 2026
3 checks passed
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.

1 participant