summaryrefslogtreecommitdiff
path: root/internal/lsp
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
committerPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
commit2efcd2c4dda97831058851e8911281d5db5ce1c6 (patch)
treec59059cb4c781878f1291ca06fe1a215579a0fa8 /internal/lsp
parentd0330d02ff040326216ab940a767490cb2de09ce (diff)
Log config reload changes
Diffstat (limited to 'internal/lsp')
-rw-r--r--internal/lsp/chat_commands.go14
-rw-r--r--internal/lsp/chat_commands_test.go2
2 files changed, 2 insertions, 14 deletions
diff --git a/internal/lsp/chat_commands.go b/internal/lsp/chat_commands.go
index 31347e9..89efa49 100644
--- a/internal/lsp/chat_commands.go
+++ b/internal/lsp/chat_commands.go
@@ -45,19 +45,7 @@ func (s *Server) handleReloadCommand() chatCommandResult {
s.logger.Printf("config reload failed: %v", err)
return chatCommandResult{message: fmt.Sprintf("Reload failed: %v", err)}
}
- summary := formatReloadSummary(changes)
+ summary := runtimeconfig.FormatSummary("Reloaded config", changes)
s.logger.Print(summary)
return chatCommandResult{message: summary}
}
-
-func formatReloadSummary(changes []runtimeconfig.Change) string {
- if len(changes) == 0 {
- return "Reloaded config (no changes detected)."
- }
- lines := make([]string, 0, len(changes)+1)
- lines = append(lines, fmt.Sprintf("Reloaded config (%d changes):", len(changes)))
- for _, ch := range changes {
- lines = append(lines, fmt.Sprintf("- %s: %s → %s", ch.Key, ch.Old, ch.New))
- }
- return strings.Join(lines, "\n")
-}
diff --git a/internal/lsp/chat_commands_test.go b/internal/lsp/chat_commands_test.go
index f9bd6a0..87cc1b4 100644
--- a/internal/lsp/chat_commands_test.go
+++ b/internal/lsp/chat_commands_test.go
@@ -17,7 +17,7 @@ func TestFormatReloadSummary(t *testing.T) {
{Key: "max_tokens", Old: "200", New: "128"},
{Key: "provider", Old: "openai", New: "ollama"},
}
- got := formatReloadSummary(changes)
+ got := runtimeconfig.FormatSummary("Reloaded config", changes)
if !strings.Contains(got, "Reloaded config (2 changes):") {
t.Fatalf("expected change count line, got %q", got)
}