Summary
Three bugs found while testing the --terminal feature (v0.0.118):
1. Socket reference wrong for @fastify/websocket v8+
connection.socket doesn't exist — connection IS the socket in v8+.
// Bug:
const socket = connection.socket;
// Fix:
const socket = connection.socket || connection;
2. Missing carriage returns (newline issue)
Shell output sends \n but xterm.js expects \r\n. Without a real PTY, lines render with staircase indentation.
// Fix: convert \n to \r\n on stdout/stderr output
socket.send(data.toString().replace(/\n/g, '\r\n'));
3. Auth required even on --public servers
The terminal endpoint always requires authentication, even when JSS is started with --public. Should respect the public flag.
4. /bin/sh vs /bin/bash -i
/bin/sh without a PTY doesn't show a prompt. Using /bin/bash -i (interactive mode) provides a prompt and better experience.
Long-term fix
Use node-pty for proper pseudo-terminal support instead of raw child_process.spawn. This would fix newlines, prompt, and interactive program support (vim, top, etc.) properly.
Summary
Three bugs found while testing the
--terminalfeature (v0.0.118):1. Socket reference wrong for @fastify/websocket v8+
connection.socketdoesn't exist —connectionIS the socket in v8+.2. Missing carriage returns (newline issue)
Shell output sends
\nbut xterm.js expects\r\n. Without a real PTY, lines render with staircase indentation.3. Auth required even on --public servers
The terminal endpoint always requires authentication, even when JSS is started with
--public. Should respect the public flag.4. /bin/sh vs /bin/bash -i
/bin/shwithout a PTY doesn't show a prompt. Using/bin/bash -i(interactive mode) provides a prompt and better experience.Long-term fix
Use
node-ptyfor proper pseudo-terminal support instead of rawchild_process.spawn. This would fix newlines, prompt, and interactive program support (vim, top, etc.) properly.