feat: add theme_mode, theme_light, theme_dark to UserAppearanceSettings (#25076)

Part 1: Backend portion of a change broken into 2 PRs.
Part 2: #25077 

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.
This commit is contained in:
Jaayden Halko
2026-05-14 05:44:05 +01:00
committed by GitHub
parent d147dd3bdd
commit 024132e8a4
23 changed files with 1209 additions and 223 deletions
+61
View File
@@ -23089,6 +23089,19 @@ const docTemplate = `{
"TerminalFontJetBrainsMono"
]
},
"codersdk.ThemeMode": {
"type": "string",
"enum": [
"",
"sync",
"single"
],
"x-enum-varnames": [
"ThemeModeUnset",
"ThemeModeSync",
"ThemeModeSingle"
]
},
"codersdk.ThinkingDisplayMode": {
"type": "string",
"enum": [
@@ -23420,6 +23433,42 @@ const docTemplate = `{
"terminal_font": {
"$ref": "#/definitions/codersdk.TerminalFontName"
},
"theme_dark": {
"description": "ThemeDark is required when ThemeMode is \"sync\". In \"single\" mode\nan empty value means \"preserve the previously persisted slot\"\nrather than \"clear the slot\", so partial updates that send only\none slot keep the other intact.",
"type": "string",
"enum": [
"light",
"light-protan-deuter",
"light-tritan",
"dark",
"dark-protan-deuter",
"dark-tritan"
]
},
"theme_light": {
"description": "ThemeLight is required when ThemeMode is \"sync\". In \"single\"\nmode an empty value means \"preserve the previously persisted\nslot\" rather than \"clear the slot\", so partial updates that send\nonly one slot keep the other intact.",
"type": "string",
"enum": [
"light",
"light-protan-deuter",
"light-tritan",
"dark",
"dark-protan-deuter",
"dark-tritan"
]
},
"theme_mode": {
"description": "ThemeMode is optional for backward compatibility. When empty,\nthe server leaves theme_mode, theme_light, and theme_dark\nunchanged so older CLI clients do not erase sync-mode settings.\nLegacy auto preferences are the exception: they clear theme_mode\nso clients can migrate the old sync-with-system setting.",
"enum": [
"sync",
"single"
],
"allOf": [
{
"$ref": "#/definitions/codersdk.ThemeMode"
}
]
},
"theme_preference": {
"type": "string"
}
@@ -23842,7 +23891,19 @@ const docTemplate = `{
"terminal_font": {
"$ref": "#/definitions/codersdk.TerminalFontName"
},
"theme_dark": {
"description": "Ignored when ThemeMode is \"single\"",
"type": "string"
},
"theme_light": {
"description": "Ignored when ThemeMode is \"single\"",
"type": "string"
},
"theme_mode": {
"$ref": "#/definitions/codersdk.ThemeMode"
},
"theme_preference": {
"description": "ThemePreference is the legacy single-field appearance setting. In\n\"single\" mode it mirrors the active theme. In \"sync\" mode modern\nclients normally mirror the active OS slot, but older clients can\nupdate only this field, so it may diverge from ThemeLight or\nThemeDark until a modern client saves the full appearance state\nagain.",
"type": "string"
}
}