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
|
||||
|
||||
Reference in New Issue
Block a user