Fix: Use VSCode Extension API for remote SSH connection (Trae IDE support) #5

Merged
mengning merged 1 commits from feature/trae-ide-support into main 2025-12-31 03:42:54 +00:00
Owner

Fix: Use VSCode Extension API for Remote SSH Connection (Trae IDE Support)

Problem

Trae IDE does not support the --remote CLI parameter (a feature specific to VSCode/Cursor).

Error observed:

trae --remote ssh-remote+root@my-server:1234 /workspace
# Command fails - Trae CLI doesn't recognize --remote parameter

The original implementation uses terminal CLI commands to open remote SSH connections, which fails on Trae IDE.


Solution

Replace CLI command execution with VSCode Extension API (vscode.commands.executeCommand). This approach works across all VSCode-based IDEs including VSCode, Cursor, and Trae.


Changes

1. openRemoteFolder Method

Before:

let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`);
terminal.show(true);
const command = `${cmd} --remote ssh-remote+root@${host}:${port} ${path} --reuse-window`;
terminal.sendText(command);

After:

const remoteUri = vscode.Uri.parse(
  `vscode-remote://ssh-remote+${host}${path}`
);
await vscode.commands.executeCommand('vscode.openFolder', remoteUri, {
  forceNewWindow: false
});

2. openProjectWithoutLogging Function

Same changes as above.


URI Format Changes

Aspect Old Format New Format
Format vscode-remote://ssh-remote+root@my-server:1234/workspace vscode-remote://ssh-remote+my-server/workspace
Username Hardcoded in URI From SSH config (User root)
Port Included in URI From SSH config (Port 1234)
Host Full hostname SSH config alias (my-server)

Why this matters:

The new format uses the SSH config Host alias, allowing the User root and port settings in ~/.ssh/config to take effect. This prevents URL parameters from overriding the correct SSH configuration.

Example SSH config:

Host my-server
  HostName your.server.com
  Port 1234
  User root
  IdentityFile ~/.ssh/id_rsa_example

Locally tested on Vscode and Trae

# Fix: Use VSCode Extension API for Remote SSH Connection (Trae IDE Support) ## Problem Trae IDE does not support the `--remote` CLI parameter (a feature specific to VSCode/Cursor). **Error observed:** ```bash trae --remote ssh-remote+root@my-server:1234 /workspace # Command fails - Trae CLI doesn't recognize --remote parameter ``` The original implementation uses terminal CLI commands to open remote SSH connections, which fails on Trae IDE. --- ## Solution Replace CLI command execution with **VSCode Extension API** (`vscode.commands.executeCommand`). This approach works across all VSCode-based IDEs including VSCode, Cursor, and Trae. --- ## Changes ### 1. `openRemoteFolder` Method **Before:** ```typescript let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`); terminal.show(true); const command = `${cmd} --remote ssh-remote+root@${host}:${port} ${path} --reuse-window`; terminal.sendText(command); ``` **After:** ```typescript const remoteUri = vscode.Uri.parse( `vscode-remote://ssh-remote+${host}${path}` ); await vscode.commands.executeCommand('vscode.openFolder', remoteUri, { forceNewWindow: false }); ``` ### 2. `openProjectWithoutLogging` Function Same changes as above. --- ## URI Format Changes | Aspect | Old Format | New Format | |--------|-----------|------------| | **Format** | `vscode-remote://ssh-remote+root@my-server:1234/workspace` | `vscode-remote://ssh-remote+my-server/workspace` | | **Username** | Hardcoded in URI | From SSH config (`User root`) | | **Port** | Included in URI | From SSH config (`Port 1234`) | | **Host** | Full hostname | SSH config alias (`my-server`) | **Why this matters:** The new format uses the SSH config Host alias, allowing the `User root` and port settings in `~/.ssh/config` to take effect. This prevents URL parameters from overriding the correct SSH configuration. **Example SSH config:** ```ssh Host my-server HostName your.server.com Port 1234 User root IdentityFile ~/.ssh/id_rsa_example ``` --- **Locally tested on Vscode and Trae**
shizi added 2 commits 2025-12-30 14:13:52 +00:00
fix: use VSCode Extension API for remote SSH connection to support Trae IDE
All checks were successful
CI/CD Pipeline for DevStar Extension / build (pull_request) Successful in 6m31s
6cdf60ced1
shizi force-pushed feature/trae-ide-support from 6cdf60ced1 to 2e9126fe64 2025-12-31 03:27:01 +00:00 Compare
mengning changed title from WIP: Fix: Use VSCode Extension API for remote SSH connection (Trae IDE support) to Fix: Use VSCode Extension API for remote SSH connection (Trae IDE support) 2025-12-31 03:42:44 +00:00
mengning merged commit 7c2d5d9ad9 into main 2025-12-31 03:42:54 +00:00
mengning deleted branch feature/trae-ide-support 2025-12-31 03:42:55 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devstar/devstar-vscode#5
No description provided.