Skip to content

Commit 340f560

Browse files
committed
Review comments
1 parent 4b6af7f commit 340f560

File tree

8 files changed

+34
-11
lines changed

8 files changed

+34
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Added
66

7+
- Automatically set `reconnectionGraceTime`, `serverShutdownTimeout`, and `maxReconnectionAttempts`
8+
on first connection to prevent disconnects during overnight workspace sleep.
9+
- New **Coder: Apply Recommended SSH Settings** command to overwrite all recommended SSH settings at once.
710
- Proxy log directory now defaults to the extension's global storage when `coder.proxyLogDirectory`
811
is not set, so SSH connection logs are always captured without manual configuration. Also respects
912
the `CODER_SSH_LOG_DIR` environment variable as a fallback.

src/commands.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,20 @@ export class Commands {
337337
key,
338338
value: setting.value,
339339
}));
340-
await applySettingOverrides(
340+
const ok = await applySettingOverrides(
341341
this.pathResolver.getUserSettingsPath(),
342342
overrides,
343343
this.logger,
344344
);
345-
if (this.remoteWorkspaceClient) {
345+
if (!ok) {
346+
const action = await vscode.window.showErrorMessage(
347+
"Failed to write SSH settings. Check the Coder output for details.",
348+
"Show Output",
349+
);
350+
if (action === "Show Output") {
351+
this.logger.show();
352+
}
353+
} else if (this.remoteWorkspaceClient) {
346354
const action = await vscode.window.showInformationMessage(
347355
"Applied recommended SSH settings. Reload the window for changes to take effect.",
348356
"Reload Window",

src/logging/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export interface Logger {
44
info(message: string, ...args: unknown[]): void;
55
warn(message: string, ...args: unknown[]): void;
66
error(message: string, ...args: unknown[]): void;
7+
show(): void;
78
}

src/remote/remote.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,16 @@ export class Remote {
465465
parts.sshHost,
466466
agent.operating_system,
467467
);
468-
await applySettingOverrides(
469-
this.pathResolver.getUserSettingsPath(),
470-
overrides,
471-
this.logger,
472-
);
468+
if (overrides.length > 0) {
469+
const ok = await applySettingOverrides(
470+
this.pathResolver.getUserSettingsPath(),
471+
overrides,
472+
this.logger,
473+
);
474+
if (ok) {
475+
this.logger.info("Settings modified successfully");
476+
}
477+
}
473478

474479
const logDir = this.getLogDir(featureSet);
475480

src/remote/userSettings.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ function recommended(
2929
return { value, label: `${shortName}: ${humanized}` };
3030
}
3131

32-
/** Applied by the "Apply Recommended SSH Settings" command. */
32+
/**
33+
* Applied by the "Apply Recommended SSH Settings" command.
34+
* These are more aggressive (24h) than AUTO_SETUP_DEFAULTS (8h) because the
35+
* user is explicitly opting in via the command palette.
36+
*/
3337
export const RECOMMENDED_SSH_SETTINGS = {
3438
"remote.SSH.connectTimeout": recommended("Connect Timeout", 1800),
3539
"remote.SSH.reconnectionGraceTime": recommended(
@@ -109,7 +113,7 @@ export async function applySettingOverrides(
109113
logger: Logger,
110114
): Promise<boolean> {
111115
if (overrides.length === 0) {
112-
return false;
116+
return true;
113117
}
114118

115119
let settingsContent = "{}";

test/mocks/testHelpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ export function createMockLogger(): Logger {
391391
info: vi.fn(),
392392
warn: vi.fn(),
393393
error: vi.fn(),
394+
show: vi.fn(),
394395
};
395396
}
396397

test/unit/error/serverCertificateError.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe("Certificate errors", () => {
4040
info: throwingLog,
4141
warn: throwingLog,
4242
error: throwingLog,
43+
show: () => {},
4344
};
4445

4546
const disposers: Array<() => void> = [];

test/unit/remote/userSettings.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ describe("applySettingOverrides", () => {
160160
return JSON.parse(raw) as Record<string, unknown>;
161161
}
162162

163-
it("returns false when overrides list is empty", async () => {
164-
expect(await applySettingOverrides(settingsPath, [], logger)).toBe(false);
163+
it("returns true when overrides list is empty", async () => {
164+
expect(await applySettingOverrides(settingsPath, [], logger)).toBe(true);
165165
});
166166

167167
it("creates file and applies overrides when file does not exist", async () => {

0 commit comments

Comments
 (0)