fix: show terminal close reason in UI
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 1m47s

Display websocket close reason text (or close code fallback) in terminal tabs so SSH/session failures are diagnosable without checking backend logs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gan, Jimmy
2026-03-06 09:15:48 +08:00
parent 61a3d0ae4b
commit b0f66f9650
@@ -135,11 +135,12 @@
}
}
ws.onopen = () => { ws.send(token); updateTab(tabId, { connected: true }); sendSize(); };
ws.onopen = () => { ws.send(token); updateTab(tabId, { connected: true, error: "" }); sendSize(); };
ws.onmessage = (e) => term.write(new Uint8Array(e.data));
ws.onclose = () => {
updateTab(tabId, { connected: false });
term.write("\r\n\x1b[90m[Connection closed]\x1b[0m");
ws.onclose = (e) => {
const reason = e.reason || `Connection closed (code ${e.code})`;
updateTab(tabId, { connected: false, error: reason });
term.write(`\r\n\x1b[90m[${reason}]\x1b[0m`);
};
ws.onerror = () => updateTab(tabId, { connected: false, error: "Connection failed" });
term.onData((data) => ws.readyState === 1 && ws.send(new TextEncoder().encode(data)));