Skip to content

feat: add theme mode dropdown - #25183

Merged
jaaydenh merged 25 commits into
mainfrom
pr25077/05-theme-mode-dropdown
May 15, 2026
Merged

jaaydenh merged 25 commits into
mainfrom
pr25077/05-theme-mode-dropdown

Conversation

@jaaydenh

Copy link
Copy Markdown
Contributor

Summary

  • Wire the Appearance settings page to the new theme mode dropdown and sync or single theme selectors.
  • Update Appearance page tests and stories for theme mode behavior.
  • Update the user settings e2e test to exercise single theme selection.

Dependencies

Validation

  • pnpm -C site exec vitest run --project=unit src/pages/UserSettingsPage/AppearancePage/AppearancePage.test.tsx src/theme/themeMode.test.ts src/api/queries/users.test.ts
  • pnpm -C site lint:types
  • pnpm -C site storybook:ci
  • pnpm -C site build
  • pnpm -C site playwright:test -- e2e/tests/users/userSettings.spec.ts
  • Pre-commit hook passed on the branch commit.

jaaydenh and others added 15 commits May 8, 2026 10:23
Adds three new UserAppearanceSettings fields (theme_mode, theme_light,
theme_dark) on top of the existing theme_preference and terminal_font.
Replaces GetUserThemePreference and GetUserTerminalFont with a single
GetUserAppearanceSettings aggregate query. The PUT handler is wrapped
in db.InTx so sync-mode's mode + slot writes can never half-apply.
@jaaydenh
jaaydenh requested a review from DanielleMaywood May 15, 2026 09:04
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
@jaaydenh

Copy link
Copy Markdown
Contributor Author

/coder-agents-review
@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jaaydenh
jaaydenh changed the base branch from pr25077/05-theme-mode-dropdown-base to main May 15, 2026 10:50

@coder-agents-review coder-agents-review Bot 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.

Solid work wiring the theme mode dropdown. The submit-queue mechanism (at-most-one in-flight, latest-wins coalescing, rollback on failure) is well-designed, and the test coverage targets the hard concurrency paths rather than surface details. Story coverage is thorough: 16 named variants covering single, sync, accessibility themes, legacy migration, hover preview, and font selection. The e2e test was updated to match the new flow.

8 P3, 1 P4, 3 Nits below. The P3s cluster around the submit state machine's edge cases: an unguarded form-submit path, a stale closure, missing documentation, and silent queue drops on failure. None are crash bugs today; all are maintenance hazards in code that is already the most complex part of this file.

Process note: the commit subjects fix: improve form handling and chore: cleanup don't convey what changed. Something like fix(site): queue rapid theme changes to prevent dropped updates would help git bisect and blame.

"Formik is introduced without using any of its features, then worked around." (Pariston)

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearancePage.test.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.stories.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated
…-conflicts

# Conflicts:
#	coderd/apidoc/docs.go
#	coderd/apidoc/swagger.json
#	coderd/database/dbauthz/dbauthz.go
#	coderd/database/dbmetrics/querymetrics.go
#	coderd/database/dbmock/dbmock.go
#	coderd/database/querier.go
#	coderd/database/queries.sql.go
#	coderd/database/queries/users.sql
#	coderd/users.go
#	codersdk/users.go
#	docs/reference/api/schemas.md
#	site/src/api/queries/users.test.ts
#	site/src/api/typesGenerated.ts
#	site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.stories.tsx
#	site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx
#	site/src/pages/UserSettingsPage/AppearancePage/AppearancePage.test.tsx
#	site/src/pages/UserSettingsPage/AppearancePage/AppearancePage.tsx
#	site/src/pages/UserSettingsPage/AppearancePage/SingleModeSection.tsx
#	site/src/pages/UserSettingsPage/AppearancePage/SyncModeSection.tsx
#	site/src/pages/UserSettingsPage/Section.tsx
#	site/src/theme/darkTritan/roles.ts
#	site/src/theme/lightTritan/roles.ts
#	site/src/theme/themeMode.test.ts
#	site/src/theme/themeMode.ts
#	site/src/theme/usePreferredColorScheme.ts
@jaaydenh jaaydenh changed the title feat(site): add theme mode dropdown feat: add theme mode dropdown May 15, 2026
coder-agents-review[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot 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.

All 13 R1 findings addressed cleanly. Formik removed, submit queue simplified, documentation added, test coverage expanded. The rewrite is well-executed.

2 P3, 3 Nits new this round. The P3s are about the confirmedValuesRef being contaminated by optimistic cache updates (one-line fix) and queue tests stopping one assertion short of proving the terminal UI state.

"The ref's name is confirmedValuesRef. The useEffect overwrites it with unconfirmed values." (Mafuuu)

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot 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.

All 18 findings across 4 rounds addressed. The submit queue is clean: confirmedValuesRef guard is correctly placed, onSubmitRef prevents stale closures, native submit is prevented, the queue is documented, and test coverage proves the terminal state. Formik removal simplified the state management without losing any capability. Story and test coverage is thorough (4 vitest tests, 7 interactive stories, 24 pure-logic unit tests, 1 e2e).

No open findings.

🤖 This review was automatically generated with Coder Agents.

@jaaydenh
jaaydenh requested a review from DanielleMaywood May 15, 2026 13:56
Comment thread site/src/pages/UserSettingsPage/AppearancePage/SingleModeSection.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/AppearancePage/SyncModeSection.tsx Outdated
Comment thread site/src/pages/UserSettingsPage/Section.tsx Outdated
@jaaydenh

Copy link
Copy Markdown
Contributor Author

@codex review

@jaaydenh
jaaydenh requested a review from DanielleMaywood May 15, 2026 14:23

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3971f2661

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/UserSettingsPage/AppearancePage/AppearanceForm.test.tsx Outdated
Comment thread site/e2e/tests/users/userSettings.spec.ts Outdated
) => void;

export const useQueuedAppearanceSubmit = (mutate: MutateAppearanceSettings) => {
const submitInFlightRef = useRef(false);

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.

Is there any reason why we can't just pass in the isPending from the mutation passed through?

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.

isPending only reflects the state of the last render. Basically, i think would need to stay like this unless the hook is restructured somehow.

@jaaydenh
jaaydenh requested a review from DanielleMaywood May 15, 2026 15:01

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

Approving but I definitely think a better design exists such that we don't have to rely on useRefs as much

@jaaydenh
jaaydenh merged commit 2c18e07 into main May 15, 2026
27 checks passed
@jaaydenh
jaaydenh deleted the pr25077/05-theme-mode-dropdown branch May 15, 2026 15:15
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants