diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.ts index 8184503691..136816b112 100644 --- a/packages/cli/src/ui/hooks/shellCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/shellCommandProcessor.ts @@ -350,6 +350,9 @@ export const useShellCommandProcessor = ( switch (event.type) { case 'raw_data': + // We rely on 'file_data' for the clean output stream. + break; + case 'file_data': if (!isBinaryStream) { outputStream.write(event.chunk); totalBytesWritten += Buffer.byteLength(event.chunk); @@ -555,19 +558,15 @@ export const useShellCommandProcessor = ( if (!outputStream.closed) { outputStream.destroy(); } - if (pwdFilePath && fs.existsSync(pwdFilePath)) { - fs.unlinkSync(pwdFilePath); + if (pwdFilePath) { + fs.promises.unlink(pwdFilePath).catch(() => {}); } dispatch({ type: 'SET_ACTIVE_PTY', pid: null }); setShellInputFocused(false); - if (!fullOutputReturned && fs.existsSync(outputFilePath)) { - try { - fs.unlinkSync(outputFilePath); - } catch { - // Ignore errors during unlink - } + if (!fullOutputReturned) { + fs.promises.unlink(outputFilePath).catch(() => {}); } } };