Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/extension/src/parts/Progress/Progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
} from '@lvce-editor/api'
import * as Rpc from '../Rpc/Rpc.ts'

let output: ReturnType<typeof createOutputChannel> | 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: {
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 16 additions & 8 deletions packages/extension/test/DevContainerProgress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>()
let startupResult: unknown = pending.promise
let workspaceProgressProvider:
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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()
Expand Down
Loading