@@ -1292,9 +1292,11 @@ export class IpcMain {
12921292 remotePath : string ;
12931293 }
12941294 ) : Promise < void > {
1295+ const isSSH = config . type === "ssh" ;
1296+
12951297 // Build SSH args if needed
12961298 let sshArgs : string [ ] | null = null ;
1297- if ( config . type === "ssh" ) {
1299+ if ( isSSH ) {
12981300 sshArgs = [ ] ;
12991301 // Add port if specified
13001302 if ( config . sshConfig . port ) {
@@ -1314,15 +1316,15 @@ export class IpcMain {
13141316 sshArgs . push ( `cd '${ config . remotePath . replace ( / ' / g, "'\\''" ) } ' && exec $SHELL` ) ;
13151317 }
13161318
1317- const logPrefix = config . type === "ssh" ? "SSH terminal" : "terminal" ;
1319+ const logPrefix = isSSH ? "SSH terminal" : "terminal" ;
13181320
13191321 if ( process . platform === "darwin" ) {
13201322 // macOS - try Ghostty first, fallback to Terminal.app
13211323 const terminal = await this . findAvailableCommand ( [ "ghostty" , "terminal" ] ) ;
13221324 if ( terminal === "ghostty" ) {
13231325 const cmd = "open" ;
13241326 let args : string [ ] ;
1325- if ( config . type === "ssh" && sshArgs ) {
1327+ if ( isSSH && sshArgs ) {
13261328 // Ghostty: Use --command flag to run SSH
13271329 // Build the full SSH command as a single string
13281330 const sshCommand = [ "ssh" , ...sshArgs ] . join ( " " ) ;
@@ -1340,9 +1342,9 @@ export class IpcMain {
13401342 child . unref ( ) ;
13411343 } else {
13421344 // Terminal.app
1343- const cmd = config . type === "ssh" ? "osascript" : "open" ;
1345+ const cmd = isSSH ? "osascript" : "open" ;
13441346 let args : string [ ] ;
1345- if ( config . type === "ssh" && sshArgs ) {
1347+ if ( isSSH && sshArgs ) {
13461348 // Terminal.app: Use osascript with proper AppleScript structure
13471349 // Properly escape single quotes in args before wrapping in quotes
13481350 const sshCommand = `ssh ${ sshArgs
@@ -1374,7 +1376,7 @@ export class IpcMain {
13741376 // Windows
13751377 const cmd = "cmd" ;
13761378 let args : string [ ] ;
1377- if ( config . type === "ssh" && sshArgs ) {
1379+ if ( isSSH && sshArgs ) {
13781380 // Windows - use cmd to start ssh
13791381 args = [ "/c" , "start" , "cmd" , "/K" , "ssh" , ...sshArgs ] ;
13801382 } else {
@@ -1392,7 +1394,7 @@ export class IpcMain {
13921394 // Linux - try terminal emulators in order of preference
13931395 let terminals : Array < { cmd : string ; args : string [ ] ; cwd ?: string } > ;
13941396
1395- if ( config . type === "ssh" && sshArgs ) {
1397+ if ( isSSH && sshArgs ) {
13961398 // x-terminal-emulator is checked first as it respects user's system-wide preference
13971399 terminals = [
13981400 { cmd : "x-terminal-emulator" , args : [ "-e" , "ssh" , ...sshArgs ] } ,
0 commit comments