diff options
| author | Adam Malczewski <[email protected]> | 2026-06-25 18:36:08 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-25 18:36:08 +0900 |
| commit | de022cee7ac66c95d7ed6a35d4e00f8e2d92cbbc (patch) | |
| tree | 041dcb1017e544a405526443cb578baa974bec0e /packages/lsp/src/tool.ts | |
| parent | fc1c3a54c3075990ec0dd0f97901bd46fe142923 (diff) | |
| parent | 649fc4f66f40f7743683546f81d3320e7394e597 (diff) | |
| download | dispatch-de022cee7ac66c95d7ed6a35d4e00f8e2d92cbbc.tar.gz dispatch-de022cee7ac66c95d7ed6a35d4e00f8e2d92cbbc.zip | |
Merge branch 'dev' into feature/ssh-support
Brings dev's retry-with-backoff (the transient `provider-retry` AgentEvent the
web frontend consumes) + the LSP-dead-server per-edit-hang fix into the SSH
feature branch, alongside the SSH waves 0-5c.
All code files auto-merged cleanly (run-turn.ts, orchestrator.ts, runtime.ts,
wire/index.ts, tool-edit-file/extension.ts, run-turn.test.ts — both computerId
threading and retry-with-backoff coexist). Only tasks.md conflicted (status
section — orchestrator-resolved; both feature sections kept).
Verified post-merge: tsc -b EXIT 0, biome clean (391 files), 1730 vitest pass
+6 sshd-integration skipped (was 1690; +40 from dev's retry/LSP tests).
Wire dist rebuilt so the FE can re-sync the pinned @dispatch/wire dep and pick
up BOTH provider-retry AND the SSH Computer/defaultComputerId types.
No merge or push (into dev or otherwise).
Diffstat (limited to 'packages/lsp/src/tool.ts')
| -rw-r--r-- | packages/lsp/src/tool.ts | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/packages/lsp/src/tool.ts b/packages/lsp/src/tool.ts index 8d282ec..be0d269 100644 --- a/packages/lsp/src/tool.ts +++ b/packages/lsp/src/tool.ts @@ -6,6 +6,7 @@ import { extname, resolve } from "node:path"; import type { ToolContract, ToolExecuteContext, ToolResult } from "@dispatch/kernel"; +import { aggregateDiagnostics } from "./aggregate.js"; import type { LspManager } from "./manager.js"; type Operation = "diagnostics" | "hover" | "definition" | "references" | "documentSymbol"; @@ -157,6 +158,8 @@ export function createLspTool(manager: LspManager): ToolContract { switch (operation) { case "diagnostics": { + // 10s hard ceiling per server (same policy as the edit path). + const DIAGNOSTICS_TIMEOUT_MS = 10_000; // Query ALL connected servers whose extensions match this file. const matching = statuses.filter( (s) => s.state === "connected" && s.extensions.some((ext) => ext === fileExt), @@ -179,31 +182,27 @@ export function createLspTool(manager: LspManager): ToolContract { if (!client) { return { content: "Language server client not available.", isError: true }; } - const result = await client.waitForDiagnostics(absolutePath); + const result = await client.waitForDiagnostics(absolutePath, { + timeoutMs: DIAGNOSTICS_TIMEOUT_MS, + }); + if (result.timedOut) { + return { + content: `⚠️ [${connected.name}] LSP took too long (>10s), diagnostics skipped — please raise this to the user.`, + }; + } return { content: result.formatted || "No diagnostics found." }; } - // Query each matching server and merge results, tagged by source. - const parts: string[] = []; - let anyTimedOut = false; - for (const s of matching) { - const client = manager.getClient(s.id, s.root); - if (!client) continue; - const result = await client.waitForDiagnostics(absolutePath, { timeoutMs: 60_000 }); - if (result.timedOut) anyTimedOut = true; - if (result.slow) { - parts.push( - `⚠️ LSP is taking unusually long. If this happens more than once, raise it to the user.`, - ); - } - if (result.formatted) { - parts.push(`[${s.name}]\n${result.formatted}`); - } - } - if (anyTimedOut && parts.length === 0) { - parts.push("Diagnostics timed out (server may still be indexing)."); - } - return { content: parts.length > 0 ? parts.join("\n\n") : "No diagnostics found." }; + // Query matching servers concurrently, each capped at 10s; + // a non-responding server is skipped with a notice. + const agg = await aggregateDiagnostics( + (id, root) => manager.getClient(id, root), + matching, + absolutePath, + DIAGNOSTICS_TIMEOUT_MS, + {}, + ); + return { content: agg.formatted || "No diagnostics found." }; } case "hover": { const client = await getFirstMatchingClient(manager, statuses, fileExt); |
