Skip to content

Commit 0a1e51f

Browse files
committed
Remove the coder.disableAutostart setting and enhance documentation
1 parent 93f4d64 commit 0a1e51f

File tree

5 files changed

+16
-111
lines changed

5 files changed

+16
-111
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- Support for paths that begin with a tilde (`~`).
8+
- Support for `coder ssh` flag configurations through the `coder.sshFlags` setting.
89

910
### Fixed
1011

package.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,15 @@
120120
"type": "boolean",
121121
"default": false
122122
},
123-
"coder.disableAutostart": {
124-
"markdownDescription": "Disable starting the workspace automatically when connecting via SSH.",
125-
"type": "string",
126-
"enum": [
127-
"auto",
128-
"always",
129-
"never"
130-
],
131-
"markdownEnumDescriptions": [
132-
"Disables autostart on macOS only (recommended to avoid sleep/wake issues)",
133-
"Disables autostart on all platforms",
134-
"Keeps autostart enabled on all platforms"
135-
],
136-
"default": "auto"
137-
},
138123
"coder.sshFlags": {
139-
"markdownDescription": "Additional flags to pass to the `coder ssh` command when establishing SSH connections. Enter each flag as a separate array item; values are passed verbatim and in order. See the [CLI ssh reference](https://coder.com/docs/reference/cli/ssh) for available flags.\n\nNote: `--network-info-dir` and `--ssh-host-prefix` are ignored (managed internally). `--disable-autostart` and `--log-dir`/`-l` can be specified here, but prefer using `#coder.disableAutostart#` and `#coder.proxyLogDirectory#` settings respectively.",
124+
"markdownDescription": "Additional flags to pass to the `coder ssh` command when establishing SSH connections. Enter each flag as a separate array item; values are passed verbatim and in order. See the [CLI ssh reference](https://coder.com/docs/reference/cli/ssh) for available flags.\n\nNote: `--network-info-dir` and `--ssh-host-prefix` are ignored (managed internally). Prefer `#coder.proxyLogDirectory#` over `--log-dir`/`-l` for full functionality.",
140125
"type": "array",
141126
"items": {
142127
"type": "string"
143-
}
128+
},
129+
"default": [
130+
"--disable-autostart"
131+
]
144132
},
145133
"coder.globalFlags": {
146134
"markdownDescription": "Global flags to pass to every Coder CLI invocation. Enter each flag as a separate array item; values are passed verbatim and in order. Do **not** include the `coder` command itself. See the [CLI reference](https://coder.com/docs/reference/cli) for available global flags.\n\nNote that for `--header-command`, precedence is: `#coder.headerCommand#` setting, then `CODER_HEADER_COMMAND` environment variable, then the value specified here. The `--global-config` flag is explicitly ignored.",

src/cliConfig.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,6 @@ export function getGlobalFlags(
2020
];
2121
}
2222

23-
type DisableAutostartSetting = "auto" | "always" | "never";
24-
25-
/**
26-
* Determines whether autostart should be disabled based on the setting and platform.
27-
* - "always": disable on all platforms
28-
* - "never": never disable
29-
* - "auto": disable only on macOS (due to sleep/wake issues)
30-
*/
31-
export function shouldDisableAutostart(
32-
configs: WorkspaceConfiguration,
33-
platform: NodeJS.Platform,
34-
): boolean {
35-
const setting = configs.get<DisableAutostartSetting>(
36-
"coder.disableAutostart",
37-
"auto",
38-
);
39-
return setting === "always" || (setting === "auto" && platform === "darwin");
40-
}
41-
4223
/**
4324
* Returns SSH flags for the `coder ssh` command from user configuration.
4425
*/

src/remote/remote.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ import {
2020
import { extractAgents } from "../api/api-helper";
2121
import { CoderApi } from "../api/coderApi";
2222
import { needToken } from "../api/utils";
23-
import {
24-
getGlobalFlags,
25-
getSshFlags,
26-
shouldDisableAutostart,
27-
} from "../cliConfig";
23+
import { getGlobalFlags, getSshFlags } from "../cliConfig";
2824
import { type Commands } from "../commands";
2925
import { type CliManager } from "../core/cliManager";
3026
import * as cliUtils from "../core/cliUtils";
@@ -560,28 +556,20 @@ export class Remote {
560556
/**
561557
* Return the --log-dir argument value for the ProxyCommand. It may be an
562558
* empty string if the setting is not set or the cli does not support it.
559+
*
560+
* Value defined in the "coder.sshFlags" setting is not considered.
563561
*/
564562
private getLogDir(featureSet: FeatureSet): string {
565563
if (!featureSet.proxyLogDirectory) {
566564
return "";
567565
}
568-
569-
const vscodeConfig = vscode.workspace.getConfiguration();
570-
const proxyLogDir = vscodeConfig
571-
.get<string>("coder.proxyLogDirectory")
572-
?.trim();
573-
if (proxyLogDir) {
574-
return expandPath(proxyLogDir);
575-
}
576-
577-
const sshFlags = getSshFlags(vscodeConfig);
578-
const logDirFlagIndex = sshFlags.findIndex(
579-
(option) => option === "-l" || option === "--log-dir",
566+
// If the proxyLogDirectory is not set in the extension settings we don't send one.
567+
return expandPath(
568+
String(
569+
vscode.workspace.getConfiguration().get("coder.proxyLogDirectory") ??
570+
"",
571+
).trim(),
580572
);
581-
if (logDirFlagIndex !== -1 && logDirFlagIndex + 1 < sshFlags.length) {
582-
return expandPath(sshFlags[logDirFlagIndex + 1].trim());
583-
}
584-
return "";
585573
}
586574

587575
/**
@@ -609,20 +597,13 @@ export class Remote {
609597
// User SSH flags are included first; internally-managed flags
610598
// are appended last so they take precedence.
611599
const userSSHFlags = getSshFlags(vscodeConfig);
612-
const disableAutostart = shouldDisableAutostart(
613-
vscodeConfig,
614-
process.platform,
615-
)
616-
? ["--disable-autostart"]
617-
: [];
618600
// Make sure to update the `coder.sshFlags` description if we add more internal flags here!
619601
const internalFlags = [
620602
"--stdio",
621603
"--usage-app=vscode",
622604
"--network-info-dir",
623605
escapeCommandArg(this.pathResolver.getNetworkInfoPath()),
624606
...logArgs,
625-
...disableAutostart,
626607
"--ssh-host-prefix",
627608
hostPrefix,
628609
"%h",

test/unit/cliConfig.test.ts

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { it, expect, describe } from "vitest";
22
import { type WorkspaceConfiguration } from "vscode";
33

4-
import {
5-
getGlobalFlags,
6-
getSshFlags,
7-
shouldDisableAutostart,
8-
} from "@/cliConfig";
4+
import { getGlobalFlags, getSshFlags } from "@/cliConfig";
95

106
import { isWindows } from "../utils/platform";
117

@@ -86,48 +82,6 @@ describe("cliConfig", () => {
8682
});
8783
});
8884

89-
describe("shouldDisableAutostart", () => {
90-
const mockConfig = (setting: string) =>
91-
({
92-
get: (key: string) =>
93-
key === "coder.disableAutostart" ? setting : undefined,
94-
}) as unknown as WorkspaceConfiguration;
95-
96-
it("returns true when setting is 'always' regardless of platform", () => {
97-
const config = mockConfig("always");
98-
expect(shouldDisableAutostart(config, "darwin")).toBe(true);
99-
expect(shouldDisableAutostart(config, "linux")).toBe(true);
100-
expect(shouldDisableAutostart(config, "win32")).toBe(true);
101-
});
102-
103-
it("returns false when setting is 'never' regardless of platform", () => {
104-
const config = mockConfig("never");
105-
expect(shouldDisableAutostart(config, "darwin")).toBe(false);
106-
expect(shouldDisableAutostart(config, "linux")).toBe(false);
107-
expect(shouldDisableAutostart(config, "win32")).toBe(false);
108-
});
109-
110-
it("returns true when setting is 'auto' and platform is darwin", () => {
111-
const config = mockConfig("auto");
112-
expect(shouldDisableAutostart(config, "darwin")).toBe(true);
113-
});
114-
115-
it("returns false when setting is 'auto' and platform is not darwin", () => {
116-
const config = mockConfig("auto");
117-
expect(shouldDisableAutostart(config, "linux")).toBe(false);
118-
expect(shouldDisableAutostart(config, "win32")).toBe(false);
119-
expect(shouldDisableAutostart(config, "freebsd")).toBe(false);
120-
});
121-
122-
it("defaults to 'auto' when setting is not configured", () => {
123-
const config = {
124-
get: (_key: string, defaultValue: unknown) => defaultValue,
125-
} as unknown as WorkspaceConfiguration;
126-
expect(shouldDisableAutostart(config, "darwin")).toBe(true);
127-
expect(shouldDisableAutostart(config, "linux")).toBe(false);
128-
});
129-
});
130-
13185
describe("getSshFlags", () => {
13286
it("returns empty array when no SSH flags configured", () => {
13387
const config = {

0 commit comments

Comments
 (0)