From fd0abeeeeee96c514f489f080bc618960cab8b70 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 24 Jun 2025 00:52:27 +0200 Subject: [PATCH] really ensures terminals close even for claude --- web/src/server/pty/process-utils.ts | 48 ++++++++++------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/web/src/server/pty/process-utils.ts b/web/src/server/pty/process-utils.ts index fe2f17dc..3e9b111e 100644 --- a/web/src/server/pty/process-utils.ts +++ b/web/src/server/pty/process-utils.ts @@ -233,21 +233,14 @@ export class ProcessUtils { // Windows shells have different syntax if (userShell.includes('bash')) { // Git Bash on Windows: Use Unix-style syntax - if (isCommand) { - // Non-interactive command execution - return { - command: userShell, - args: ['-c', command.join(' ')], - useShell: true, - }; - } else { - // Interactive shell session - return { - command: userShell, - args: ['-i', '-c', command.join(' ')], - useShell: true, - }; - } + // Always use -i to ensure aliases work, but append '; exit' for commands + const commandStr = isCommand ? `${command.join(' ')}; exit` : command.join(' '); + + return { + command: userShell, + args: ['-i', '-c', commandStr], + useShell: true, + }; } else if (userShell.includes('pwsh') || userShell.includes('powershell')) { // PowerShell: Use -Command for execution // Note: PowerShell aliases work differently than Unix aliases @@ -266,22 +259,15 @@ export class ProcessUtils { }; } } else { - // Unix shells: Choose execution mode based on command type - if (isCommand) { - // Non-interactive command execution: shell will exit after completion - return { - command: userShell, - args: ['-c', command.join(' ')], - useShell: true, - }; - } else { - // Interactive shell session: use -i for alias support - return { - command: userShell, - args: ['-i', '-c', command.join(' ')], - useShell: true, - }; - } + // Unix shells: Always use -i to ensure aliases work + // But append '; exit' for non-interactive commands to ensure shell exits + const commandStr = isCommand ? `${command.join(' ')}; exit` : command.join(' '); + + return { + command: userShell, + args: ['-i', '-c', commandStr], + useShell: true, + }; } }