v0.31.0 bf0756b

webui_payload.go RawHistoryFolder

1package config
2
3import (
4	"github.com/bnema/dumber/internal/application/dto"
5	"github.com/bnema/dumber/internal/application/port"
6)
7
8// BuildSystemviewConfigPayload projects the full config into the stable DTO used by
9// the settings page across engines.
10func BuildSystemviewConfigPayload(cfg *Config, hw *port.HardwareInfo) dto.SystemviewConfigPayload {
11	payload := dto.SystemviewConfigPayload{
12		SearchShortcuts: map[string]dto.SearchShortcut{},
13	}
14	if cfg == nil {
15		return payload
16	}
17
18	perfCfg := PerformanceConfigFromEngine(&cfg.Engine)
19	resolved := ResolvePerformanceProfile(&perfCfg, hw)
20
21	payload.Appearance = buildSystemviewAppearancePayload(cfg.Appearance)
22	payload.DefaultUIScale = cfg.DefaultUIScale
23	payload.DefaultSearchEngine = cfg.DefaultSearchEngine
24	payload.SearchShortcuts = buildSystemviewSearchShortcutsPayload(cfg.SearchShortcuts)
25	payload.EngineType = cfg.Engine.ResolveEngineType()
26	payload.Performance = dto.SystemviewPerformancePayload{
27		Profile: string(cfg.Engine.Profile),
28		Custom: dto.SystemviewCustomPerformancePayload{
29			SkiaCPUThreads:         cfg.Engine.WebKit.SkiaCPUPaintingThreads,
30			SkiaGPUThreads:         cfg.Engine.WebKit.SkiaGPUPaintingThreads,
31			WebProcessMemoryMB:     cfg.Engine.WebKit.WebProcessMemoryLimitMB,
32			NetworkProcessMemoryMB: cfg.Engine.WebKit.NetworkProcessMemoryLimitMB,
33			WebViewPoolPrewarm:     cfg.Engine.PoolPrewarmCount,
34		},
35		Resolved: dto.SystemviewResolvedPerformancePayload{
36			SkiaCPUThreads:         resolved.SkiaCPUPaintingThreads,
37			SkiaGPUThreads:         resolved.SkiaGPUPaintingThreads,
38			WebProcessMemoryMB:     resolved.WebProcessMemoryLimitMB,
39			NetworkProcessMemoryMB: resolved.NetworkProcessMemoryLimitMB,
40			WebViewPoolPrewarm:     resolved.WebViewPoolPrewarmCount,
41			ConservativeThreshold:  resolved.WebProcessMemoryConservativeThreshold,
42			StrictThreshold:        resolved.WebProcessMemoryStrictThreshold,
43		},
44		Hardware: buildSystemviewHardwarePayload(hw),
45	}
46
47	return payload
48}
49
50func buildSystemviewAppearancePayload(appearance AppearanceConfig) dto.WebUIAppearanceConfig {
51	defaults := DefaultConfig().Appearance
52	return dto.WebUIAppearanceConfig{
53		SansFont:        appearance.SansFont,
54		SerifFont:       appearance.SerifFont,
55		MonospaceFont:   appearance.MonospaceFont,
56		GtkFont:         appearance.GtkFont,
57		DefaultFontSize: appearance.DefaultFontSize,
58		ColorScheme:     appearance.ColorScheme,
59		LightPalette:    buildSystemviewPalettePayload(appearance.LightPalette, defaults.LightPalette),
60		DarkPalette:     buildSystemviewPalettePayload(appearance.DarkPalette, defaults.DarkPalette),
61		ExternalTheme: dto.WebUIExternalThemeConfig{
62			Enabled:  appearance.ExternalTheme.Enabled,
63			Provider: appearance.ExternalTheme.Provider,
64			Format:   appearance.ExternalTheme.Format,
65			Path:     appearance.ExternalTheme.Path,
66		},
67	}
68}
69
70func buildSystemviewPalettePayload(palette, fallback ColorPalette) dto.ColorPalette {
71	return dto.ColorPalette{
72		Background:     nonEmptyColor(palette.Background, fallback.Background),
73		Surface:        nonEmptyColor(palette.Surface, fallback.Surface),
74		SurfaceVariant: nonEmptyColor(palette.SurfaceVariant, fallback.SurfaceVariant),
75		Text:           nonEmptyColor(palette.Text, fallback.Text),
76		Muted:          nonEmptyColor(palette.Muted, fallback.Muted),
77		Accent:         nonEmptyColor(palette.Accent, fallback.Accent),
78		Border:         nonEmptyColor(palette.Border, fallback.Border),
79	}
80}
81
82func nonEmptyColor(value, fallback string) string {
83	if value != "" {
84		return value
85	}
86	return fallback
87}
88
89func buildSystemviewSearchShortcutsPayload(shortcuts map[string]SearchShortcut) map[string]dto.SearchShortcut {
90	if len(shortcuts) == 0 {
91		return map[string]dto.SearchShortcut{}
92	}
93
94	result := make(map[string]dto.SearchShortcut, len(shortcuts))
95	for key, shortcut := range shortcuts {
96		result[key] = dto.SearchShortcut{URL: shortcut.URL, Description: shortcut.Description}
97	}
98	return result
99}
100
101func buildSystemviewHardwarePayload(hw *port.HardwareInfo) dto.SystemviewHardwarePayload {
102	if hw == nil {
103		return dto.SystemviewHardwarePayload{}
104	}
105	return dto.SystemviewHardwarePayload{
106		CPUCores:   hw.CPUCores,
107		CPUThreads: hw.CPUThreads,
108		TotalRAMMB: hw.TotalRAMMB(),
109		GPUVendor:  string(hw.GPUVendor),
110		GPUName:    hw.GPUName,
111		VRAMMB:     hw.VRAMMB(),
112	}
113}

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