Skip to content

Modern Docker Management, Designed for Everyone

refactor: move all appearance settings to the user profile view (#3384)

Kyle Mendell682a2bd5f69f
diff --git a/backend/api/handlers/auth.go b/backend/api/handlers/auth.go
index 793157b5b..c0f342431 100644
--- a/backend/api/handlers/auth.go
+++ b/backend/api/handlers/auth.go
@@ -11,6 +11,8 @@ import (
"log/slog"
"mime/multipart"
"net/http"
+ "reflect"
+ "strings"
"time"
"emperror.dev/errors"
@@ -22,6 +24,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/cookie"
"github.com/getarcaneapp/arcane/types/v2/auth"
"github.com/getarcaneapp/arcane/types/v2/base"
+ "github.com/getarcaneapp/arcane/types/v2/settings"
"github.com/getarcaneapp/arcane/types/v2/user"
)
@@ -74,11 +77,12 @@ type LogoutAllOtherSessionsOutput struct {
type UpdateMyProfileInput struct {
Body struct {
- DisplayName *string `json:"displayName,omitempty"`
- Email *string `json:"email,omitempty"`
- Locale *string `json:"locale,omitempty"`
- TimeFormat *user.TimeFormat `json:"timeFormat,omitempty" enum:"auto,12h,24h"`
- FontSize *int `json:"fontSize,omitempty" minimum:"12" maximum:"20"`
+ DisplayName *string `json:"displayName,omitempty"`
+ Email *string `json:"email,omitempty"`
+ Locale *string `json:"locale,omitempty"`
+ TimeFormat *user.TimeFormat `json:"timeFormat,omitempty" enum:"auto,12h,24h"`
+ FontSize *int `json:"fontSize,omitempty" minimum:"12" maximum:"20"`
+ Preferences *user.Preferences `json:"preferences,omitempty"`
}
}
@@ -400,6 +404,39 @@ func (h *AuthHandler) LogoutAllOtherSessions(ctx context.Context, input *struct{
}, nil
}
+// validatePreferencesInternal checks the preference values Huma's enum tags
+// cannot express. Everything else is constrained by the schema.
+func validatePreferencesInternal(p *user.Preferences) error {
+ // The "default" sentinel means "no override"; anything else must be a color
+ // literal safe to inject into CSS.
+ if v := p.AccentColor; v != nil && *v != "" && *v != "default" && !settings.SafeAccentColor.MatchString(*v) {
+ return huma.Error400BadRequest("invalid accentColor value")
+ }
+ // Keep the landing page a same-origin relative path. The frontend
+ // additionally validates it against the known nav pages, falling back to
+ // /dashboard.
+ if v := p.DefaultLandingPage; v != nil && (!strings.HasPrefix(*v, "/") || strings.HasPrefix(*v, "//")) {
+ return huma.Error400BadRequest("invalid defaultLandingPage value")
+ }
+ return nil
+}
+
+// mergePreferencesInternal copies every set (non-nil) field of src onto dst.
+// Reflection keeps this merge-only update free of per-field branches, the same
+// way the settings update path walks its DTO, so a new preference needs no
+// handler change.
+func mergePreferencesInternal(dst, src *user.Preferences) {
+ dstValue := reflect.ValueOf(dst).Elem()
+ srcValue := reflect.ValueOf(src).Elem()
+
+ for i := range srcValue.NumField() {
+ field := srcValue.Field(i)
+ if field.Kind() == reflect.Pointer && !field.IsNil() {
+ dstValue.Field(i).Set(field)
+ }
+ }
+}
+
// UpdateMyProfile lets the current user update their own displayName and email.
// OIDC-managed accounts are read-only here.
func (h *AuthHandler) UpdateMyProfile(ctx context.Context, input *UpdateMyProfileInput) (*UpdateMyProfileOutput, error) {
@@ -438,6 +475,12 @@ func (h *AuthHandler) UpdateMyProfile(ctx context.Context, input *UpdateMyProfil
if input.Body.FontSize != nil {
userModel.FontSize = input.Body.FontSize
}
+ if p := input.Body.Preferences; p != nil {
+ if err := validatePreferencesInternal(p); err != nil {
+ return nil, err
+ }
+ mergePreferencesInternal(&userModel.Preferences, p)
+ }
updated, err := h.userService.UpdateUser(ctx, userModel)
if err != nil {
diff --git a/backend/api/handlers/volumes_upload_test.go b/backend/api/handlers/volumes_upload_test.go
index be8af7514..11e3d533f 100644
--- a/backend/api/handlers/volumes_upload_test.go
+++ b/backend/api/handlers/volumes_upload_test.go
@@ -1,13 +1,11 @@
package handlers
import (
- "context"
"mime/multipart"
"net/http"
"testing"
"github.com/danielgtaylor/huma/v2"
- humamw "github.com/getarcaneapp/arcane/backend/v2/api/middleware"
"github.com/getarcaneapp/arcane/backend/v2/internal/models"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/stretchr/testify/assert"
@@ -34,7 +32,7 @@ func TestUploadFileReturnsBadRequestWhenNoFileProvided(t *testing.T) {
func TestUploadAndRestoreReturnsBadRequestWhenNoFileProvided(t *testing.T) {
h := &VolumeHandler{volumeService: &services.VolumeService{}}
- ctx := context.WithValue(adminTestContextInternal(), humamw.ContextKeyCurrentUser, &models.User{BaseModel: models.BaseModel{ID: "u-1"}})
+ ctx := models.WithCurrentUser(adminTestContextInternal(), &models.User{BaseModel: models.BaseModel{ID: "u-1"}})
_, err := h.UploadAndRestore(ctx, &UploadAndRestoreInput{
EnvironmentID: "0",
diff --git a/backend/api/middleware/auth.go b/backend/api/middleware/auth.go
index 9ea8b3792..2278837f5 100644
--- a/backend/api/middleware/auth.go
+++ b/backend/api/middleware/auth.go
@@ -24,8 +24,6 @@ type ContextKey string
const (
// ContextKeyUserID is the context key for the authenticated user's ID.
ContextKeyUserID ContextKey = "userID"
- // ContextKeyCurrentUser is the context key for the authenticated user model.
- ContextKeyCurrentUser ContextKey = "currentUser"
// ContextKeyCurrentSessionID is the context key for the authenticated session ID.
ContextKeyCurrentSessionID ContextKey = "currentSessionID"
// ContextKeyUserPermissions is the context key for the caller's resolved
@@ -43,8 +41,7 @@ func GetUserIDFromContext(ctx context.Context) (string, bool) {
// GetCurrentUserFromContext retrieves the current user from the context.
func GetCurrentUserFromContext(ctx context.Context) (*models.User, bool) {
- u, ok := ctx.Value(ContextKeyCurrentUser).(*models.User)
- return u, ok
+ return models.CurrentUserFromContext(ctx)
}
// GetCurrentSessionIDFromContext retrieves the current session ID from the context.
@@ -417,7 +414,7 @@ func setUserInContextInternal(ctx context.Context, user *models.User, ps *authz.
ps = authz.NewPermissionSet()
}
ctx = context.WithValue(ctx, ContextKeyUserID, user.ID)
- ctx = context.WithValue(ctx, ContextKeyCurrentUser, user)
+ ctx = models.WithCurrentUser(ctx, user)
ctx = context.WithValue(ctx, ContextKeyUserPermissions, ps)
return ctx
}
diff --git a/backend/internal/configschema/schema_test.go b/backend/internal/configschema/schema_test.go
index 654a57b0f..7a6688d84 100644
--- a/backend/internal/configschema/schema_test.go
+++ b/backend/internal/configschema/schema_test.go
@@ -263,11 +263,8 @@ var expectedEnvConfigVars = []string{
}
var expectedSettingOverrideKeys = []string{
- "accentColor",
"activityHistoryMaxEntries",
"activityHistoryRetentionDays",
- "animationsEnabled",
- "applicationTheme",
"authLocalEnabled",
"authPasswordPolicy",
"authSessionTimeout",
@@ -286,7 +283,6 @@ var expectedSettingOverrideKeys = []string{
"buildTimeout",
"buildsDirectory",
"defaultDeployPullPolicy",
- "defaultLandingPage",
"defaultShell",
"depotProjectId",
"depotToken",
@@ -304,17 +300,12 @@ var expectedSettingOverrideKeys = []string{
"gitSyncMaxBinarySizeMb",
"gitSyncMaxFiles",
"gitSyncMaxTotalSizeMb",
- "glassEffectsEnabled",
"httpClientTimeout",
- "iconCatalog",
- "keyboardShortcutsEnabled",
"lifecycleDefaultRunnerImage",
"lifecycleEnabled",
"lifecycleMaxTimeoutSec",
"maxConcurrentActivities",
"maxImageUploadSize",
- "mobileNavigationMode",
- "mobileNavigationShowLabels",
"oidcAuthorizationEndpoint",
"oidcAutoRedirectToProvider",
"oidcClientId",
@@ -332,7 +323,6 @@ var expectedSettingOverrideKeys = []string{
"oidcSkipTlsVerify",
"oidcTokenEndpoint",
"oidcUserinfoEndpoint",
- "oledMode",
"pollingEnabled",
"pollingInterval",
"projectsDirectory",
@@ -349,7 +339,6 @@ var expectedSettingOverrideKeys = []string{
"registryTimeout",
"scheduledPruneEnabled",
"scheduledPruneInterval",
- "sidebarHoverExpansion",
"swarmStackSourcesDirectory",
"templatesDirectory",
"trivyConcurrentScanContainers",
diff --git a/backend/internal/database/database_test.go b/backend/internal/database/database_test.go
index cf8ad4916..514729886 100644
--- a/backend/internal/database/database_test.go
+++ b/backend/internal/database/database_test.go
@@ -139,6 +139,39 @@ func TestMigration067_ActivityBatchID_UpAndDown(t *testing.T) {
assert.Zero(t, indexCount)
}
+func TestMigration068_UserPreferences_UpAndDown(t *testing.T) {
+ ctx := context.Background()
+ rawDB, _ := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-user-preferences.db")
+
+ require.NoError(t, migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}, 67))
+ var columnCount int
+ require.NoError(t, rawDB.QueryRow(`SELECT COUNT(*) FROM pragma_table_info('users') WHERE name = 'preferences'`).Scan(&columnCount))
+ assert.Zero(t, columnCount)
+
+ _, err := rawDB.Exec(`INSERT INTO users (id, created_at, updated_at, username, password_hash) VALUES ('u-1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'kyle', 'hash')`)
+ require.NoError(t, err)
+ // One string setting and one boolean setting are seeded; iconCatalog is
+ // deliberately absent so the migration must leave it JSON null.
+ _, err = rawDB.Exec(`INSERT INTO settings (key, value) VALUES ('applicationTheme', 'nord'), ('oledMode', 'true')`)
+ require.NoError(t, err)
+
+ require.NoError(t, migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}, 68))
+ require.NoError(t, rawDB.QueryRow(`SELECT COUNT(*) FROM pragma_table_info('users') WHERE name = 'preferences'`).Scan(&columnCount))
+ assert.Equal(t, 1, columnCount)
+
+ var theme string
+ var oled bool
+ var iconCatalog stdsql.NullString
+ require.NoError(t, rawDB.QueryRow(`SELECT json_extract(preferences, '$.applicationTheme'), json_extract(preferences, '$.oledMode'), json_extract(preferences, '$.iconCatalog') FROM users WHERE id = 'u-1'`).Scan(&theme, &oled, &iconCatalog))
+ assert.Equal(t, "nord", theme)
+ assert.True(t, oled)
+ assert.False(t, iconCatalog.Valid)
+
+ require.NoError(t, migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true}, 67))
+ require.NoError(t, rawDB.QueryRow(`SELECT COUNT(*) FROM pragma_table_info('users') WHERE name = 'preferences'`).Scan(&columnCount))
+ assert.Zero(t, columnCount)
+}
+
func TestMigrateDatabase_BlocksFutureGooseVersionWithoutFlag(t *testing.T) {
ctx := context.Background()
rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-future.db")
diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.go
index f8dc2c3dc..e407264bb 100644
--- a/backend/internal/models/settings.go
+++ b/backend/internal/models/settings.go
@@ -35,7 +35,6 @@ type settingFieldMeta struct {
isPublic bool
isVisibleToNonAdmin bool
isSensitive bool
- isLocal bool
}
var settingsFieldCache struct {
@@ -73,14 +72,10 @@ type Settings struct {
SwarmStackSourcesDirectory SettingVariable `key:"swarmStackSourcesDirectory,envOverride" meta:"label=Swarm Stack Sources Directory;type=text;keywords=swarm,stacks,stack,source,sources,directory,path,folder,location,storage,compose,env;category=internal;description=Configure where swarm stack source files are stored"`
DiskUsagePath SettingVariable `key:"diskUsagePath" meta:"label=Disk Usage Path;type=text;keywords=disk,usage,path,storage,folder,files;category=general;description=Path used for disk usage calculations"`
BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`
- EnableGravatar SettingVariable `key:"enableGravatar,authrequired" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=general;description=Enable Gravatar profile pictures for users"`
- AvatarMaxUploadSizeMb SettingVariable `key:"avatarMaxUploadSizeMb,authrequired,local" meta:"label=Avatar Max Upload Size (MB);type=number;keywords=avatar,profile,picture,upload,size,limit,maximum,image,user,photo,mb;category=general;description=Maximum size in MB for profile picture uploads (default: 2)"`
+ EnableGravatar SettingVariable `key:"enableGravatar,authrequired" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=users;description=Enable Gravatar profile pictures for users"`
+ AvatarMaxUploadSizeMb SettingVariable `key:"avatarMaxUploadSizeMb,authrequired" meta:"label=Avatar Max Upload Size (MB);type=number;keywords=avatar,profile,picture,upload,size,limit,maximum,image,user,photo,mb;category=users;description=Maximum size in MB for profile picture uploads (default: 2)"`
DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`
EnvironmentHealthInterval SettingVariable `key:"environmentHealthInterval" meta:"label=Environment Health Check Interval;type=cron;keywords=environment,health,check,interval,frequency,heartbeat,status,monitoring,uptime,jobs,schedule;description=How often to check environment connectivity (cron expression)" catmeta:"id=jobschedule;title=Automations;icon=jobs;url=/settings/jobs;description=Configure how often Arcane background jobs run"`
- ApplicationTheme SettingVariable `key:"applicationTheme,public,local" meta:"label=Application Theme;type=select;keywords=theme,appearance,style,visual,palette,background,interface,ui;category=appearance;description=Choose the overall visual theme for the application"`
- IconCatalog SettingVariable `key:"iconCatalog,public,local" meta:"label=Icon Catalog;type=select;keywords=icon,catalog,selfhst,dashboard-icons,appearance,container,project;category=appearance;description=Choose the catalog used to resolve project and container icon slugs"`
- AccentColor SettingVariable `key:"accentColor,public,local" meta:"label=Accent Color;type=text;keywords=color,accent,theme,css,appearance,ui;category=general;description=Primary accent color for UI"`
- OledMode SettingVariable `key:"oledMode,public,local" meta:"label=OLED Mode;type=boolean;keywords=oled,dark,theme,black,amoled,appearance,display;category=general;description=Use true-black backgrounds for OLED displays (only active in dark mode)"`
// Docker category
AutoUpdate SettingVariable `key:"autoUpdate" meta:"label=Auto Update;type=boolean;keywords=auto,update,automatic,upgrade,refresh,restart,deploy;category=internal;description=Automatically update containers when new images are available"`
@@ -166,15 +161,6 @@ type Settings struct {
OidcProviderLogoUrl SettingVariable `key:"oidcProviderLogoUrl,public,envOverride" meta:"label=OIDC Provider Logo URL;type=text;keywords=oidc,provider,logo,url,image,icon,sso;category=authentication;description=Custom logo URL for the OIDC provider"`
OidcMobileRedirectUris SettingVariable `key:"oidcMobileRedirectUris,envOverride" meta:"label=OIDC Mobile Redirect URIs;type=text;keywords=oidc,mobile,redirect,uri,callback,scheme,ios,android,native;category=authentication;description=Comma-separated allowlist of native app redirect URIs (e.g., arcane-mobile://oidc-callback)"`
- // Appearance category
- DefaultLandingPage SettingVariable `key:"defaultLandingPage,authrequired,local" meta:"label=Default Landing Page;type=select;keywords=landing,default,home,start,startup,page,route,redirect,login,dashboard,navigation;category=appearance;description=Page to open after signing in"`
- MobileNavigationMode SettingVariable `key:"mobileNavigationMode,authrequired,local" meta:"label=Mobile Navigation Mode;type=select;keywords=mode,style,type,floating,docked,position,layout,design,appearance,bottom;category=appearance;description=Choose between floating or docked navigation on mobile" catmeta:"id=appearance;title=Appearance;icon=appearance;url=/settings/appearance;description=Customize navigation, theme, and interface behavior"`
- MobileNavigationShowLabels SettingVariable `key:"mobileNavigationShowLabels,authrequired,local" meta:"label=Show Navigation Labels;type=boolean;keywords=labels,text,icons,display,show,hide,names,captions,titles,visible,toggle;category=appearance;description=Display text labels alongside navigation icons"`
- SidebarHoverExpansion SettingVariable `key:"sidebarHoverExpansion,authrequired,local" meta:"label=Sidebar Hover Expansion;type=boolean;keywords=sidebar,hover,expansion,expand,desktop,mouse,over,collapsed,collapsible,icon,labels,text,preview,peek,tooltip,overlay,temporary,quick,access,navigation,menu,items,submenu,nested;category=appearance;description=Expand sidebar on hover in desktop mode"`
- KeyboardShortcutsEnabled SettingVariable `key:"keyboardShortcutsEnabled,authrequired,local" meta:"label=Keyboard Shortcuts;type=boolean;keywords=keyboard,shortcuts,hotkeys,keybindings,navigation,tooltips,disable;category=appearance;description=Enable keyboard shortcuts for navigation and show shortcut hints in tooltips"`
- GlassEffectsEnabled SettingVariable `key:"glassEffectsEnabled,public,local" meta:"label=Glass & Blur Effects;type=boolean;keywords=blur,glass,glassmorphism,backdrop,transparency,frosted,performance,gpu,appearance;category=appearance;description=Apply blur and glass effects to UI surfaces. Disable for solid surfaces and lower GPU usage."`
- AnimationsEnabled SettingVariable `key:"animationsEnabled,public,local" meta:"label=Interface Animations;type=boolean;keywords=animation,animations,motion,shimmer,pulse,glow,effects,performance,gpu,appearance;category=appearance;description=Enable decorative interface animations. Disable to reduce motion and GPU usage."`
-
// Notifications category (placeholder for category metadata only - actual settings managed via notification service)
NotificationsCategoryPlaceholder SettingVariable `key:"notificationsCategory,internal" meta:"label=Notifications;type=internal;keywords=notifications,alerts,email,discord,webhooks,events,messages;category=notifications;description=Configure notification providers and alerts" catmeta:"id=notifications;title=Notifications;icon=bell;url=/settings/notifications;description=Configure email and Discord notifications for container and image updates"`
@@ -227,7 +213,6 @@ func buildSettingsFieldCacheInternal() {
isPublic: slices.Contains(attrList, "public"),
isVisibleToNonAdmin: slices.Contains(attrList, "public") || slices.Contains(attrList, "authrequired"),
isSensitive: slices.Contains(attrList, "sensitive"),
- isLocal: slices.Contains(attrList, "local"),
}
ordered = append(ordered, meta)
byKey[key] = meta
@@ -307,16 +292,6 @@ func (s *Settings) FieldByKey(key string) (defaultValue string, isPublic bool, i
return valueField.String(), field.isPublic, field.isSensitive, nil
}
-func (s *Settings) IsLocalSetting(key string) bool {
- _, byKey := getSettingsFieldCacheInternal()
- field, ok := byKey[key]
- if !ok {
- return false
- }
-
- return field.isLocal
-}
-
func (s *Settings) UpdateField(key string, value string, noSensitive bool) error {
rv := reflect.ValueOf(s).Elem()
_, byKey := getSettingsFieldCacheInternal()
diff --git a/backend/internal/models/settings_test.go b/backend/internal/models/settings_test.go
index 19b5b252a..19a4c1ed0 100644
--- a/backend/internal/models/settings_test.go
+++ b/backend/internal/models/settings_test.go
@@ -8,9 +8,6 @@ import (
func TestSettings_ToSettingVariableSlice_Visibility(t *testing.T) {
settings := &Settings{
- ApplicationTheme: SettingVariable{Value: "default"},
- AccentColor: SettingVariable{Value: "oklch(0.6 0.2 240)"},
- OledMode: SettingVariable{Value: "false"},
AuthLocalEnabled: SettingVariable{Value: "true"},
OidcEnabled: SettingVariable{Value: "true"},
OidcAutoRedirectToProvider: SettingVariable{Value: "false"},
@@ -23,15 +20,12 @@ func TestSettings_ToSettingVariableSlice_Visibility(t *testing.T) {
OidcGroupsClaim: SettingVariable{Value: "groups"},
OidcSkipTlsVerify: SettingVariable{Value: "false"},
OidcMergeAccounts: SettingVariable{Value: "true"},
- MobileNavigationMode: SettingVariable{Value: "floating"},
- MobileNavigationShowLabels: SettingVariable{Value: "true"},
- SidebarHoverExpansion: SettingVariable{Value: "true"},
- KeyboardShortcutsEnabled: SettingVariable{Value: "true"},
+ EnableGravatar: SettingVariable{Value: "true"},
+ AvatarMaxUploadSizeMb: SettingVariable{Value: "2"},
OidcClientSecret: SettingVariable{Value: "secret"},
}
publicKeys := settingKeysFromSliceInternal(settings.ToSettingVariableSlice(SettingVisibilityPublic, true))
- require.Contains(t, publicKeys, "applicationTheme")
require.Contains(t, publicKeys, "authLocalEnabled")
require.Contains(t, publicKeys, "oidcEnabled")
require.Contains(t, publicKeys, "oidcAutoRedirectToProvider")
@@ -39,10 +33,9 @@ func TestSettings_ToSettingVariableSlice_Visibility(t *testing.T) {
require.Contains(t, publicKeys, "oidcProviderLogoUrl")
require.NotContains(t, publicKeys, "dockerHost")
require.NotContains(t, publicKeys, "oidcClientId")
- require.NotContains(t, publicKeys, "mobileNavigationMode")
+ require.NotContains(t, publicKeys, "enableGravatar")
nonAdminKeys := settingKeysFromSliceInternal(settings.ToSettingVariableSlice(SettingVisibilityNonAdmin, true))
- require.Contains(t, nonAdminKeys, "applicationTheme")
require.Contains(t, nonAdminKeys, "dockerHost")
require.Contains(t, nonAdminKeys, "oidcClientId")
require.Contains(t, nonAdminKeys, "oidcIssuerUrl")
@@ -50,8 +43,6 @@ func TestSettings_ToSettingVariableSlice_Visibility(t *testing.T) {
require.Contains(t, nonAdminKeys, "oidcGroupsClaim")
require.Contains(t, nonAdminKeys, "oidcSkipTlsVerify")
require.Contains(t, nonAdminKeys, "oidcMergeAccounts")
- require.Contains(t, nonAdminKeys, "mobileNavigationMode")
- require.Contains(t, nonAdminKeys, "keyboardShortcutsEnabled")
require.Contains(t, nonAdminKeys, "enableGravatar")
require.Contains(t, nonAdminKeys, "avatarMaxUploadSizeMb")
require.NotContains(t, nonAdminKeys, "baseServerUrl")
diff --git a/backend/internal/models/user.go b/backend/internal/models/user.go
index 45280b698..791607866 100644
--- a/backend/internal/models/user.go
+++ b/backend/internal/models/user.go
@@ -1,6 +1,7 @@
package models
import (
+ "context"
"time"
"github.com/getarcaneapp/arcane/types/v2/user"
@@ -9,17 +10,18 @@ import (
type User struct {
BaseModel
- Username string `json:"username" sortable:"true"`
- PasswordHash string `json:"-" gorm:"column:password_hash"`
- DisplayName *string `json:"displayName,omitempty" gorm:"column:display_name" sortable:"true"`
- Email *string `json:"email,omitempty" sortable:"true"`
- OidcSubjectId *string `json:"oidcSubjectId,omitempty" gorm:"column:oidc_subject_id"`
- LastLogin *time.Time `json:"lastLogin,omitempty" gorm:"column:last_login" sortable:"true"`
- Locale *string `json:"locale,omitempty" gorm:"column:locale"`
- TimeFormat user.TimeFormat `json:"timeFormat" gorm:"column:time_format;not null;default:auto"`
- FontSize *int `json:"fontSize,omitempty" gorm:"column:font_size"`
- RequiresPasswordChange bool `json:"requiresPasswordChange" gorm:"column:requires_password_change"`
- IsServiceAccount bool `json:"isServiceAccount" gorm:"column:is_service_account;not null;default:false"`
+ Username string `json:"username" sortable:"true"`
+ PasswordHash string `json:"-" gorm:"column:password_hash"`
+ DisplayName *string `json:"displayName,omitempty" gorm:"column:display_name" sortable:"true"`
+ Email *string `json:"email,omitempty" sortable:"true"`
+ OidcSubjectId *string `json:"oidcSubjectId,omitempty" gorm:"column:oidc_subject_id"`
+ LastLogin *time.Time `json:"lastLogin,omitempty" gorm:"column:last_login" sortable:"true"`
+ Locale *string `json:"locale,omitempty" gorm:"column:locale"`
+ TimeFormat user.TimeFormat `json:"timeFormat" gorm:"column:time_format;not null;default:auto"`
+ FontSize *int `json:"fontSize,omitempty" gorm:"column:font_size"`
+ Preferences user.Preferences `json:"preferences" gorm:"column:preferences;serializer:json"`
+ RequiresPasswordChange bool `json:"requiresPasswordChange" gorm:"column:requires_password_change"`
+ IsServiceAccount bool `json:"isServiceAccount" gorm:"column:is_service_account;not null;default:false"`
// Avatar metadata
HasAvatar bool `json:"hasAvatar" gorm:"column:has_avatar;not null;default:false"`
@@ -33,3 +35,21 @@ type User struct {
func (User) TableName() string {
return "users"
}
+
+// currentUserContextKeyInternal is the context key holding the authenticated
+// user model. It lives here (rather than in api/middleware) so that services,
+// which cannot import the middleware package, can read the requesting user for
+// per-user preferences.
+type currentUserContextKeyInternal struct{}
+
+// WithCurrentUser returns a context carrying the authenticated user.
+func WithCurrentUser(ctx context.Context, u *User) context.Context {
+ return context.WithValue(ctx, currentUserContextKeyInternal{}, u)
+}
+
+// CurrentUserFromContext retrieves the authenticated user from the context.
+// Returns nil, false on unauthenticated paths (background jobs, agent proxying).
+func CurrentUserFromContext(ctx context.Context) (*User, bool) {
+ u, ok := ctx.Value(currentUserContextKeyInternal{}).(*User)
+ return u, ok
+}
diff --git a/backend/internal/services/app_images_service.go b/backend/internal/services/app_images_service.go
index 9f26897e8..b03826a34 100644
--- a/backend/internal/services/app_images_service.go
+++ b/backend/internal/services/app_images_service.go
@@ -78,19 +78,9 @@ func (s *ApplicationImagesService) GetImageWithColor(name string, colorOverride
}
func (s *ApplicationImagesService) applyAccentColorToSVGInternal(svgData []byte, colorOverride string) []byte {
- accentColor := ""
+ accentColor := settings.DefaultAccentColor
if settings.SafeAccentColor.MatchString(colorOverride) {
accentColor = colorOverride
- } else if s.settingsService != nil {
- if cfg := s.settingsService.GetSettingsConfig(); cfg != nil {
- stored := cfg.AccentColor.Value
- if stored != "" && stored != "default" && settings.SafeAccentColor.MatchString(stored) {
- accentColor = stored
- }
- }
- }
- if accentColor == "" {
- accentColor = settings.DefaultAccentColor
}
svgStr := string(svgData)
diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.go
index 607e39367..5f3ec99b0 100644
--- a/backend/internal/services/container_service.go
+++ b/backend/internal/services/container_service.go
@@ -1297,11 +1297,7 @@ func (s *ContainerService) getCachedProjectIconMetadataInternal(ctx context.Cont
}
func (s *ContainerService) resolveIconSetInternal(ctx context.Context, iconSet iconcatalog.IconSet) iconcatalog.ResolvedIconSet {
- catalog := iconcatalog.DefaultCatalog
- if s != nil && s.settingsService != nil {
- catalog = s.settingsService.GetStringSetting(ctx, "iconCatalog", iconcatalog.DefaultCatalog)
- }
- return iconcatalog.Resolve(catalog, iconSet)
+ return iconcatalog.Resolve(iconCatalogForContextInternal(ctx), iconSet)
}
func (s *ContainerService) buildContainerPaginationConfig() pagination.Config[containertypes.Summary] {
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index 1de87e39a..157d3297e 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -4294,11 +4294,7 @@ func (s *ProjectService) appendDiscoveredComposeProjectUpdatesInternal(
}
knownProjectNames := s.buildKnownComposeProjectNameSetInternal(ctx, projectsArray)
- iconCatalog := iconcatalog.DefaultCatalog
- if s.settingsService != nil {
- iconCatalog = s.settingsService.GetStringSetting(ctx, "iconCatalog", iconcatalog.DefaultCatalog)
- }
- discovered := buildDiscoveredComposeProjectUpdateRowsInternal(ctx, composeContainers, knownProjectNames, s.imageService, iconCatalog)
+ discovered := buildDiscoveredComposeProjectUpdateRowsInternal(ctx, composeContainers, knownProjectNames, s.imageService, iconCatalogForContextInternal(ctx))
if len(discovered) == 0 {
return items
}
@@ -4856,12 +4852,18 @@ func (s *ProjectService) getProjectMetadataForProject(ctx context.Context, p mod
return meta
}
-func (s *ProjectService) resolveIconSetInternal(ctx context.Context, iconSet iconcatalog.IconSet) iconcatalog.ResolvedIconSet {
- catalog := iconcatalog.DefaultCatalog
- if s != nil && s.settingsService != nil {
- catalog = s.settingsService.GetStringSetting(ctx, "iconCatalog", iconcatalog.DefaultCatalog)
+// iconCatalogForContextInternal resolves the icon catalog of the requesting
+// user. Background jobs and agent-proxied calls have no user attached and fall
+// back to the default catalog.
+func iconCatalogForContextInternal(ctx context.Context) string {
+ if u, ok := models.CurrentUserFromContext(ctx); ok && u != nil && u.Preferences.IconCatalog != nil && *u.Preferences.IconCatalog != "" {
+ return *u.Preferences.IconCatalog
}
- return iconcatalog.Resolve(catalog, iconSet)
+ return iconcatalog.DefaultCatalog
+}
+
+func (s *ProjectService) resolveIconSetInternal(ctx context.Context, iconSet iconcatalog.IconSet) iconcatalog.ResolvedIconSet {
+ return iconcatalog.Resolve(iconCatalogForContextInternal(ctx), iconSet)
}
func applyResolvedProjectIconInternal(resp *project.Details, icon iconcatalog.ResolvedIconSet) {
diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.go
index e0afd0ed5..564c6baf1 100644
--- a/backend/internal/services/settings_service.go
+++ b/backend/internal/services/settings_service.go
@@ -184,17 +184,6 @@ func DefaultSettingsConfig() *models.Settings {
OidcProviderName: models.SettingVariable{Value: ""},
OidcProviderLogoUrl: models.SettingVariable{Value: ""},
OidcMobileRedirectUris: models.SettingVariable{Value: "arcane-mobile://oidc-callback"},
- DefaultLandingPage: models.SettingVariable{Value: "/dashboard"},
- MobileNavigationMode: models.SettingVariable{Value: "floating"},
- MobileNavigationShowLabels: models.SettingVariable{Value: "true"},
- SidebarHoverExpansion: models.SettingVariable{Value: "true"},
- KeyboardShortcutsEnabled: models.SettingVariable{Value: "true"},
- ApplicationTheme: models.SettingVariable{Value: "default"},
- IconCatalog: models.SettingVariable{Value: "selfhst"},
- AccentColor: models.SettingVariable{Value: "oklch(0.606 0.25 292.717)"},
- OledMode: models.SettingVariable{Value: "false"},
- GlassEffectsEnabled: models.SettingVariable{Value: "true"},
- AnimationsEnabled: models.SettingVariable{Value: "true"},
MaxImageUploadSize: models.SettingVariable{Value: "500"},
GitSyncMaxFiles: models.SettingVariable{Value: "500"},
GitSyncMaxTotalSizeMb: models.SettingVariable{Value: "50"},
@@ -513,10 +502,6 @@ func (s *SettingsService) prepareUpdateValues(updates settings.Update, cfg, defa
return nil, false, false, false, false, false, nil, errors.WrapIff(err, "invalid cron expression for %s", key)
}
- if key == "accentColor" && value != "" && value != "default" && !settings.SafeAccentColor.MatchString(value) {
- return nil, false, false, false, false, false, nil, errors.New("invalid accentColor value")
- }
-
var valueToSave string
var err error
diff --git a/backend/internal/services/user_service.go b/backend/internal/services/user_service.go
index 322d4c65f..8d89eeed2 100644
--- a/backend/internal/services/user_service.go
+++ b/backend/internal/services/user_service.go
@@ -445,6 +445,7 @@ func (s *UserService) toUserResponseDtoInternal(ctx context.Context, u models.Us
Locale: u.Locale,
TimeFormat: u.TimeFormat,
FontSize: u.FontSize,
+ Preferences: u.Preferences,
RequiresPasswordChange: u.RequiresPasswordChange,
CreatedAt: u.CreatedAt.Format("2006-01-02T15:04:05.999999Z"),
UpdatedAt: u.UpdatedAt.Format("2006-01-02T15:04:05.999999Z"),
diff --git a/backend/pkg/authz/access_policy.go b/backend/pkg/authz/access_policy.go
index a6a15b609..a39a83e1d 100644
--- a/backend/pkg/authz/access_policy.go
+++ b/backend/pkg/authz/access_policy.go
@@ -43,7 +43,6 @@ var accessSurfacesInternal = []AccessSurface{
landingSurfaceInternal("landing.settings", "/settings", "Settings", []string{
"settings.category.activity",
"settings.category.apikeys",
- "settings.category.appearance",
"settings.category.authentication",
"settings.category.build",
"settings.category.jobschedule",
@@ -95,7 +94,6 @@ var accessSurfacesInternal = []AccessSurface{
settingsCategorySurfaceInternal("activity", "/settings/activity", "Activity", AccessScopeModeGlobalOnly, []string{PermSettingsRead}),
settingsCategorySurfaceInternal("apikeys", "/settings/api-keys", "API Keys", AccessScopeModeGlobalOnly, []string{PermApiKeysList, PermApiKeysRead}),
- settingsCategorySurfaceInternal("appearance", "/settings/appearance", "Appearance", AccessScopeModeGlobalOnly, []string{PermSettingsRead}),
settingsCategorySurfaceInternal("authentication", "/settings/authentication", "Authentication", AccessScopeModeGlobalOnly, []string{PermSettingsRead}),
settingsCategorySurfaceInternal("build", "/settings/builds", "Builds", AccessScopeModeGlobalOnly, []string{PermSettingsRead}),
settingsCategorySurfaceInternal("jobschedule", "", "Automations", AccessScopeModeSelectedEnvPlusGlobal, []string{PermJobsManage}),
diff --git a/backend/resources/migrations/postgres/068_add_user_preferences.sql b/backend/resources/migrations/postgres/068_add_user_preferences.sql
new file mode 100644
index 000000000..5da65a9b6
--- /dev/null
+++ b/backend/resources/migrations/postgres/068_add_user_preferences.sql
@@ -0,0 +1,29 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN IF NOT EXISTS preferences TEXT;
+
+-- Seed every user's preferences from the current global settings so that
+-- upgrading does not visually change anything. The old settings rows are left
+-- in place; PruneUnknownSettings removes them on first startup of the new
+-- binary, which keeps this migration reversible.
+UPDATE users SET preferences = jsonb_build_object(
+ 'applicationTheme', (SELECT value FROM settings WHERE key = 'applicationTheme'),
+ 'accentColor', (SELECT value FROM settings WHERE key = 'accentColor'),
+ 'iconCatalog', (SELECT value FROM settings WHERE key = 'iconCatalog'),
+ 'defaultLandingPage', (SELECT value FROM settings WHERE key = 'defaultLandingPage'),
+ 'mobileNavigationMode', (SELECT value FROM settings WHERE key = 'mobileNavigationMode'),
+ 'oledMode', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'oledMode'),
+ 'glassEffectsEnabled', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'glassEffectsEnabled'),
+ 'animationsEnabled', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'animationsEnabled'),
+ 'sidebarHoverExpansion', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'sidebarHoverExpansion'),
+ 'keyboardShortcutsEnabled', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'keyboardShortcutsEnabled'),
+ 'mobileNavigationShowLabels', (SELECT CASE value WHEN 'true' THEN to_jsonb(TRUE) WHEN 'false' THEN to_jsonb(FALSE) END
+ FROM settings WHERE key = 'mobileNavigationShowLabels')
+)::text;
+
+-- +goose Down
+ALTER TABLE users DROP COLUMN IF EXISTS preferences;
diff --git a/backend/resources/migrations/sqlite/068_add_user_preferences.sql b/backend/resources/migrations/sqlite/068_add_user_preferences.sql
new file mode 100644
index 000000000..6294c21cc
--- /dev/null
+++ b/backend/resources/migrations/sqlite/068_add_user_preferences.sql
@@ -0,0 +1,29 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN preferences TEXT;
+
+-- Seed every user's preferences from the current global settings so that
+-- upgrading does not visually change anything. The old settings rows are left
+-- in place; PruneUnknownSettings removes them on first startup of the new
+-- binary, which keeps this migration reversible.
+UPDATE users SET preferences = json_object(
+ 'applicationTheme', (SELECT value FROM settings WHERE key = 'applicationTheme'),
+ 'accentColor', (SELECT value FROM settings WHERE key = 'accentColor'),
+ 'iconCatalog', (SELECT value FROM settings WHERE key = 'iconCatalog'),
+ 'defaultLandingPage', (SELECT value FROM settings WHERE key = 'defaultLandingPage'),
+ 'mobileNavigationMode', (SELECT value FROM settings WHERE key = 'mobileNavigationMode'),
+ 'oledMode', json(CASE (SELECT value FROM settings WHERE key = 'oledMode')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END),
+ 'glassEffectsEnabled', json(CASE (SELECT value FROM settings WHERE key = 'glassEffectsEnabled')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END),
+ 'animationsEnabled', json(CASE (SELECT value FROM settings WHERE key = 'animationsEnabled')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END),
+ 'sidebarHoverExpansion', json(CASE (SELECT value FROM settings WHERE key = 'sidebarHoverExpansion')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END),
+ 'keyboardShortcutsEnabled', json(CASE (SELECT value FROM settings WHERE key = 'keyboardShortcutsEnabled')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END),
+ 'mobileNavigationShowLabels', json(CASE (SELECT value FROM settings WHERE key = 'mobileNavigationShowLabels')
+ WHEN 'true' THEN 'true' WHEN 'false' THEN 'false' ELSE 'null' END)
+);
+
+-- +goose Down
+ALTER TABLE users DROP COLUMN preferences;
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index d6ffadd5c..dbf773d9e 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1484,7 +1484,7 @@
"navigation_settings_saved": "Navigation settings saved successfully",
"navigation_desktop_sidebar_title": "Desktop Sidebar",
"navigation_default_landing_page_label": "Default Landing Page",
- "navigation_default_landing_page_description": "Page to open after signing in. Applies to this browser when set here; the server default applies everywhere else.",
+ "navigation_default_landing_page_description": "Page to open after signing in.",
"navigation_sidebar_hover_expansion_label": "Enable Hover Expansion",
"navigation_sidebar_hover_expansion_description": "When enabled, hovering over the collapsed sidebar will temporarily expand it to show full labels. When disabled, tooltips will appear instead for a cleaner, fixed-width navigation.",
"navigation_keyboard_shortcuts_label": "Keyboard Shortcuts",
@@ -2374,6 +2374,8 @@
"update_center_complete": "Update complete.",
"auto_start": "Auto-start",
"api_key_name_placeholder": "Enter a name for this API key",
+ "api_key_save_warning": "Save this key now — it won't be shown again.",
+ "api_keys_empty": "No API keys yet",
"api_key_name_description": "A friendly name to identify this API key",
"optional_description_placeholder": "Optional description",
"api_key_description_help": "Additional details about what this API key is used for",
diff --git a/frontend/src/lib/components/accent-color/accent-color-picker.svelte b/frontend/src/lib/components/accent-color/accent-color-picker.svelte
index c4c630348..9c913c4f1 100644
--- a/frontend/src/lib/components/accent-color/accent-color-picker.svelte
+++ b/frontend/src/lib/components/accent-color/accent-color-picker.svelte
@@ -8,8 +8,15 @@
let {
selectedColor = $bindable(),
previousColor,
- disabled = false
- }: { selectedColor: string; previousColor: string; disabled?: boolean } = $props();
+ disabled = false,
+ onSelect
+ }: {
+ selectedColor: string;
+ previousColor: string;
+ disabled?: boolean;
+ /** Called whenever the user picks a different accent color. */
+ onSelect?: (color: string) => void;
+ } = $props();
let showCustomColorDialog = $state(false);
const accentColors = [
@@ -29,6 +36,7 @@
function handleAccentColorChange(accentValue: string) {
selectedColor = accentValue;
applyAccentColor(accentValue);
+ onSelect?.(accentValue);
}
</script>
diff --git a/frontend/src/lib/components/application-theme/application-theme-picker.svelte b/frontend/src/lib/components/application-theme/application-theme-picker.svelte
index 892c25796..23d65cc66 100644
--- a/frontend/src/lib/components/application-theme/application-theme-picker.svelte
+++ b/frontend/src/lib/components/application-theme/application-theme-picker.svelte
@@ -12,11 +12,14 @@
let {
selectedTheme = $bindable(),
accentColor = '',
- disabled = false
+ disabled = false,
+ onSelect
}: {
selectedTheme: ApplicationTheme;
accentColor?: string;
disabled?: boolean;
+ /** Called whenever the user picks a different theme. */
+ onSelect?: (theme: ApplicationTheme) => void;
} = $props();
const themeCopy: Record<ApplicationTheme, { label: string; description: string }> = {
@@ -90,6 +93,7 @@
selectedTheme = centeredTheme;
applyApplicationTheme(centeredTheme);
+ onSelect?.(centeredTheme);
};
api.on('select', syncCenteredTheme);
@@ -109,6 +113,7 @@
const nextTheme = resolveApplicationTheme(value);
selectedTheme = nextTheme;
applyApplicationTheme(nextTheme);
+ onSelect?.(nextTheme);
}
</script>
diff --git a/frontend/src/lib/components/code-editor/editor.svelte b/frontend/src/lib/components/code-editor/editor.svelte
index 13186bf20..b59abdffe 100644
--- a/frontend/src/lib/components/code-editor/editor.svelte
+++ b/frontend/src/lib/components/code-editor/editor.svelte
@@ -24,7 +24,7 @@
import { type Extension } from '@codemirror/state';
import { browser } from '$app/env';
import { m } from '#lib/paraglide/messages';
- import configStore from '#lib/stores/config-store';
+ import userStore from '#lib/stores/user-store';
import { mode } from 'mode-watcher';
import { arcaneDarkInit, arcaneLightInit } from './theme';
import { createDefaultSummary, ENV_SNIPPETS, YAML_SNIPPETS } from './editor-constants';
@@ -93,7 +93,7 @@
let activeOutlineItems = $state<OutlineItem[]>([]);
let activeView = $state<EditorView | null>(null);
let schemaState = $state<ComposeSchemaContext | null>(null);
- let shortcutsEnabled = $derived($configStore?.keyboardShortcutsEnabled !== false);
+ let shortcutsEnabled = $derived($userStore?.preferences?.keyboardShortcutsEnabled !== false);
let schemaHoverSuppressedUntil = 0;
const schemaHoverSelectionSuppressionMs = 2500;
@@ -752,7 +752,8 @@
}
const theme = $derived.by(() => {
- $configStore;
+ // Re-derive when the user's theme/accent preferences change.
+ $userStore;
return mode.current === 'dark' ? arcaneDarkInit() : arcaneLightInit();
});
diff --git a/frontend/src/lib/components/sidebar/sidebar-item-tooltip-content.svelte b/frontend/src/lib/components/sidebar/sidebar-item-tooltip-content.svelte
index e086d70c1..e95ecb89e 100644
--- a/frontend/src/lib/components/sidebar/sidebar-item-tooltip-content.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-item-tooltip-content.svelte
@@ -1,7 +1,7 @@
<script lang="ts">
import * as Kbd from '#lib/components/ui/kbd/index.js';
import { formatShortcutKeys, type ShortcutKey } from '#lib/utils/navigation';
- import settingsStore from '#lib/stores/config-store';
+ import userStore from '#lib/stores/user-store';
let {
title,
@@ -13,7 +13,7 @@
includeTitle?: boolean;
} = $props();
- const showShortcut = $derived($settingsStore?.keyboardShortcutsEnabled ?? true);
+ const showShortcut = $derived($userStore?.preferences?.keyboardShortcutsEnabled ?? true);
</script>
<div class="flex flex-wrap items-center gap-2">
diff --git a/frontend/src/lib/components/sidebar/sidebar-itemgroup.svelte b/frontend/src/lib/components/sidebar/sidebar-itemgroup.svelte
index 9c43158b5..c492324e9 100644
--- a/frontend/src/lib/components/sidebar/sidebar-itemgroup.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-itemgroup.svelte
@@ -8,7 +8,7 @@
import { ArrowRightIcon } from '#lib/icons';
import SidebarCollapsibleItem from './sidebar-collapsible-item.svelte';
import SidebarItemTooltipContent from './sidebar-item-tooltip-content.svelte';
- import settingsStore from '#lib/stores/config-store';
+ import userStore from '#lib/stores/user-store';
let {
items,
@@ -72,7 +72,7 @@
const collapsed = $derived(sidebar.state === 'collapsed');
const includeTitleInTooltip = $derived(collapsed && !(sidebar.hoverExpansionEnabled && sidebar.isHovered));
- const shortcutsEnabled = $derived($settingsStore?.keyboardShortcutsEnabled ?? true);
+ const shortcutsEnabled = $derived($userStore?.preferences?.keyboardShortcutsEnabled ?? true);
</script>
{#snippet itemAnchor(entry: { title: string; url: string; icon?: typeof ArrowRightIcon }, props: Record<string, unknown>)}
diff --git a/frontend/src/lib/components/theme-mode/theme-mode-selector.svelte b/frontend/src/lib/components/theme-mode/theme-mode-selector.svelte
index 396ed2e30..af440d25e 100644
--- a/frontend/src/lib/components/theme-mode/theme-mode-selector.svelte
+++ b/frontend/src/lib/components/theme-mode/theme-mode-selector.svelte
@@ -3,6 +3,8 @@
import { m } from '#lib/paraglide/messages';
import { SunIcon, MoonIcon, MonitorIcon } from '#lib/icons';
import { cn } from '#lib/utils';
+ import { userService } from '#lib/services/user-service';
+ import userStore from '#lib/stores/user-store';
type Props = {
disabled?: boolean;
@@ -18,6 +20,19 @@
] as const);
const current = $derived(userPrefersMode.current);
+
+ // Applied to this device immediately, then stored on the account so the
+ // choice follows the user to their other devices.
+ async function selectMode(value: 'light' | 'dark' | 'system') {
+ setMode(value);
+ if (!$userStore) return;
+ try {
+ const updated = await userService.updateMyProfile({ preferences: { themeMode: value } });
+ await userStore.setUser(updated);
+ } catch (err) {
+ console.error('Failed to save theme mode', err);
+ }
+ }
</script>
<div class={cn('inline-flex rounded-lg bg-muted/40 p-0.5', className)} role="group" aria-label={m.common_toggle_theme()}>
@@ -27,7 +42,7 @@
type="button"
{disabled}
aria-pressed={current === option.value}
- onclick={() => setMode(option.value)}
+ onclick={() => void selectMode(option.value)}
class={cn(
'inline-flex items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
current === option.value ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'
diff --git a/frontend/src/lib/components/ui/sidebar/context.svelte.ts b/frontend/src/lib/components/ui/sidebar/context.svelte.ts
index 683c63a8d..323c930bd 100644
--- a/frontend/src/lib/components/ui/sidebar/context.svelte.ts
+++ b/frontend/src/lib/components/ui/sidebar/context.svelte.ts
@@ -27,7 +27,9 @@ class SidebarState {
setOpen: SidebarStateProps['setOpen'];
#isTablet: IsTablet;
#isPinnedState = new PersistedState('sidebar-pinned', true);
- #hoverExpansionEnabled = new PersistedState('sidebar-hover-expansion', false);
+ // Effective value comes from the signed-in user's `sidebarHoverExpansion`
+ // preference, synced in by `sidebar-provider.svelte`.
+ #hoverExpansionEnabled = $state(true);
#isHovered = $state(false);
#hoverTimeout: ReturnType<typeof setTimeout> | null = null;
state = $derived.by(() => (this.open ? 'expanded' : 'collapsed'));
@@ -70,12 +72,12 @@ class SidebarState {
// Getter for hover expansion preference
get hoverExpansionEnabled() {
- return this.#hoverExpansionEnabled.current;
+ return this.#hoverExpansionEnabled;
}
// Setter for hover expansion preference
setHoverExpansion = (enabled: boolean) => {
- this.#hoverExpansionEnabled.current = enabled;
+ this.#hoverExpansionEnabled = enabled;
};
// Derived state that shows if sidebar should be visually expanded (either open or hovered)
@@ -86,7 +88,7 @@ class SidebarState {
return this.#isHovered;
}
// Only consider hover state for expansion if hover expansion is enabled
- const shouldExpandOnHover = !this.open && this.#isHovered && this.#hoverExpansionEnabled.current;
+ const shouldExpandOnHover = !this.open && this.#isHovered && this.#hoverExpansionEnabled;
return this.open || shouldExpandOnHover;
}
diff --git a/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte b/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
index 075cc400f..8b3ab373d 100644
--- a/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
+++ b/frontend/src/lib/components/ui/sidebar/sidebar-provider.svelte
@@ -7,7 +7,7 @@
import { IsTablet } from '#lib/hooks/is-tablet.svelte.js';
import { IsMobile } from '#lib/hooks/is-mobile.svelte.js';
import { PersistedState } from 'runed';
- import settingsStore from '#lib/stores/config-store';
+ import userStore from '#lib/stores/user-store';
const persistedPinned = new PersistedState('sidebar-pinned', true);
@@ -60,18 +60,15 @@
}
});
- // Sync sidebar hover expansion with backend settings
+ // Sync sidebar hover expansion with the signed-in user's preference
$effect(() => {
- const settings = $settingsStore;
- if (settings && settings.sidebarHoverExpansion !== undefined) {
- sidebar.setHoverExpansion(settings.sidebarHoverExpansion);
- }
+ sidebar.setHoverExpansion($userStore?.preferences?.sidebarHoverExpansion ?? true);
});
</script>
<svelte:window
onkeydown={(event) => {
- if ($settingsStore?.keyboardShortcutsEnabled !== false) {
+ if ($userStore?.preferences?.keyboardShortcutsEnabled !== false) {
sidebar.handleShortcutKeydown(event);
}
}}
diff --git a/frontend/src/lib/config/navigation-config.ts b/frontend/src/lib/config/navigation-config.ts
index 52dfd9631..c593441a1 100644
--- a/frontend/src/lib/config/navigation-config.ts
+++ b/frontend/src/lib/config/navigation-config.ts
@@ -1,6 +1,5 @@
import {
ApiKeyIcon,
- AppearanceIcon,
UsersIcon,
LockIcon,
NotificationsIcon,
@@ -196,13 +195,6 @@ export const navigationItems: NavigationSections = {
shortcut: ['mod', 'shift', '1'],
accessSurfaceId: 'settings.category.apikeys'
},
- {
- title: m.appearance_title(),
- url: '/settings/appearance',
- icon: AppearanceIcon,
- shortcut: ['mod', 'shift', '2'],
- accessSurfaceId: 'settings.category.appearance'
- },
{
title: m.webhook_page_title(),
url: '/settings/webhooks',
diff --git a/frontend/src/lib/services/user-service.ts b/frontend/src/lib/services/user-service.ts
index f5fe66a33..2c5b2ce1c 100644
--- a/frontend/src/lib/services/user-service.ts
+++ b/frontend/src/lib/services/user-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import type { User, CreateUser, TimeFormat } from '#lib/types/auth';
+import type { User, CreateUser, TimeFormat, UserPreferences } from '#lib/types/auth';
import type { Paginated, SearchPaginationSortRequest } from '#lib/types/shared';
import { transformPaginationParams } from '#lib/utils/tables';
@@ -44,6 +44,7 @@ class UserAPIService extends BaseAPIService {
locale?: string;
timeFormat?: TimeFormat;
fontSize?: number;
+ preferences?: Partial<UserPreferences>;
}): Promise<User> {
return this.handleResponse(this.api.put('/auth/me/profile', data)) as Promise<User>;
}
diff --git a/frontend/src/lib/stores/config-store.ts b/frontend/src/lib/stores/config-store.ts
index 0bf4a9e4d..422e0c86b 100644
--- a/frontend/src/lib/stores/config-store.ts
+++ b/frontend/src/lib/stores/config-store.ts
@@ -1,12 +1,5 @@
import { settingsService } from '#lib/services/settings-service';
import type { Settings } from '#lib/types/settings';
-import {
- applyAccentColor,
- applyApplicationTheme,
- applyOledMode,
- applyGlassEffects,
- applyInterfaceAnimations
-} from '#lib/utils/theme';
import { get, writable } from 'svelte/store';
const settingsStore = writable<Settings>();
@@ -18,11 +11,6 @@ const reload = async () => {
};
const set = (settings: Settings) => {
- applyApplicationTheme(settings.applicationTheme);
- applyAccentColor(settings.accentColor);
- applyOledMode(settings.oledMode ?? false);
- applyGlassEffects(settings.glassEffectsEnabled ?? true);
- applyInterfaceAnimations(settings.animationsEnabled ?? true);
settingsStore.set(settings);
};
diff --git a/frontend/src/lib/stores/user-store.ts b/frontend/src/lib/stores/user-store.ts
index 7a0fb313a..1e7242177 100644
--- a/frontend/src/lib/stores/user-store.ts
+++ b/frontend/src/lib/stores/user-store.ts
@@ -2,7 +2,16 @@ import type { User } from '#lib/types/auth';
import { GLOBAL_SCOPE, SUDO_PERMISSION } from '#lib/types/auth';
import { writable, get } from 'svelte/store';
import { setLocale } from '#lib/utils/formatting';
-import { applyFontSize, FONT_SIZE_DEFAULT } from '#lib/utils/theme';
+import {
+ applyAccentColor,
+ applyApplicationTheme,
+ applyFontSize,
+ applyGlassEffects,
+ applyInterfaceAnimations,
+ applyOledMode,
+ FONT_SIZE_DEFAULT
+} from '#lib/utils/theme';
+import { setMode } from 'mode-watcher';
import { timeFormatStore } from '#lib/stores/time-format.store.svelte';
const userStore = writable<User | null>(null);
@@ -20,12 +29,32 @@ const setUser = async (user: User) => {
}
applyFontSize(user.fontSize ?? FONT_SIZE_DEFAULT);
timeFormatStore.set(user.timeFormat ?? 'auto');
+
+ const preferences = user.preferences ?? {};
+ applyApplicationTheme(preferences.applicationTheme);
+ applyAccentColor(preferences.accentColor ?? 'default');
+ applyOledMode(preferences.oledMode ?? false);
+ applyGlassEffects(preferences.glassEffectsEnabled ?? true);
+ applyInterfaceAnimations(preferences.animationsEnabled ?? true);
+ // Only override the device-local mode when the account carries an explicit
+ // choice, so a browser that has never synced keeps its own light/dark mode.
+ if (preferences.themeMode) {
+ setMode(preferences.themeMode);
+ }
+
userStore.set(user);
};
const clearUser = () => {
applyFontSize(FONT_SIZE_DEFAULT);
timeFormatStore.reset();
+ applyApplicationTheme('default');
+ applyAccentColor('default');
+ applyOledMode(false);
+ applyGlassEffects(true);
+ applyInterfaceAnimations(true);
+ // Light/dark mode is deliberately left alone on logout: it is a device-local
+ // preference and flipping it mid-session is jarring.
userStore.set(null);
};
diff --git a/frontend/src/lib/types/auth.ts b/frontend/src/lib/types/auth.ts
index fbfcb69d0..69262191c 100644
--- a/frontend/src/lib/types/auth.ts
+++ b/frontend/src/lib/types/auth.ts
@@ -1,4 +1,5 @@
import type { Locale } from '#lib/paraglide/runtime';
+import type { ApplicationTheme, IconCatalog } from '#lib/types/settings';
// --- RBAC: roles, permissions, assignments ---
@@ -130,6 +131,25 @@ export const GLOBAL_SCOPE = 'global';
export type TimeFormat = 'auto' | '12h' | '24h';
+/**
+ * Personal display/UI preferences stored on the user record. Every field is
+ * optional: an unset value falls back to the frontend default.
+ */
+export type UserPreferences = {
+ themeMode?: 'light' | 'dark' | 'system';
+ applicationTheme?: ApplicationTheme;
+ accentColor?: string;
+ iconCatalog?: IconCatalog;
+ oledMode?: boolean;
+ glassEffectsEnabled?: boolean;
+ animationsEnabled?: boolean;
+ sidebarHoverExpansion?: boolean;
+ keyboardShortcutsEnabled?: boolean;
+ mobileNavigationMode?: 'floating' | 'docked';
+ mobileNavigationShowLabels?: boolean;
+ defaultLandingPage?: string;
+};
+
export type User = {
id: string;
username: string;
@@ -148,6 +168,7 @@ export type User = {
locale?: Locale;
timeFormat: TimeFormat;
fontSize?: number;
+ preferences?: UserPreferences;
requiresPasswordChange?: boolean;
};
diff --git a/frontend/src/lib/types/settings.ts b/frontend/src/lib/types/settings.ts
index d6303704f..982137e3b 100644
--- a/frontend/src/lib/types/settings.ts
+++ b/frontend/src/lib/types/settings.ts
@@ -55,12 +55,6 @@ export type Settings = {
uiConfigDisabled: boolean;
defaultShell: string;
dockerHost: string;
- applicationTheme: ApplicationTheme;
- iconCatalog: IconCatalog;
- accentColor: string;
- oledMode: boolean;
- glassEffectsEnabled: boolean;
- animationsEnabled: boolean;
autoInjectEnv: boolean;
backupVolumeName?: string;
edgeMTLSManagerCAAvailable?: boolean;
@@ -96,12 +90,6 @@ export type Settings = {
oidcProviderName: string;
oidcProviderLogoUrl: string;
- defaultLandingPage: string;
- mobileNavigationMode: 'floating' | 'docked';
- mobileNavigationShowLabels: boolean;
- sidebarHoverExpansion: boolean;
- keyboardShortcutsEnabled: boolean;
-
dockerApiTimeout: number;
dockerImagePullTimeout: number;
trivyScanTimeout: number;
diff --git a/frontend/src/lib/utils/navigation.ts b/frontend/src/lib/utils/navigation.ts
index 52cda8fba..b5e90f334 100644
--- a/frontend/src/lib/utils/navigation.ts
+++ b/frontend/src/lib/utils/navigation.ts
@@ -7,16 +7,12 @@ import {
getLandingPageNavItems,
type MobileNavigationSettings
} from '#lib/config/navigation-config';
-import settingsStore from '#lib/stores/config-store';
+import userStore from '#lib/stores/user-store';
// --- Mobile nav state ---
const pinnedItemsStore = new PersistedState('mobile-nav-settings', defaultMobileNavigationSettings);
-export const navigationSettingsOverridesStore = new PersistedState<
- Partial<MobileNavigationSettings> & { defaultLandingPage?: string }
->('navigation-settings-overrides', {});
-
type NavigationVisibilityController = {
resetVisibility: () => void;
};
@@ -32,36 +28,24 @@ export function resetNavigationVisibility() {
}
export function getEffectiveNavigationSettings(): MobileNavigationSettings {
- const serverSettings = get(settingsStore);
- const overrides = navigationSettingsOverridesStore.current;
- const currentPinnedItems = pinnedItemsStore.current;
-
- const getEffectiveValue = <T>(serverValue: T | undefined, overrideValue: T | undefined, defaultValue: T): T => {
- return overrideValue !== undefined ? overrideValue : (serverValue ?? defaultValue);
- };
-
- const mode = getEffectiveValue(serverSettings?.mobileNavigationMode, overrides.mode, defaultMobileNavigationSettings.mode);
+ const preferences = get(userStore)?.preferences;
+ const mode = preferences?.mobileNavigationMode ?? defaultMobileNavigationSettings.mode;
return {
- pinnedItems: overrides.pinnedItems ?? currentPinnedItems.pinnedItems,
+ pinnedItems: pinnedItemsStore.current.pinnedItems,
mode,
- showLabels: getEffectiveValue(
- serverSettings?.mobileNavigationShowLabels,
- overrides.showLabels,
- defaultMobileNavigationSettings.showLabels
- ),
+ showLabels: preferences?.mobileNavigationShowLabels ?? defaultMobileNavigationSettings.showLabels,
scrollToHide: mode === 'floating'
};
}
/**
- * Resolve the page to open after signing in: per-browser override first, then
- * the server-side setting, then the built-in default. A stale value (e.g. a
- * page that no longer exists) falls back to the default rather than 404ing.
+ * Resolve the page to open after signing in from the signed-in user's account
+ * preference, falling back to the built-in default. A stale value (e.g. a page
+ * that no longer exists) falls back to the default rather than 404ing.
*/
export function getEffectiveLandingPage(): string {
- const candidate =
- navigationSettingsOverridesStore.current.defaultLandingPage ?? get(settingsStore)?.defaultLandingPage ?? DEFAULT_LANDING_PAGE;
+ const candidate = get(userStore)?.preferences?.defaultLandingPage ?? DEFAULT_LANDING_PAGE;
return getLandingPageNavItems().some((item) => item.url === candidate) ? candidate : DEFAULT_LANDING_PAGE;
}
diff --git a/frontend/src/lib/utils/settings.ts b/frontend/src/lib/utils/settings.ts
index 55b53916d..cfd1566eb 100644
--- a/frontend/src/lib/utils/settings.ts
+++ b/frontend/src/lib/utils/settings.ts
@@ -1,38 +1,14 @@
import { get, writable } from 'svelte/store';
import { z } from 'zod/v4';
-import type { ApplicationTheme } from '#lib/types/settings';
-import type { IconCatalog } from '#lib/types/settings';
// --- Local vs environment settings classification ---
export type LocalSettings = {
- applicationTheme: ApplicationTheme;
- iconCatalog: IconCatalog;
- accentColor: string;
- oledMode: boolean;
- glassEffectsEnabled: boolean;
- animationsEnabled: boolean;
- defaultLandingPage: string;
- mobileNavigationMode: string;
- mobileNavigationShowLabels: boolean;
- sidebarHoverExpansion: boolean;
- keyboardShortcutsEnabled: boolean;
edgeMTLSManagerCAAvailable?: boolean;
avatarMaxUploadSizeMb: number;
};
const LOCAL_SETTING_KEYS = new Set([
- 'applicationTheme',
- 'iconCatalog',
- 'accentColor',
- 'oledMode',
- 'glassEffectsEnabled',
- 'animationsEnabled',
- 'defaultLandingPage',
- 'mobileNavigationMode',
- 'mobileNavigationShowLabels',
- 'sidebarHoverExpansion',
- 'keyboardShortcutsEnabled',
'avatarMaxUploadSizeMb',
'authLocalEnabled',
'authSessionTimeout',
diff --git a/frontend/src/lib/utils/theme.ts b/frontend/src/lib/utils/theme.ts
index 0f18a24b6..bff6efde7 100644
--- a/frontend/src/lib/utils/theme.ts
+++ b/frontend/src/lib/utils/theme.ts
@@ -209,7 +209,7 @@ const APP_THEME_ATTRIBUTE = 'data-app-theme';
const OLED_CLASS = 'oled';
const DARK_CLASS = 'dark';
const OLED_THEME_COLOR = '#000000';
-const DEFAULT_ACCENT_COLOR = 'oklch(0.606 0.25 292.717)';
+export const DEFAULT_ACCENT_COLOR = 'oklch(0.606 0.25 292.717)';
let htmlClassObserver: MutationObserver | null = null;
diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelte
index f95138201..c5868c7b2 100644
--- a/frontend/src/routes/(app)/+layout.svelte
+++ b/frontend/src/routes/(app)/+layout.svelte
@@ -9,22 +9,17 @@
import OperationWatchDialog from '#lib/components/operation-watch-dialog.svelte';
import { IsMobile } from '#lib/hooks/is-mobile.svelte.js';
import { IsTablet } from '#lib/hooks/is-tablet.svelte.js';
- import {
- getEffectiveLandingPage,
- getEffectiveNavigationSettings,
- navigationSettingsOverridesStore
- } from '#lib/utils/navigation';
+ import { getEffectiveLandingPage, getEffectiveNavigationSettings } from '#lib/utils/navigation';
import { browser } from '$app/env';
import { environmentStore } from '#lib/stores/environment.store.svelte';
import { navigationItems, getManagementItems, filterByPermissions, type NavigationItem } from '#lib/config/navigation-config';
import { isEditableTarget, matchesShortcutEvent } from '#lib/utils/navigation';
import { cn } from '#lib/utils';
- import { userHasPermissionInAnyEnvironment } from '#lib/stores/user-store';
+ import userStore, { userHasPermissionInAnyEnvironment } from '#lib/stores/user-store';
let { data, children }: LayoutProps = $props();
const versionInformation = $derived(data.versionInformation);
const user = $derived(data.user);
- const settings = $derived(data.settings);
const permissionsManifest = $derived(data.permissionsManifest);
const permissionsManifestLoadFailed = $derived(data.permissionsManifestLoadFailed);
const swarmEnabled = $derived(data.swarmEnabled === true);
@@ -34,8 +29,9 @@
const isTablet = new IsTablet();
const navigationSettings = $derived.by(() => {
- settings;
- navigationSettingsOverridesStore.current;
+ // Track the store, not the loader snapshot: saving a preference calls
+ // userStore.setUser() without re-running load().
+ $userStore;
return getEffectiveNavigationSettings();
});
const navigationMode = $derived(navigationSettings.mode);
@@ -81,7 +77,7 @@
function handleNavigationShortcut(event: KeyboardEvent) {
if (event.defaultPrevented) return;
- if (settings?.keyboardShortcutsEnabled === false) return;
+ if ($userStore?.preferences?.keyboardShortcutsEnabled === false) return;
if (isMobile.current || isTablet.current) return;
if (isEditableTarget(event.target)) return;
diff --git a/frontend/src/routes/(app)/account/+page.svelte b/frontend/src/routes/(app)/account/+page.svelte
index 7726229b5..9b4dd5411 100644
--- a/frontend/src/routes/(app)/account/+page.svelte
+++ b/frontend/src/routes/(app)/account/+page.svelte
@@ -2,12 +2,12 @@
import { onMount } from 'svelte';
import { fromStore } from 'svelte/store';
import { toast } from 'svelte-sonner';
+ import { mode } from 'mode-watcher';
import ThemeModeSelector from '#lib/components/theme-mode/theme-mode-selector.svelte';
import { format, formatDistanceToNow } from 'date-fns';
import HeaderCard from '#lib/components/header-card.svelte';
import ApiKeyFormSheet from '#lib/components/sheets/api-key-form-sheet.svelte';
import { Card } from '#lib/components/ui/card';
- import { Separator } from '#lib/components/ui/separator';
import * as Avatar from '#lib/components/ui/avatar';
import * as ImageCropper from '#lib/components/ui/image-cropper';
import { ArcaneButton } from '#lib/components/arcane-button/index.js';
@@ -15,6 +15,15 @@
import LocalePicker from '#lib/components/locale-picker.svelte';
import TimeFormatPicker from '#lib/components/time-format-picker.svelte';
import FontSizePicker from '#lib/components/font-size-picker.svelte';
+ import SettingsRow from '#lib/components/settings/settings-row.svelte';
+ import SelectWithLabel from '#lib/components/form/select-with-label.svelte';
+ import AccentColorPicker from '#lib/components/accent-color/accent-color-picker.svelte';
+ import ApplicationThemePicker from '#lib/components/application-theme/application-theme-picker.svelte';
+ import { Switch } from '#lib/components/ui/switch/index.js';
+ import { DEFAULT_LANDING_PAGE, getLandingPageNavItems } from '#lib/config/navigation-config';
+ import { resetNavigationVisibility } from '#lib/utils/navigation';
+ import { applyGlassEffects, applyInterfaceAnimations, applyOledMode, DEFAULT_ACCENT_COLOR } from '#lib/utils/theme';
+ import { debounced } from '#lib/utils/ws';
import { m } from '#lib/paraglide/messages';
import { userService } from '#lib/services/user-service';
import { apiKeyService } from '#lib/services/api-key-service';
@@ -24,8 +33,19 @@
import { avatarUploadLimitBytes, prepareAvatarUploadFile } from '#lib/utils/avatar-upload';
import { cn } from '#lib/utils';
import { GLOBAL_SCOPE } from '#lib/types/auth';
- import type { ApiKey, ApiKeyCreated, ApiKeyPermissionGrant, CreateUserApiKey } from '#lib/types/auth';
- import { UserIcon, LogoutIcon, ShieldAlertIcon, ApiKeyIcon, AddIcon, CopyIcon, TrashIcon } from '#lib/icons';
+ import type { ApiKey, ApiKeyCreated, ApiKeyPermissionGrant, CreateUserApiKey, UserPreferences } from '#lib/types/auth';
+ import type { ApplicationTheme, IconCatalog } from '#lib/types/settings';
+ import {
+ UserIcon,
+ LogoutIcon,
+ ShieldAlertIcon,
+ ApiKeyIcon,
+ AddIcon,
+ CopyIcon,
+ TrashIcon,
+ MonitorSpeakerIcon,
+ DockIcon
+ } from '#lib/icons';
let { data: _data }: PageProps = $props();
@@ -112,6 +132,82 @@
const passwordValid = $derived(currentPassword.length > 0 && newPassword.length >= 8 && newPassword === confirmPassword);
+ // --- Appearance preferences ---
+ // Each control writes straight through to the account: the visual change is
+ // applied by the control itself, then persisted; a failed save reverts by
+ // re-applying the stored user.
+ const preferences = $derived(currentUser?.preferences ?? {});
+ const applicationThemeValue = $derived<ApplicationTheme>(preferences.applicationTheme ?? 'default');
+ const accentColorValue = $derived(
+ preferences.accentColor && preferences.accentColor !== 'default' ? preferences.accentColor : DEFAULT_ACCENT_COLOR
+ );
+ const iconCatalogValue = $derived(preferences.iconCatalog ?? 'selfhst');
+ const oledModeEnabled = $derived(preferences.oledMode ?? false);
+ const glassEffectsEnabled = $derived(preferences.glassEffectsEnabled ?? true);
+ const animationsEnabled = $derived(preferences.animationsEnabled ?? true);
+ const sidebarHoverExpansionEnabled = $derived(preferences.sidebarHoverExpansion ?? true);
+ const keyboardShortcutsEnabled = $derived(preferences.keyboardShortcutsEnabled ?? true);
+
+ const isDarkMode = $derived(mode.current === 'dark');
+ const isDefaultApplicationTheme = $derived(applicationThemeValue === 'default');
+
+ const iconCatalogOptions = $derived([
+ { value: 'selfhst', label: m.icon_catalog_selfhst(), description: m.icon_catalog_selfhst_description() },
+ {
+ value: 'dashboard-icons',
+ label: m.icon_catalog_dashboard_icons(),
+ description: m.icon_catalog_dashboard_icons_description()
+ }
+ ]);
+
+ const landingPageOptions = $derived(getLandingPageNavItems().map((item) => ({ value: item.url, label: item.title })));
+ const landingValue = $derived.by(() => {
+ const current = preferences.defaultLandingPage ?? DEFAULT_LANDING_PAGE;
+ // A stale value (page removed, or a hand-edited preference) falls back to
+ // the dashboard rather than leaving the select showing a placeholder.
+ return landingPageOptions.some((option) => option.value === current) ? current : DEFAULT_LANDING_PAGE;
+ });
+
+ async function savePreferences(patch: Partial<UserPreferences>) {
+ const previous = currentUser;
+ if (!previous) return;
+ try {
+ const updated = await userService.updateMyProfile({ preferences: patch });
+ await userStore.setUser(updated);
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : m.common_update_failed({ resource: m.account_preferences() }));
+ // Re-applying the stored user rolls the live preview back.
+ await userStore.setUser(previous);
+ }
+ }
+
+ // The theme carousel emits a value per scroll snap, so persistence is
+ // debounced. Patches are merged rather than replaced, so a theme change
+ // immediately followed by an accent change still saves both.
+ let pendingPreferences: Partial<UserPreferences> = {};
+ const flushPreferences = debounced(() => {
+ const patch = pendingPreferences;
+ pendingPreferences = {};
+ void savePreferences(patch);
+ }, 400);
+
+ function savePreferencesDebounced(patch: Partial<UserPreferences>) {
+ pendingPreferences = { ...pendingPreferences, ...patch };
+ flushPreferences();
+ }
+
+ // --- Mobile navigation ---
+ const mobileNavigationMode = $derived(preferences.mobileNavigationMode ?? 'floating');
+ const mobileNavigationShowLabels = $derived(preferences.mobileNavigationShowLabels ?? true);
+
+ function selectMobileNavigationMode(value: 'floating' | 'docked') {
+ if (value === mobileNavigationMode) return;
+ // The bar hides itself on scroll in floating mode; reset it so the change
+ // is visible right away.
+ resetNavigationVisibility();
+ void savePreferences({ mobileNavigationMode: value });
+ }
+
async function updateAvatar(email: string | undefined, enabled: boolean) {
if (!enabled || !email) {
avatarUrl = getDefaultProfilePicture();
@@ -306,7 +402,7 @@
{#if currentUser}
<div class="grid gap-6 lg:grid-cols-3">
- <!-- Left column: profile + password + API keys -->
+ <!-- Left column: profile + password -->
<div class="space-y-6 lg:col-span-2">
<!-- Profile -->
<Card class="overflow-hidden">
@@ -438,6 +534,84 @@
{:else}
<p class="text-xs text-muted-foreground">{m.account_profile_managed_by_idp()}</p>
{/if}
+
+ <!-- Roles & access -->
+ <div class="border-t pt-5">
+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">
+ {m.account_roles_and_access()}
+ </h3>
+
+ {#if currentUser.roleAssignments && currentUser.roleAssignments.length > 0}
+ <ul class="mt-3 flex flex-wrap gap-2">
+ {#each currentUser.roleAssignments as ra (`${ra.roleId}-${ra.environmentId ?? 'global'}`)}
+ <li class="rounded-lg bg-muted/30 px-3 py-2">
+ <div class="text-sm font-medium">{prettyRoleName(ra.roleId)}</div>
+ <div class="text-xs text-muted-foreground">
+ {ra.environmentId ? m.account_role_environment({ env: ra.environmentId }) : m.account_global_scope()}
+ {#if ra.source === 'oidc'}
+ <span class="ml-1 opacity-70">{m.account_via_sso()}</span>
+ {/if}
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {:else}
+ <p class="mt-3 text-sm text-muted-foreground">{m.account_no_roles()}</p>
+ {/if}
+
+ {#if currentUser.permissionsByEnv}
+ {@const envCount = Object.keys(currentUser.permissionsByEnv).length}
+ {@const globalCount = currentUser.permissionsByEnv[GLOBAL_SCOPE]?.length ?? 0}
+ <p class="mt-3 text-xs text-muted-foreground">
+ {globalCount} global permission{globalCount === 1 ? '' : 's'} across {envCount} environment{envCount === 1
+ ? ''
+ : 's'}.
+ </p>
+ {/if}
+ </div>
+
+ <!-- Danger zone -->
+ {#if !autoLoginEnabled}
+ <div class="rounded-lg border border-destructive/30 bg-destructive/5 p-4">
+ <div class="flex items-center gap-2">
+ <ShieldAlertIcon class="size-4 text-destructive" />
+ <h3 class="text-sm font-semibold tracking-tight">{m.account_danger_zone()}</h3>
+ </div>
+ <p class="mt-1 text-xs text-muted-foreground">{m.account_danger_zone_desc()}</p>
+
+ <div class="mt-4 grid gap-4 sm:grid-cols-2">
+ <div class="space-y-2">
+ <div class="text-sm font-medium">{m.account_signout_other()}</div>
+ <p class="text-xs text-muted-foreground">{m.account_signout_other_desc()}</p>
+ <ArcaneButton
+ action="restart"
+ tone="outline"
+ size="sm"
+ customLabel={m.account_signout_other()}
+ onclick={logoutAllOther}
+ loading={revokingAll}
+ disabled={revokingAll}
+ />
+ </div>
+
+ <div class="space-y-2">
+ <div class="text-sm font-medium">{m.common_log_out()}</div>
+ <p class="text-xs text-muted-foreground">{m.account_signout_this()}</p>
+ <form action="/logout" method="POST">
+ <ArcaneButton
+ action="cancel"
+ tone="outline"
+ size="sm"
+ customLabel={m.common_log_out()}
+ icon={LogoutIcon}
+ type="submit"
+ class="border-destructive/30 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ />
+ </form>
+ </div>
+ </div>
+ </div>
+ {/if}
</div>
</Card>
@@ -486,233 +660,323 @@
</div>
</Card>
{/if}
+ </div>
- <!-- API keys -->
- <Card class="overflow-hidden">
- <div class="flex items-start justify-between gap-3 border-b p-4 sm:p-6">
- <div class="min-w-0">
- <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_api_keys_title()}</h2>
- <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_api_keys_description()}</p>
+ <!-- Right column: API keys -->
+ <!--
+ Pinned to the row box so the card never grows taller than the profile
+ column: the panel is taken out of flow at `lg`, which leaves the grid
+ row height driven entirely by the left column. The key list absorbs
+ the slack and scrolls on its own.
+ -->
+ <div class="lg:relative">
+ <div class="flex flex-col gap-6 lg:absolute lg:inset-0">
+ <!-- API keys -->
+ <Card class="overflow-hidden lg:flex lg:min-h-0 lg:flex-1 lg:flex-col">
+ <div class="flex shrink-0 items-start justify-between gap-3 border-b p-4 sm:p-6">
+ <div class="min-w-0">
+ <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_api_keys_title()}</h2>
+ <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_api_keys_description()}</p>
+ </div>
+ {#if !showCreateKeyForm && !createdKey}
+ <ArcaneButton
+ action="create"
+ tone="outline"
+ size="sm"
+ customLabel={m.account_new_key()}
+ icon={AddIcon}
+ class="shrink-0"
+ onclick={() => (showCreateKeyForm = true)}
+ />
+ {/if}
</div>
- {#if !showCreateKeyForm && !createdKey}
- <ArcaneButton
- action="create"
- tone="outline"
- size="sm"
- customLabel={m.account_new_key()}
- icon={AddIcon}
- onclick={() => (showCreateKeyForm = true)}
- />
- {/if}
- </div>
- <div class="p-4 sm:p-6">
- {#if createdKey}
- <div class="mb-4 space-y-3 rounded-lg border border-primary/30 bg-primary/5 p-4">
- <div>
- <div class="text-sm font-semibold">Key created: {createdKey.name}</div>
- <p class="mt-1 text-xs text-muted-foreground">Copy this token now &mdash; you won't be able to see it again.</p>
- </div>
- <div class="flex items-center gap-2">
- <code class="flex-1 truncate rounded border bg-background px-3 py-2 font-mono text-xs">
+ <div class="p-4 sm:p-6 lg:min-h-0 lg:flex-1 lg:overflow-y-auto">
+ {#if createdKey}
+ <div class="mb-4 space-y-3 rounded-lg border border-primary/30 bg-primary/5 p-4">
+ <div>
+ <div class="truncate text-sm font-semibold">{m.api_key_created_title()}: {createdKey.name}</div>
+ <p class="mt-1 text-xs text-muted-foreground">{m.api_key_save_warning()}</p>
+ </div>
+ <code class="block truncate rounded border bg-background px-3 py-2 font-mono text-xs">
{createdKey.key}
</code>
- <ArcaneButton
- action="base"
- tone="outline"
- size="sm"
- customLabel={m.common_copy()}
- icon={CopyIcon}
- onclick={() => copyKeyToClipboard(createdKey!.key)}
- />
+ <div class="flex flex-wrap justify-end gap-2">
+ <ArcaneButton
+ action="base"
+ tone="outline"
+ size="sm"
+ customLabel={m.common_copy()}
+ icon={CopyIcon}
+ onclick={() => copyKeyToClipboard(createdKey!.key)}
+ />
+ <ArcaneButton
+ action="cancel"
+ tone="ghost"
+ size="sm"
+ customLabel={m.common_ive_saved_it()}
+ onclick={() => (createdKey = null)}
+ />
+ </div>
</div>
- <div class="flex justify-end">
- <ArcaneButton
- action="cancel"
- tone="ghost"
- size="sm"
- customLabel={m.common_ive_saved_it()}
- onclick={() => (createdKey = null)}
- />
+ {/if}
+
+ {#if apiKeysLoading && apiKeys.length === 0}
+ <div class="py-8 text-center text-sm text-muted-foreground">{m.common_loading()}</div>
+ {:else if apiKeys.length === 0}
+ <div class="py-8 text-center text-sm text-muted-foreground">
+ <ApiKeyIcon class="mx-auto mb-2 size-8 opacity-40" />
+ {m.api_keys_empty()}
</div>
- </div>
- {/if}
-
- {#if apiKeysLoading && apiKeys.length === 0}
- <div class="py-8 text-center text-sm text-muted-foreground">Loading keys…</div>
- {:else if apiKeys.length === 0}
- <div class="py-8 text-center text-sm text-muted-foreground">
- <ApiKeyIcon class="mx-auto mb-2 size-8 opacity-40" />
- No API keys yet.
- </div>
- {:else}
- <ul class="divide-y">
- {#each apiKeys as key (key.id)}
- <li class="flex items-center justify-between gap-3 py-3 first:pt-0 last:pb-0">
- <div class="min-w-0 flex-1">
- <div class="flex items-center gap-2">
- <span class="truncate text-sm font-medium">{key.name}</span>
- <code class="rounded bg-muted/40 px-1.5 py-0.5 font-mono text-xs text-muted-foreground">
- {key.keyPrefix}…
- </code>
+ {:else}
+ <ul class="divide-y divide-border/40">
+ {#each apiKeys as key (key.id)}
+ <li class="py-3 first:pt-0 last:pb-0">
+ <div class="flex items-start justify-between gap-2">
+ <div class="min-w-0 flex-1">
+ <div class="truncate text-sm font-medium">{key.name}</div>
+ {#if key.description}
+ <div class="mt-0.5 truncate text-xs text-muted-foreground">{key.description}</div>
+ {/if}
+ </div>
+ <ArcaneButton
+ action="remove"
+ tone="ghost"
+ size="sm"
+ icon={TrashIcon}
+ customLabel={m.common_delete()}
+ showLabel={false}
+ class="shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive"
+ onclick={() => deleteApiKey(key.id, key.name)}
+ />
</div>
- {#if key.description}
- <div class="mt-0.5 truncate text-xs text-muted-foreground">{key.description}</div>
- {/if}
- <div class="mt-1 text-xs text-muted-foreground">
+ <div class="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
+ <code class="rounded bg-muted/40 px-1.5 py-0.5 font-mono">{key.keyPrefix}…</code>
{#if safeFormatDate(key.createdAt, 'PP')}
- Created {safeFormatDate(key.createdAt, 'PP')}
- {/if}
- {#if key.lastUsedAt && safeFormatRelative(key.lastUsedAt)}
- · Last used {safeFormatRelative(key.lastUsedAt)}
- {:else}
- · Never used
+ <span>{m.common_created()} {safeFormatDate(key.createdAt, 'PP')}</span>
+ <span aria-hidden="true">·</span>
{/if}
+ <span>{m.last_used()} {safeFormatRelative(key.lastUsedAt) ?? m.common_never()}</span>
</div>
- </div>
- <ArcaneButton
- action="remove"
- tone="ghost"
- size="sm"
- icon={TrashIcon}
- customLabel={m.common_delete()}
- showLabel={false}
- class="text-muted-foreground hover:bg-destructive/10 hover:text-destructive"
- onclick={() => deleteApiKey(key.id, key.name)}
- />
- </li>
- {/each}
- </ul>
- {/if}
- </div>
- </Card>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ </div>
+ </Card>
+ </div>
</div>
+ </div>
- <!-- Right column: preferences + roles + danger zone -->
- <div class="space-y-6">
- <!-- Preferences -->
- <Card class="overflow-hidden">
- <div class="border-b p-4 sm:p-6">
- <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_preferences()}</h2>
- <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_preferences_desc()}</p>
+ <!-- Preferences -->
+ <Card class="overflow-hidden">
+ <div class="border-b p-4 sm:p-6">
+ <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_preferences()}</h2>
+ <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_preferences_desc()}</p>
+ </div>
+
+ <div class="divide-y divide-border/50">
+ <!-- General -->
+ <section class="p-4 sm:p-6">
+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">{m.general_title()}</h3>
+ <div class="mt-4 divide-y divide-border/40 [&>*]:py-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
+ <SettingsRow label={m.language()} description={m.account_language_desc()} layout="inline">
+ <LocalePicker inline id="accountLocalePicker" />
+ </SettingsRow>
+
+ <SettingsRow label={m.time_format()} description={m.account_time_format_desc()} layout="inline">
+ <TimeFormatPicker id="accountTimeFormatPicker" />
+ </SettingsRow>
</div>
- <div class="divide-y p-2">
- <div class="flex items-center justify-between gap-4 p-3">
- <div class="min-w-0">
- <div class="text-sm font-medium">{m.account_theme()}</div>
- <div class="text-xs text-muted-foreground">{m.appearance_theme_current_user_description()}</div>
- </div>
+ </section>
+
+ <!-- Appearance -->
+ <section class="p-4 sm:p-6">
+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">{m.appearance_title()}</h3>
+ <div class="mt-4 divide-y divide-border/40 [&>*]:py-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
+ <SettingsRow label={m.account_theme()} description={m.appearance_theme_current_user_description()} layout="inline">
<ThemeModeSelector />
- </div>
- <div class="flex items-center justify-between gap-4 p-3">
- <div class="min-w-0">
- <div class="text-sm font-medium">{m.language()}</div>
- <div class="text-xs text-muted-foreground">{m.account_language_desc()}</div>
- </div>
- <LocalePicker inline />
- </div>
- <div class="flex items-center justify-between gap-4 p-3">
- <div class="min-w-0">
- <div class="text-sm font-medium">{m.time_format()}</div>
- <div class="text-xs text-muted-foreground">{m.account_time_format_desc()}</div>
- </div>
- <TimeFormatPicker id="accountTimeFormatPicker" />
- </div>
- <div class="flex items-center justify-between gap-4 p-3">
- <div class="min-w-0">
- <div class="text-sm font-medium">{m.font_size()}</div>
- <div class="text-xs text-muted-foreground">{m.font_size_description()}</div>
- </div>
+ </SettingsRow>
+
+ <SettingsRow label={m.font_size()} description={m.font_size_description()} layout="inline">
<FontSizePicker />
- </div>
- </div>
- </Card>
+ </SettingsRow>
+
+ <SettingsRow label={m.icon_catalog()} description={m.icon_catalog_description()} layout="inline">
+ <div class="w-52">
+ <SelectWithLabel
+ id="account-icon-catalog"
+ label={m.icon_catalog()}
+ hideLabel
+ triggerSize="sm"
+ value={iconCatalogValue}
+ options={iconCatalogOptions}
+ onValueChange={(value) => void savePreferences({ iconCatalog: value as IconCatalog })}
+ />
+ </div>
+ </SettingsRow>
- <!-- Roles & access -->
- <Card class="overflow-hidden">
- <div class="border-b p-4 sm:p-6">
- <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_roles_and_access()}</h2>
- <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_roles()}</p>
- </div>
- <div class="p-4 sm:p-6">
- {#if currentUser.roleAssignments && currentUser.roleAssignments.length > 0}
- <ul class="space-y-2">
- {#each currentUser.roleAssignments as ra (`${ra.roleId}-${ra.environmentId ?? 'global'}`)}
- <li class="flex items-center justify-between gap-3 rounded-lg bg-muted/30 px-3 py-2">
- <div class="min-w-0">
- <div class="text-sm font-medium">{prettyRoleName(ra.roleId)}</div>
- <div class="text-xs text-muted-foreground">
- {ra.environmentId ? m.account_role_environment({ env: ra.environmentId }) : m.account_global_scope()}
- {#if ra.source === 'oidc'}
- <span class="ml-1 opacity-70">{m.account_via_sso()}</span>
- {/if}
- </div>
- </div>
- </li>
- {/each}
- </ul>
- {:else}
- <p class="text-sm text-muted-foreground">{m.account_no_roles()}</p>
- {/if}
+ <SettingsRow label={m.application_theme()} description={m.application_theme_description()}>
+ <ApplicationThemePicker
+ selectedTheme={applicationThemeValue}
+ accentColor={accentColorValue}
+ onSelect={(value) => savePreferencesDebounced({ applicationTheme: value })}
+ />
+ </SettingsRow>
- {#if currentUser.permissionsByEnv}
- {@const envCount = Object.keys(currentUser.permissionsByEnv).length}
- {@const globalCount = currentUser.permissionsByEnv[GLOBAL_SCOPE]?.length ?? 0}
- <p class="mt-3 text-xs text-muted-foreground">
- {globalCount} global permission{globalCount === 1 ? '' : 's'} across {envCount} environment{envCount === 1
- ? ''
- : 's'}.
- </p>
- {/if}
+ <SettingsRow label={m.accent_color()} description={m.accent_color_description()}>
+ <AccentColorPicker
+ previousColor={accentColorValue}
+ selectedColor={accentColorValue}
+ onSelect={(value) => savePreferencesDebounced({ accentColor: value })}
+ />
+ </SettingsRow>
+
+ <SettingsRow label={m.oled_mode()} description={m.oled_mode_description()} layout="inline">
+ {#snippet helpText()}
+ {#if !isDefaultApplicationTheme}
+ <p class="mt-1 text-xs text-muted-foreground/70 italic">{m.oled_mode_requires_default_theme()}</p>
+ {:else if !isDarkMode}
+ <p class="mt-1 text-xs text-muted-foreground/70 italic">{m.oled_mode_requires_dark()}</p>
+ {/if}
+ {/snippet}
+ <Switch
+ id="account-oled-mode"
+ checked={oledModeEnabled}
+ disabled={!isDefaultApplicationTheme}
+ onCheckedChange={(checked) => {
+ applyOledMode(checked);
+ void savePreferences({ oledMode: checked });
+ }}
+ />
+ </SettingsRow>
+
+ <SettingsRow label={m.glass_effects()} description={m.glass_effects_description()} layout="inline">
+ <Switch
+ id="account-glass-effects"
+ checked={glassEffectsEnabled}
+ onCheckedChange={(checked) => {
+ applyGlassEffects(checked);
+ void savePreferences({ glassEffectsEnabled: checked });
+ }}
+ />
+ </SettingsRow>
+
+ <SettingsRow label={m.interface_animations()} description={m.interface_animations_description()} layout="inline">
+ <Switch
+ id="account-animations"
+ checked={animationsEnabled}
+ onCheckedChange={(checked) => {
+ applyInterfaceAnimations(checked);
+ void savePreferences({ animationsEnabled: checked });
+ }}
+ />
+ </SettingsRow>
</div>
- </Card>
-
- {#if !autoLoginEnabled}
- <Card class="overflow-hidden border-destructive/30">
- <div class="border-b border-destructive/20 p-4 sm:p-6">
- <div class="flex items-center gap-2">
- <ShieldAlertIcon class="size-5 text-destructive" />
- <h2 class="text-base font-semibold tracking-tight sm:text-lg">{m.account_danger_zone()}</h2>
- </div>
- <p class="mt-1 text-xs text-muted-foreground sm:text-sm">{m.account_danger_zone_desc()}</p>
- </div>
- <div class="space-y-4 p-4 sm:p-6">
- <div class="space-y-2">
- <div class="text-sm font-medium">{m.account_signout_other()}</div>
- <p class="text-xs text-muted-foreground">
- {m.account_signout_other_desc()}
- </p>
- <ArcaneButton
- action="restart"
- tone="outline"
- customLabel={m.account_signout_other()}
- onclick={logoutAllOther}
- loading={revokingAll}
- disabled={revokingAll}
+ </section>
+
+ <!-- Navigation -->
+ <section class="p-4 sm:p-6">
+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">{m.navigation_title()}</h3>
+ <div class="mt-4 divide-y divide-border/40 [&>*]:py-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
+ <SettingsRow
+ label={m.navigation_default_landing_page_label()}
+ description={m.navigation_default_landing_page_description()}
+ layout="inline"
+ >
+ <div class="w-52">
+ <SelectWithLabel
+ id="account-default-landing-page"
+ label={m.navigation_default_landing_page_label()}
+ hideLabel
+ triggerSize="sm"
+ value={landingValue}
+ options={landingPageOptions}
+ onValueChange={(value) => void savePreferences({ defaultLandingPage: value })}
/>
</div>
+ </SettingsRow>
- <Separator />
-
- <div class="space-y-2">
- <div class="text-sm font-medium">{m.common_log_out()}</div>
- <p class="text-xs text-muted-foreground">{m.account_signout_this()}</p>
- <form action="/logout" method="POST">
- <ArcaneButton
- action="cancel"
- tone="outline"
- customLabel={m.common_log_out()}
- icon={LogoutIcon}
- type="submit"
- class="border-destructive/30 text-destructive hover:bg-destructive/10 hover:text-destructive"
- />
- </form>
+ <SettingsRow
+ label={m.navigation_sidebar_hover_expansion_label()}
+ description={m.navigation_sidebar_hover_expansion_description()}
+ layout="inline"
+ >
+ <Switch
+ id="account-sidebar-hover-expansion"
+ checked={sidebarHoverExpansionEnabled}
+ onCheckedChange={(checked) => void savePreferences({ sidebarHoverExpansion: checked })}
+ />
+ </SettingsRow>
+
+ <SettingsRow
+ label={m.navigation_keyboard_shortcuts_label()}
+ description={m.navigation_keyboard_shortcuts_description()}
+ layout="inline"
+ >
+ <Switch
+ id="account-keyboard-shortcuts"
+ checked={keyboardShortcutsEnabled}
+ onCheckedChange={(checked) => void savePreferences({ keyboardShortcutsEnabled: checked })}
+ />
+ </SettingsRow>
+ </div>
+ </section>
+
+ <!-- Mobile navigation -->
+ <section class="p-4 sm:p-6">
+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">
+ {m.navigation_mobile_appearance_title()}
+ </h3>
+ <div class="mt-4 divide-y divide-border/40 [&>*]:py-4 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
+ <SettingsRow label={m.navigation_mode_label()} description={m.navigation_mode_description()} layout="inline">
+ <div class="inline-flex rounded-lg bg-muted/40 p-0.5">
+ <button
+ type="button"
+ aria-pressed={mobileNavigationMode === 'floating'}
+ onclick={() => selectMobileNavigationMode('floating')}
+ class={cn(
+ 'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
+ mobileNavigationMode === 'floating'
+ ? 'bg-background text-foreground shadow-sm'
+ : 'text-muted-foreground hover:text-foreground'
+ )}
+ >
+ <MonitorSpeakerIcon class="size-3.5" />
+ {m.navigation_mode_floating()}
+ </button>
+ <button
+ type="button"
+ aria-pressed={mobileNavigationMode === 'docked'}
+ onclick={() => selectMobileNavigationMode('docked')}
+ class={cn(
+ 'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
+ mobileNavigationMode === 'docked'
+ ? 'bg-background text-foreground shadow-sm'
+ : 'text-muted-foreground hover:text-foreground'
+ )}
+ >
+ <DockIcon class="size-3.5" />
+ {m.navigation_mode_docked()}
+ </button>
</div>
- </div>
- </Card>
- {/if}
+ </SettingsRow>
+
+ <SettingsRow
+ label={m.navigation_show_labels_label()}
+ description={m.navigation_show_labels_description()}
+ layout="inline"
+ >
+ <Switch
+ id="account-mobile-nav-labels"
+ checked={mobileNavigationShowLabels}
+ onCheckedChange={(checked) => void savePreferences({ mobileNavigationShowLabels: checked })}
+ />
+ </SettingsRow>
+ </div>
+ </section>
</div>
- </div>
+ </Card>
{:else}
<div class="py-12 text-center text-sm text-muted-foreground">Loading account…</div>
{/if}
diff --git a/frontend/src/routes/(app)/settings/+layout.svelte b/frontend/src/routes/(app)/settings/+layout.svelte
index 7d6b12768..7061b68e5 100644
--- a/frontend/src/routes/(app)/settings/+layout.svelte
+++ b/frontend/src/routes/(app)/settings/+layout.svelte
@@ -29,8 +29,6 @@
return m.security();
case 'users':
return m.users_title();
- case 'navigation':
- return m.navigation_title();
case 'notifications':
return m.notifications_title();
case 'api-keys':
diff --git a/frontend/src/routes/(app)/settings/+page.svelte b/frontend/src/routes/(app)/settings/+page.svelte
index f3d2a6404..aa58bc8e8 100644
--- a/frontend/src/routes/(app)/settings/+page.svelte
+++ b/frontend/src/routes/(app)/settings/+page.svelte
@@ -9,7 +9,6 @@
NotificationsIcon,
DockerBrandIcon,
ApiKeyIcon,
- AppearanceIcon,
JobsIcon,
CodeIcon,
GlobeIcon,
@@ -42,7 +41,6 @@
database: DockerBrandIcon,
lock: LockIcon,
shield: SecurityIcon,
- appearance: AppearanceIcon,
bell: NotificationsIcon,
user: UserIcon,
apikey: ApiKeyIcon,
diff --git a/frontend/src/routes/(app)/settings/appearance/+page.svelte b/frontend/src/routes/(app)/settings/appearance/+page.svelte
deleted file mode 100644
index 5ef58c76a..000000000
--- a/frontend/src/routes/(app)/settings/appearance/+page.svelte
+++ /dev/null
@@ -1,467 +0,0 @@
-<script lang="ts">
- import { onDestroy } from 'svelte';
- import { z } from 'zod/v4';
- import { mode } from 'mode-watcher';
- import settingsStore from '#lib/stores/config-store';
- import { m } from '#lib/paraglide/messages';
- import { navigationSettingsOverridesStore, resetNavigationVisibility } from '#lib/utils/navigation';
- import { DEFAULT_LANDING_PAGE, getLandingPageNavItems } from '#lib/config/navigation-config';
- import { SettingsPageLayout } from '#lib/layouts';
- import { Switch } from '#lib/components/ui/switch/index.js';
- import { Input } from '#lib/components/ui/input/index.js';
- import { useSidebar } from '#lib/components/ui/sidebar/context.svelte.js';
- import { createSettingsForm } from '#lib/utils/settings-form';
- import SettingsRow from '#lib/components/settings/settings-row.svelte';
- import LocalePicker from '#lib/components/locale-picker.svelte';
- import TimeFormatPicker from '#lib/components/time-format-picker.svelte';
- import SelectWithLabel from '#lib/components/form/select-with-label.svelte';
- import AccentColorPicker from '#lib/components/accent-color/accent-color-picker.svelte';
- import ApplicationThemePicker from '#lib/components/application-theme/application-theme-picker.svelte';
- import ThemeModeSelector from '#lib/components/theme-mode/theme-mode-selector.svelte';
- import { applyAccentColor } from '#lib/utils/theme';
- import { APPLICATION_THEME_VALUES, applyApplicationTheme } from '#lib/utils/theme';
- import { applyOledMode } from '#lib/utils/theme';
- import { applyGlassEffects, applyInterfaceAnimations } from '#lib/utils/theme';
- import { AppearanceIcon, MonitorSpeakerIcon, DockIcon } from '#lib/icons';
- import { cn } from '#lib/utils';
-
- let { data } = $props();
- const currentSettings = $derived($settingsStore || data.settings!);
- const isReadOnly = $derived.by(() => $settingsStore?.uiConfigDisabled);
-
- const formSchema = z.object({
- applicationTheme: z.enum(APPLICATION_THEME_VALUES),
- iconCatalog: z.enum(['selfhst', 'dashboard-icons']),
- defaultLandingPage: z.string(),
- mobileNavigationMode: z.enum(['floating', 'docked']),
- mobileNavigationShowLabels: z.boolean(),
- sidebarHoverExpansion: z.boolean(),
- keyboardShortcutsEnabled: z.boolean(),
- accentColor: z.string(),
- enableGravatar: z.boolean(),
- avatarMaxUploadSizeMb: z.coerce.number().int().min(1).max(50),
- oledMode: z.boolean(),
- glassEffectsEnabled: z.boolean(),
- animationsEnabled: z.boolean()
- });
-
- // Track local override state using the shared store
- let persistedState = $state(navigationSettingsOverridesStore.current);
-
- // Sidebar context is only available in desktop view
- let sidebar: ReturnType<typeof useSidebar> | null = null;
- try {
- sidebar = useSidebar();
- } catch {
- // Sidebar context not available (mobile view)
- }
-
- let { formInputs } = $derived(
- createSettingsForm({
- schema: formSchema,
- currentSettings,
- getCurrentSettings: () => $settingsStore || data.settings!,
- successMessage: m.navigation_settings_saved(),
- onReset: restorePersistedAppearance
- })
- );
-
- function restorePersistedAppearance() {
- applyApplicationTheme(currentSettings.applicationTheme);
- applyAccentColor(currentSettings.accentColor);
- applyOledMode(currentSettings.oledMode ?? false);
- applyGlassEffects(currentSettings.glassEffectsEnabled ?? true);
- applyInterfaceAnimations(currentSettings.animationsEnabled ?? true);
- }
-
- onDestroy(() => {
- restorePersistedAppearance();
- });
-
- function setLocalOverride(key: 'mode' | 'showLabels' | 'defaultLandingPage', value: any) {
- const currentOverrides = navigationSettingsOverridesStore.current;
- navigationSettingsOverridesStore.current = { ...currentOverrides, [key]: value };
- persistedState = navigationSettingsOverridesStore.current;
- if (key === 'mode') resetNavigationVisibility();
- }
-
- function clearLocalOverride(key: 'mode' | 'showLabels') {
- const currentOverrides = navigationSettingsOverridesStore.current;
- const newOverrides = { ...currentOverrides };
- delete newOverrides[key];
- navigationSettingsOverridesStore.current = newOverrides;
- persistedState = navigationSettingsOverridesStore.current;
- if (key === 'mode') resetNavigationVisibility();
- }
-
- // Navigation Mode state
- const modeIsLocal = $derived(persistedState.mode !== undefined);
- const modeSegment = $derived<'default' | 'floating' | 'docked'>(
- modeIsLocal ? (persistedState.mode as 'floating' | 'docked') : 'default'
- );
-
- function handleModeSegmentSelect(segment: 'default' | 'floating' | 'docked') {
- if (segment === 'default') {
- clearLocalOverride('mode');
- } else {
- setLocalOverride('mode', segment);
- }
- }
-
- // Default Landing Page state
- const landingPageOptions = $derived(getLandingPageNavItems().map((item) => ({ value: item.url, label: item.title })));
- const landingValue = $derived.by(() => {
- const current = persistedState.defaultLandingPage ?? currentSettings.defaultLandingPage ?? DEFAULT_LANDING_PAGE;
- // A stale value (page removed, or a hand-edited setting) falls back to the
- // dashboard rather than leaving the select showing a placeholder.
- return landingPageOptions.some((option) => option.value === current) ? current : DEFAULT_LANDING_PAGE;
- });
-
- function handleLandingPageSelect(value: string) {
- setLocalOverride('defaultLandingPage', value);
- }
-
- // Show Labels state
- const labelsIsLocal = $derived(persistedState.showLabels !== undefined);
- const labelsSegment = $derived<'default' | 'on' | 'off'>(
- labelsIsLocal ? (persistedState.showLabels ? 'on' : 'off') : 'default'
- );
- const isDarkMode = $derived(mode.current === 'dark');
- const isDefaultApplicationTheme = $derived($formInputs.applicationTheme.value === 'default');
- const iconCatalogOptions = $derived([
- { value: 'selfhst', label: m.icon_catalog_selfhst(), description: m.icon_catalog_selfhst_description() },
- {
- value: 'dashboard-icons',
- label: m.icon_catalog_dashboard_icons(),
- description: m.icon_catalog_dashboard_icons_description()
- }
- ]);
-
- function handleOledModeChange(checked: boolean) {
- $formInputs.oledMode.value = checked;
- // Live preview: apply immediately so the user sees the effect
- applyOledMode(checked);
- }
-
- function handleGlassEffectsChange(checked: boolean) {
- $formInputs.glassEffectsEnabled.value = checked;
- // Live preview: apply immediately so the user sees the effect
- applyGlassEffects(checked);
- }
-
- function handleAnimationsChange(checked: boolean) {
- $formInputs.animationsEnabled.value = checked;
- // Live preview: apply immediately so the user sees the effect
- applyInterfaceAnimations(checked);
- }
-
- function handleLabelsSegmentSelect(segment: 'default' | 'on' | 'off') {
- if (segment === 'default') {
- clearLocalOverride('showLabels');
- } else {
- setLocalOverride('showLabels', segment === 'on');
- }
- }
-</script>
-
-<SettingsPageLayout
- title={m.appearance_title()}
- description={m.appearance_description()}
- icon={AppearanceIcon}
- pageType="form"
- showReadOnlyTag={isReadOnly}
->
- {#snippet mainContent()}
- <div class="space-y-8">
- <!-- Appearance Section -->
- <div class="space-y-4">
- <h3 class="text-base font-semibold">{m.appearance_title()}</h3>
- <div class="divide-y divide-border/40 [&>*]:py-5 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
- <!-- Application Theme -->
- <SettingsRow label={m.application_theme()} description={m.application_theme_description()}>
- <ApplicationThemePicker
- bind:selectedTheme={$formInputs.applicationTheme.value}
- accentColor={$formInputs.accentColor.value}
- disabled={isReadOnly}
- />
- </SettingsRow>
-
- <!-- Accent Color -->
- <SettingsRow label={m.accent_color()} description={m.accent_color_description()}>
- <AccentColorPicker
- previousColor={currentSettings.accentColor}
- bind:selectedColor={$formInputs.accentColor.value}
- disabled={isReadOnly}
- />
- </SettingsRow>
-
- <!-- Icon Catalog -->
- <SettingsRow label={m.icon_catalog()} description={m.icon_catalog_description()}>
- <SelectWithLabel
- id="iconCatalog"
- label={m.icon_catalog()}
- bind:value={$formInputs.iconCatalog.value}
- error={$formInputs.iconCatalog.error}
- disabled={isReadOnly}
- options={iconCatalogOptions}
- />
- </SettingsRow>
-
- <!-- Gravatar -->
- <SettingsRow
- label={m.general_enable_gravatar_label()}
- description={m.general_enable_gravatar_description()}
- layout="inline"
- >
- <Switch
- id="enableGravatar"
- bind:checked={$formInputs.enableGravatar.value}
- disabled={isReadOnly}
- onCheckedChange={(checked) => {
- $formInputs.enableGravatar.value = checked;
- }}
- />
- </SettingsRow>
-
- <SettingsRow
- label={m.general_avatar_upload_size_label()}
- description={m.general_avatar_upload_size_description()}
- helpText={m.general_avatar_upload_size_help()}
- layout="inline"
- >
- <div class="flex w-24 flex-col gap-1">
- <Input
- id="avatarMaxUploadSizeMb"
- type="number"
- min="1"
- max="50"
- bind:value={$formInputs.avatarMaxUploadSizeMb.value}
- placeholder="2"
- disabled={isReadOnly}
- aria-invalid={Boolean($formInputs.avatarMaxUploadSizeMb.error)}
- />
- {#if $formInputs.avatarMaxUploadSizeMb.error}
- <p class="text-xs font-medium text-destructive">{$formInputs.avatarMaxUploadSizeMb.error}</p>
- {/if}
- </div>
- </SettingsRow>
-
- <!-- Language -->
- <SettingsRow label={m.language()} description={m.appearance_language_current_user_description()} layout="inline">
- <LocalePicker
- inline={true}
- id="appearanceLocalePicker"
- class="h-9 w-32 border-border/30 text-sm font-medium text-foreground"
- />
- </SettingsRow>
-
- <!-- Time Format -->
- <SettingsRow label={m.time_format()} description={m.time_format_description()} layout="inline">
- <TimeFormatPicker id="appearanceTimeFormatPicker" />
- </SettingsRow>
-
- <!-- Default Landing Page -->
- <SettingsRow
- label={m.navigation_default_landing_page_label()}
- description={m.navigation_default_landing_page_description()}
- layout="inline"
- >
- <div class="w-56">
- <SelectWithLabel
- id="defaultLandingPage"
- label={m.navigation_default_landing_page_label()}
- hideLabel
- value={landingValue}
- disabled={isReadOnly}
- options={landingPageOptions}
- onValueChange={handleLandingPageSelect}
- />
- </div>
- </SettingsRow>
-
- <!-- Theme -->
- <SettingsRow
- label={m.common_toggle_theme()}
- description={m.appearance_theme_current_user_description()}
- layout="inline"
- >
- <ThemeModeSelector disabled={isReadOnly} />
- </SettingsRow>
-
- <!-- OLED Mode -->
- <SettingsRow label={m.oled_mode()} description={m.oled_mode_description()} layout="inline">
- {#snippet helpText()}
- {#if !isDefaultApplicationTheme}
- <p class="mt-1 text-xs text-muted-foreground/70 italic">{m.oled_mode_requires_default_theme()}</p>
- {:else if !isDarkMode}
- <p class="mt-1 text-xs text-muted-foreground/70 italic">{m.oled_mode_requires_dark()}</p>
- {/if}
- {/snippet}
- <Switch
- id="oledMode"
- checked={$formInputs.oledMode.value}
- disabled={isReadOnly || !isDefaultApplicationTheme}
- onCheckedChange={handleOledModeChange}
- />
- </SettingsRow>
-
- <SettingsRow label={m.glass_effects()} description={m.glass_effects_description()} layout="inline">
- <Switch
- id="glassEffectsEnabled"
- checked={$formInputs.glassEffectsEnabled.value}
- disabled={isReadOnly}
- onCheckedChange={handleGlassEffectsChange}
- />
- </SettingsRow>
-
- <SettingsRow label={m.interface_animations()} description={m.interface_animations_description()} layout="inline">
- <Switch
- id="animationsEnabled"
- checked={$formInputs.animationsEnabled.value}
- disabled={isReadOnly}
- onCheckedChange={handleAnimationsChange}
- />
- </SettingsRow>
- </div>
- </div>
-
- <!-- Desktop Sidebar Section -->
- <div class="space-y-4">
- <h3 class="text-base font-semibold">{m.navigation_desktop_sidebar_title()}</h3>
- <div class="divide-y divide-border/40 [&>*]:py-5 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
- <SettingsRow
- label={m.navigation_sidebar_hover_expansion_label()}
- description={m.navigation_sidebar_hover_expansion_description()}
- layout="inline"
- >
- <Switch
- id="sidebarHoverExpansion"
- checked={$formInputs.sidebarHoverExpansion.value}
- disabled={isReadOnly}
- onCheckedChange={(checked) => {
- $formInputs.sidebarHoverExpansion.value = checked;
- if (sidebar) {
- sidebar.setHoverExpansion(checked);
- }
- }}
- />
- </SettingsRow>
-
- <!-- Keyboard Shortcuts -->
- <SettingsRow
- label={m.navigation_keyboard_shortcuts_label()}
- description={m.navigation_keyboard_shortcuts_description()}
- layout="inline"
- >
- <Switch
- id="keyboardShortcutsEnabled"
- checked={$formInputs.keyboardShortcutsEnabled.value}
- disabled={isReadOnly}
- onCheckedChange={(checked) => {
- $formInputs.keyboardShortcutsEnabled.value = checked;
- }}
- />
- </SettingsRow>
- </div>
- </div>
-
- <!-- Mobile Appearance Section -->
- <div class="space-y-4">
- <h3 class="text-base font-semibold">{m.navigation_mobile_appearance_title()}</h3>
- <div class="divide-y divide-border/40 [&>*]:py-5 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0">
- <!-- Navigation Mode -->
- <SettingsRow label={m.navigation_mode_label()} description={m.navigation_mode_description()}>
- <div class="inline-flex rounded-lg bg-muted/40 p-0.5">
- <button
- type="button"
- disabled={isReadOnly && modeSegment !== 'default'}
- onclick={() => handleModeSegmentSelect('default')}
- class={cn(
- 'rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- modeSegment === 'default'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- {m.server_default()}
- </button>
- <button
- type="button"
- disabled={isReadOnly && modeSegment === 'default'}
- onclick={() => handleModeSegmentSelect('floating')}
- class={cn(
- 'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- modeSegment === 'floating'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- <MonitorSpeakerIcon class="size-3.5" />
- {m.navigation_mode_floating()}
- </button>
- <button
- type="button"
- disabled={isReadOnly && modeSegment === 'default'}
- onclick={() => handleModeSegmentSelect('docked')}
- class={cn(
- 'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- modeSegment === 'docked'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- <DockIcon class="size-3.5" />
- {m.navigation_mode_docked()}
- </button>
- </div>
- </SettingsRow>
-
- <!-- Show Labels -->
- <SettingsRow label={m.navigation_show_labels_label()} description={m.navigation_show_labels_description()}>
- <div class="inline-flex rounded-lg bg-muted/40 p-0.5">
- <button
- type="button"
- disabled={isReadOnly && labelsSegment !== 'default'}
- onclick={() => handleLabelsSegmentSelect('default')}
- class={cn(
- 'rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- labelsSegment === 'default'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- {m.server_default()}
- </button>
- <button
- type="button"
- disabled={isReadOnly && labelsSegment === 'default'}
- onclick={() => handleLabelsSegmentSelect('on')}
- class={cn(
- 'rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- labelsSegment === 'on'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- {m.on()}
- </button>
- <button
- type="button"
- disabled={isReadOnly && labelsSegment === 'default'}
- onclick={() => handleLabelsSegmentSelect('off')}
- class={cn(
- 'rounded-md px-3 py-1.5 text-xs font-medium transition-colors',
- labelsSegment === 'off'
- ? 'bg-background text-foreground shadow-sm'
- : 'text-muted-foreground hover:text-foreground'
- )}
- >
- {m.off()}
- </button>
- </div>
- </SettingsRow>
- </div>
- </div>
- </div>
- {/snippet}
-</SettingsPageLayout>
diff --git a/frontend/src/routes/(app)/settings/users/+page.svelte b/frontend/src/routes/(app)/settings/users/+page.svelte
index d48abfb9d..7d77a534f 100644
--- a/frontend/src/routes/(app)/settings/users/+page.svelte
+++ b/frontend/src/routes/(app)/settings/users/+page.svelte
@@ -6,14 +6,20 @@
import UserTable from './user-table.svelte';
import UserFormSheet from '#lib/components/sheets/user-form-sheet.svelte';
import type { SearchPaginationSortRequest } from '#lib/types/shared';
+ import type { Settings } from '#lib/types/settings';
import type { User } from '#lib/types/auth';
import type { CreateUser } from '#lib/types/auth';
import { m } from '#lib/paraglide/messages';
import { userService } from '#lib/services/user-service';
import { roleService } from '#lib/services/role-service';
+ import { settingsService } from '#lib/services/settings-service';
import userStore from '#lib/stores/user-store';
+ import settingsStore from '#lib/stores/config-store';
import { untrack } from 'svelte';
import { SettingsPageLayout, type SettingsActionButton } from '#lib/layouts/index.js';
+ import SettingsRow from '#lib/components/settings/settings-row.svelte';
+ import { Switch } from '#lib/components/ui/switch/index.js';
+ import { Input } from '#lib/components/ui/input/index.js';
let { data } = $props();
@@ -126,6 +132,40 @@
}
}
+ // Avatar policy: server-wide settings that belong with user management.
+ const isReadOnly = $derived(Boolean($settingsStore?.uiConfigDisabled));
+ const gravatarEnabled = $derived(Boolean($settingsStore?.enableGravatar));
+ const avatarMaxUploadSizeMb = $derived(
+ Number($settingsStore?.avatarMaxUploadSizeMb) > 0 ? Number($settingsStore?.avatarMaxUploadSizeMb) : 2
+ );
+ let avatarSizeInput = $state('');
+ let avatarSizeError = $state<string | null>(null);
+
+ $effect(() => {
+ avatarSizeInput = String(avatarMaxUploadSizeMb);
+ });
+
+ async function saveAvatarSettings(patch: Partial<Settings>) {
+ try {
+ const updated = await settingsService.updateSettings(patch);
+ settingsStore.set(updated);
+ toast.success(m.common_update_success({ resource: m.settings() }));
+ } catch (error) {
+ toast.error(error instanceof Error ? error.message : m.common_update_failed({ resource: m.settings() }));
+ }
+ }
+
+ function handleAvatarSizeCommit() {
+ const parsed = Number(avatarSizeInput);
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > 50) {
+ avatarSizeError = m.general_avatar_upload_size_help();
+ return;
+ }
+ avatarSizeError = null;
+ if (parsed === avatarMaxUploadSizeMb) return;
+ void saveAvatarSettings({ avatarMaxUploadSizeMb: parsed });
+ }
+
const actionButtons: SettingsActionButton[] = $derived.by(() => [
{
id: 'create',
@@ -146,6 +186,45 @@
{actionButtons}
>
{#snippet mainContent()}
+ <div class="mb-6 divide-y divide-border/40 border-b border-border/50 pb-6 [&>*]:py-5 [&>*:first-child]:pt-0">
+ <SettingsRow
+ label={m.general_enable_gravatar_label()}
+ description={m.general_enable_gravatar_description()}
+ layout="inline"
+ >
+ <Switch
+ id="enableGravatar"
+ checked={gravatarEnabled}
+ disabled={isReadOnly}
+ onCheckedChange={(checked) => void saveAvatarSettings({ enableGravatar: checked })}
+ />
+ </SettingsRow>
+
+ <SettingsRow
+ label={m.general_avatar_upload_size_label()}
+ description={m.general_avatar_upload_size_description()}
+ helpText={m.general_avatar_upload_size_help()}
+ layout="inline"
+ >
+ <div class="flex w-24 flex-col gap-1">
+ <Input
+ id="avatarMaxUploadSizeMb"
+ type="number"
+ min="1"
+ max="50"
+ bind:value={avatarSizeInput}
+ placeholder="2"
+ disabled={isReadOnly}
+ aria-invalid={Boolean(avatarSizeError)}
+ onblur={handleAvatarSizeCommit}
+ />
+ {#if avatarSizeError}
+ <p class="text-xs font-medium text-destructive">{avatarSizeError}</p>
+ {/if}
+ </div>
+ </SettingsRow>
+ </div>
+
<UserTable
bind:users
bind:selectedIds
diff --git a/frontend/src/routes/(auth)/login/+page.svelte b/frontend/src/routes/(auth)/login/+page.svelte
index d7639b900..bdc1e5455 100644
--- a/frontend/src/routes/(auth)/login/+page.svelte
+++ b/frontend/src/routes/(auth)/login/+page.svelte
@@ -21,15 +21,13 @@
let password = $state('');
const queryClient = useQueryClient();
- // The ambient shimmer is a ~300vmax rotating conic-gradient that pegs the GPU
- // on Firefox-based browsers. `animationsEnabled` is a public setting, so it
- // reaches this pre-auth page via data.settings — skip rendering the shimmer
- // when animations are disabled. (OS reduced-motion is handled by the
+ // Animations and accent color are per-user preferences now, so neither is
+ // available before sign-in: this page always renders the ambient shimmer and
+ // the default-tinted logo. (OS reduced-motion is still honoured by the
// prefers-reduced-motion rule in the <style> below.)
- const showAmbientMotion = $derived(data.settings?.animationsEnabled !== false);
+ const showAmbientMotion = true;
- const accentColor = $derived(data.settings?.accentColor);
- const logoUrl = $derived(getApplicationLogo(false, accentColor, accentColor));
+ const logoUrl = getApplicationLogo();
const oidcEnabledBySettings = $derived(data.settings?.oidcEnabled === true);
const showOidcLoginButton = $derived(oidcEnabledBySettings);
@@ -45,18 +43,22 @@
oidcProviderName ? m.auth_oidc_signin_with({ provider: oidcProviderName }) : m.auth_oidc_signin()
);
+ // Only an explicit redirect is handed to the OIDC flow. Resolving the account
+ // landing page here would bake the signed-out default into the OIDC round
+ // trip, where it would then outrank the user's saved preference.
+ const oidcLoginHref = $derived(data.redirectTo ? `/oidc/login?redirect=${encodeURIComponent(data.redirectTo)}` : '/oidc/login');
+
const oidcLoginMutation = createMutation(() => ({
mutationFn: async () => {
error = null;
- const currentRedirect = data.redirectTo || getEffectiveLandingPage();
- await goto(`/oidc/login?redirect=${encodeURIComponent(currentRedirect)}`);
+ await goto(oidcLoginHref);
}
}));
const loginMutation = createMutation(() => ({
mutationFn: () => authService.login({ username, password }),
onSuccess: async (user) => {
- userStore.setUser(user);
+ await userStore.setUser(user);
await queryClient.invalidateQueries({ queryKey: queryKeys.auth.all });
const redirectTo = data.redirectTo || getEffectiveLandingPage();
await goto(redirectTo, { replaceState: true });
@@ -76,11 +78,10 @@
});
function handleOidcLogin() {
- const currentRedirect = data.redirectTo || getEffectiveLandingPage();
oidcLoginMutation.mutate(undefined, {
onError: () => {
// Fallback to direct navigation when mutation fails unexpectedly
- void goto(`/oidc/login?redirect=${encodeURIComponent(currentRedirect)}`);
+ void goto(oidcLoginHref);
}
});
}
diff --git a/frontend/src/routes/(auth)/login/+page.ts b/frontend/src/routes/(auth)/login/+page.ts
index f2ba1969d..c8d95d7a4 100644
--- a/frontend/src/routes/(auth)/login/+page.ts
+++ b/frontend/src/routes/(auth)/login/+page.ts
@@ -4,13 +4,15 @@ import { getEffectiveLandingPage } from '#lib/utils/navigation';
export const load = async ({ parent, url }) => {
const data = await parent();
- const landingPage = getEffectiveLandingPage();
- const rawRedirect = url.searchParams.get('redirect') || landingPage;
+ // Only an explicit `redirect` param produces a target here. The account-level
+ // landing page is a per-user preference, so it can only be resolved once the
+ // user is signed in — the post-login handlers fall back to it themselves.
+ const rawRedirect = url.searchParams.get('redirect');
// Guard against open redirects — only allow same-origin relative paths
- const redirectTo = rawRedirect.startsWith('/') && !rawRedirect.startsWith('//') ? rawRedirect : landingPage;
+ const redirectTo = rawRedirect?.startsWith('/') && !rawRedirect.startsWith('//') ? rawRedirect : '';
if (data.user) {
- throw redirect(302, redirectTo);
+ throw redirect(302, redirectTo || getEffectiveLandingPage());
}
const error = url.searchParams.get('error');
diff --git a/frontend/src/routes/(auth)/oidc/callback/+page.svelte b/frontend/src/routes/(auth)/oidc/callback/+page.svelte
index 47a596cd1..f80cd9f70 100644
--- a/frontend/src/routes/(auth)/oidc/callback/+page.svelte
+++ b/frontend/src/routes/(auth)/oidc/callback/+page.svelte
@@ -29,9 +29,12 @@
return `/login?${params.toString()}`;
};
+ // Returns '' when no explicit target was carried across the OIDC round trip.
+ // This runs before the user is in the store, so the account landing page must
+ // not be resolved here — it is resolved after sign-in, below.
const getStoredRedirect = () => {
const storedRedirect = localStorage.getItem('oidc_redirect');
- return storedRedirect?.startsWith('/') && !storedRedirect.startsWith('//') ? storedRedirect : getEffectiveLandingPage();
+ return storedRedirect?.startsWith('/') && !storedRedirect.startsWith('//') ? storedRedirect : '';
};
type CallbackFailure = {
@@ -141,15 +144,19 @@
// to /no-access mid-navigation. refreshAll() above has repopulated
// page.data (user + permissions manifest) and the environment store.
const landingUser = page.data['user'] ?? user;
+ // Resolved here, after setUser/refreshAll, so the user's saved landing
+ // page applies when no explicit redirect was requested.
+ const landingPage = getEffectiveLandingPage();
+ const requestedTarget = redirectTo || landingPage;
const target =
getAuthRedirectPath(
- redirectTo,
+ requestedTarget,
landingUser,
environmentStore.selected?.id,
page.data['permissionsManifest'],
page.data['permissionsManifestLoadFailed'] ?? false,
- getEffectiveLandingPage()
- ) ?? redirectTo;
+ landingPage
+ ) ?? requestedTarget;
await goto(target, { replaceState: true });
},
onError: (err: unknown) => {
diff --git a/frontend/src/routes/(auth)/oidc/login/+page.svelte b/frontend/src/routes/(auth)/oidc/login/+page.svelte
index 6670c3364..6f5212bc0 100644
--- a/frontend/src/routes/(auth)/oidc/login/+page.svelte
+++ b/frontend/src/routes/(auth)/oidc/login/+page.svelte
@@ -4,7 +4,6 @@
import { page } from '$app/state';
import { m } from '#lib/paraglide/messages';
import { authService } from '#lib/services/auth-service';
- import { getEffectiveLandingPage } from '#lib/utils/navigation';
import OidcStatusPanel from '#lib/components/oidc-status-panel.svelte';
import { createMutation } from '@tanstack/svelte-query';
@@ -14,14 +13,25 @@
const oidcLoginMutation = createMutation(() => ({
mutationFn: async () => {
- const redirect = page.url.searchParams.get('redirect') || getEffectiveLandingPage();
+ // Carry only an explicit, same-origin redirect across the OIDC round
+ // trip. The account landing page is a per-user preference and cannot be
+ // resolved while signed out — storing the signed-out default here would
+ // make the callback treat it as an explicit target and override the
+ // user's saved page. The callback resolves the preference itself.
+ const requested = page.url.searchParams.get('redirect') ?? '';
+ const redirect = requested.startsWith('/') && !requested.startsWith('//') ? requested : '';
const authUrl = await authService.getAuthUrl(redirect);
if (!authUrl) {
throw new Error('oidc_url_generation_failed');
}
- localStorage.setItem('oidc_redirect', redirect);
+ if (redirect) {
+ localStorage.setItem('oidc_redirect', redirect);
+ } else {
+ // Clear any target left behind by an earlier sign-in attempt.
+ localStorage.removeItem('oidc_redirect');
+ }
window.location.href = authUrl;
},
onError: (err: any) => {
diff --git a/types/settings/settings.go b/types/settings/settings.go
index b459d951d..3565be094 100644
--- a/types/settings/settings.go
+++ b/types/settings/settings.go
@@ -246,21 +246,6 @@ type Update struct {
// Required: false
DockerHost *string `json:"dockerHost,omitempty"`
- // AccentColor is the UI accent color.
- //
- // Required: false
- AccentColor *string `json:"accentColor,omitempty"`
-
- // ApplicationTheme is the overall application theme preset.
- //
- // Required: false
- ApplicationTheme *string `json:"applicationTheme,omitempty"`
-
- // IconCatalog is the catalog used to resolve icon slugs.
- //
- // Required: false
- IconCatalog *string `json:"iconCatalog,omitempty"`
-
// AuthLocalEnabled indicates if local authentication is enabled.
//
// Required: false
@@ -403,41 +388,6 @@ type Update struct {
// Required: false
OidcProviderLogoUrl *string `json:"oidcProviderLogoUrl,omitempty"`
- // DefaultLandingPage is the route opened after signing in.
- //
- // Required: false
- DefaultLandingPage *string `json:"defaultLandingPage,omitempty"`
-
- // MobileNavigationMode is the navigation mode for mobile devices.
- //
- // Required: false
- MobileNavigationMode *string `json:"mobileNavigationMode,omitempty"`
-
- // MobileNavigationShowLabels indicates if labels should be shown in mobile navigation.
- //
- // Required: false
- MobileNavigationShowLabels *string `json:"mobileNavigationShowLabels,omitempty"`
-
- // SidebarHoverExpansion indicates if the sidebar expands on hover.
- //
- // Required: false
- SidebarHoverExpansion *string `json:"sidebarHoverExpansion,omitempty"`
-
- // KeyboardShortcutsEnabled indicates if keyboard shortcuts are enabled.
- //
- // Required: false
- KeyboardShortcutsEnabled *string `json:"keyboardShortcutsEnabled,omitempty"`
-
- // GlassEffectsEnabled indicates if blur/glass effects are applied to UI surfaces.
- //
- // Required: false
- GlassEffectsEnabled *string `json:"glassEffectsEnabled,omitempty"`
-
- // AnimationsEnabled indicates if decorative interface animations are enabled.
- //
- // Required: false
- AnimationsEnabled *string `json:"animationsEnabled,omitempty"`
-
// DockerApiTimeout is the timeout for Docker API operations in seconds.
//
// Required: false
@@ -533,9 +483,4 @@ type Update struct {
//
// Required: false
DepotToken *string `json:"depotToken,omitempty"`
-
- // OledMode sets whether OLED dark mode is enabled or not.
- //
- // Required: false
- OledMode *string `json:"oledMode,omitempty"`
}
diff --git a/types/user/user.go b/types/user/user.go
index 035d4d69e..483b4279b 100644
--- a/types/user/user.go
+++ b/types/user/user.go
@@ -9,6 +9,25 @@ const (
TimeFormat24Hour TimeFormat = "24h"
)
+// Preferences holds the per-user display/UI preferences. Every field is a
+// pointer so that "unset" (nil) is distinguishable from an explicit value and
+// falls back to the frontend default. It doubles as the GORM serializer target
+// on the user model and as the wire DTO.
+type Preferences struct {
+ ThemeMode *string `json:"themeMode,omitempty" enum:"light,dark,system" doc:"Light/dark mode preference"`
+ ApplicationTheme *string `json:"applicationTheme,omitempty" enum:"default,graphite,ocean,amber,github,nord,everforest,rosepine" doc:"Application theme preset"`
+ AccentColor *string `json:"accentColor,omitempty" doc:"Primary accent color, or 'default'"`
+ IconCatalog *string `json:"iconCatalog,omitempty" enum:"selfhst,dashboard-icons" doc:"Catalog used to resolve project and container icon slugs"`
+ OledMode *bool `json:"oledMode,omitempty" doc:"Use true-black backgrounds in dark mode"`
+ GlassEffectsEnabled *bool `json:"glassEffectsEnabled,omitempty" doc:"Apply blur and glass effects to UI surfaces"`
+ AnimationsEnabled *bool `json:"animationsEnabled,omitempty" doc:"Enable decorative interface animations"`
+ SidebarHoverExpansion *bool `json:"sidebarHoverExpansion,omitempty" doc:"Expand the desktop sidebar on hover"`
+ KeyboardShortcutsEnabled *bool `json:"keyboardShortcutsEnabled,omitempty" doc:"Enable keyboard shortcuts and shortcut hints"`
+ MobileNavigationMode *string `json:"mobileNavigationMode,omitempty" enum:"floating,docked" doc:"Mobile navigation style"`
+ MobileNavigationShowLabels *bool `json:"mobileNavigationShowLabels,omitempty" doc:"Show text labels in mobile navigation"`
+ DefaultLandingPage *string `json:"defaultLandingPage,omitempty" doc:"Route opened after signing in"`
+}
+
// CreateUser represents the request body for creating a new user.
// Role assignments are managed separately via PUT /users/{userId}/role-assignments.
type CreateUser struct {
@@ -49,6 +68,7 @@ type User struct {
OidcSubjectId *string `json:"oidcSubjectId,omitempty" doc:"OIDC subject identifier for SSO users"`
Locale *string `json:"locale,omitempty" doc:"Locale preference of the user" example:"en-US"`
PermissionsByEnv map[string][]string `json:"permissionsByEnv" doc:"Permissions the user effectively holds, keyed by environment ID. The 'global' key holds permissions that apply across every environment (and to org-level endpoints)."`
+ Preferences Preferences `json:"preferences" doc:"Personal display and UI preferences"`
ID string `json:"id" doc:"Unique identifier of the user" example:"550e8400-e29b-41d4-a716-446655440000"`
Username string `json:"username" doc:"Username of the user" example:"johndoe"`
TimeFormat TimeFormat `json:"timeFormat" enum:"auto,12h,24h" doc:"Preferred time display format" example:"auto"`