feat: shell integration-based terminal output capture for remote environments#10786
feat: shell integration-based terminal output capture for remote environments#10786shanevcantwell wants to merge 1 commit intocontinuedev:mainfrom
Conversation
|
Want AI-powered code review for this PR? Get instant analysis, interactive visualizations, and actionable insights. |
There was a problem hiding this comment.
1 issue found across 10 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/tools/implementations/runTerminalCommand.vitest.ts">
<violation number="1" location="core/tools/implementations/runTerminalCommand.vitest.ts:273">
P0: Fallback on empty output causes commands to execute twice in remote environments</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Better now in ssh and wsl-Ubuntu remote. Containers, JetBrains, linux mint, macos use the same code path. Thanks for the patience while I got to the core of the issue. |
…environments When the extension host runs on Windows with a remote workspace (SSH, WSL, Dev Container), childProcess.spawn executes locally instead of on the remote. The existing fallback used ide.runCommand (sendText) which had no output capture, returning a hardcoded "Command failed" status. This adds a new runCommandWithOutput IDE method that uses VS Code's Shell Integration API (1.93+) to execute commands on remote terminals with full output capture. The method creates an invisible terminal, waits for shell integration to activate, executes via shellIntegration.executeCommand(), and reads output via the async iterable read() API. ANSI color codes are preserved for rendering by the UnifiedTerminal component; only VS Code's internal OSC 633 shell integration markers are stripped. Falls back gracefully to sendText when shell integration is unavailable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f8e9317 to
bccf81f
Compare
RomneyDa
left a comment
There was a problem hiding this comment.
@shanevcantwell I think current implementation would break things for Jetbrains. You could add ide type detection or jetbrains support
Hi Dallin - I completely missed your update here. I'm curious why you think Jetbrains won't go down the same code path as what #10538 fixed. I don't have $700+ to repro tho. I only had the preview subscription. |
|
Analysis strictly from the code: PR #10538 established IDE-agnostic routing — the decision is local vs remote, not IDE type. Both VS Code and JetBrains go through PR #10786 adds a new protocol method (
This is an implementation gap on the JetBrains side, not an architecture problem. The delegation pattern already works — each IDE provides its own native output capture. Adding it to IntelliJIDE.kt follows the same protocol-driven approach that has worked for all prior PRs (#9679, #9740, #10391, etc.). |
Summary
childProcess.spawnexecutes locally instead of on the remote. The existing fallback usedide.runCommand(sendText) with no output capture, returning a hardcoded "Command failed" status.runCommandWithOutputIDE method using VS Code's Shell Integration API (1.93+) to execute commands on remote terminals with full stdout capture and ANSI color preservation.runCommandWithOutputfalls back tosendTextinternally and the caller reports "Command completed" — no double-execution.How it works
onDidChangeTerminalShellIntegration(10s timeout)shellIntegration.executeCommand(command)execution.read()async iterableUnifiedTerminal'sAnsiRenderersendText, returns empty string (command still executes, just without output capture)Files changed (10)
core/index.d.tsrunCommandWithOutputto IDE interfacecore/config/types.tscore/protocol/ide.tscore/protocol/messenger/messageIde.tscore/protocol/messenger/reverseMessageIde.tsextensions/vscode/src/extension/VsCodeMessenger.tsextensions/vscode/src/VsCodeIde.tsrunCommandWithOutput()+waitForShellIntegration()implementationcore/tools/implementations/runTerminalCommand.tscore/tools/implementations/runTerminalCommand.vitest.tscore/util/filesystem.tsFileSystemIdeTest plan
pwd,echo, Python scripts with ANSI output — green "Command completed" with captured output and rendered colorschildProcess.spawnpath completely unaffected — no changes to that code pathsendTextinternally, reports "Command completed" without double-executingRelated issues
spawn powershell.exe ENOENTin WSL2/Dev Container) — fix: generalize Windows remote detection for terminal commands #10391 partially addressed this by adding theisWindowsHostWithRemoteguard but the fallback had no output captureUnifiedTerminalcomponent (feat: 💄 Unified Terminal #7383)🤖 Generated with Claude Code