detached 82561bc

fix(config): simplify runtime provider snapshots

commit
82561bc5411dbacdb19de0281fea6f558104a396
author
brice · · 2026-06-23 14:33 UTC
committer
brice · · 2026-06-23 20:01 UTC
parent
035c4f0
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +14 -6
M internal/bootstrap/runtime_config.go +3 -6
@@ -31,7 +31,7 @@ func (p *runtimeConfigProvider) Current() port.RuntimeConfigSnapshot {
3131 if p.manager == nil {
3232 return cloneRuntimeConfigSnapshot(p.fallback)
3333 }
34- return cloneRuntimeConfigSnapshot(RuntimeConfigSnapshotFromConfig(p.manager.Get()))
34+ return RuntimeConfigSnapshotFromConfig(p.manager.Get())
3535 }
3636
3737 func (p *runtimeConfigProvider) Watch() error {
@@ -42,14 +42,11 @@ func (p *runtimeConfigProvider) Watch() error {
4242 }
4343
4444 func (p *runtimeConfigProvider) OnChange(callback func(port.RuntimeConfigSnapshot)) {
45- if p == nil || p.manager == nil {
45+ if p == nil || p.manager == nil || callback == nil {
4646 return
4747 }
4848 p.manager.OnConfigChange(func(cfg *config.Config) {
49- snapshot := RuntimeConfigSnapshotFromConfig(cfg)
50- if callback != nil {
51- callback(cloneRuntimeConfigSnapshot(snapshot))
52- }
49+ callback(RuntimeConfigSnapshotFromConfig(cfg))
5350 })
5451 }
5552
@@ -31,7 +31,7 @@ func (p *runtimeConfigProvider) Current() port.RuntimeConfigSnapshot {
31 if p.manager == nil {31 if p.manager == nil {
32 return cloneRuntimeConfigSnapshot(p.fallback)32 return cloneRuntimeConfigSnapshot(p.fallback)
33 }33 }
34- return cloneRuntimeConfigSnapshot(RuntimeConfigSnapshotFromConfig(p.manager.Get()))34+ return RuntimeConfigSnapshotFromConfig(p.manager.Get())
35 }35 }
36 36
37 func (p *runtimeConfigProvider) Watch() error {37 func (p *runtimeConfigProvider) Watch() error {
@@ -42,14 +42,11 @@ func (p *runtimeConfigProvider) Watch() error {
42 }42 }
43 43
44 func (p *runtimeConfigProvider) OnChange(callback func(port.RuntimeConfigSnapshot)) {44 func (p *runtimeConfigProvider) OnChange(callback func(port.RuntimeConfigSnapshot)) {
45- if p == nil || p.manager == nil {45+ if p == nil || p.manager == nil || callback == nil {
46 return46 return
47 }47 }
48 p.manager.OnConfigChange(func(cfg *config.Config) {48 p.manager.OnConfigChange(func(cfg *config.Config) {
49- snapshot := RuntimeConfigSnapshotFromConfig(cfg)49+ callback(RuntimeConfigSnapshotFromConfig(cfg))
50- if callback != nil {
51- callback(cloneRuntimeConfigSnapshot(snapshot))
52- }
53 })50 })
54 }51 }
55 52
M internal/bootstrap/runtime_config_test.go +11 -0
@@ -131,6 +131,17 @@ func TestRuntimeConfigProviderOnChangeCallbackCanCallCurrent(t *testing.T) {
131131 }
132132 }
133133
134+func TestRuntimeConfigProviderOnChangeNilCallbackDoesNotRegister(t *testing.T) {
135+ manager := &fakeConfigManager{current: config.DefaultConfig()}
136+ provider := NewRuntimeConfigProvider(config.DefaultConfig(), manager)
137+
138+ provider.OnChange(nil)
139+
140+ if len(manager.callbacks) != 0 {
141+ t.Fatalf("callbacks=%d, want 0", len(manager.callbacks))
142+ }
143+}
144+
134145 func TestRuntimeConfigProviderWatchDelegatesToManager(t *testing.T) {
135146 manager := &fakeConfigManager{}
136147 provider := NewRuntimeConfigProvider(config.DefaultConfig(), manager)
@@ -131,6 +131,17 @@ func TestRuntimeConfigProviderOnChangeCallbackCanCallCurrent(t *testing.T) {
131 }131 }
132 }132 }
133 133
134+func TestRuntimeConfigProviderOnChangeNilCallbackDoesNotRegister(t *testing.T) {
135+ manager := &fakeConfigManager{current: config.DefaultConfig()}
136+ provider := NewRuntimeConfigProvider(config.DefaultConfig(), manager)
137+
138+ provider.OnChange(nil)
139+
140+ if len(manager.callbacks) != 0 {
141+ t.Fatalf("callbacks=%d, want 0", len(manager.callbacks))
142+ }
143+}
144+
134 func TestRuntimeConfigProviderWatchDelegatesToManager(t *testing.T) {145 func TestRuntimeConfigProviderWatchDelegatesToManager(t *testing.T) {
135 manager := &fakeConfigManager{}146 manager := &fakeConfigManager{}
136 provider := NewRuntimeConfigProvider(config.DefaultConfig(), manager)147 provider := NewRuntimeConfigProvider(config.DefaultConfig(), manager)

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