Skip to content

open remote vscode windows with --new-window - #3155

Open
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/remote-editor-new-window
Open

open remote vscode windows with --new-window#3155
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/remote-editor-new-window

Conversation

@thedhruvhegde

@thedhruvhegde thedhruvhegde commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

summary

opening a second remote workspace used vscode:// which reuses the existing window. the cli now prefers code --new-window --folder-uri vscode-remote://... (and cursor/codium equivalents), with the url as fallback.

local vscode/cursor/codium launch commands also pass -n / --new-window.

closes #2904

test plan

  • open two remote workspaces in vs code and get two windows
  • local "open in vs code" also opens a new window
  • pnpm --dir apps/emdash-desktop exec vitest run --project node src/main/host/remoteOpenIn.test.ts src/core/primitives/open-in-apps/api/open-in-apps.test.ts

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes local and remote VS Code-family launches to request a fresh editor window.

  • Adds -n or --new-window to local Cursor, VS Code, and VSCodium commands.
  • Prefers each editor’s CLI with --new-window --folder-uri for remote workspaces and retains custom URLs as fallback.
  • Adds helpers and limited unit assertions for CLI selection and remote folder URI construction.
  • The VS Code CLI selection does not account for supported Insiders-only installations, and the orchestration and platform command matrix remain largely untested.

Confidence Score: 3/5

The PR is not yet safe to merge because remote new-window launching remains broken for supported VS Code Insiders-only installations.

The preferred remote path always invokes code, while installation detection also accepts code-insiders and the Insiders bundle; this causes the launch to fall back to the old URL behavior for those users. The tests also omit most of the changed launch matrix and service orchestration.

Files Needing Attention: apps/emdash-desktop/src/main/host/remoteOpenIn.ts, apps/emdash-desktop/src/main/host/remoteOpenIn.test.ts, apps/emdash-desktop/src/core/primitives/open-in-apps/api/open-in-apps.test.ts

Important Files Changed

Filename Overview
apps/emdash-desktop/src/main/core/app/service.ts Adds preferred remote editor CLI execution with explicit new-window arguments and URL fallback.
apps/emdash-desktop/src/main/host/remoteOpenIn.ts Adds shared remote folder URI and executable mapping helpers, but maps supported VS Code Insiders installations to the stable-only executable.
apps/emdash-desktop/src/core/primitives/open-in-apps/api/open-in-apps.ts Adds new-window flags to local launch commands for three VS Code-family editors on supported platforms.
apps/emdash-desktop/src/main/host/remoteOpenIn.test.ts Tests the VS Code mapping and URI serialization but not editor variants or service-level launch behavior.
apps/emdash-desktop/src/core/primitives/open-in-apps/api/open-in-apps.test.ts Adds one macOS VS Code assertion while leaving most changed platform/editor commands uncovered.

Sequence Diagram

sequenceDiagram
  participant U as User
  participant A as AppService
  participant C as Editor CLI
  participant E as Editor URL handler
  U->>A: Open remote workspace
  A->>C: --new-window --folder-uri URI
  alt CLI succeeds
    C-->>U: New remote editor window
  else CLI unavailable or fails
    A->>E: Open vscode-family URL
    E-->>U: Editor-defined window reuse behavior
  end
Loading
Prompt To Fix All With AI
### Issue 1
apps/emdash-desktop/src/main/host/remoteOpenIn.ts:66
**Insiders Uses Wrong CLI**

The `vscode` app is considered installed when either `code-insiders` or the VS Code Insiders bundle is present, but this function always selects `code`. On an Insiders-only installation, the preferred CLI launch fails and falls back to the existing `vscode://` URL, which can reuse the current window and leaves the remote multi-workspace bug unfixed for a supported installation.

### Issue 2
apps/emdash-desktop/src/main/host/remoteOpenIn.test.ts:49-55
**Launch Paths Lack Coverage**

These tests cover only the VS Code CLI mapping and one shared folder URI. They do not exercise the service-level CLI invocation and fallback or the Cursor and VSCodium mappings. Likewise, `open-in-apps.test.ts:115` checks only one macOS VS Code command even though this PR changes three editors across three platforms. As a result, the tests would miss mistakes such as selecting the wrong executable or omitting a new-window flag from most changed configurations.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "open remote vscode-family editors in a n..." | Re-trigger Greptile

export function buildRemoteEditorCli(scheme: Exclude<RemoteEditorScheme, 'zed'>): string {
if (scheme === 'vscodium') return 'codium';
if (scheme === 'cursor') return 'cursor';
return 'code';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Insiders Uses Wrong CLI

The vscode app is considered installed when either code-insiders or the VS Code Insiders bundle is present, but this function always selects code. On an Insiders-only installation, the preferred CLI launch fails and falls back to the existing vscode:// URL, which can reuse the current window and leaves the remote multi-workspace bug unfixed for a supported installation.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/main/host/remoteOpenIn.ts
Line: 66

Comment:
**Insiders Uses Wrong CLI**

The `vscode` app is considered installed when either `code-insiders` or the VS Code Insiders bundle is present, but this function always selects `code`. On an Insiders-only installation, the preferred CLI launch fails and falls back to the existing `vscode://` URL, which can reuse the current window and leaves the remote multi-workspace bug unfixed for a supported installation.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +49 to +55
describe('buildRemoteEditorFolderUri', () => {
it('builds a vscode-remote folder uri for a new window', () => {
expect(buildRemoteEditorCli('vscode')).toBe('code');
expect(buildRemoteEditorFolderUri('localhost', 'dev', '/repo')).toBe(
'vscode-remote://ssh-remote+7b22686f73744e616d65223a226c6f63616c686f7374222c2275736572223a22646576227d/repo'
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Launch Paths Lack Coverage

These tests cover only the VS Code CLI mapping and one shared folder URI. They do not exercise the service-level CLI invocation and fallback or the Cursor and VSCodium mappings. Likewise, open-in-apps.test.ts:115 checks only one macOS VS Code command even though this PR changes three editors across three platforms. As a result, the tests would miss mistakes such as selecting the wrong executable or omitting a new-window flag from most changed configurations.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/main/host/remoteOpenIn.test.ts
Line: 49-55

Comment:
**Launch Paths Lack Coverage**

These tests cover only the VS Code CLI mapping and one shared folder URI. They do not exercise the service-level CLI invocation and fallback or the Cursor and VSCodium mappings. Likewise, `open-in-apps.test.ts:115` checks only one macOS VS Code command even though this PR changes three editors across three platforms. As a result, the tests would miss mistakes such as selecting the wrong executable or omitting a new-window flag from most changed configurations.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

[bug]: Opening a second remote workspace in VS Code closes the first window (only one at a time)

1 participant