a0cd808456
A terminal mounted on a hidden tab sits in a 0x0 box; its first fit shrank xterm to 12x6 and the attach carried that size to tmux, so every background pane was squeezed (Claude's TUI redrawn at 12 columns). It now neither fits nor reports a size until shown, attaches with no size, and the server spawns such an attach at the window's own size (tmux.windowSize). A shown tab reports its size even when the fit did not change xterm's. Settings > Agents shows the host's login profiles to staff only: a developer got two 403s from reads that were never theirs.
36 lines
1.6 KiB
JavaScript
36 lines
1.6 KiB
JavaScript
/**
|
||
* @file websocket-pty-size.test.js
|
||
* @description Regression test for issue #33: the `/ws-pty/:runId` attach
|
||
* spawns `tmux attach-session` at the size the CLIENT reports in the attach
|
||
* URL, not a hardcoded 80×24. tmux sizes the window to the newest client, so
|
||
* attaching at 80 columns and fixing it from the first `resize` message made
|
||
* `claude` redraw its whole UI at 80 columns — wreckage that stays in the
|
||
* scrollback and shows up as torn left-margin fragments when scrolling back.
|
||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||
*/
|
||
const { describe, it } = require("node:test");
|
||
const assert = require("node:assert/strict");
|
||
const { sizeFromQuery } = require("../websocket");
|
||
|
||
const query = (search) => new URL(`http://x/ws-pty/agenthub-lane-1${search}`).searchParams;
|
||
|
||
describe("sizeFromQuery — the attach carries the client's real size", () => {
|
||
it("reads the terminal's own cols/rows", () => {
|
||
assert.deepEqual(sizeFromQuery(query("?cols=226&rows=29")), { cols: 226, rows: 29 });
|
||
});
|
||
|
||
// No size (a terminal on a hidden tab) stays no size: the attach then takes
|
||
// the window's own, never a default that would resize the pane.
|
||
const none = { cols: undefined, rows: undefined };
|
||
|
||
it("names no size when the client named none", () => {
|
||
assert.deepEqual(sizeFromQuery(query("")), none);
|
||
});
|
||
|
||
it("refuses anything out of bounds — this number reaches an ioctl", () => {
|
||
assert.deepEqual(sizeFromQuery(query("?cols=0&rows=-5")), none);
|
||
assert.deepEqual(sizeFromQuery(query("?cols=99999&rows=99999")), none);
|
||
assert.deepEqual(sizeFromQuery(query("?cols=abc&rows=12")), none);
|
||
});
|
||
});
|