From 1b202aadb419208089bd6458a87b2f775ddeaaf6 Mon Sep 17 00:00:00 2001 From: TA Date: Fri, 6 Mar 2026 22:49:36 +0700 Subject: [PATCH] fix: filter LSP diagnostics by client root Fixes issue #16353 where diagnostics from external projects leak into tool results and context window. Only include diagnostics for files within each LSP client's workspace root. --- packages/opencode/src/lsp/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/lsp/index.ts b/packages/opencode/src/lsp/index.ts index 9d7d30632ab..6d924884854 100644 --- a/packages/opencode/src/lsp/index.ts +++ b/packages/opencode/src/lsp/index.ts @@ -290,8 +290,11 @@ export namespace LSP { export async function diagnostics() { const results: Record = {} - for (const result of await runAll(async (client) => client.diagnostics)) { + const clients = await state().then((x) => x.clients) + for (const client of clients) { + const result = await client.diagnostics for (const [path, diagnostics] of result.entries()) { + if (!path.startsWith(client.root)) continue const arr = results[path] || [] arr.push(...diagnostics) results[path] = arr