From 2216ee79aaafcf346008be6681fc7bcd67ff8352 Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Sat, 14 Mar 2026 01:32:48 -0400 Subject: [PATCH] fix: close WebSocket and auto-remove session on SSH connect failure When SSH connection fails, close the WebSocket immediately and auto-remove the pending session after 3 seconds so the user sees the error message before the panel clears. Prevents stuck sessions. Co-Authored-By: Claude Opus 4.6 --- frontend/composables/useTerminal.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/composables/useTerminal.ts b/frontend/composables/useTerminal.ts index c3ad837..8ad3358 100644 --- a/frontend/composables/useTerminal.ts +++ b/frontend/composables/useTerminal.ts @@ -84,12 +84,23 @@ export function useTerminal() { break case 'error': term.write(`\r\n\x1b[31mError: ${msg.message}\x1b[0m\r\n`) + term.write('\x1b[33mPress any key to close this session.\x1b[0m\r\n') + // Mark this connection as failed so onData closes it + ws?.close() break } } ws.onclose = () => { term.write('\r\n\x1b[33mConnection closed.\x1b[0m\r\n') + // Clean up pending session if connection never succeeded + if (pendingSessionId.startsWith('pending-')) { + const session = sessions.sessions.find(s => s.id === pendingSessionId) + if (session) { + // Session was never replaced with a real one — remove after short delay so user sees the error + setTimeout(() => sessions.removeSession(pendingSessionId), 3000) + } + } } // Terminal input → WebSocket