From 32a72e6533ecf3d4e0c53137692c658b512abcd1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 28 Aug 2025 23:56:28 +0300 Subject: lsp: limit to one in-flight LLM query; return visible 'LLM busy' completion item with provider/model; retain chat EOL suppression --- internal/lsp/llm_busy_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 internal/lsp/llm_busy_test.go (limited to 'internal/lsp/llm_busy_test.go') diff --git a/internal/lsp/llm_busy_test.go b/internal/lsp/llm_busy_test.go new file mode 100644 index 0000000..95123d2 --- /dev/null +++ b/internal/lsp/llm_busy_test.go @@ -0,0 +1,25 @@ +package lsp + +import ( + "encoding/json" + "testing" +) + +// Ensure a visible busy item is returned when a prior LLM request is in flight. +func TestLLMBusy_YieldsBusyCompletionItem(t *testing.T) { + s := &Server{ maxTokens: 32, triggerChars: []string{"."}, compCache: make(map[string]string) } + s.llmClient = &countingLLM{} + // Mark busy + s.setLLMBusy(true) + t.Cleanup(func(){ s.setLLMBusy(false) }) + line := "obj." + p := CompletionParams{ Position: Position{ Line: 0, Character: len(line) }, TextDocument: TextDocumentIdentifier{URI: "file://busy.go"} } + // Simulate manual invoke to bypass min-prefix + p.Context = json.RawMessage([]byte(`{"triggerKind":1}`)) + items, ok := s.tryLLMCompletion(p, "", line, "", "", "", false, "") + if !ok { t.Fatalf("expected ok=true") } + if len(items) != 1 { t.Fatalf("expected one busy item, got %d", len(items)) } + if items[0].InsertText != "" { t.Fatalf("busy item should not insert text") } + if items[0].Label == "" { t.Fatalf("busy item should have a label") } +} + -- cgit v1.2.3