Skip to content

fix(ui): a signed-in visitor gets one navigation on public pages (#1190) - #1196

Merged
frankbria merged 2 commits into
mainfrom
fix/1190-one-nav
Nov 9, 2026
Merged

frankbria merged 2 commits into
mainfrom
fix/1190-one-nav

Conversation

@frankbria

Copy link
Copy Markdown
Owner

Closes #1190.

What changed

  • components/AppShell.tsx: AppShellProvider marks the signed-in shell. app/layout.tsx wraps children with it in the signed-in branch only.
  • components/PublicNav.tsx is now a client component that renders nothing inside the shell. A signed-in visitor on /pricing, /security or /how-it-works gets the app's sidebar and sheet tabs, not a second logo with "Sign in / Start free". Anonymous visitors see the same public header as before.

Verification

  • Unit: PublicNav inside AppShellProvider renders no Public navigation and no Sign in link. The existing public-page tests (rendered outside the shell) are unchanged and pass.
  • e2e (public-trust-pages.spec.ts, @smoke): signed in, each of the three pages shows exactly one logo, no Public nav and no Sign in link. With the fix stashed it fails (Received: 2 logos). With it, the full chromium smoke passes 48/48.
  • tsc clean; eslint 66; crap.sh passes (all new bodies cc 1).

Review

Review chain: APPROVE. MINOR 1 (write if (…) return null instead of the lookup): declined. The repo's CRAP rule keeps branches out of JSX-returning components, because Jest never records their return ( line (root CLAUDE.md, "JSX"). MINOR 2 (e2e brittleness): the spec was run red and green against the real page.

🤖 Generated with Claude Code

/pricing, /security and /how-it-works rendered the public header (logo,
Sign in, Start free) inside the app shell's sidebar and sheet tabs. The
layout's signed-in branch now marks the shell with AppShellProvider and
PublicNav renders nothing inside it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frankbria

Copy link
Copy Markdown
Owner Author

Third-party review (review chain)

I'll verify the key claims against the actual codebase before giving findings.I attempted to load a review skill and inspect the repo directly, but neither is available in this environment, so this is a static review of the diff itself. Here are my findings.

How the fix behaves (verifying the review checklist)

SSR/hydration: Sound. AppShellProvider is a client component with a constant value={true}, and it receives {children} as a prop (server-rendered content passed through a client wrapper — the correct pattern, no extra DOM). Client components are executed during SSR, so useContext(InAppShell) resolves to true on the server inside the signed-in branch and false (default) everywhere else — identical trees on both sides, no mismatch. The branch decision lives entirely in the async server root layout, so it can't drift between server and client.

Pages rendering PublicNav outside the provider while signed in: None exist by construction. The provider wraps {children} in the root layout's signed-in branch, so /pricing, /security, /how-it-works, /legal/*, and the landing page are all inside it when signed in. The only un-wrapped path is the anonymous branch, where PublicNav correctly renders. The legal layout and landing redirect both inherit the root layout, so they're covered.

Server-component boundaries: The conversion is safe in principle — server pages importing a now-client PublicNav is a legal direction, and lib/publicLinks is plain data. This is the one thing I couldn't verify without repo access: PublicNav imports Logo and Button, and a client component may only import client/shared modules. If Logo uses server-only APIs the build fails loudly, so this resolves itself at build time — but it's worth a next build confirmation.

E2E failure modes: The new spec's assertions are logically right, but two things to confirm (neither shown in the diff):

  1. COMPANY is used in the new spec block, but no import hunk appears — if it wasn't already imported in public-trust-pages.spec.ts, the spec fails at compile. Likely already there (trust-page assertions plausibly reference it), but verify.
  2. getByRole('img', { name: COMPANY.serviceName }) toHaveCount(1) assumes the app shell's sidebar logo is an <img> with exactly that accessible name and that nothing else on these pages exposes that role/name. If the sidebar logo is a text/SVG mark, this test fails even though the product behavior is correct.

Anonymous path: Unchanged — default context value false, PublicNavBar renders as before.

Findings

CRITICAL: None.

MAJOR: None confirmed in the diff.

MINOR:

  1. PublicNav's dispatch via const view = { true: null, false: <PublicNavBar /> }; return view[\${useInAppShell()}`]is functionally correct but needlessly obfuscated — an earlyif (useInAppShell()) return null` is clearer, cheaper to read during review, and doesn't build both branches' JSX map on every render. Not blocking.
  2. E2E brittleness per above (logo img role/name assumption, COMPANY import) — verify before merge; these are test-only risks.
  3. The context approach means every public page now silently depends on the root layout's signed-in branch to suppress its header. That's the intended centralized behavior and is documented in CLAUDE.md, but it's implicit coupling — the doc update included in the diff mitigates this well.

Verdict

The fix is architecturally correct: the provider/children pattern avoids DOM and hydration issues, the suppression is centralized and total (no signed-in page can leak the public header), the anonymous path is untouched, CLAUDE.md and unit/e2e guards are updated. Remaining risks are verifiable at build/test time rather than design flaws.

APPROVE

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T04:34:01.155271Z
We couldn’t complete this review. Comment @codex review to try again.
aaf0e73 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review: one navigation for signed-in visitors on public pages (#1190)

The approach is sound. AppShellProvider wraps children only in the session ? … branch of layout.tsx, so anonymous visitors keep PublicNav. A context flag is a good fit because it avoids per-page session checks and keeps the public pages static.

Bugs / risks

  • Hydration and flash: none expected. The context value is fixed at render and the server decides which branch renders, so server and client agree.
  • Nested pages: PublicNav is now a client component that hides itself when it is under the provider. Any future page that renders PublicNav inside the signed-in shell (for example a legal page opened while signed in) will lose its header. That is intended here, but worth a line in the CLAUDE.md note that the hiding is by design for all public pages.
  • Duplicate logo/landmarks: the e2e asserts getByRole('img', { name: COMPANY.serviceName }) has count 1. That is a fragile proxy, because it breaks if the sidebar logo ever gets a different label or the footer adds a logo. Consider asserting only on the Public navigation and the Sign in link, which are the real regressions.

Style / conventions

  • const view = { true: null, false: <PublicNavBar /> }; view[\${useInAppShell()}`]follows the repo's CRAP/JSX lookup convention, so it fits. It builds a JSX element on every render even whennull is chosen, which is trivial. Calling the hook on its own line (const inShell = useInAppShell()`) would read more clearly than calling it inside the template literal.
  • Making PublicNav 'use client' pulls Logo, Button and NAV_LINKS into the client bundle for the public pages that were previously server-rendered. This is a small cost. The alternative is to keep PublicNav as a server component and put the hiding in a thin client wrapper, but the current approach is simpler.
  • AppShell.tsx is named for the shell, but it only exports a flag provider. InAppShellProvider or AppShellContext.tsx would describe it better. This is minor.

Tests

  • The unit test covers the in-shell case, and the existing test covers the default case. Neither checks that the provider is actually mounted in layout.tsx. The e2e @smoke covers that for /pricing, /security and /how-it-works, which is good.
  • The e2e does not cover / (landing) or /legal/*, which also render PublicNav. Landing redirects signed-in users, so skipping it is fine, but the legal pages are worth adding to the path list.
  • The CLAUDE.md says to break the thing a new spec tests once before trusting it. Confirm that removing the provider makes the e2e fail.

Security / performance

No concerns. The change is presentational, and middleware and auth are untouched.

Overall this is a clean, small fix. The points above are non-blocking.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Third Party Review — Kimi

✅ Third Party Review: no defects found.

Verified against the checked-out code, not just the diff:

  • AppShellProvider wraps children only in the session branch of app/layout.tsx (line 91); the anonymous branch is untouched, so no signed-in page can leak the public header and no anonymous page can lose it.
  • The view[\${useInAppShell()}`]dispatch is total: the context iscreateContext(false)`, strictly boolean, both keys covered — no undefined-render path.
  • E2e concerns from earlier review rounds resolve: COMPANY is already imported in public-trust-pages.spec.ts (line 3), and Logo is a span role="img" named COMPANY.serviceName rendered once by the sidebar (Sidebar.tsx:202) and never by SiteFooter, so the toHaveCount(1) assertion is sound and was demonstrated red/green.
  • The 'use client' conversion of PublicNav is safe: all five consumers import it as a leaf with plain-data dependencies only.

Model: k3[1m]

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Reviewer failover

  • Codex: ⚠️ failed (failure) for a reason other than quota — investigate the job run
  • Kimi: reviewed
  • glm-5.2: not run (no secret, or an earlier reviewer finished)

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review of #1196

The approach is small and clean: a context flag set in the signed-in branch of the layout, with PublicNav stepping aside inside it. The hook is called unconditionally, and the unit and e2e tests exercise the change.

Bugs / risks

  • Lint cap: the PR description says "eslint 66", but root CLAUDE.md caps eslint . --max-warnings 64, and the cap only ratchets down. If 66 is the real count, CI Success will fail on lint. If main was already at 66, the cap is stale. Please confirm the count against main and make sure this PR adds no warnings.
  • Hydration and SSR: PublicNav is now a client component. The provider sits in the server layout's signed-in branch, so the server-rendered HTML should already omit the nav for signed-in users. Please check there is no flash of the public header on first paint. The e2e test only asserts after load.
  • Footer: SiteFooter is not gated. If signed-in users should see only one footer too, that is a follow-up. If not, a line in the docs would help.

Code quality

  • The lookup keyed on a template string of useInAppShell() is hard to read. I understand it follows the CRAP/JSX rule in CLAUDE.md. A short comment saying why would help the next reader, or a named const inShell = useInAppShell() before the lookup.

Tests

  • The unit test checks that the nav is absent inside the provider, and the existing tests cover presence outside it, so both directions are covered.
  • The e2e assertions can fail, and you ran it red and green. Good.
  • Optional: add an anonymous-visitor assertion for the same three pages, so a provider placed too widely in the layout is caught at e2e level too.

Security / performance

  • No concerns. This is presentational only, and middleware still gates access. The cost is one tiny client component.

Docs

  • The apps/frontend/CLAUDE.md update states the rule and its guard, which matches the repo conventions.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Third Party Review — Kimi

✅ Third Party Review: no defects found.

Verified against the checked-out code, not just the diff:

  • The view[\${useInAppShell()}`]lookup incomponents/PublicNav.tsxcan only produce"true"/"false"keys (boolean template-literal type), so it never returnsundefined` from render.
  • AppShellProvider wraps children only in the signed-in branch of app/layout.tsx; context reaches PublicNav through the server-component page tree (same mechanism as the existing SessionProvider). The layout awaits auth(), and none of the public pages force static rendering, so the nav is omitted at SSR for signed-in users — no hydration mismatch path.
  • All five PublicNav consumers (pricing, legal layout, landing, how-it-works, security) sit under the provider when signed in; anonymous renders hit the default false and still show the nav.
  • The e2e assertions hold: authenticatedPage exists in e2e/fixtures/index.ts, exactly one role="img" logo remains (the sidebar's), and the sidebar's "Sign out" cannot match the "Sign in" link query.

Model: k3[1m]

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Reviewer failover

  • Codex: ⚠️ failed (failure) for a reason other than quota — investigate the job run
  • Kimi: reviewed
  • glm-5.2: not run (no secret, or an earlier reviewer finished)

@frankbria
frankbria merged commit e6187ff into main Nov 9, 2026
17 checks passed
@frankbria
frankbria deleted the fix/1190-one-nav branch November 9, 2026 05:17
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.

[P3.67] [ui] Signed-in visitors see public pages (/pricing, /security, /how-it-works) inside the app shell with two navigations

1 participant