summaryrefslogtreecommitdiff
path: root/internal/appconfig
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-03 16:00:26 +0300
committerPaul Buetow <paul@buetow.org>2025-09-03 16:00:26 +0300
commitffe9ed5531b6e62706ea555c48964ea0e560b780 (patch)
tree81974f771543827f4c0743f5f1d66f5fbd06a2bd /internal/appconfig
parent71f0d04bd558433cebf1b05845c9fa0e2957eba8 (diff)
Phase 2: add configurable completion debounce\n\n- App config: completion_debounce_ms (default 200)\n- Server: wait until no input for debounce before LLM calls\n- Applies to chat and provider-native completion paths\n- Tests: add debounce and adjust to verify behavior\n\nAll unit tests pass.
Diffstat (limited to 'internal/appconfig')
-rw-r--r--internal/appconfig/config.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go
index 7bcafda..2110831 100644
--- a/internal/appconfig/config.go
+++ b/internal/appconfig/config.go
@@ -25,6 +25,14 @@ type App struct {
// to proceed without structural triggers. 0 means always allow.
ManualInvokeMinPrefix int `json:"manual_invoke_min_prefix"`
+ // Completion debounce in milliseconds. When > 0, the server waits until
+ // there has been no text change for at least this duration before sending
+ // an LLM completion request.
+ CompletionDebounceMs int `json:"completion_debounce_ms"`
+ // Completion throttle in milliseconds. When > 0, caps the minimum spacing
+ // between LLM requests (both chat and code-completer paths).
+ CompletionThrottleMs int `json:"completion_throttle_ms"`
+
TriggerCharacters []string `json:"trigger_characters"`
Provider string `json:"provider"`
@@ -59,6 +67,8 @@ func newDefaultConfig() App {
OllamaTemperature: &t,
CopilotTemperature: &t,
ManualInvokeMinPrefix: 0,
+ CompletionDebounceMs: 200,
+ CompletionThrottleMs: 0,
}
}
@@ -139,6 +149,8 @@ func (a *App) mergeBasics(other *App) {
if other.ManualInvokeMinPrefix >= 0 {
a.ManualInvokeMinPrefix = other.ManualInvokeMinPrefix
}
+ if other.CompletionDebounceMs > 0 { a.CompletionDebounceMs = other.CompletionDebounceMs }
+ if other.CompletionThrottleMs > 0 { a.CompletionThrottleMs = other.CompletionThrottleMs }
if len(other.TriggerCharacters) > 0 {
a.TriggerCharacters = slices.Clone(other.TriggerCharacters)
}
@@ -238,6 +250,12 @@ func loadFromEnv(logger *log.Logger) *App {
if n, ok := parseInt("HEXAI_MANUAL_INVOKE_MIN_PREFIX"); ok {
out.ManualInvokeMinPrefix = n; any = true
}
+ if n, ok := parseInt("HEXAI_COMPLETION_DEBOUNCE_MS"); ok {
+ out.CompletionDebounceMs = n; any = true
+ }
+ if n, ok := parseInt("HEXAI_COMPLETION_THROTTLE_MS"); ok {
+ out.CompletionThrottleMs = n; any = true
+ }
if f, ok := parseFloatPtr("HEXAI_CODING_TEMPERATURE"); ok {
out.CodingTemperature = f; any = true
}