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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
from published versions since it shows up in the VS Code extension changelog
tab and is confusing to users. Add it back between releases if needed. -->

## Unreleased

### Fixed

- The **Coder: Workspace Build** output channel is no longer created when reconnecting to an
already-running workspace, so the Output panel doesn't pop open empty.

## [v1.14.4-pre](https://github.com/coder/vscode-coder/releases/tag/v1.14.4-pre) 2026-04-20

### Added
Expand Down
20 changes: 13 additions & 7 deletions src/remote/terminalOutputChannel.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import stripAnsi from "strip-ansi";
import * as vscode from "vscode";

/** Adapts terminal-style output for a VS Code OutputChannel. Strips ANSI escape sequences and carriage returns. */
/**
* Wraps a VS Code OutputChannel for terminal-style output, stripping ANSI
* escapes and carriage returns. The channel is created lazily on first write
* to avoid surfacing an empty pane in the Output dropdown when nothing is
* ever written.
*/
export class TerminalOutputChannel implements vscode.Disposable {
private readonly channel: vscode.OutputChannel;
private channel: vscode.OutputChannel | undefined;

constructor(name: string) {
this.channel = vscode.window.createOutputChannel(name);
this.channel.show(true);
}
constructor(private readonly name: string) {}

write(data: string): void {
if (!this.channel) {
this.channel = vscode.window.createOutputChannel(this.name);
this.channel.show(true);
}
this.channel.append(stripAnsi(data).replace(/\r/g, ""));
}

dispose(): void {
this.channel.dispose();
this.channel?.dispose();
}
}
9 changes: 9 additions & 0 deletions test/unit/remote/terminalOutputChannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ describe("TerminalOutputChannel", () => {
])("%s", (_label, input, expected) => {
expect(setup(input).content.join("")).toBe(expected);
});

it("does not create the channel until first write", () => {
vi.mocked(vscode.window.createOutputChannel).mockClear();
const channel = new TerminalOutputChannel("test");
expect(vscode.window.createOutputChannel).not.toHaveBeenCalled();

channel.write("hello");
expect(vscode.window.createOutputChannel).toHaveBeenCalledOnce();
});
});