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 <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-19 18:55:59 +00:00
Unverified
parent 7043427658
commit d834a64d62

View File

@@ -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 {