Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions internal/http/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,24 @@ func (h *ConsoleHandler) ServeWS(w http.ResponseWriter, r *http.Request) {
// WebSocket → SSH stdin
go func() {
for {
_, msg, err := conn.ReadMessage()
messageType, msg, err := conn.ReadMessage()
if err != nil {
errCh <- err
return
}
var input ssh.Input
if json.Unmarshal(msg, &input) == nil {
if input.Resize != nil {
inCh <- input
continue
}
if len(input.Data) > 0 {

switch messageType {
case websocket.TextMessage:
// Keystrokes — raw text, no JSON parsing
inCh <- ssh.Input{Data: string(msg)}

case websocket.BinaryMessage:
// Resize events — JSON
var input ssh.Input
if json.Unmarshal(msg, &input) == nil && input.Resize != nil {
inCh <- input
continue
}
}

inCh <- ssh.Input{Data: string(msg)}
}
}()

Expand Down
5 changes: 3 additions & 2 deletions internal/http/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,10 @@
document.getElementById('console-status').textContent = 'Connected';
document.getElementById('console-status').className = 'badge badge-online';
term.focus();
var enc = new TextEncoder();
var dims = fitAddon.proposeDimensions();
if (dims) {
ws.send(JSON.stringify({resize: {width: dims.cols, height: dims.rows}}));
ws.send(enc.encode(JSON.stringify({resize: {width: dims.cols, height: dims.rows}})));
}
};

Expand Down Expand Up @@ -448,7 +449,7 @@
fitAddon.fit();
var dims = fitAddon.proposeDimensions();
if (dims) {
ws.send(JSON.stringify({resize: {width: dims.cols, height: dims.rows}}));
ws.send(enc.encode(JSON.stringify({resize: {width: dims.cols, height: dims.rows}})));
}
};
window.addEventListener('resize', window._consoleResizeHandler);
Expand Down
1 change: 0 additions & 1 deletion internal/ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (c *Client) Shell(ctx context.Context, rows, cols int) (<-chan Output, chan

if err := session.RequestPty("xterm-256color", rows, cols, gossh.TerminalModes{
gossh.ECHO: 1,
gossh.OCRNL: 1,
gossh.TTY_OP_ISPEED: 14400,
gossh.TTY_OP_OSPEED: 14400,
}); err != nil {
Expand Down
Loading