From 620d9cc70fe7e5b4099f7cebcfc656340e593837 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 30 Apr 2026 11:10:36 -0400 Subject: [PATCH] feat: warm-start LSP server on file read --- index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.ts b/index.ts index 89fd4af..48b6c6b 100644 --- a/index.ts +++ b/index.ts @@ -432,6 +432,25 @@ export default function (pi: ExtensionAPI) { default: true, }); + // Background Init on Read - Fire-and-forget LSP initialization when the + // LLM reads a file with a supported extension. Doesn't block the read, + // just ensures the server is warm by the time an LSP tool is called. + pi.on("tool_result", async (event, ctx) => { + if (event.toolName !== "read" || event.isError) return; + + const filePath = event.input?.path; + if (!filePath || typeof filePath !== "string") return; + + try { + const absolutePath = path.resolve(ctx.cwd, filePath); + // daemonDiagnostics triggers getOrCreateEntry + syncFile in the daemon. + // We don't await it — just fire and forget so the server starts warming up. + void daemonDiagnostics(absolutePath); + } catch { + // Silently ignore — unsupported file type, missing binary, etc. + } + }); + // Auto-Check After Edit/Write - Run diagnostics automatically pi.on("tool_result", async (event, ctx) => { // Check Enabled