Skip to content

Commit 7bee2d3

Browse files
committed
🤖 refactor: check SSH type once in openTerminal method
Store config.type === 'ssh' check in isSSH constant at the start of openTerminal() to avoid multiple type checks throughout. Generated with `cmux`
1 parent 56b0961 commit 7bee2d3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/services/ipcMain.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ export class IpcMain {
13221322
if (terminal === "ghostty") {
13231323
const cmd = "open";
13241324
let args: string[];
1325-
if (config.type === "ssh" && sshArgs) {
1325+
if (isSSH && sshArgs) {
13261326
// Ghostty: Use --command flag to run SSH
13271327
// Build the full SSH command as a single string
13281328
const sshCommand = ["ssh", ...sshArgs].join(" ");
@@ -1340,9 +1340,9 @@ export class IpcMain {
13401340
child.unref();
13411341
} else {
13421342
// Terminal.app
1343-
const cmd = config.type === "ssh" ? "osascript" : "open";
1343+
const cmd = isSSH ? "osascript" : "open";
13441344
let args: string[];
1345-
if (config.type === "ssh" && sshArgs) {
1345+
if (isSSH && sshArgs) {
13461346
// Terminal.app: Use osascript with proper AppleScript structure
13471347
// Properly escape single quotes in args before wrapping in quotes
13481348
const sshCommand = `ssh ${sshArgs
@@ -1374,7 +1374,7 @@ export class IpcMain {
13741374
// Windows
13751375
const cmd = "cmd";
13761376
let args: string[];
1377-
if (config.type === "ssh" && sshArgs) {
1377+
if (isSSH && sshArgs) {
13781378
// Windows - use cmd to start ssh
13791379
args = ["/c", "start", "cmd", "/K", "ssh", ...sshArgs];
13801380
} else {
@@ -1392,7 +1392,7 @@ export class IpcMain {
13921392
// Linux - try terminal emulators in order of preference
13931393
let terminals: Array<{ cmd: string; args: string[]; cwd?: string }>;
13941394

1395-
if (config.type === "ssh" && sshArgs) {
1395+
if (isSSH && sshArgs) {
13961396
// x-terminal-emulator is checked first as it respects user's system-wide preference
13971397
terminals = [
13981398
{ cmd: "x-terminal-emulator", args: ["-e", "ssh", ...sshArgs] },

0 commit comments

Comments
 (0)