Skip to content

Commit a7afdd6

Browse files
committed
Remove testmode flag in favor of checking existence of remote ssh extension and warning user
1 parent d9b543a commit a7afdd6

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/extension.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
2121
//
2222
// Cursor and VSCode are covered by ms remote, and the only other is windsurf for now
2323
// Means that vscodium is not supported by this for now
24-
const isTestMode =
25-
process.env.NODE_ENV === "test" ||
26-
ctx.extensionMode === vscode.ExtensionMode.Test;
2724

2825
const remoteSSHExtension =
2926
vscode.extensions.getExtension("jeanp413.open-remote-ssh") ||
@@ -34,13 +31,11 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
3431
let vscodeProposed: typeof vscode = vscode;
3532

3633
if (!remoteSSHExtension) {
37-
if (!isTestMode) {
38-
vscode.window.showErrorMessage(
39-
"Remote SSH extension not found, cannot activate Coder extension",
40-
);
41-
throw new Error("Remote SSH extension not found");
42-
}
43-
// In test mode, use regular vscode API
34+
vscode.window.showErrorMessage(
35+
"Remote SSH extension not found, this may not work as expected.\n" +
36+
// NB should we link to documentation or marketplace?
37+
"Please install your choice of Remote SSH extension from the VS Code Marketplace.",
38+
);
4439
} else {
4540
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4641
vscodeProposed = (module as any)._load(
@@ -289,7 +284,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
289284
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
290285
// in package.json we're able to perform actions before the authority is
291286
// resolved by the remote SSH extension.
292-
if (!isTestMode && vscodeProposed.env.remoteAuthority) {
287+
//
288+
// In addition, if we don't have a remote SSH extension, we skip this
289+
// activation event. This may allow the user to install the extension
290+
// after the Coder extension is installed, instead of throwing a fatal error
291+
// (this would require the user to uninstall the Coder extension and
292+
// reinstall after installing the remote SSH extension, which is annoying)
293+
if (remoteSSHExtension && vscodeProposed.env.remoteAuthority) {
293294
const remote = new Remote(
294295
vscodeProposed,
295296
storage,

0 commit comments

Comments
 (0)