fix(terminal): a pane on a hidden tab never shrinks its tmux window
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.
This commit is contained in:
@@ -235,6 +235,26 @@ describe("pty-attach", () => {
|
||||
assert.deepEqual(JSON.parse(a.__sent.at(-1).data), { type: "lead" });
|
||||
});
|
||||
|
||||
it("attaches a terminal that names no size at the window's own size", () => {
|
||||
// A terminal on a hidden tab is 0×0 and sends no size; spawning its attach
|
||||
// at a default resized the pane under every other client.
|
||||
const opts = [];
|
||||
ptyAttach.__setSpawnImpl((_f, _a, o) => {
|
||||
opts.push(o);
|
||||
return makeFakePty();
|
||||
});
|
||||
tmux.__setExecImpl((args) => (args.includes("#{window_width} #{window_height}") ? "141 48\n" : ""));
|
||||
ptyAttach.attach(makeFakeWs(), "agenthub-lane-1", { cols: undefined, rows: undefined });
|
||||
assert.deepEqual([opts[0].cols, opts[0].rows], [141, 48]);
|
||||
// tmux cannot answer: the old default, never a crash.
|
||||
ptyAttach.__resetGroups();
|
||||
tmux.__setExecImpl(() => {
|
||||
throw new Error("no server");
|
||||
});
|
||||
ptyAttach.attach(makeFakeWs(), "agenthub-lane-2", { cols: undefined, rows: undefined });
|
||||
assert.deepEqual([opts[1].cols, opts[1].rows], [80, 24]);
|
||||
});
|
||||
|
||||
it("survives a stopped pane: pipe errors, typing and resizes after the attach exited", () => {
|
||||
// Windows node-pty re-throws a read-pipe error nobody listens for, and its
|
||||
// write pipe has no listener at all: Stop (kill-session) ended the attach
|
||||
|
||||
@@ -19,13 +19,17 @@ describe("sizeFromQuery — the attach carries the client's real size", () => {
|
||||
assert.deepEqual(sizeFromQuery(query("?cols=226&rows=29")), { cols: 226, rows: 29 });
|
||||
});
|
||||
|
||||
it("falls back to 80x24 when the client named no size", () => {
|
||||
assert.deepEqual(sizeFromQuery(query("")), { cols: 80, rows: 24 });
|
||||
// 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")), { cols: 80, rows: 24 });
|
||||
assert.deepEqual(sizeFromQuery(query("?cols=99999&rows=99999")), { cols: 80, rows: 24 });
|
||||
assert.deepEqual(sizeFromQuery(query("?cols=abc&rows=12.5")), { cols: 80, rows: 12 });
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user