Skip to content

fix(theme): Update config.theme when mutating user theme option#116336

Merged
TkDodo merged 1 commit into
masterfrom
tkdodo/fix-theme-switch-stale-tokens
May 28, 2026
Merged

fix(theme): Update config.theme when mutating user theme option#116336
TkDodo merged 1 commit into
masterfrom
tkdodo/fix-theme-switch-stale-tokens

Conversation

@TkDodo
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo commented May 27, 2026

The command palette's theme switching uses useMutateUserOptions, which optimistically updates config.user.options.theme but never updates the derived config.theme field that ThemeAndStyleProvider reads. On the first dark→light switch after page load, the theme object stays stale until useColorscheme's useEffect catches up a frame later, causing some tokens to not update.

Set config.theme directly in onMutate for non-system theme changes, matching the pattern already used by updateUser in actionCreators/account.tsx.

fixes DE-1266

The command palette's theme switching uses useMutateUserOptions, which
optimistically updates config.user.options.theme but never updates the
derived config.theme field. ThemeAndStyleProvider reads config.theme to
select the theme object, so the first dark-to-light switch after page
load renders with stale tokens until useColorscheme's useEffect catches
up a frame later.

Set config.theme directly in onMutate for non-system theme changes,
matching the pattern already used by updateUser in account.tsx.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 27, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 27, 2026

DE-1266

@TkDodo TkDodo marked this pull request as ready for review May 27, 2026 20:12
@TkDodo TkDodo requested a review from a team as a code owner May 27, 2026 20:12
@TkDodo TkDodo requested a review from a team May 27, 2026 20:12
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.58%

@TkDodo TkDodo merged commit b10549c into master May 28, 2026
78 checks passed
@TkDodo TkDodo deleted the tkdodo/fix-theme-switch-stale-tokens branch May 28, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants