From d834a64d622bece4a01606042a648c43e237ac07 Mon Sep 17 00:00:00 2001 From: uroma Date: Mon, 19 Jan 2026 18:55:59 +0000 Subject: [PATCH] fix: backend sends ready message when WebSocket connects Critical fix: The frontend was waiting for a 'ready' message that the backend never sent, causing commands to timeout. Root Cause: Frontend connectTerminal() waits for 'ready' message from backend before resolving, but backend never sent this message. Result: Frontend timed out after 5 seconds waiting for ready state, and commands were never sent. Fix: Send 'ready' message immediately when WebSocket connection is established. This signals to frontend that PTY is initialized and ready to receive input. Flow Now: 1. Frontend creates terminal UI 2. Frontend initializes xterm.js 3. Frontend connects WebSocket 4. Backend receives connection, sends 'ready' message 5. Frontend receives 'ready', sets ready=true, resolves promise 6. Frontend sends claude --dangerously-skip-permissions command 7. Command executes successfully Resolves: "still getting empty terminal" Co-Authored-By: Claude Sonnet 4.5 --- services/terminal-service.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/terminal-service.js b/services/terminal-service.js index 014f7efb..dfd92ed6 100644 --- a/services/terminal-service.js +++ b/services/terminal-service.js @@ -109,6 +109,12 @@ class TerminalService { console.log(`[TerminalService] WebSocket connected for terminal ${terminalId}`); + // Send ready message to client to indicate PTY is ready for input + ws.send(JSON.stringify({ + type: 'ready', + terminalId: terminalId + })); + // Handle incoming messages from client (user input) ws.on('message', (data) => { try {