detached b5135b0

fix: resolve lint errors in webui_gateway validation

commit
b5135b099bd687ba71ee22357253bb26696def2b
author
brice · · 2025-12-29 17:35 UTC
parent
5bc7d83
signature
unsigned
1 file · +16 -9
M internal/infrastructure/config/webui_gateway.go +16 -9
@@ -15,13 +15,20 @@ func NewWebUIConfigGateway(mgr *Manager) *WebUIConfigGateway {
1515 return &WebUIConfigGateway{mgr: mgr}
1616 }
1717
18-// clampInt returns v clamped to [min, max].
19-func clampInt(v, min, max int) int {
20- if v < min {
21- return min
18+// Validation limits for custom performance fields.
19+const (
20+ maxWebProcessMemoryMB = 16384
21+ maxNetworkProcessMemoryMB = 4096
22+ maxWebViewPoolPrewarm = 20
23+)
24+
25+// clampInt returns v clamped to [lo, hi].
26+func clampInt(v, lo, hi int) int {
27+ if v < lo {
28+ return lo
2229 }
23- if v > max {
24- return max
30+ if v > hi {
31+ return hi
2532 }
2633 return v
2734 }
@@ -80,9 +87,9 @@ func (g *WebUIConfigGateway) SaveWebUIConfig(ctx context.Context, cfg port.WebUI
8087 if cfg.Performance.Profile == string(ProfileCustom) {
8188 current.Performance.SkiaCPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaCPUThreads, 0, maxSkiaCPUThreads)
8289 current.Performance.SkiaGPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaGPUThreads, -1, maxSkiaCPUThreads)
83- current.Performance.WebProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.WebProcessMemoryMB, 0, 16384)
84- current.Performance.NetworkProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.NetworkProcessMemoryMB, 0, 4096)
85- current.Performance.WebViewPoolPrewarmCount = clampInt(cfg.Performance.Custom.WebViewPoolPrewarm, 0, 20)
90+ current.Performance.WebProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.WebProcessMemoryMB, 0, maxWebProcessMemoryMB)
91+ current.Performance.NetworkProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.NetworkProcessMemoryMB, 0, maxNetworkProcessMemoryMB)
92+ current.Performance.WebViewPoolPrewarmCount = clampInt(cfg.Performance.Custom.WebViewPoolPrewarm, 0, maxWebViewPoolPrewarm)
8693 }
8794
8895 return g.mgr.Save(current)
@@ -15,13 +15,20 @@ func NewWebUIConfigGateway(mgr *Manager) *WebUIConfigGateway {
15 return &WebUIConfigGateway{mgr: mgr}15 return &WebUIConfigGateway{mgr: mgr}
16 }16 }
17 17
18-// clampInt returns v clamped to [min, max].18+// Validation limits for custom performance fields.
19-func clampInt(v, min, max int) int {19+const (
20- if v < min {20+ maxWebProcessMemoryMB = 16384
21- return min21+ maxNetworkProcessMemoryMB = 4096
22+ maxWebViewPoolPrewarm = 20
23+)
24+
25+// clampInt returns v clamped to [lo, hi].
26+func clampInt(v, lo, hi int) int {
27+ if v < lo {
28+ return lo
22 }29 }
23- if v > max {30+ if v > hi {
24- return max31+ return hi
25 }32 }
26 return v33 return v
27 }34 }
@@ -80,9 +87,9 @@ func (g *WebUIConfigGateway) SaveWebUIConfig(ctx context.Context, cfg port.WebUI
80 if cfg.Performance.Profile == string(ProfileCustom) {87 if cfg.Performance.Profile == string(ProfileCustom) {
81 current.Performance.SkiaCPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaCPUThreads, 0, maxSkiaCPUThreads)88 current.Performance.SkiaCPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaCPUThreads, 0, maxSkiaCPUThreads)
82 current.Performance.SkiaGPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaGPUThreads, -1, maxSkiaCPUThreads)89 current.Performance.SkiaGPUPaintingThreads = clampInt(cfg.Performance.Custom.SkiaGPUThreads, -1, maxSkiaCPUThreads)
83- current.Performance.WebProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.WebProcessMemoryMB, 0, 16384)90+ current.Performance.WebProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.WebProcessMemoryMB, 0, maxWebProcessMemoryMB)
84- current.Performance.NetworkProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.NetworkProcessMemoryMB, 0, 4096)91+ current.Performance.NetworkProcessMemoryLimitMB = clampInt(cfg.Performance.Custom.NetworkProcessMemoryMB, 0, maxNetworkProcessMemoryMB)
85- current.Performance.WebViewPoolPrewarmCount = clampInt(cfg.Performance.Custom.WebViewPoolPrewarm, 0, 20)92+ current.Performance.WebViewPoolPrewarmCount = clampInt(cfg.Performance.Custom.WebViewPoolPrewarm, 0, maxWebViewPoolPrewarm)
86 }93 }
87 94
88 return g.mgr.Save(current)95 return g.mgr.Save(current)

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