From d98c854a148e5dce070c9d1d0a9b07749fbebaf5 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 26 Feb 2026 14:29:01 -0500 Subject: [PATCH] perf(lsp): use shared timeout for parallel diagnostics collection --- internal/agent/tools/diagnostics.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/agent/tools/diagnostics.go b/internal/agent/tools/diagnostics.go index 06c2c1e813a61099be6aad26a988317df38b639b..bce1661151e12a78c1fc969077d70bfb4015fbc6 100644 --- a/internal/agent/tools/diagnostics.go +++ b/internal/agent/tools/diagnostics.go @@ -7,6 +7,7 @@ import ( "log/slog" "sort" "strings" + "sync" "time" "charm.land/fantasy" @@ -72,12 +73,21 @@ func waitForLSPDiagnostics( return } + waitCtx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + var wg sync.WaitGroup for client := range manager.Clients().Seq() { if !client.HandlesFile(filepath) { continue } - client.WaitForDiagnostics(ctx, timeout) + wg.Add(1) + go func() { + defer wg.Done() + client.WaitForDiagnostics(waitCtx, timeout) + }() } + wg.Wait() } // notifyLSPs notifies LSP servers that a file has changed and waits for