Skip to content

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

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

Activity

  1. added
    ide:vscode
    kind:bug
    on Feb 15, 2026
  2. jamblejoe commented on Apr 23, 2026

    @jamblejoe

    is this related #7636 (comment)?

  3. shanevcantwell commented on Apr 23, 2026

    @shanevcantwell
    ContributorAuthor

    Yes, same root cause at different layers. Both stem from VS Code terminal APIs not working correctly for remote terminals when the extension runs on the local host.

    #7636 is about output capture failing (onDidReadText doesn't fire). #10542 is about command execution failing (sendText never presses Enter, createTerminal creates a local terminal).

    PR #10786 attempts to fix both by using shell integration for output capture and workbench.action.terminal.new (which is remote-aware) instead of createTerminal. Both bugs remain unfixed currently.

  4. zwancho commented on May 7, 2026

    @zwancho

    I can reproduce this issue consistently with VS Code Remote SSH on Ubuntu 20.04.
    The command is only inserted into the terminal input buffer but never actually executes.
    Example terminal state after asking Agent to run pwd:

    user@remote-host:~/project$ pwd

    The cursor remains at the end of the line and no Enter/Return is sent.
    Continue still reports:

    Command executed in remote terminal. Output capture is not yet available for remote environments.
    

    but no process actually starts.

  5. mujtahid-akon commented on May 7, 2026

    @mujtahid-akon

    Any timeline for a fix? cli is working fine but the chat mode is still failing as others said above.

  6. karypid commented on Jul 5, 2026

    @karypid

    I am running a podman dev container in Linux and getting this same problem. The inline terminal box reads:

    Command executed in remote terminal. Output capture is not yet available for remote environments.
    

    And in the chat response the model thinks:

    The user wants to know the state of the project and whether tests pass. I have just run the tests. The output capture is not yet available for remote environments. I should check if there's a way to see the output or if I need to ask the user to paste it. However, usually, in this environment, the output is returned in the tool response. If it says "Output capture is not yet available", I might need to try a different approach

  7. limpidautumn commented on Jul 12, 2026

    @limpidautumn

    I encountered the same issue when connecting to WSL remotely: the Agent interface indicated "Command Executed," but the returned result was:

    Command executed in remote terminal. Output capture is not yet available for remote environments.
    

    At the same time, a command was entered into the built-in terminal, but it was not executed.

  8. shanevcantwell commented on Jul 12, 2026

    @shanevcantwell
    ContributorAuthor

    Note that if you're up to it, and need this working today rather than waiting on review:
    gh pr checkout 10786, build the extension, and load the VSIX. That path has the output capture the merged fixes don't yet.

  9. limpidautumn commented on Jul 13, 2026

    @limpidautumn

    Thanks for the heads-up, I'll try it now.

  10. shanevcantwell commented on Jul 13, 2026

    @shanevcantwell
    ContributorAuthor

    Thanks for the heads-up, I'll try it now.

    Nice - do let me and the thread know whether it solves the problem for you.

  11. brakubraku commented on Jul 27, 2026

    @brakubraku

    can we get this fix merged finally? what is the timeline?

  12. fletort commented on Oct 21, 2026

    @fletort

    ANy update on this ?

  13. shanevcantwell commented on Oct 21, 2026

    @shanevcantwell
    ContributorAuthor

    19. ANy update on this ?

    Yeah, actually spotted the inconsistency. I'll see if I can get my open PR updated.

    Some cross-indexing below:


    Related implementation paths — important for custom VSIX builds

    The root cause goes beyond sendText(command, false). Continue's preference for the local VS Code UI extension host creates a boundary between the process executing Continue and the remote workspace where its tools must operate.

    #10786 — Shell Integration with remote output capture (February 24)

    Introduces IDE.runCommandWithOutput() across the IDE protocol, using VS Code Shell Integration to execute remote commands and return their output to the agent.

    This is the branch I've tested with SSH and WSL and previously recommended to users willing to build a custom VSIX. It addresses remote execution and output capture for the agent terminal-tool path. It does not replace the original VsCodeIde.runCommand() for other callers.

    The implementation remains unmerged. Recent community testing reported occasional hangs and missed output, so those edge cases still warrant investigation.

    #12063 — Remote-aware terminal creation (April 7)

    Fixes VsCodeIde.runCommand() using remote-aware terminal creation and newline submission. This repairs command submission for its callers, but does not capture and return output to the agent.

    #13243 — Newline-only fix (September 7)

    Corrects the missing Enter key. Does not address remote terminal creation or output capture.

    These PRs are not interchangeable. In particular, successful command submission does not establish successful agent tool execution with captured results.

    For users evaluating an unmerged PR checkout, #10786 provides the more complete agent terminal-tool implementation, subject to its outstanding limitations. The other PRs address narrower parts of the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ide:vscodekind:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions