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 11:44:05 +07:00
committed by GitHub
parent d147dd3bdd
commit 024132e8a4
23 changed files with 1209 additions and 223 deletions
+55 -13
View File
@@ -125,14 +125,24 @@ SET
WHERE
id = $1;
-- name: GetUserThemePreference :one
-- name: GetUserAppearanceSettings :one
SELECT
value as theme_preference
COALESCE(MAX(value) FILTER (WHERE key = 'theme_preference'), '')::text AS theme_preference,
COALESCE(MAX(value) FILTER (WHERE key = 'theme_mode'), '')::text AS theme_mode,
COALESCE(MAX(value) FILTER (WHERE key = 'theme_light'), '')::text AS theme_light,
COALESCE(MAX(value) FILTER (WHERE key = 'theme_dark'), '')::text AS theme_dark,
COALESCE(MAX(value) FILTER (WHERE key = 'terminal_font'), '')::text AS terminal_font
FROM
user_configs
WHERE
user_id = @user_id
AND key = 'theme_preference';
AND key IN (
'theme_preference',
'theme_mode',
'theme_light',
'theme_dark',
'terminal_font'
);
-- name: UpdateUserThemePreference :one
INSERT INTO
@@ -148,15 +158,6 @@ WHERE user_configs.user_id = @user_id
AND user_configs.key = 'theme_preference'
RETURNING *;
-- name: GetUserTerminalFont :one
SELECT
value as terminal_font
FROM
user_configs
WHERE
user_id = @user_id
AND key = 'terminal_font';
-- name: UpdateUserTerminalFont :one
INSERT INTO
user_configs (user_id, key, value)
@@ -171,6 +172,48 @@ WHERE user_configs.user_id = @user_id
AND user_configs.key = 'terminal_font'
RETURNING *;
-- name: UpdateUserThemeMode :one
INSERT INTO
user_configs (user_id, key, value)
VALUES
(@user_id, 'theme_mode', @theme_mode)
ON CONFLICT
ON CONSTRAINT user_configs_pkey
DO UPDATE
SET
value = @theme_mode
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'theme_mode'
RETURNING *;
-- name: UpdateUserThemeLight :one
INSERT INTO
user_configs (user_id, key, value)
VALUES
(@user_id, 'theme_light', @theme_light)
ON CONFLICT
ON CONSTRAINT user_configs_pkey
DO UPDATE
SET
value = @theme_light
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'theme_light'
RETURNING *;
-- name: UpdateUserThemeDark :one
INSERT INTO
user_configs (user_id, key, value)
VALUES
(@user_id, 'theme_dark', @theme_dark)
ON CONFLICT
ON CONSTRAINT user_configs_pkey
DO UPDATE
SET
value = @theme_dark
WHERE user_configs.user_id = @user_id
AND user_configs.key = 'theme_dark'
RETURNING *;
-- name: GetUserChatCustomPrompt :one
SELECT
value as chat_custom_prompt
@@ -304,7 +347,6 @@ WHERE user_configs.user_id = @user_id
AND user_configs.key = 'preference_thinking_display_mode'
RETURNING value AS thinking_display_mode;
-- name: GetUserCodeDiffDisplayMode :one
SELECT
value AS code_diff_display_mode