Skip to content

fix(auth): start a browser with no saved theme on dark on sign-in and the password pages too - #2453

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/auth-pages-dark-start
Nov 16, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/auth-pages-dark-start

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Please wait for the owner's decision before merging (see "Decision for the owner"): today's change also switches many existing users to dark the next time they see sign-in.

Summary

The owner saw in PostHog that a first-time visitor who lands on sign-in sees the light theme. Since #2280, only sign-up and onboarding start a new browser on dark, and many first visits land on sign-in.

  • On Ansvisor Cloud, sign-in, forgot password and reset password now start a browser with no saved theme on dark, as sign-up already does.
  • A browser that already has a saved theme never changes. Self-hosted is unchanged.

Accepted trade-off: the theme is saved per browser, not per account. On sign-in we can't tell new people from returning ones, so a returning person on a new browser or device also starts on dark. So does a returning person who never picked a theme in this browser, the next time they see the sign-in page. The sun/moon button beside the logo switches back, and that choice is kept.

Changes

  • Sign-in, forgot password, reset password. Each page renders <NewUserTheme /> at the top, with a short comment, the same way sign-up does. Sign-in keeps its structure: the async server page still wraps SignInView, and NewUserTheme sits inside the view.
  • Consent page left as it is. oauth/consent uses the same auth frame, but a signed-out person is sent to sign-in first, and sign-in now starts them on dark. Adding it would reach no new visitor. It would only switch people who are already signed in.
  • Comments. new-user-theme.tsx and config/theme.ts now say which pages run it, and what sign-in can't tell apart.
  • Tests. auth-pages.test.tsx checks that on Cloud, sign-up, sign-in, forgot password and reset password carry the script once, before the page. Self-hosted, they carry nothing. The consent page carries nothing.
  • Help. In "Switch between light and dark mode", the "Which mode you start in" section names the sign-up, sign-in and password reset pages, and says a returning person may start on dark. "Switch the mode" says another browser starts on dark when you sign in there. Every section is 150 words or fewer, and approved-articles.json is regenerated. The FAQ entry the article comes from says the same.
  • No What's new entry, since feat(ui): start new people on the dark theme, for a while #2280 had none. No en.json change, no migration, no new dependency.

Who sees what

Browser Sign-up Sign-in Forgot password Reset password Onboarding
Cloud, no saved theme Dark (as before) Dark (new) Dark (new) Dark (new) Dark (as before)
Cloud, saved theme (picked or given earlier) Unchanged Unchanged Unchanged Unchanged Unchanged
Self-hosted Unchanged Unchanged Unchanged Unchanged Unchanged

Decision for the owner

next-themes saves a theme only when someone presses the sun/moon button. So an existing user who never pressed it has no saved theme, even on the browser they always use. With this change, the next time they reach sign-in signed out (after signing out, or when their session ends), they switch to dark.

  • A. Ship as is. Those people switch to dark once, and the sun/moon button switches them back.
  • B. Keep existing users on light (recommended). A small addition in this PR: when a signed-in person opens the dashboard in a browser with no saved theme, light is saved, the look they already have. After this ships, existing users keep light. New people still start on dark, because sign-up, sign-in and onboarding save dark first. Only an existing user whose first visit after the release is the sign-in page would still start on dark.

How to test

  1. On Cloud (NEXT_PUBLIC_IS_CLOUD=true), open a fresh private window and go to /sign-in. It opens dark.
  2. In the same window, sign in. The dashboard opens dark, and the sun/moon button beside the logo switches back to light.
  3. In a window where light was picked with the sun/moon button, open /sign-in. It stays light.
  4. In fresh private windows, open /forgot-password and /reset-password. Both open dark.
  5. Self-hosted (NEXT_PUBLIC_IS_CLOUD=false), a fresh private window on /sign-in stays light.

Checks

  • tsc --noEmit: clean.
  • Vitest, 14 files and 97 tests, all passing: src/components/auth, src/components/theme, the (marketing) and (onboarding) page tests, src/lib/help, src/i18n, use-server-exports, theme-toggle.
  • New tests: 9 in auth-pages.test.tsx (4 pages on Cloud, 4 pages self-hosted, the consent page). The sign-in test fails without the change.
  • ESLint and Prettier on the changed TypeScript files: clean.
  • Local run (next dev, Cloud on, fresh headless Chrome profile): sign-in, forgot password, reset password and sign-up each opened with dark on the page and theme=dark saved. After light was saved, sign-in stayed light.
  • The branch merges cleanly on main.

Generated by Claude Code

… the password pages too

PostHog showed a first-time visitor who lands on sign-in seeing the light
theme: only sign-up and onboarding rendered NewUserTheme. Sign-in, forgot
password and reset password now render it too, at the top of the page as
sign-up does. On Ansvisor Cloud, a browser with no saved theme starts on
dark there and keeps it; a browser with a saved theme never changes;
self-hosted is unchanged.

Sign-in can't tell new people from returning ones, so someone on a new
browser or device, or one where they never picked a theme, also starts
dark (accepted by the owner). The consent page is left as it is: a
signed-out person is sent to sign-in first.

- auth-pages.test.tsx: the four pages carry the script first on Cloud and
  nothing self-hosted; the consent page carries none.
- Comments in new-user-theme.tsx and config/theme.ts say where it runs.
- Help light-and-dark-mode and its FAQ source updated; approved-articles
  regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@mintlify

mintlify Bot commented Nov 16, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 9536835.

Approve preview

@gkhngyk gkhngyk 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.

LGTM.

@gkhngyk
gkhngyk merged commit 4daf49b into ansvisor:main Nov 16, 2026
12 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 16, 2026
Follow-up to #2453, the owner's option B. Since #2280 and #2453, on
Ansvisor Cloud the sign-up, sign-in, password and onboarding pages save
dark in a browser with no saved theme. Someone who already used Ansvisor
and never pressed the sun/moon button has no saved theme either, so they
would switch to dark the next time they saw sign-in signed out.

KeepCurrentTheme, rendered once in the dashboard layout, saves light in a
browser with no saved theme when a signed-in person opens a dashboard
page, on Cloud only. Light is the ThemeProvider's default, so nothing
changes on screen. A saved theme is never changed, and a new person
already has dark saved before they reach the dashboard. Self-hosted is
unchanged.

- config/theme.ts: EXISTING_USER_THEME ('light'), with the owner's
  choice and how to remove it; the comments on who starts dark updated,
  in new-user-theme.tsx too.
- keep-current-theme.test.tsx: saves light only when nothing is saved,
  never overrides dark or light, nothing self-hosted, survives a
  throwing localStorage, draws nothing.
- Dashboard layout tests: light saved on Cloud with nothing saved; a
  saved theme kept; nothing saved on the way to onboarding or
  self-hosted.
- Help light-and-dark-mode and its FAQ source: people who already use
  Ansvisor keep their mode, new people start on dark; approved-articles
  regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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.

3 participants