Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

test(pane): redraw the fake child with relative cursor-down moves

Jack Rudenkoe83b2ae94420
diff --git a/packages/cli/src/pane/pane-resize.integration.test.ts b/packages/cli/src/pane/pane-resize.integration.test.ts
index e0311872..d0b06514 100644
--- a/packages/cli/src/pane/pane-resize.integration.test.ts
+++ b/packages/cli/src/pane/pane-resize.integration.test.ts
@@ -174,6 +174,44 @@ describe.skipIf(!RESIZE_AVAILABLE)("pane resize through MCP (requires magmux res
expect((await redrawn(id, 100, 40)).lines.some((l) => /─{99,}/.test(l))).toBe(true);
}, T_TEST);
+ for (const growth of [
+ { name: "160x50 → 160x60", from: undefined, cols: 160 },
+ { name: "100x40 → 220x60", from: { cols: 100, rows: 40 }, cols: 220 },
+ ]) {
+ test(`row grow ${growth.name} preserves the input box and settles the next turn`, async () => {
+ const id = await create();
+ expect(await capture(id)).toMatchObject({ cols: 160, rows: 50 });
+ const firstPrompt = "answer before growing the pane";
+ await call("send_input", { session_id: id, text: firstPrompt });
+ await waitFor(async () => {
+ const s = await row(id);
+ return s?.state === "AWAITING_INPUT" && (s.turns_completed as number) >= 1;
+ }, { what: "first turn settled before grow", timeoutMs: 25_000, intervalMs: 100 });
+
+ if (growth.from) {
+ await resize(id, growth.from.cols, growth.from.rows);
+ await redrawn(id, growth.from.cols, growth.from.rows);
+ }
+ await resize(id, growth.cols, 60);
+ const c = await redrawn(id, growth.cols, 60);
+ expect(c).toMatchObject({ cols: growth.cols, rows: 60 });
+ const rule = new RegExp(`─{${growth.cols - 1},}`);
+ expect(c.lines.slice(-6).some((l) => rule.test(l))).toBe(true);
+ expect(c.lines.some((l) => l.includes("─") && /cwd • fake|bypass permissions on/.test(l)))
+ .toBe(false);
+
+ const prompt = "answer after growing the pane";
+ await call("send_input", { session_id: id, text: prompt });
+ const answer = `ANSWER contract-fake-model ${createHash("sha1").update(prompt).digest("hex").slice(0, 8)}`;
+ await waitFor(async () => {
+ const s = await row(id);
+ const screen = await capture(id);
+ return s?.state === "AWAITING_INPUT" && (s.turns_completed as number) >= 2
+ && screen.lines.some((l) => l.includes(answer));
+ }, { what: "grown pane turn settled with answer", timeoutMs: 25_000, intervalMs: 100 });
+ }, T_TEST);
+ }
+
test("same size leaves the idle capture seq unchanged", async () => {
const id = await create();
await resize(id, 100, 40);
diff --git a/packages/cli/src/pane/test-helpers/fake-interactive-child.ts b/packages/cli/src/pane/test-helpers/fake-interactive-child.ts
index 4bb7ae79..0e588962 100755
--- a/packages/cli/src/pane/test-helpers/fake-interactive-child.ts
+++ b/packages/cli/src/pane/test-helpers/fake-interactive-child.ts
@@ -422,9 +422,12 @@ function fit(l: string): string {
function render(): void {
let out = "\x1b[H\x1b[2J";
const rows = S.full ? S.full.slice(0, ROWS) : replRows();
+ let cursorRow = 0;
rows.forEach((l, y) => {
if (!l) return;
- out += `\x1b[${y + 1};1H`;
+ // Claude Code walks down relatively; CUP here would hide stale scroll-region bugs.
+ if (y > cursorRow) out += `\r\x1b[${y - cursorRow}B`;
+ cursorRow = y;
if (l.startsWith("\u0000ghost")) out += `❯ \x1b[2m${PLACEHOLDER}\x1b[22m`;
else out += fit(l);
});