fix(config): persist performance profile from webui save
- commit
- 8cf3f3c02150a9bb890b8eb56c0c586f167519a6
- author
- brice · · 2025-12-28 19:15 UTC
- committer
- brice · · 2025-12-29 17:28 UTC
- parent
- 8db9a6a
- signature
- unsigned
3 files · +14 -0
M internal/application/port/webui_config.go +6 -0
| @@ -5,11 +5,17 @@ import "context" | |||
| 5 | 5 | // WebUIConfig represents the subset of configuration editable in dumb://config. | |
| 6 | 6 | type WebUIConfig struct { | |
| 7 | 7 | Appearance WebUIAppearanceConfig `json:"appearance"` | |
| 8 | + | Performance WebUIPerformanceConfig `json:"performance"` | |
| 8 | 9 | DefaultUIScale float64 `json:"default_ui_scale"` | |
| 9 | 10 | DefaultSearchEngine string `json:"default_search_engine"` | |
| 10 | 11 | SearchShortcuts map[string]SearchShortcut `json:"search_shortcuts"` | |
| 11 | 12 | } | |
| 12 | 13 | ||
| 14 | + | // WebUIPerformanceConfig represents performance settings editable in dumb://config. | |
| 15 | + | type WebUIPerformanceConfig struct { | |
| 16 | + | Profile string `json:"profile"` | |
| 17 | + | } | |
| 18 | + | ||
| 13 | 19 | type WebUIAppearanceConfig struct { | |
| 14 | 20 | SansFont string `json:"sans_font"` | |
| 15 | 21 | SerifFont string `json:"serif_font"` | |
| @@ -5,11 +5,17 @@ import "context" | |||||
| 5 | // WebUIConfig represents the subset of configuration editable in dumb://config. | 5 | // WebUIConfig represents the subset of configuration editable in dumb://config. | ||
| 6 | type WebUIConfig struct { | 6 | type WebUIConfig struct { | ||
| 7 | Appearance WebUIAppearanceConfig `json:"appearance"` | 7 | Appearance WebUIAppearanceConfig `json:"appearance"` | ||
| 8 | + | Performance WebUIPerformanceConfig `json:"performance"` | |||
| 8 | DefaultUIScale float64 `json:"default_ui_scale"` | 9 | DefaultUIScale float64 `json:"default_ui_scale"` | ||
| 9 | DefaultSearchEngine string `json:"default_search_engine"` | 10 | DefaultSearchEngine string `json:"default_search_engine"` | ||
| 10 | SearchShortcuts map[string]SearchShortcut `json:"search_shortcuts"` | 11 | SearchShortcuts map[string]SearchShortcut `json:"search_shortcuts"` | ||
| 11 | } | 12 | } | ||
| 12 | 13 | ||||
| 14 | + | // WebUIPerformanceConfig represents performance settings editable in dumb://config. | |||
| 15 | + | type WebUIPerformanceConfig struct { | |||
| 16 | + | Profile string `json:"profile"` | |||
| 17 | + | } | |||
| 18 | + | ||||
| 13 | type WebUIAppearanceConfig struct { | 19 | type WebUIAppearanceConfig struct { | ||
| 14 | SansFont string `json:"sans_font"` | 20 | SansFont string `json:"sans_font"` | ||
| 15 | SerifFont string `json:"serif_font"` | 21 | SerifFont string `json:"serif_font"` | ||
M internal/infrastructure/config/loader.go +3 -0
| @@ -266,6 +266,9 @@ func (m *Manager) Save(cfg *Config) error { | |||
| 266 | 266 | m.viper.Set("default_ui_scale", cfg.DefaultUIScale) | |
| 267 | 267 | m.viper.Set("default_search_engine", cfg.DefaultSearchEngine) | |
| 268 | 268 | ||
| 269 | + | // Performance profile (requires browser restart to take effect) | |
| 270 | + | m.viper.Set("performance.profile", string(cfg.Performance.Profile)) | |
| 271 | + | ||
| 269 | 272 | if err := m.viper.WriteConfig(); err != nil { | |
| 270 | 273 | return fmt.Errorf("failed to write config: %w", err) | |
| 271 | 274 | } | |
| @@ -266,6 +266,9 @@ func (m *Manager) Save(cfg *Config) error { | |||||
| 266 | m.viper.Set("default_ui_scale", cfg.DefaultUIScale) | 266 | m.viper.Set("default_ui_scale", cfg.DefaultUIScale) | ||
| 267 | m.viper.Set("default_search_engine", cfg.DefaultSearchEngine) | 267 | m.viper.Set("default_search_engine", cfg.DefaultSearchEngine) | ||
| 268 | 268 | ||||
| 269 | + | // Performance profile (requires browser restart to take effect) | |||
| 270 | + | m.viper.Set("performance.profile", string(cfg.Performance.Profile)) | |||
| 271 | + | ||||
| 269 | if err := m.viper.WriteConfig(); err != nil { | 272 | if err := m.viper.WriteConfig(); err != nil { | ||
| 270 | return fmt.Errorf("failed to write config: %w", err) | 273 | return fmt.Errorf("failed to write config: %w", err) | ||
| 271 | } | 274 | } | ||
M internal/infrastructure/config/webui_gateway.go +5 -0
| @@ -60,5 +60,10 @@ func (g *WebUIConfigGateway) SaveWebUIConfig(ctx context.Context, cfg port.WebUI | |||
| 60 | 60 | current.SearchShortcuts = shortcuts | |
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | + | // Performance profile (requires restart to take effect) | |
| 64 | + | if cfg.Performance.Profile != "" { | |
| 65 | + | current.Performance.Profile = PerformanceProfile(cfg.Performance.Profile) | |
| 66 | + | } | |
| 67 | + | ||
| 63 | 68 | return g.mgr.Save(current) | |
| 64 | 69 | } | |
| @@ -60,5 +60,10 @@ func (g *WebUIConfigGateway) SaveWebUIConfig(ctx context.Context, cfg port.WebUI | |||||
| 60 | current.SearchShortcuts = shortcuts | 60 | current.SearchShortcuts = shortcuts | ||
| 61 | } | 61 | } | ||
| 62 | 62 | ||||
| 63 | + | // Performance profile (requires restart to take effect) | |||
| 64 | + | if cfg.Performance.Profile != "" { | |||
| 65 | + | current.Performance.Profile = PerformanceProfile(cfg.Performance.Profile) | |||
| 66 | + | } | |||
| 67 | + | ||||
| 63 | return g.mgr.Save(current) | 68 | return g.mgr.Save(current) | ||
| 64 | } | 69 | } | ||