diff --git a/packages/vscode/src/opencode.ts b/packages/vscode/src/opencode.ts index 6a9d6504..ce72a9d1 100644 --- a/packages/vscode/src/opencode.ts +++ b/packages/vscode/src/opencode.ts @@ -15,6 +15,17 @@ import { applyProviderEnvAliases } from './provider-env-aliases'; 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()) @@ -613,7 +624,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; @@ -641,7 +651,7 @@ async function waitForReady( } clearTimeout(timeout); - outputChannel?.appendLine( + getManagerOutputChannel().appendLine( `Health check to ${url.toString()} returned ${res.status} with body: ${JSON.stringify(body)}` );