summaryrefslogtreecommitdiff
path: root/internal/lsp/server.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-17 11:28:19 +0200
committerPaul Buetow <paul@buetow.org>2026-03-17 11:28:19 +0200
commit6f1c8bf7a36eb7044ed7aad30f84664cbbf0d303 (patch)
treedd2ac6e1433177fb59c167a12fa0b4b91132f34a /internal/lsp/server.go
parent10562cc510f64d5ac38aeb76f03e18eb76cca40f (diff)
Fix bugs, remove duplication, and clean up code quality issues
- Log swallowed JSON unmarshal errors in stats and LSP handlers - Fix debug log file handle leak in tmuxedit (return closer from initDebugLog) - Check f.Close() errors on write paths in promptstore and tmuxedit - Fix cacheGet TOCTOU race by using single write lock - Fix readInput to use passed stdin reader instead of os.Stdin.Stat() - Remove 45 'moved to' comment tombstones from lsp/handlers.go - Deduplicate canonicalProvider wrappers (use llmutils.CanonicalProvider directly) - Remove SetWindow side effect from stats.TakeSnapshot (pure read now) - Move duplicated splitLines to textutil.SplitLinesBytes - Collapse StatusSink.SetGlobal 10 params into GlobalStatus struct - Simplify LRU touchLocked to in-place delete-and-append Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'internal/lsp/server.go')
-rw-r--r--internal/lsp/server.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/internal/lsp/server.go b/internal/lsp/server.go
index 9c476ed..c266e91 100644
--- a/internal/lsp/server.go
+++ b/internal/lsp/server.go
@@ -77,10 +77,24 @@ type llmStatsSubsystem struct {
startTime time.Time
}
+// GlobalStatus bundles the fields for a global status update,
+// replacing a long parameter list.
+type GlobalStatus struct {
+ Reqs int64
+ RPM float64
+ Sent int64
+ Recv int64
+ Provider string
+ Model string
+ ScopeRPM float64
+ ScopeReqs int64
+ Window time.Duration
+}
+
// StatusSink receives status updates from the LSP server.
type StatusSink interface {
SetLLMStart(provider, model string) error
- SetGlobal(reqs int64, rpm float64, sent int64, recv int64, provider, model string, scopeRPM float64, scopeReqs int64, window time.Duration) error
+ SetGlobal(gs GlobalStatus) error
}
// ServerOptions collects configuration for NewServer to avoid long parameter lists.
@@ -334,9 +348,9 @@ func (s *Server) emitLLMStartStatus(provider, model string) {
}
}
-func (s *Server) emitGlobalStatus(reqs int64, rpm float64, sent int64, recv int64, provider, model string, scopeRPM float64, scopeReqs int64, window time.Duration) {
+func (s *Server) emitGlobalStatus(gs GlobalStatus) {
if s.statusSink != nil {
- _ = s.statusSink.SetGlobal(reqs, rpm, sent, recv, provider, model, scopeRPM, scopeReqs, window)
+ _ = s.statusSink.SetGlobal(gs)
}
}