diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 03:55:40 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 03:55:40 +0200 |
| commit | 35f1097f473e51be82f68e93ea2db48dd1c98519 (patch) | |
| tree | 1b0a316caa9bbbbfab20b6665b424f356f411ac2 | |
| parent | 93dfe3798e03e74766b229418cde364a5ef29ae9 (diff) | |
Fix mixed pointer/value receivers on appconfig.App
Change all value receivers on App to pointer receivers for consistency.
Update callers that pass App values to pass pointers where needed for
the actionConfig interface.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/appconfig/app_sections.go | 10 | ||||
| -rw-r--r-- | internal/appconfig/config_validate.go | 2 | ||||
| -rw-r--r-- | internal/hexaiaction/custom_exec_more_test.go | 4 | ||||
| -rw-r--r-- | internal/hexaiaction/custom_exec_test.go | 4 | ||||
| -rw-r--r-- | internal/hexaiaction/parse_test.go | 8 | ||||
| -rw-r--r-- | internal/hexaiaction/prompts_more_test.go | 4 | ||||
| -rw-r--r-- | internal/hexaiaction/prompts_simplify_test.go | 2 | ||||
| -rw-r--r-- | internal/hexaiaction/run.go | 4 | ||||
| -rw-r--r-- | internal/hexaiaction/run_more_test.go | 6 | ||||
| -rw-r--r-- | internal/hexaiaction/run_test.go | 8 |
10 files changed, 26 insertions, 26 deletions
diff --git a/internal/appconfig/app_sections.go b/internal/appconfig/app_sections.go index 7422152..430ebce 100644 --- a/internal/appconfig/app_sections.go +++ b/internal/appconfig/app_sections.go @@ -127,7 +127,7 @@ type AppSections struct { } // Sections returns the app configuration split into focused sub-configs. -func (a App) Sections() AppSections { +func (a *App) Sections() AppSections { return AppSections{ Core: a.CoreSection(), Providers: a.ProviderSection(), @@ -146,7 +146,7 @@ func (a *App) ApplySections(sections AppSections) { // CoreSection returns a deep copy of the core runtime and interaction settings. // Slices are cloned to prevent callers from mutating the original. -func (a App) CoreSection() CoreConfig { +func (a *App) CoreSection() CoreConfig { c := a.CoreConfig c.TriggerCharacters = slices.Clone(a.TriggerCharacters) c.ChatPrefixes = slices.Clone(a.ChatPrefixes) @@ -163,7 +163,7 @@ func (a *App) ApplyCoreSection(core CoreConfig) { // ProviderSection returns a deep copy of provider endpoint/model settings. // Surface config slices are cloned to prevent callers from mutating the original. -func (a App) ProviderSection() ProviderConfig { +func (a *App) ProviderSection() ProviderConfig { p := a.ProviderConfig p.CompletionConfigs = cloneSurfaceConfigs(a.CompletionConfigs) p.CodeActionConfigs = cloneSurfaceConfigs(a.CodeActionConfigs) @@ -184,7 +184,7 @@ func (a *App) ApplyProviderSection(providers ProviderConfig) { // PromptSection returns a deep copy of prompt templates and custom action settings. // The CustomActions slice is cloned to prevent callers from mutating the original. -func (a App) PromptSection() PromptConfig { +func (a *App) PromptSection() PromptConfig { p := a.PromptConfig p.CustomActions = append([]CustomAction{}, a.CustomActions...) return p @@ -199,7 +199,7 @@ func (a *App) ApplyPromptSection(prompts PromptConfig) { // FeatureSection returns a deep copy of non-LLM feature toggles and integrations. // Slices are cloned to prevent callers from mutating the original. -func (a App) FeatureSection() FeatureConfig { +func (a *App) FeatureSection() FeatureConfig { f := a.FeatureConfig f.IgnoreExtraPatterns = slices.Clone(a.IgnoreExtraPatterns) f.TmuxEditAgents = append([]TmuxEditAgentCfg{}, a.TmuxEditAgents...) diff --git a/internal/appconfig/config_validate.go b/internal/appconfig/config_validate.go index f5e698f..19cfcd0 100644 --- a/internal/appconfig/config_validate.go +++ b/internal/appconfig/config_validate.go @@ -6,7 +6,7 @@ import ( ) // Validate checks custom actions and tmux settings for duplicates and consistency. -func (a App) Validate() error { +func (a *App) Validate() error { if err := validateCustomActions(a.CustomActions); err != nil { return err } diff --git a/internal/hexaiaction/custom_exec_more_test.go b/internal/hexaiaction/custom_exec_more_test.go index 28bbb97..d826b39 100644 --- a/internal/hexaiaction/custom_exec_more_test.go +++ b/internal/hexaiaction/custom_exec_more_test.go @@ -22,7 +22,7 @@ func TestExecuteAction_Custom_DoesNotMutateProvidedSelection(t *testing.T) { cfg := appconfig.Load(nil) parts := InputParts{Selection: "code"} selectedCustom := &appconfig.CustomAction{ID: "x", Title: "X", Instruction: "Do it"} - _, _ = executeAction(context.Background(), ActionCustom, parts, cfg, fakeDoer{"OK"}, nil, selectedCustom) + _, _ = executeAction(context.Background(), ActionCustom, parts, &cfg, fakeDoer{"OK"}, nil, selectedCustom) if selectedCustom == nil { t.Fatalf("expected provided selectedCustom to remain local state") } @@ -33,7 +33,7 @@ func TestRunCustom_UserTemplate_InjectsDiagnostics(t *testing.T) { parts := InputParts{Selection: "code", Diagnostics: []string{"L1", "L2"}} ca := appconfig.CustomAction{ID: "y", Title: "Y", User: "{{diagnostics}}\n{{selection}}"} cap := &capDoer{} - _, err := runCustom(context.Background(), cfg, cap, ca, parts) + _, err := runCustom(context.Background(), &cfg, cap, ca, parts) if err != nil { t.Fatalf("runCustom error: %v", err) } diff --git a/internal/hexaiaction/custom_exec_test.go b/internal/hexaiaction/custom_exec_test.go index 24f549e..1a5b99e 100644 --- a/internal/hexaiaction/custom_exec_test.go +++ b/internal/hexaiaction/custom_exec_test.go @@ -12,7 +12,7 @@ func TestExecuteAction_CustomConfigured_Instruction(t *testing.T) { cfg := appconfig.Load(nil) parts := InputParts{Selection: "code"} selectedCustom := &appconfig.CustomAction{ID: "x", Title: "X", Instruction: "Do it"} - out, err := executeAction(context.Background(), ActionCustom, parts, cfg, fakeDoer{"OK"}, nil, selectedCustom) + out, err := executeAction(context.Background(), ActionCustom, parts, &cfg, fakeDoer{"OK"}, nil, selectedCustom) if err != nil || strings.TrimSpace(out) != "OK" { t.Fatalf("custom-instruction failed: %q %v", out, err) } @@ -22,7 +22,7 @@ func TestExecuteAction_CustomConfigured_User(t *testing.T) { cfg := appconfig.Load(nil) parts := InputParts{Selection: "sel"} selectedCustom := &appconfig.CustomAction{ID: "y", Title: "Y", User: "Apply to: {{selection}}"} - out, err := executeAction(context.Background(), ActionCustom, parts, cfg, fakeDoer{"OK2"}, nil, selectedCustom) + out, err := executeAction(context.Background(), ActionCustom, parts, &cfg, fakeDoer{"OK2"}, nil, selectedCustom) if err != nil || strings.TrimSpace(out) != "OK2" { t.Fatalf("custom-user failed: %q %v", out, err) } diff --git a/internal/hexaiaction/parse_test.go b/internal/hexaiaction/parse_test.go index 40ddd9a..713561e 100644 --- a/internal/hexaiaction/parse_test.go +++ b/internal/hexaiaction/parse_test.go @@ -95,28 +95,28 @@ func TestRuners_Prompts(t *testing.T) { f := &fakeClient{out: "```\nDONE\n```"} ctx := context.Background() // rewrite - if out, err := runRewrite(ctx, cfg, f, "instr", "sel"); err != nil || out != "DONE" { + if out, err := runRewrite(ctx, &cfg, f, "instr", "sel"); err != nil || out != "DONE" { t.Fatalf("rewrite failed: %q %v", out, err) } if len(f.last) != 2 || f.last[0].Content != "SYS-R" || !strings.Contains(f.last[1].Content, "instr") { t.Fatalf("rewrite prompts wrong: %#v", f.last) } // diagnostics - if out, err := runDiagnostics(ctx, cfg, f, []string{"a", "b"}, "sel"); err != nil || out != "DONE" { + if out, err := runDiagnostics(ctx, &cfg, f, []string{"a", "b"}, "sel"); err != nil || out != "DONE" { t.Fatalf("diagnostics failed: %q %v", out, err) } if f.last[0].Content != "SYS-D" || !strings.Contains(f.last[1].Content, "a\nb") { t.Fatalf("diagnostics prompts wrong: %#v", f.last) } // document - if out, err := runDocument(ctx, cfg, f, "sel"); err != nil || out != "DONE" { + if out, err := runDocument(ctx, &cfg, f, "sel"); err != nil || out != "DONE" { t.Fatalf("document failed: %q %v", out, err) } if f.last[0].Content != "SYS-C" || !strings.Contains(f.last[1].Content, "sel") { t.Fatalf("document prompts wrong: %#v", f.last) } // gotest - if out, err := runGoTest(ctx, cfg, f, "func A(){}"); err != nil || out != "DONE" { + if out, err := runGoTest(ctx, &cfg, f, "func A(){}"); err != nil || out != "DONE" { t.Fatalf("gotest failed: %q %v", out, err) } if f.last[0].Content != "SYS-T" || !strings.Contains(f.last[1].Content, "func A(){") { diff --git a/internal/hexaiaction/prompts_more_test.go b/internal/hexaiaction/prompts_more_test.go index 844bafe..67672fb 100644 --- a/internal/hexaiaction/prompts_more_test.go +++ b/internal/hexaiaction/prompts_more_test.go @@ -42,7 +42,7 @@ func TestReqOptsFrom_Override(t *testing.T) { CodeActionConfigs: []appconfig.SurfaceConfig{{Provider: "anthropic", Model: "override", Temperature: ptrFloat(0.6)}}, }, } - req := reqOptsFrom(cfg) + req := reqOptsFrom(&cfg) if req.model != "override" { t.Fatalf("expected override model, got %q", req.model) } @@ -63,7 +63,7 @@ func TestReqOptsFrom_Gpt5Temp(t *testing.T) { }, ProviderConfig: appconfig.ProviderConfig{OpenAIModel: "gpt-5.0"}, } - req := reqOptsFrom(cfg) + req := reqOptsFrom(&cfg) var opts llm.Options for _, o := range req.options { o(&opts) diff --git a/internal/hexaiaction/prompts_simplify_test.go b/internal/hexaiaction/prompts_simplify_test.go index 4daba38..4cd831d 100644 --- a/internal/hexaiaction/prompts_simplify_test.go +++ b/internal/hexaiaction/prompts_simplify_test.go @@ -17,7 +17,7 @@ func (simplifyClient) DefaultModel() string { return "m" } func TestRunSimplify_Smoke(t *testing.T) { cfg := appconfig.Load(nil) - out, err := runSimplify(context.Background(), cfg, simplifyClient{}, "code") + out, err := runSimplify(context.Background(), &cfg, simplifyClient{}, "code") if err != nil { t.Fatalf("runSimplify: %v", err) } diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go index bf36f2f..f36b0cf 100644 --- a/internal/hexaiaction/run.go +++ b/internal/hexaiaction/run.go @@ -123,7 +123,7 @@ func (r *Runner) Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Wri _, _ = fmt.Fprintf(stderr, logging.AnsiBase+"hexai-tmux-action: LLM disabled: %v"+logging.AnsiReset+"\n", err) return err } - primaryModel := strings.TrimSpace(reqOptsFrom(cfg).model) + primaryModel := strings.TrimSpace(reqOptsFrom(&cfg).model) if primaryModel == "" { primaryModel = cli.DefaultModel() } @@ -141,7 +141,7 @@ func (r *Runner) Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Wri if err != nil { return err } - out, err := executeAction(ctx, choice.kind, parts, cfg, client, stderr, choice.custom) + out, err := executeAction(ctx, choice.kind, parts, &cfg, client, stderr, choice.custom) if err != nil { return err } diff --git a/internal/hexaiaction/run_more_test.go b/internal/hexaiaction/run_more_test.go index 0e391ed..6a4959e 100644 --- a/internal/hexaiaction/run_more_test.go +++ b/internal/hexaiaction/run_more_test.go @@ -46,7 +46,7 @@ func TestHandleDiagnosticsActionInvokesLLM(t *testing.T) { parts := InputParts{Diagnostics: []string{"warn1"}, Selection: "code"} client := &stubChatDoer{} cfg := appconfig.Load(nil) - if _, err := handleDiagnosticsAction(context.Background(), parts, cfg, client); err != nil { + if _, err := handleDiagnosticsAction(context.Background(), parts, &cfg, client); err != nil { t.Fatalf("handleDiagnosticsAction: %v", err) } if client.calls != 1 { @@ -68,7 +68,7 @@ func TestHandleSimplifyActionPassesSelection(t *testing.T) { parts := InputParts{Selection: "value := 1"} client := &stubChatDoer{} cfg := appconfig.Load(nil) - if _, err := handleSimplifyAction(context.Background(), parts, cfg, client); err != nil { + if _, err := handleSimplifyAction(context.Background(), parts, &cfg, client); err != nil { t.Fatalf("handleSimplifyAction: %v", err) } if client.calls != 1 { @@ -91,7 +91,7 @@ func TestHandleCustomActionUsesProvidedCustom(t *testing.T) { parts := InputParts{Selection: "text"} client := &stubChatDoer{} cfg := appconfig.Load(nil) - if _, err := handleCustomAction(context.Background(), parts, cfg, client, &sel); err != nil { + if _, err := handleCustomAction(context.Background(), parts, &cfg, client, &sel); err != nil { t.Fatalf("handleCustomAction: %v", err) } if client.calls != 1 { diff --git a/internal/hexaiaction/run_test.go b/internal/hexaiaction/run_test.go index adc3159..b927d57 100644 --- a/internal/hexaiaction/run_test.go +++ b/internal/hexaiaction/run_test.go @@ -19,7 +19,7 @@ func (f fakeDoer) DefaultModel() string { return "m" } func TestExecuteAction_Skip(t *testing.T) { cfg := appconfig.App{} parts := InputParts{Selection: "data"} - out, err := executeAction(context.Background(), ActionSkip, parts, cfg, fakeDoer{"IGN"}, nil, nil) + out, err := executeAction(context.Background(), ActionSkip, parts, &cfg, fakeDoer{"IGN"}, nil, nil) if err != nil || out != "data" { t.Fatalf("skip failed: %q %v", out, err) } @@ -32,19 +32,19 @@ func TestExecuteAction_Rewrite_Document_GoTest(t *testing.T) { // rewrite with inline instruction sel := ";change;\ncode" - out, err := executeAction(context.Background(), ActionRewrite, InputParts{Selection: sel}, cfg, client, nil, nil) + out, err := executeAction(context.Background(), ActionRewrite, InputParts{Selection: sel}, &cfg, client, nil, nil) if err != nil || strings.TrimSpace(out) != "DONE" { t.Fatalf("rewrite failed: %q %v", out, err) } // document - out, err = executeAction(context.Background(), ActionDocument, InputParts{Selection: "code"}, cfg, client, nil, nil) + out, err = executeAction(context.Background(), ActionDocument, InputParts{Selection: "code"}, &cfg, client, nil, nil) if err != nil || strings.TrimSpace(out) != "DONE" { t.Fatalf("document failed: %q %v", out, err) } // go test - out, err = executeAction(context.Background(), ActionGoTest, InputParts{Selection: "func A(){}"}, cfg, client, nil, nil) + out, err = executeAction(context.Background(), ActionGoTest, InputParts{Selection: "func A(){}"}, &cfg, client, nil, nil) if err != nil || strings.TrimSpace(out) != "DONE" { t.Fatalf("gotest failed: %q %v", out, err) } |
