From 1c4b6a711836fdadf439dc0b5cd838f573fea9cf Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Wed, 14 Oct 2026 19:30:38 +0000 Subject: [PATCH] fix: register devcontainer output channel during activation --- .../extension/src/parts/Progress/Progress.ts | 5 ++-- .../test/DevContainerProgress.test.ts | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/extension/src/parts/Progress/Progress.ts b/packages/extension/src/parts/Progress/Progress.ts index 81f70f9..950d0eb 100644 --- a/packages/extension/src/parts/Progress/Progress.ts +++ b/packages/extension/src/parts/Progress/Progress.ts @@ -11,7 +11,9 @@ import { } from '@lvce-editor/api' import * as Rpc from '../Rpc/Rpc.ts' -let output: ReturnType | undefined +// Register the channel during extension activation so it is available in the +// Output dropdown before the first container operation starts. +const output = createOutputChannel('dev-containers') let busy = false let monitorGeneration = 0 const workspaceProgressState: { @@ -73,7 +75,6 @@ export const run = async ( busy = true const generation = ++monitorGeneration try { - output ||= createOutputChannel('dev-containers') const channel = output const header = `Starting Dev Containers for ${workspaceFolder}…\n` await channel.replace(header) diff --git a/packages/extension/test/DevContainerProgress.test.ts b/packages/extension/test/DevContainerProgress.test.ts index ac27e16..5a6f40c 100644 --- a/packages/extension/test/DevContainerProgress.test.ts +++ b/packages/extension/test/DevContainerProgress.test.ts @@ -2,6 +2,7 @@ import assert from 'node:assert/strict' import { mock, test } from 'node:test' const events: string[] = [] +const createdOutputChannels: string[] = [] const pending = Promise.withResolvers() let startupResult: unknown = pending.promise let workspaceProgressProvider: @@ -14,14 +15,17 @@ let lifecycle = { mock.module('@lvce-editor/api', { namedExports: { closeUri: async () => {}, - createOutputChannel: () => ({ - appendLine: async (text: string) => { - events.push(text) - }, - replace: async (text: string) => { - events.push(text) - }, - }), + createOutputChannel: (id: string) => { + createdOutputChannels.push(id) + return { + appendLine: async (text: string) => { + events.push(text) + }, + replace: async (text: string) => { + events.push(text) + }, + } + }, executeCommand: async () => {}, getPreference: async () => 'docker', openOutputView: async () => { @@ -56,6 +60,10 @@ const { openWorkspace } = await import('../src/parts/DevContainerCommands/DevContainerCommands.ts') const Progress = await import('../src/parts/Progress/Progress.ts') +await test('registers the output channel as soon as the extension activates', () => { + assert.deepEqual(createdOutputChannels, ['dev-containers']) +}) + await test('reopen opens output and displays logs before the build finishes', async () => { Progress.registerWorkspaceProgress() const operation = openWorkspace()