From 4b6cf1d40a7af3f9d3094de894e6eddb65662b85 Mon Sep 17 00:00:00 2001 From: tttpob Date: Tue, 4 Aug 2026 15:12:51 +0800 Subject: [PATCH] fix(vscode): reuse manager output channel across restarts --- packages/vscode/src/opencode.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/vscode/src/opencode.ts b/packages/vscode/src/opencode.ts index c1f60f73..d694abbd 100644 --- a/packages/vscode/src/opencode.ts +++ b/packages/vscode/src/opencode.ts @@ -14,6 +14,17 @@ import { registerManagedProcess, unregisterManagedProcess, reapOrphanedProcesses const t = vscode.l10n.t; const READY_CHECK_TIMEOUT_MS = 30000; + +// Reuse a single output channel across restarts instead of creating (and +// leaking) a new one on every waitForReady call. +let managerOutputChannel: vscode.OutputChannel | null = null; + +function getManagerOutputChannel(): vscode.OutputChannel { + if (!managerOutputChannel) { + managerOutputChannel = vscode.window.createOutputChannel('OpenChamberManager'); + } + return managerOutputChannel; +} const WINDOWS_EXECUTABLE_EXTENSIONS = (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM') .split(';') .map((ext) => ext.trim().toLowerCase()) @@ -612,7 +623,6 @@ async function waitForReady( timeoutMs = 15000, authHeaders: Record = {} ): Promise { - const outputChannel = vscode.window.createOutputChannel('OpenChamberManager'); const start = Date.now(); const candidates = getCandidateBaseUrls(serverUrl); let attempts = 0; @@ -640,7 +650,7 @@ async function waitForReady( } clearTimeout(timeout); - outputChannel?.appendLine( + getManagerOutputChannel().appendLine( `Health check to ${url.toString()} returned ${res.status} with body: ${JSON.stringify(body)}` );