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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,9 @@
|
||||
sendResize();
|
||||
};
|
||||
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onmessage = (e) => {
|
||||
term.write(e.data);
|
||||
term.write(new Uint8Array(e.data));
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
|
||||
Reference in New Issue
Block a user