@@ -10,6 +10,30 @@ export interface SettingOverride {
1010 value : unknown ;
1111}
1212
13+ interface RecommendedSetting {
14+ readonly value : number | null ;
15+ readonly label : string ;
16+ }
17+
18+ export const RECOMMENDED_SSH_SETTINGS = {
19+ "remote.SSH.connectTimeout" : {
20+ value : 1800 ,
21+ label : "Connect Timeout: 1800s (30 min)" ,
22+ } ,
23+ "remote.SSH.reconnectionGraceTime" : {
24+ value : 28800 ,
25+ label : "Reconnection Grace Time: 28800s (8 hours)" ,
26+ } ,
27+ "remote.SSH.serverShutdownTimeout" : {
28+ value : 28800 ,
29+ label : "Server Shutdown Timeout: 28800s (8 hours)" ,
30+ } ,
31+ "remote.SSH.maxReconnectionAttempts" : {
32+ value : null ,
33+ label : "Max Reconnection Attempts: max allowed" ,
34+ } ,
35+ } as const satisfies Record < string , RecommendedSetting > ;
36+
1337/**
1438 * Build the list of VS Code setting overrides needed for a remote SSH
1539 * connection to a Coder workspace.
@@ -21,7 +45,7 @@ export function buildSshOverrides(
2145) : SettingOverride [ ] {
2246 const overrides : SettingOverride [ ] = [ ] ;
2347
24- // Bypass the platform prompt by setting the remote platform for this host.
48+ // Set the remote platform for this host to bypass the platform prompt .
2549 const remotePlatforms = config . get < Record < string , string > > (
2650 "remote.SSH.remotePlatform" ,
2751 { } ,
@@ -33,9 +57,9 @@ export function buildSshOverrides(
3357 } ) ;
3458 }
3559
36- // VS Code's default connect timeout of 15s is too short when waiting for
37- // startup scripts. Enforce a minimum.
38- const minConnTimeout = 1800 ;
60+ // Default 15s is too short for startup scripts; enforce a minimum.
61+ const minConnTimeout =
62+ RECOMMENDED_SSH_SETTINGS [ "remote.SSH.connectTimeout" ] . value ;
3963 const connTimeout = config . get < number > ( "remote.SSH.connectTimeout" ) ;
4064 if ( ! connTimeout || connTimeout < minConnTimeout ) {
4165 overrides . push ( {
@@ -44,14 +68,16 @@ export function buildSshOverrides(
4468 } ) ;
4569 }
4670
47- // VS Code's default reconnection grace time (ProtocolConstants.ReconnectionGraceTime)
48- // is 3 hours (10800s). Coder workspaces commonly go offline overnight, so we
49- // bump to 8 hours. See https://github.com/microsoft/vscode/blob/main/src/vs/base/parts/ipc/common/ipc.net.ts
50- if ( config . get < number > ( "remote.SSH.reconnectionGraceTime" ) === undefined ) {
51- overrides . push ( {
52- key : "remote.SSH.reconnectionGraceTime" ,
53- value : 28800 , // 8 hours in seconds
54- } ) ;
71+ // Set recommended defaults for settings the user hasn't configured.
72+ const setIfUndefined = [
73+ "remote.SSH.reconnectionGraceTime" ,
74+ "remote.SSH.serverShutdownTimeout" ,
75+ "remote.SSH.maxReconnectionAttempts" ,
76+ ] as const ;
77+ for ( const key of setIfUndefined ) {
78+ if ( config . get ( key ) === undefined ) {
79+ overrides . push ( { key, value : RECOMMENDED_SSH_SETTINGS [ key ] . value } ) ;
80+ }
5581 }
5682
5783 return overrides ;
0 commit comments