Fix/wsl remote tool calling

Closed
AE
6mo ago
+25757-113321

Summary

This PR is based almost entirely on the earlier work from PR #10786 by @shanevcantwell, titled: feat: shell integration-based terminal output capture for remote environments.

The original PR addressed the issue where the extension host runs on Windows with a remote workspace (SSH, WSL, Dev Container) and child process execution was incorrectly performed locally instead of on the remote machine. The existing fallback used ide.runCommand with no output capture, returning a hardcoded "Command completed" status with no actual remote output.

In addition to applying Shane's solution, this PR also updates the repository to work with Node 22.22.3, which required changes to the dependency installation and packaging workflow.

What this PR includes

  • Credit to @shanevcantwell for the remote terminal shell integration solution.
  • Implementation of a new runCommandWithOutput IDE method using VS Code Shell Integration API (1.93+) for remote terminal execution and output capture.
  • A fallback path when shell integration is unavailable that still executes commands via sendText without double-execution.
  • Packaging and install workflow updates to support Node 22.22.3 and Node SEA-based binary bundling.
  • Additional dependency manifest updates and generated lockfiles for the new environment.

Key changes

Remote shell integration support

  • Adds runCommandWithOutput to the IDE interface and protocol layers:
    • core/index.d.ts
    • core/protocol/ide.ts
    • core/protocol/messenger/messageIde.ts
    • core/protocol/messenger/reverseMessageIde.ts
  • Adds VS Code extension support for the new handler:
    • extensions/vscode/src/extension/VsCodeMessenger.ts
  • Implements the remote shell integration flow in the VS Code IDE adapter:
    • extensions/vscode/src/VsCodeIde.ts
  • Updates the remote fallback path in the terminal tool implementation to use the new method:
    • core/tools/implementations/runTerminalCommand.ts
  • Adds a stub fallback in the filesystem IDE implementation:
    • core/util/filesystem.ts
  • Enhances WSL/remote path handling for config storage:
    • core/util/paths.ts
  • Includes related type and protocol support updates:
    • core/config/types.ts
  • Adds test support/mocks for the new behavior:
    • core/tools/implementations/runTerminalCommand.vitest.ts

Node and install workflow updates

  • Updated the root package.json and binary/package.json for new devDependencies and runtime requirements.
  • Added support for Node SEA-based binary packaging in binary/utils/bundle-binary.js.
  • Adjusted binary build expectations in binary/build.js.
  • Updated the install script to validate Node version compatibility and support the new package workflow:
    • scripts/install-dependencies.sh
  • Hardened VS Code packaging dependency copying for @vscode/ripgrep and temporary install behavior:
    • extensions/vscode/scripts/install-copy-nodemodule.js

Tests and validation

  • Verified remote terminal integration behavior in the expected Shell Integration path.
  • Ensured fallback behavior still executes commands when shell integration is unavailable.
  • Confirmed Node 22.22.3 compatible install flow and packaging changes.
  • Updated any associated test harness expectations where needed.

Why this matters

The original issue affected remote development workflows where commands executed by the extension host were incorrectly routed to the local machine. This PR delivers the intended fix by capturing remote terminal output with VS Code shell integration, while preserving ANSI formatting and providing a safe fallback.

The Node 22.22.3 update is also important because it aligns the repository with the newer runtime and packaging expectations, and it required corresponding install and bundle adjustments.

Notes

  • This PR is intentionally built on top of Shane's original shell integration approach.

  • The Node upgrade is a complementary change needed to make the updated install and packaging flow work reliably.

  • The new output capture preserves ANSI colors and strips only VS Code internal OSC markers.

  • When shell integration is unavailable, the command still executes and the caller receives a sensible completion message without duplicate execution.

  • Some files were automatically updated by Prettier formatting as part of these changes. These formatting-only edits are non-functional and should be considered separate from the behavioral changes above.


Summary by cubic

Fixes remote tool execution in SSH/WSL/dev containers by running commands on the remote machine and capturing output via VS Code shell integration. Also upgrades to Node 22.22.3, switches the binary to Node SEA packaging, and adjusts @vscode/ripgrep handling for reliable builds.

  • Bug Fixes

    • Remote terminal tool now runs on the remote host and captures output using a new IDE method runCommandWithOutput (uses VS Code Shell Integration; falls back to sendText when unavailable).
    • Handles non‑zero exit codes, avoids double execution, and preserves ANSI colors. Improves WSL/remote path detection for config storage.
    • In remote VS Code sessions, always use the compiled GUI (not the localhost dev server) to ensure accessibility.
  • Migration

    • Requires Node 22.22.3 across the repo (.nvmrc, .node-version, engines updated).
    • Binary build switches to Node SEA; install/build scripts and dependencies updated (adds postject, ncp).
    • Adds @vscode/ripgrep and updates packaging: dev packaging writes placeholder rg/rg.exe to satisfy VS Code validation on Windows; copy/cleanup scripts adjusted.