Skip to content

feat(ui): start new people on the dark theme, for a while - #2280

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/new-user-dark-theme
Nov 10, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feature/new-user-dark-theme

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The owner's decision of 2026-11-10: greet every new person in dark mode, for a while.

What a person sees (Ansvisor Cloud)

  • A new person: the sign-up page opens dark, and so do onboarding, the welcome page and the rest of the app after it.
  • Someone who used Ansvisor before: nothing changes. Their browser already has a theme, or they reach the app through sign-in, which doesn't set one.
  • The sun/moon button beside the logo switches back to light, as before, and that choice is kept.
  • Self-hosted is unchanged: it opens light, the ThemeProvider's default.

How it works

  • web/src/config/theme.ts:
    • NEW_USER_THEME ('dark') is the switch. Set it to null to stop: people who already started dark keep it until they switch.
    • THEME_STORAGE_KEY is next-themes' own key (theme).
  • web/src/components/theme/new-user-theme.tsx (<NewUserTheme />), on Cloud only:
    • An inline script stores the dark theme and sets the dark class before the page paints, in a browser that has no theme yet. So there is no flash of the light theme first. next-themes then reads the stored theme when the page hydrates.
    • An effect does the same through setTheme for a page reached inside the app (sign-in to sign-up), where React doesn't run an inline script.
    • A browser with any stored theme is left alone.
  • It is mounted on the sign-up page (before the page's shell, so the script runs first) and in the onboarding layout. The onboarding layout covers onboarding and the welcome page, so it also catches a new person who signed up with Google from the sign-in page, or who came through an invitation.
  • The ThemeProvider default stays light, so people with no stored theme who sign in are not switched.

Help and docs

  • New Help article getting-started/light-and-dark-mode ("Switch between light and dark mode"), approved: false, for the owner to approve.
  • New FAQ entry in docs/faq.mdx, "Is there a dark mode?", the article's source.

No migration, no new dependency, no lockfile change, no new UI string.

Related issue

Owner decision 2026-11-10.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd web && yarn vitest run src/components/theme src/lib/help. new-user-theme.test.tsx covers:
    • the script on a browser without a theme;
    • one that has light;
    • the effect;
    • self-hosted.
  2. On a Cloud preview, in a private window, open /sign-up. The page is dark from the first paint, and the app after sign-up opens dark.
  3. In a window where you set light with the sun/moon button, open /sign-up. It stays light.
  4. Sign in with an existing account in a fresh window. The app opens light, as today.
  5. Set NEW_USER_THEME to null. A fresh window's /sign-up opens light.

Not checked by eye: the built app redirects to itself on localhost in the session that built this (the locale middleware), so the dark pages weren't screenshotted. The sign-up shell and onboarding already have dark styles (dark: classes, no fixed light colors).

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/) — 0 errors; the warnings are all in files this PR doesn't touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

Checks run:

  • yarn format:check, yarn lint (0 errors) and yarn typecheck pass.
  • Touched tests: 6 files, 42 tests pass.
  • Full yarn test: 1,078 files, 11,823 passed, 1 skipped.
  • yarn build (with NEXT_PUBLIC_IS_CLOUD=true and CI's placeholder env) passes.

Generated by Claude Code

Owner decision 2026-11-10: every new person is greeted in dark mode for a
while. On Ansvisor Cloud, the sign-up page and onboarding (the welcome
page included) store the dark theme in a browser that has none yet, so
the rest of the app opens dark too and the sun/moon button switches it
back. A browser that already has a theme keeps it, so no one who uses
Ansvisor today changes. Self-hosted is unchanged.

- config/theme.ts: NEW_USER_THEME ('dark'; null stops it) and the
  next-themes storage key.
- components/theme/new-user-theme.tsx: an inline script that sets it
  before the page paints, and an effect for pages reached in the app.
- Help: getting-started/light-and-dark-mode (unapproved), from a new FAQ
  entry.

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

mintlify Bot commented Nov 10, 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 2d5e4da.

Approve preview

The sun/moon button is hidden while the menu is folded to icons
(sidebar.tsx), so the article and the FAQ now say where to find it.

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

@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 aeea559 into ansvisor:main Nov 10, 2026
13 checks passed
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 10, 2026
Brings in ansvisor#2280 (new people start on the dark theme). sign-up/page.tsx
keeps both: <NewUserTheme /> before the shell, and the shell's headline
and footnote with the untitled card.

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