Skip to content

feat: add remote SSH host support - #192

Open
michidk wants to merge 11 commits into
mainfrom
feat/remote-host-support
Open

michidk wants to merge 11 commits into
mainfrom
feat/remote-host-support

Conversation

@michidk

@michidk michidk commented Mar 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • address Support for remote docker hosts #3 by adding remote SSH host support for open and recent, generating vscode-remote://ssh-remote+... URIs and persisting the remote host in history
  • reuse the same launch flow for remote workspaces while keeping existing local devcontainer behavior intact
  • add a Docker-based remote SSH smoke harness and verify the flow end-to-end by opening a real VS Code SSH window through vscli

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 10 files

Prompt for AI agents (unresolved 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="tests/remote-host/smoke.sh">

<violation number="1" location="tests/remote-host/smoke.sh:44">
P2: This smoke command never exercises the remote SSH launch path: `SSH_CONFIG_FILE` is unused and `--dry-run` skips running the editor, so the test can pass without validating the temporary host setup.</violation>
</file>

<file name="src/main.rs">

<violation number="1" location="src/main.rs:87">
P2: This check misses remote/config combinations inherited from history, so `recent` can silently ignore a config when reopening a remote workspace.</violation>
</file>

<file name="tests/remote-host/docker-compose.yml">

<violation number="1" location="tests/remote-host/docker-compose.yml:9">
P2: Bind the test SSH port to localhost so the smoke harness does not expose it beyond the machine running the test.</violation>
</file>

<file name="src/workspace.rs">

<violation number="1" location="src/workspace.rs:303">
P2: Reject user-supplied `--folder-uri` in remote classic mode before appending your own.</violation>
</file>

<file name="src/launch.rs">

<violation number="1" location="src/launch.rs:165">
P1: Remote SSH launches silently ignore `--behavior force-container` and fall back to a plain remote open.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/launch.rs Resolved
Comment thread tests/remote-host/smoke.sh Resolved
Comment thread src/main.rs Resolved
Comment thread tests/remote-host/docker-compose.yml Resolved
Comment thread src/workspace.rs Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved 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="src/main.rs">

<violation number="1" location="src/main.rs:193">
P1: Default remote reopens from `recent` will error on entries that were previously opened locally with the default `detect` behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/main.rs Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved 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="src/main.rs">

<violation number="1" location="src/main.rs:200">
P2: This now rejects `recent --remote-host` for history entries that merely have a stored `config_path`, even when the user did not pass `--config` in this invocation.</violation>
</file>

<file name="tests/remote-host/smoke.sh">

<violation number="1" location="tests/remote-host/smoke.sh:55">
P3: Assert the full fake-editor argv instead of grepping individual lines.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/main.rs Resolved
Comment thread tests/remote-host/smoke.sh Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@codacy-production

codacy-production Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 high · 1 medium

Alerts:
⚠ 4 issues (≤ 0 issues of at least minor severity)

Results:
4 new issues

Category Results
BestPractice 1 medium
Security 3 high

View in Codacy

🟢 Metrics 45 complexity · 4 duplication

Metric Results
Complexity 45
Duplication 4

View in Codacy

🟢 Coverage 73.02% diff coverage · +9.13% coverage variation

Metric Results
Coverage variation ✅ +9.13% coverage variation (-1.00%)
Diff coverage ✅ 73.02% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d86b538) 1659 222 13.38%
Head commit (69e1df6) 1897 (+238) 427 (+205) 22.51% (+9.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#192) 252 184 73.02%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

vibepodml Bot and others added 5 commits November 19, 2026 09:20
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Codex <codex@openai.com>
@sonarqubecloud

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/workspace.rs">

<violation number="1" location="src/workspace.rs:123">
P1: `is_absolute()` is false on Windows for POSIX remote paths like `/home/dev/project`, so `from_remote_path` rejects them on Windows clients. Use `has_root()`, which accepts `/`-rooted paths on every platform.</violation>

<violation number="2" location="src/workspace.rs:223">
P2: The remote folder URI interpolates the SSH alias and path without URI-encoding them. Paths containing valid characters such as `#` or `?` are parsed as a fragment or query, so VS Code opens a different path; encode the URI components while preserving path separators.</violation>
</file>

<file name="src/history.rs">

<violation number="1" location="src/history.rs:238">
P3: This helper leaves a new temp directory on every run because nothing deletes it. Use `tempfile::TempDir` as the other test does, and drop `unique_test_path`.</violation>
</file>

<file name="tests/remote-host/smoke.sh">

<violation number="1" location="tests/remote-host/smoke.sh:53">
P2: `cargo run` resolves the crate from the current working directory, but this script never changes to `$ROOT_DIR`. Running it from outside the repo root fails before the smoke test starts. Add `cd "$ROOT_DIR"` after the `ROOT_DIR` assignment.</violation>
</file>

<file name="src/opts.rs">

<violation number="1" location="src/opts.rs:54">
P1: Binding `VSCLI_REMOTE_HOST` to this shared flag makes it override everything. With the variable set in the shell, local `recent` entries are opened as `vscode-remote://ssh-remote+...` with local paths, and remote entries are re-pointed to the env host because `launch.remote_host.or(entry.remote_host)` gives the env value precedence. Plain `vscli open <local-path>` also turns remote, and fails with "Remote path must be absolute" when the default `.` is used. Either drop the env binding here and read the default only in `open`, with the stored history host taking precedence, or document that the variable forces every launch remote.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/opts.rs
pub config: Option<PathBuf>,

/// Open the workspace on a remote SSH host.
#[arg(long, env = "VSCLI_REMOTE_HOST")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Binding VSCLI_REMOTE_HOST to this shared flag makes it override everything. With the variable set in the shell, local recent entries are opened as vscode-remote://ssh-remote+... with local paths, and remote entries are re-pointed to the env host because launch.remote_host.or(entry.remote_host) gives the env value precedence. Plain vscli open <local-path> also turns remote, and fails with "Remote path must be absolute" when the default . is used. Either drop the env binding here and read the default only in open, with the stored history host taking precedence, or document that the variable forces every launch remote.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/opts.rs, line 54:

<comment>Binding `VSCLI_REMOTE_HOST` to this shared flag makes it override everything. With the variable set in the shell, local `recent` entries are opened as `vscode-remote://ssh-remote+...` with local paths, and remote entries are re-pointed to the env host because `launch.remote_host.or(entry.remote_host)` gives the env value precedence. Plain `vscli open <local-path>` also turns remote, and fails with "Remote path must be absolute" when the default `.` is used. Either drop the env binding here and read the default only in `open`, with the stored history host taking precedence, or document that the variable forces every launch remote.</comment>

<file context>
@@ -50,6 +50,10 @@ pub(crate) struct LaunchArgs {
     pub config: Option<PathBuf>,
 
+    /// Open the workspace on a remote SSH host.
+    #[arg(long, env = "VSCLI_REMOTE_HOST")]
+    pub remote_host: Option<String>,
+
</file context>
Suggested change
#[arg(long, env = "VSCLI_REMOTE_HOST")]
#[arg(long)]

Comment thread src/workspace.rs

/// Creates a new remote `Workspace` from the given absolute path and SSH host alias.
pub fn from_remote_path(path: &Path, remote_host: String) -> Result<Workspace> {
if !path.is_absolute() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: is_absolute() is false on Windows for POSIX remote paths like /home/dev/project, so from_remote_path rejects them on Windows clients. Use has_root(), which accepts /-rooted paths on every platform.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/workspace.rs, line 123:

<comment>`is_absolute()` is false on Windows for POSIX remote paths like `/home/dev/project`, so `from_remote_path` rejects them on Windows clients. Use `has_root()`, which accepts `/`-rooted paths on every platform.</comment>

<file context>
@@ -104,16 +106,29 @@ impl Workspace {
+
+    /// Creates a new remote `Workspace` from the given absolute path and SSH host alias.
+    pub fn from_remote_path(path: &Path, remote_host: String) -> Result<Workspace> {
+        if !path.is_absolute() {
+            bail!("Remote path must be absolute: {}", path.display());
+        }
</file context>
Suggested change
if !path.is_absolute() {
if !path.has_root() {

Comment thread src/workspace.rs
.as_deref()
.expect("remote folder URI requires remote host");
let remote_path = remote_workspace_path(&self.path, subfolder);
format!("vscode-remote://ssh-remote+{host}{remote_path}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The remote folder URI interpolates the SSH alias and path without URI-encoding them. Paths containing valid characters such as # or ? are parsed as a fragment or query, so VS Code opens a different path; encode the URI components while preserving path separators.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/workspace.rs, line 223:

<comment>The remote folder URI interpolates the SSH alias and path without URI-encoding them. Paths containing valid characters such as `#` or `?` are parsed as a fragment or query, so VS Code opens a different path; encode the URI components while preserving path separators.</comment>

<file context>
@@ -172,114 +187,73 @@ impl Workspace {
+            .as_deref()
+            .expect("remote folder URI requires remote host");
+        let remote_path = remote_workspace_path(&self.path, subfolder);
+        format!("vscode-remote://ssh-remote+{host}{remote_path}")
+    }
+}
</file context>

done

ssh -F "$SSH_CONFIG" vscli-remote-test 'test -f /home/dev/workspace/.devcontainer/devcontainer.json'
VSCLI_EDITOR_LOG="$EDITOR_LOG" cargo run -- --history-path "$TMP_DIR/history.json" --config-dir "$TMP_DIR/configs" open --remote-host vscli-remote-test /home/dev/workspace --command "$FAKE_EDITOR"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: cargo run resolves the crate from the current working directory, but this script never changes to $ROOT_DIR. Running it from outside the repo root fails before the smoke test starts. Add cd "$ROOT_DIR" after the ROOT_DIR assignment.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/remote-host/smoke.sh, line 53:

<comment>`cargo run` resolves the crate from the current working directory, but this script never changes to `$ROOT_DIR`. Running it from outside the repo root fails before the smoke test starts. Add `cd "$ROOT_DIR"` after the `ROOT_DIR` assignment.</comment>

<file context>
@@ -0,0 +1,55 @@
+done
+
+ssh -F "$SSH_CONFIG" vscli-remote-test 'test -f /home/dev/workspace/.devcontainer/devcontainer.json'
+VSCLI_EDITOR_LOG="$EDITOR_LOG" cargo run -- --history-path "$TMP_DIR/history.json" --config-dir "$TMP_DIR/configs" open --remote-host vscli-remote-test /home/dev/workspace --command "$FAKE_EDITOR"
+
+printf '%s\n' '--folder-uri' 'vscode-remote://ssh-remote+vscli-remote-test/home/dev/workspace' | cmp -s - "$EDITOR_LOG"
</file context>
Suggested change
VSCLI_EDITOR_LOG="$EDITOR_LOG" cargo run -- --history-path "$TMP_DIR/history.json" --config-dir "$TMP_DIR/configs" open --remote-host vscli-remote-test /home/dev/workspace --command "$FAKE_EDITOR"
VSCLI_EDITOR_LOG="$EDITOR_LOG" cargo run --manifest-path "$ROOT_DIR/Cargo.toml" -- --history-path "$TMP_DIR/history.json" --config-dir "$TMP_DIR/configs" open --remote-host vscli-remote-test /home/dev/workspace --command "$FAKE_EDITOR"

Comment thread src/history.rs
use std::ffi::OsString;
use std::path::PathBuf;

fn unique_test_path(name: &str) -> PathBuf {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This helper leaves a new temp directory on every run because nothing deletes it. Use tempfile::TempDir as the other test does, and drop unique_test_path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/history.rs, line 238:

<comment>This helper leaves a new temp directory on every run because nothing deletes it. Use `tempfile::TempDir` as the other test does, and drop `unique_test_path`.</comment>

<file context>
@@ -213,15 +217,130 @@ impl Tracker {
+    use std::ffi::OsString;
+    use std::path::PathBuf;
+
+    fn unique_test_path(name: &str) -> PathBuf {
+        let unique = format!(
+            "vscli-history-{name}-{}-{}",
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 existing issues remain and 4 new issues found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/remote_launch.rs">

<violation number="1" location="tests/remote_launch.rs:56">
P2: The new tests cover only `open`. Add coverage for `recent` with a stored remote entry, including its remote-host fallback and the forced `ForceClassic` normalization, since `open_recent` has separate remote logic.</violation>
</file>

<file name="src/history.rs">

<violation number="1" location="src/history.rs:47">
P3: The `PartialEq` change means the same workspace path with and without `remote_host` is now two entries, but nothing tests that. Add an upsert assertion covering `remote_host: None` versus `Some(..)` for the same path, and a deserialization case for a legacy entry without the field.</violation>
</file>

<file name="src/main.rs">

<violation number="1" location="src/main.rs:217">
P3: When a stored remote entry is reopened from `recent`, these errors mention `--remote-host`, which the user never passed. Reword them for `recent`, or say the entry is a remote workspace.</violation>
</file>

<file name="README.md">

<violation number="1" location="README.md:145">
P3: `--remote-host` is missing from the `open` and `recent` Options blocks above, so the README's command help contradicts this new shared option. Add it to both usage snippets.</violation>
</file>

Requires human review: Auto-approval blocked because this review re-detected 4 unresolved issues already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread tests/remote_launch.rs
}

#[test]
fn remote_launch_rejects_unsupported_options_before_starting_an_editor() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new tests cover only open. Add coverage for recent with a stored remote entry, including its remote-host fallback and the forced ForceClassic normalization, since open_recent has separate remote logic.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/remote_launch.rs, line 56:

<comment>The new tests cover only `open`. Add coverage for `recent` with a stored remote entry, including its remote-host fallback and the forced `ForceClassic` normalization, since `open_recent` has separate remote logic.</comment>

<file context>
@@ -0,0 +1,95 @@
+}
+
+#[test]
+fn remote_launch_rejects_unsupported_options_before_starting_an_editor() {
+    let temp = tempfile::tempdir().unwrap();
+    for (args, message) in [
</file context>

Comment thread src/history.rs
impl PartialEq for Entry {
fn eq(&self, other: &Self) -> bool {
self.workspace_path == other.workspace_path
&& self.remote_host == other.remote_host

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The PartialEq change means the same workspace path with and without remote_host is now two entries, but nothing tests that. Add an upsert assertion covering remote_host: None versus Some(..) for the same path, and a deserialization case for a legacy entry without the field.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/history.rs, line 47:

<comment>The `PartialEq` change means the same workspace path with and without `remote_host` is now two entries, but nothing tests that. Add an upsert assertion covering `remote_host: None` versus `Some(..)` for the same path, and a deserialization case for a legacy entry without the field.</comment>

<file context>
@@ -41,6 +44,7 @@ pub struct Entry {
 impl PartialEq for Entry {
     fn eq(&self, other: &Self) -> bool {
         self.workspace_path == other.workspace_path
+            && self.remote_host == other.remote_host
             && self.config_path == other.config_path
             && self.behavior == other.behavior
</file context>

Comment thread src/main.rs

let workspace = Workspace::from_path(&entry.workspace_path)?;
let remote_host = launch.remote_host.clone().or(entry.remote_host.clone());
ensure_remote_has_no_config(remote_host.as_deref(), launch.config.as_deref())?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: When a stored remote entry is reopened from recent, these errors mention --remote-host, which the user never passed. Reword them for recent, or say the entry is a remote workspace.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/main.rs, line 217:

<comment>When a stored remote entry is reopened from `recent`, these errors mention `--remote-host`, which the user never passed. Reword them for `recent`, or say the entry is a remote workspace.</comment>

<file context>
@@ -157,19 +213,29 @@ impl Application {
 
-        let workspace = Workspace::from_path(&entry.workspace_path)?;
+        let remote_host = launch.remote_host.clone().or(entry.remote_host.clone());
+        ensure_remote_has_no_config(remote_host.as_deref(), launch.config.as_deref())?;
+        let workspace = if let Some(remote_host) = remote_host.clone() {
+            Workspace::from_remote_path(&entry.workspace_path, remote_host)?
</file context>

Comment thread README.md
- `--command`: Specify which editor command to use (e.g., "code", "code-insiders", "cursor")
- `--behavior`: Set the launch behavior ("detect", "force-container", "force-classic")
- `--config`: Override the path to the dev container config file, or pass a config name to resolve from the config directory
- `--remote-host`: Open the given path on a remote SSH host alias configured for VS Code Remote SSH

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: --remote-host is missing from the open and recent Options blocks above, so the README's command help contradicts this new shared option. Add it to both usage snippets.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At README.md, line 145:

<comment>`--remote-host` is missing from the `open` and `recent` Options blocks above, so the README's command help contradicts this new shared option. Add it to both usage snippets.</comment>

<file context>
@@ -142,6 +142,7 @@ Both the `open` and `recent` commands share the same set of launch arguments:
 - `--command`: Specify which editor command to use (e.g., "code", "code-insiders", "cursor")
 - `--behavior`: Set the launch behavior ("detect", "force-container", "force-classic")
 - `--config`: Override the path to the dev container config file, or pass a config name to resolve from the config directory
+- `--remote-host`: Open the given path on a remote SSH host alias configured for VS Code Remote SSH
 - Additional arguments can be passed to the editor executable by specifying them after `--`
 
</file context>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant