fix(run): forward text-frame keystrokes to pty and fix ws-pty upgrade dispatch
xterm.js's onData hands the browser a plain string, and WebSocket.send(string)
always emits a TEXT frame — pty-attach.js only forwarded BINARY frames to
pty.write(), so every keystroke was silently dropped as an unparseable JSON
control message. Now any non-control text frame reaches the pty.
Deeper root cause of the terminal never accepting input at all: the /ws
WebSocketServer used the {server, path} shorthand, whose own internal
upgrade listener calls handleUpgrade() for every upgrade on the shared
http.Server and aborts with 400 on a path mismatch — killing /ws-pty/*
upgrades before the PTY server's own listener ever ran. Switched /ws to
noServer + a manual path-checked dispatch, matching /ws-pty's pattern.
This commit is contained in:
@@ -78,6 +78,17 @@ describe("pty-attach", () => {
|
||||
assert.deepEqual(fakePty.__writes[0], { resize: [100, 40] });
|
||||
});
|
||||
|
||||
it("forwards a plain text WS frame (keystrokes) to pty.write", () => {
|
||||
// xterm.js's onData hands the browser a plain string, and
|
||||
// WebSocket.send(string) always emits a TEXT frame — so every keystroke
|
||||
// arrives here as non-binary. This must reach the pty, not be dropped as
|
||||
// an unparseable control message.
|
||||
const ws = makeFakeWs();
|
||||
ptyAttach.attach(ws, "ccam-lane-1", { cols: 80, rows: 24 });
|
||||
ws.__emitter.emit("message", Buffer.from("ls -la\r"), { binary: false });
|
||||
assert.deepEqual(fakePty.__writes[0], "ls -la\r");
|
||||
});
|
||||
|
||||
it("sends an exit control message and closes on PTY exit", () => {
|
||||
const ws = makeFakeWs();
|
||||
let closed = false;
|
||||
|
||||
Reference in New Issue
Block a user