Skip to content

fix: use OutputChannel for build logs instead of pseudoterminal#897

Merged
EhabY merged 3 commits intomainfrom
fix/terminal-output-channel
Apr 18, 2026
Merged

fix: use OutputChannel for build logs instead of pseudoterminal#897
EhabY merged 3 commits intomainfrom
fix/terminal-output-channel

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented Apr 15, 2026

Summary

  • Replace TerminalSession (pseudoterminal) with TerminalOutputChannel (OutputChannel wrapper) for streaming build and agent logs during connection
  • Strip ANSI escape sequences via strip-ansi since OutputChannels render them as raw text
  • Simplify the write interface: CliContext now takes a plain write callback instead of a vscode.EventEmitter

Why OutputChannel instead of a pseudoterminal?

VS Code never fires the pseudoterminal open() callback for terminals created during the remote connection resolve flow. Without open(), VS Code hasn't subscribed to onDidWrite, so all writeEmitter.fire() calls are silently dropped — the "Workspace Build" terminal appears but remains empty.

This affects any pseudoterminal created inside the remote resolver's resolve() method. Terminals created during normal operation (e.g. "Coder: Ping Workspace") work fine because VS Code has fully initialized the terminal renderer by then.

OutputChannels don't depend on a rendering lifecycle callback, so they work reliably in any context.

This now looks like this and the output channel is disposed (and removed) after this is done, the only downside is that we also ANSI formatting but the terminal was always readonly so this works:

image

@EhabY EhabY requested a review from code-asher April 15, 2026 21:05
EhabY added 3 commits April 16, 2026 14:42
Replace TerminalSession with TerminalOutputChannel backed by a VS Code
OutputChannel. CliContext now takes a plain write callback instead of
an EventEmitter.
OutputChannels render ANSI codes as raw text. Use strip-ansi (already
a project dependency) to clean the output.
Add a fully-implemented MockOutputChannel to testHelpers, add LogLevel
to the vscode mock runtime, and use a setup function in the
TerminalOutputChannel tests for black-box input/output assertions.
@EhabY EhabY force-pushed the fix/terminal-output-channel branch from f4aed13 to 7db73e9 Compare April 16, 2026 11:42
Copy link
Copy Markdown
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem unfortunate to lose any potential coloring (not sure if we did color anything though) but what can ya do if VS Code is being buggy.

@EhabY EhabY merged commit f3f4c7c into main Apr 18, 2026
10 of 12 checks passed
@EhabY EhabY deleted the fix/terminal-output-channel branch April 18, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants