Skip to content

VsCodeIde.runCommand() doesn't execute commands in remote terminals #10542

@shanevcantwell

Description

@shanevcantwell

Description

VsCodeIde.runCommand() in extensions/vscode/src/VsCodeIde.ts has two bugs that prevent it from executing commands in remote environments (SSH, Dev Container, Codespaces, etc.):

Bug 1: sendText(command, false) — command typed but never executed

terminal.sendText(command, false);

The second parameter of Terminal.sendText() controls whether a newline is appended. false means the command text is typed into the terminal but Enter is never pressed, so the command never executes. Should be true.

Bug 2: createTerminal() creates local terminals from UI-side extensions

When no existing terminal is available to reuse, the code calls:

terminal = vscode.window.createTerminal(options?.terminalName);

With extensionKind: ["ui", "workspace"], the extension host runs on the local machine. createTerminal() from the local extension host creates a local terminal, not a remote one. For SSH/DevContainer connections, this means the terminal opens on the wrong machine.

Impact

These bugs were latent because the terminal tool's primary code path used childProcess.spawn() for most remote types (via ENABLED_FOR_REMOTES). Draft PR #10538 proposes restricting childProcess.spawn to local-only environments (since it also runs on the wrong machine for remotes), which routes all remote terminal commands through runCommand() — exposing both bugs.

Other callers of runCommand (Ollama/Lemonade helpers, legacy /cmd slash command) are also affected.

Observed behavior

Tested with SSH loopback on Linux. Terminal panel shows empty — command is not executed in the remote terminal.

Proposed fix

  1. Change sendText(command, false) to sendText(command, true)
  2. Replace createTerminal() with workbench.action.terminal.new (a VS Code built-in command that is remote-aware) + onDidOpenTerminal event to get the terminal reference

Related

Metadata

Metadata

Assignees

Labels

ide:vscodeRelates specifically to VS Code extensionkind:bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions