summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-28 11:16:03 +0300
committerPaul Buetow <paul@buetow.org>2025-08-28 11:16:03 +0300
commitfaf87a23a782bc7d717e363a3a399a64d6a34146 (patch)
tree40d94eee9ee43f3784ca33d0746f07f1c58359a6
parentd7c52fc31e233e97d80a5340cf2a1c451ae465af (diff)
lsp/chat: remove '..' trigger; docs: update triggers; tests: align throttle test; version: bump to 0.2.1v0.2.1
-rw-r--r--docs/usage-examples.md4
-rw-r--r--internal/lsp/completion_throttle_test.go24
-rw-r--r--internal/lsp/handlers.go12
-rw-r--r--internal/version.go2
4 files changed, 22 insertions, 20 deletions
diff --git a/docs/usage-examples.md b/docs/usage-examples.md
index 8d628d8..aa8205f 100644
--- a/docs/usage-examples.md
+++ b/docs/usage-examples.md
@@ -32,8 +32,8 @@ Note: additional LSPs (`gopls`, `golangci-lint-lsp`) are optional; Hexai works w
Ask a question at the end of a line and receive the answer inline.
-- End your question line with a trigger: `..`, `??`, `!!`, or `::`.
-- Hexai removes the trailing marker (last char for `..`/`??`/`!!`/`::`, both for `;;`).
+- End your question line with a trigger: `??`, `!!`, or `::`.
+- Hexai removes the trailing marker (last char for `??`/`!!`/`::`, both for `;;`).
- It inserts a blank line, then a reply line prefixed with `> `, then one extra newline so most
editors place the cursor on a fresh blank line after the answer.
- If a `>` reply already exists below the question, Hexai won’t answer again.
diff --git a/internal/lsp/completion_throttle_test.go b/internal/lsp/completion_throttle_test.go
index 46975a0..11b0e7a 100644
--- a/internal/lsp/completion_throttle_test.go
+++ b/internal/lsp/completion_throttle_test.go
@@ -34,25 +34,27 @@ func TestDefaultTriggerChars_DoesNotIncludeSemicolonOrQuestion(t *testing.T) {
}
}
-func TestTryLLMCompletion_BusySkipsConcurrent(t *testing.T) {
+// Note: The server no longer exposes a busy guard; completion requests are
+// handled sequentially and the LSP can request again if needed. This test used
+// to assert a busy path; it now asserts that a normal trigger proceeds and
+// calls the LLM without reporting busy.
+func TestTryLLMCompletion_NoBusyPath_CurrentBehavior(t *testing.T) {
s := &Server{ maxTokens: 32, triggerChars: []string{".", ":", "/", "_"} }
fake := &countingLLM{}
s.llmClient = fake
- // Simulate another LLM request in flight
- s.llmBusy = true
p := CompletionParams{ Position: Position{ Line: 0, Character: 4 }, TextDocument: TextDocumentIdentifier{URI: "file://x.go"} }
items, ok, busy := s.tryLLMCompletion(p, "", "foo.", "", "", "", false, "")
- if ok {
- t.Fatalf("expected ok=false when busy guard triggers")
+ if !ok {
+ t.Fatalf("expected ok=true for a normal triggered completion")
}
- if !busy {
- t.Fatalf("expected busy=true when another request in flight")
+ if busy {
+ t.Fatalf("did not expect busy=true in current behavior")
}
- if len(items) != 0 {
- t.Fatalf("expected zero items when busy, got %d", len(items))
+ if len(items) == 0 {
+ t.Fatalf("expected some completion items when triggered")
}
- if fake.calls != 0 {
- t.Fatalf("LLM Chat should not be called when busy; calls=%d", fake.calls)
+ if fake.calls == 0 {
+ t.Fatalf("expected LLM Chat to be called")
}
}
diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go
index f0f73ed..1b7436e 100644
--- a/internal/lsp/handlers.go
+++ b/internal/lsp/handlers.go
@@ -553,7 +553,7 @@ func (s *Server) detectAndHandleChat(uri string) {
continue
}
pair := raw[j-1 : j+1]
- isTrigger := pair == ".." || pair == "??" || pair == "!!" || pair == "::"
+ isTrigger := pair == "??" || pair == "!!" || pair == "::"
if !isTrigger {
continue
}
@@ -690,7 +690,7 @@ func (s *Server) buildChatHistory(uri string, lineIdx int, currentPrompt string)
}
// stripTrailingTrigger removes a single trailing punctuation from the set
-// [.,?,!,:] or both semicolons if present at end, mirroring the inline trigger rules.
+// [?,!,:] or both semicolons if present at end, mirroring the inline trigger rules.
func stripTrailingTrigger(sx string) string {
s := strings.TrimRight(sx, " \t")
if strings.HasSuffix(s, ";;") {
@@ -699,10 +699,10 @@ func stripTrailingTrigger(sx string) string {
if len(s) == 0 {
return sx
}
- last := s[len(s)-1]
- switch last {
- case '.', '?', '!', ':':
- return strings.TrimRight(s[:len(s)-1], " \t")
+ last := s[len(s)-1]
+ switch last {
+ case '?', '!', ':':
+ return strings.TrimRight(s[:len(s)-1], " \t")
default:
return sx
}
diff --git a/internal/version.go b/internal/version.go
index 876cbc5..40e4f17 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -1,4 +1,4 @@
// Summary: Hexai semantic version identifier used by CLI and LSP binaries.
package internal
-const Version = "0.2.0"
+const Version = "0.2.1"