diff options
Diffstat (limited to 'internal/runtimeconfig')
| -rw-r--r-- | internal/runtimeconfig/store.go | 24 | ||||
| -rw-r--r-- | internal/runtimeconfig/store_test.go | 22 |
2 files changed, 38 insertions, 8 deletions
diff --git a/internal/runtimeconfig/store.go b/internal/runtimeconfig/store.go index 3112951..4ee7ada 100644 --- a/internal/runtimeconfig/store.go +++ b/internal/runtimeconfig/store.go @@ -129,6 +129,14 @@ func flattenAppConfig(cfg appconfig.App) map[string]string { switch field.Name { case "StatsWindowMinutes": key = "stats_window_minutes" + case "CompletionConfigs": + key = "completion_configs" + case "CodeActionConfigs": + key = "code_action_configs" + case "ChatConfigs": + key = "chat_configs" + case "CLIConfigs": + key = "cli_configs" default: continue } @@ -170,6 +178,22 @@ func stringifyValue(v reflect.Value) string { } return strings.Join(parts, ",") } + if v.Type().Elem() == reflect.TypeOf(appconfig.SurfaceConfig{}) { + parts := make([]string, 0, v.Len()) + for i := 0; i < v.Len(); i++ { + entry := v.Index(i).Interface().(appconfig.SurfaceConfig) + segment := strings.TrimSpace(entry.Provider) + if segment != "" { + segment += ":" + } + segment += strings.TrimSpace(entry.Model) + if entry.Temperature != nil { + segment += fmt.Sprintf("@%.3f", *entry.Temperature) + } + parts = append(parts, segment) + } + return strings.Join(parts, "|") + } return fmt.Sprint(v.Interface()) case reflect.Ptr: if v.IsNil() { diff --git a/internal/runtimeconfig/store_test.go b/internal/runtimeconfig/store_test.go index 6d23b33..1c05cc9 100644 --- a/internal/runtimeconfig/store_test.go +++ b/internal/runtimeconfig/store_test.go @@ -96,16 +96,22 @@ func TestStoreReloadLogsSummary(t *testing.T) { } func TestDiff_SurfaceModel(t *testing.T) { - oldCfg := appconfig.App{CompletionModel: "gpt-4o", CompletionProvider: "openai"} - newCfg := appconfig.App{CompletionModel: "gpt-4.1", CompletionProvider: "copilot"} + oldCfg := appconfig.App{CompletionConfigs: []appconfig.SurfaceConfig{{Provider: "openai", Model: "gpt-4o"}}} + newCfg := appconfig.App{CompletionConfigs: []appconfig.SurfaceConfig{{Provider: "copilot", Model: "gpt-4.1"}}} changes := Diff(oldCfg, newCfg) - if len(changes) != 2 { - t.Fatalf("expected single change, got %+v", changes) + if len(changes) == 0 { + t.Fatalf("expected diff entries, got none") } - if changes[0].Key != "completion_model" || changes[0].Old != "gpt-4o" || changes[0].New != "gpt-4.1" { - t.Fatalf("unexpected diff entry: %+v", changes[0]) + found := false + for _, ch := range changes { + if ch.Key == "completion_configs" { + if !strings.Contains(ch.Old, "gpt-4o") || !strings.Contains(ch.New, "gpt-4.1") { + t.Fatalf("unexpected diff contents: %+v", ch) + } + found = true + } } - if changes[1].Key != "completion_provider" || changes[1].Old != "openai" || changes[1].New != "copilot" { - t.Fatalf("unexpected provider diff: %+v", changes[1]) + if !found { + t.Fatalf("expected completion configs diff, got %+v", changes) } } |
