fix: use binary WebSocket frames for SSH PTY output

SSH PTY output contains non-UTF-8 bytes (terminal escape sequences).
Sending as TextMessage caused WebSocket decode errors. Switch to
BinaryMessage and handle arraybuffer on the client side.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 22:30:24 +09:00
parent 1563091de1
commit 08d97b3f89
2 changed files with 3 additions and 2 deletions

View File

@@ -131,7 +131,7 @@ func handleWS(w http.ResponseWriter, r *http.Request, sshPort int) {
for {
n, err := stdout.Read(buf)
if n > 0 {
if writeErr := ws.WriteMessage(websocket.TextMessage, buf[:n]); writeErr != nil {
if writeErr := ws.WriteMessage(websocket.BinaryMessage, buf[:n]); writeErr != nil {
return
}
}

View File

@@ -72,8 +72,9 @@
sendResize();
};
ws.binaryType = 'arraybuffer';
ws.onmessage = (e) => {
term.write(e.data);
term.write(new Uint8Array(e.data));
};
ws.onclose = () => {