v0.30.0 eb3068f

webui_gateway.go RawHistoryFolder

1package config
2
3import (
4	"context"
5	"fmt"
6
7	"github.com/bnema/dumber/internal/application/dto"
8)
9
10type WebUIConfigGateway struct {
11	mgr *Manager
12}
13
14func NewWebUIConfigGateway(mgr *Manager) *WebUIConfigGateway {
15	return &WebUIConfigGateway{mgr: mgr}
16}
17
18// Validation limits for custom performance fields.
19const (
20	maxWebProcessMemoryMB     = 16384
21	maxNetworkProcessMemoryMB = 4096
22	maxWebViewPoolPrewarm     = 20
23)
24
25// clampInt returns v clamped to [lo, hi].
26func clampInt(v, lo, hi int) int {
27	if v < lo {
28		return lo
29	}
30	if v > hi {
31		return hi
32	}
33	return v
34}
35
36func (g *WebUIConfigGateway) SaveWebUIConfig(ctx context.Context, cfg dto.WebUIConfig) error {
37	_ = ctx
38	if g == nil || g.mgr == nil {
39		return fmt.Errorf("config manager not initialized")
40	}
41
42	current := Get()
43	current.Appearance.SansFont = cfg.Appearance.SansFont
44	current.Appearance.SerifFont = cfg.Appearance.SerifFont
45	current.Appearance.MonospaceFont = cfg.Appearance.MonospaceFont
46	current.Appearance.GtkFont = cfg.Appearance.GtkFont
47	current.Appearance.DefaultFontSize = cfg.Appearance.DefaultFontSize
48	current.Appearance.ColorScheme = cfg.Appearance.ColorScheme
49	current.Appearance.LightPalette = ColorPalette{
50		Background:     cfg.Appearance.LightPalette.Background,
51		Surface:        cfg.Appearance.LightPalette.Surface,
52		SurfaceVariant: cfg.Appearance.LightPalette.SurfaceVariant,
53		Text:           cfg.Appearance.LightPalette.Text,
54		Muted:          cfg.Appearance.LightPalette.Muted,
55		Accent:         cfg.Appearance.LightPalette.Accent,
56		Border:         cfg.Appearance.LightPalette.Border,
57	}
58	current.Appearance.DarkPalette = ColorPalette{
59		Background:     cfg.Appearance.DarkPalette.Background,
60		Surface:        cfg.Appearance.DarkPalette.Surface,
61		SurfaceVariant: cfg.Appearance.DarkPalette.SurfaceVariant,
62		Text:           cfg.Appearance.DarkPalette.Text,
63		Muted:          cfg.Appearance.DarkPalette.Muted,
64		Accent:         cfg.Appearance.DarkPalette.Accent,
65		Border:         cfg.Appearance.DarkPalette.Border,
66	}
67	current.Appearance.ExternalTheme = cfg.Appearance.ExternalTheme
68	current.DefaultUIScale = cfg.DefaultUIScale
69	current.DefaultSearchEngine = cfg.DefaultSearchEngine
70	if len(cfg.SearchShortcuts) == 0 {
71		current.SearchShortcuts = nil
72	} else {
73		shortcuts := make(map[string]SearchShortcut, len(cfg.SearchShortcuts))
74		for key, shortcut := range cfg.SearchShortcuts {
75			shortcuts[key] = SearchShortcut{
76				URL:         shortcut.URL,
77				Description: shortcut.Description,
78			}
79		}
80		current.SearchShortcuts = shortcuts
81	}
82
83	// Performance profile (requires restart to take effect)
84	if cfg.Performance.Profile != "" {
85		current.Engine.Profile = PerformanceProfile(cfg.Performance.Profile)
86	}
87
88	// Custom performance fields (only used when profile is "custom")
89	if cfg.Performance.Profile == string(ProfileCustom) {
90		current.Engine.WebKit.SkiaCPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaCPUThreads, 0, maxSkiaCPUThreads)
91		current.Engine.WebKit.SkiaGPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaGPUThreads, -1, maxSkiaGPUThreads)
92		current.Engine.WebKit.WebProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.WebProcessMemoryMB, 0, maxWebProcessMemoryMB)
93		current.Engine.WebKit.NetworkProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.NetworkProcessMemoryMB, 0, maxNetworkProcessMemoryMB)
94		current.Engine.PoolPrewarmCount = clampInt(cfg.Performance.Custom.WebViewPoolPrewarm, 0, maxWebViewPoolPrewarm)
95	}
96
97	return g.mgr.Save(current)
98}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close