From aba492ff43c3b880cd4996d32d1ae34cb04e4829 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 4 May 2025 16:51:19 +0800 Subject: [PATCH] fix: reset terminal on connection and improve error handling --- app/src/utils/terminal.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/utils/terminal.ts b/app/src/utils/terminal.ts index 4a937c9..a32ff1b 100644 --- a/app/src/utils/terminal.ts +++ b/app/src/utils/terminal.ts @@ -37,6 +37,7 @@ class SocketTerminal { }) this.socket.onopen = () => { console.log('Connected to terminal') + this.term.reset() this.term.write('\r\n\x1B[1;32mConnected to terminal\x1B[0m\r\n') resolve() } @@ -44,7 +45,6 @@ class SocketTerminal { this.socket.onclose = () => { console.log('Disconnected from terminal') this.term.write('\r\n\x1B[1;31mDisconnected from terminal\x1B[0m\r\n') - reject(new Error('Disconnected from terminal')) } this.socket.onerror = (error) => { @@ -52,7 +52,6 @@ class SocketTerminal { this.term.write( `\r\n\x1B[1;31mWebSocket error: ${'message' in error ? error.message : ''}\x1B[0m\r\n` ) - reject(error) } this.socket.onmessage = (event) => { console.log('Received message from terminal')