From 252f178bbdbcfe96ccf0b2a5f9c8c99c9d814349 Mon Sep 17 00:00:00 2001 From: Augustin Date: Wed, 22 Apr 2026 20:05:10 +0200 Subject: [PATCH] fix(terminal): init payload never sent due to ws.onopen being overwritten connectWebSocket set ws.onopen to send the shell init payload, but initTerminal immediately overwrote it with a state-only handler. Switched to addEventListener so both handlers coexist. --- web/src/components/Shell.jsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/src/components/Shell.jsx b/web/src/components/Shell.jsx index 8f3a16b..2d0dbbb 100644 --- a/web/src/components/Shell.jsx +++ b/web/src/components/Shell.jsx @@ -94,15 +94,15 @@ function connectWebSocket(term, fitAddon, initPayload) { const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:' const ws = new WebSocket(`${proto}//${window.location.host}/api/ws/terminal`) - ws.onopen = () => { + ws.addEventListener('open', () => { ws.send(JSON.stringify(initPayload)) const dims = fitAddon.proposeDimensions() if (dims) { ws.send(JSON.stringify({ type: 'resize', rows: dims.rows, cols: dims.cols })) } - } + }) - ws.onmessage = (event) => { + ws.addEventListener('message', (event) => { try { const msg = JSON.parse(event.data) if (msg.type === 'output') { @@ -113,15 +113,15 @@ function connectWebSocket(term, fitAddon, initPayload) { } catch { term.write(event.data) } - } + }) - ws.onclose = () => { + ws.addEventListener('close', () => { term.write('\r\n\x1b[33m— Connection closed —\x1b[0m\r\n') - } + }) - ws.onerror = () => { + ws.addEventListener('error', () => { term.write('\r\n\x1b[31m— Connection error —\x1b[0m\r\n') - } + }) term.onData((data) => { if (ws.readyState === WebSocket.OPEN) {