Skip to content

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

test(pane): pin the 40-column resize floor and 40x24 screen readings

Jack Rudenkoc532eb5b02d2
diff --git a/packages/cli/src/pane/box-locate.test.ts b/packages/cli/src/pane/box-locate.test.ts
index f111be4b..070b2136 100644
--- a/packages/cli/src/pane/box-locate.test.ts
+++ b/packages/cli/src/pane/box-locate.test.ts
@@ -5,6 +5,10 @@ import { loadScreen } from "./test-helpers/fixtures.js";
// Literal row indexes read from the real captures, independent of either locator.
const BOX_SCREENS = [
+ ["size-40x24-answer-short", 17, 19, 18],
+ ["size-40x24-repl-boot-empty", 17, 19, 18],
+ ["size-40x24-working", 17, 19, 18],
+ ["size-40x24-repl-typed-long", 14, 19, 18],
["api-error", 45, 47, 46],
["ask-user-question-declined", 45, 47, 46],
["background-agent-wait", 45, 47, 46],
@@ -56,6 +60,9 @@ const BOX_SCREENS = [
] as const;
const NO_BOX_SCREENS = [
+ "size-40x24-ask-user-question",
+ "size-40x24-permission-bash",
+ "size-40x24-permission-write-long-path",
"agent-rejected",
"ask-user-question",
"dialog-bypass",
@@ -97,10 +104,10 @@ function withRuleDistances(above: number, below: number): ScreenState {
}
describe("U5 locateBox at captured widths", () => {
- test("accounts for all 69 supplied screens without duplicate names", () => {
+ test("accounts for all 76 supplied screens without duplicate names", () => {
const names = [...BOX_SCREENS.map(([name]) => name), ...NO_BOX_SCREENS];
- expect(names).toHaveLength(69);
- expect(new Set(names).size).toBe(69);
+ expect(names).toHaveLength(76);
+ expect(new Set(names).size).toBe(76);
});
test.each(BOX_SCREENS)("%s: locates the captured REPL box", (name, top, bottom, caretRow) => {
@@ -238,6 +245,7 @@ describe("U6 isRuleRow without a width test", () => {
test("locates 20-cell boundaries at every captured width without proportional sizing", () => {
for (const [name, top, bottom, caretRow] of [
+ ["size-40x24-repl-boot-empty", 17, 19, 18],
["size-80x24-repl-boot-empty", 20, 22, 21],
["size-120x40-repl-boot-empty", 36, 38, 37],
["repl-boot-empty", 45, 47, 46],
diff --git a/packages/cli/src/pane/pane-resize.integration.test.ts b/packages/cli/src/pane/pane-resize.integration.test.ts
index ffadff90..cf6f2f2d 100644
--- a/packages/cli/src/pane/pane-resize.integration.test.ts
+++ b/packages/cli/src/pane/pane-resize.integration.test.ts
@@ -273,11 +273,11 @@ describe.skipIf(!RESIZE_AVAILABLE)("pane resize through MCP (requires magmux res
);
test(
- "small dimensions clamp to 80 columns and 24 rows",
+ "small dimensions clamp to 40 columns and 24 rows",
async () => {
const id = await create();
- expect(await resize(id, 5, 5)).toMatchObject({ cols: 80, rows: 24, changed: true });
- await redrawn(id, 80, 24);
+ expect(await resize(id, 5, 5)).toMatchObject({ cols: 40, rows: 24, changed: true });
+ await redrawn(id, 40, 24);
},
T_TEST
);
diff --git a/packages/cli/src/pane/pane-size.test.ts b/packages/cli/src/pane/pane-size.test.ts
index 9dd0cefa..e6abc2bd 100644
--- a/packages/cli/src/pane/pane-size.test.ts
+++ b/packages/cli/src/pane/pane-size.test.ts
@@ -15,18 +15,21 @@ describe("clampPaneSize", () => {
[120, 40, 120, 40],
[250, 60, 250, 60],
[500, 200, 500, 200],
- [1, 1, 80, 24],
+ [1, 1, 40, 24],
+ [10, 5, 40, 24],
+ [40, 24, 40, 24],
+ [39, 24, 40, 24],
[501, 201, 501, 201],
- [79, 60, 80, 60],
+ [79, 60, 79, 60],
[501, 60, 501, 60],
[250, 23, 250, 24],
[250, 201, 250, 201],
- [79, 201, 80, 201],
+ [79, 201, 79, 201],
[501, 23, 501, 24],
[400, 100, 400, 100],
[10_000, 50, 9_999, 50],
[9_999, 9_999, 9_999, 400],
- [50, 10, 80, 24],
+ [50, 10, 50, 24],
[2_000, 2_001, 2_000, 2_000],
[9_999, 50, 9_999, 50],
[80, 9_999, 80, 9_999],
@@ -36,9 +39,9 @@ describe("clampPaneSize", () => {
[8_000, 500, 8_000, 500],
[8_000, 501, 8_000, 500],
[2_001, 2_000, 2_001, 1_999],
- [0, 0, 80, 24],
- [-1, -1, 80, 24],
- [-1, 60, 80, 60],
+ [0, 0, 40, 24],
+ [-1, -1, 40, 24],
+ [-1, 60, 40, 60],
[120, -1, 120, 24],
])("%i × %i clamps to %i × %i", (cols, rows, expectedCols, expectedRows) => {
expect(clampPaneSize(cols, rows)).toEqual({ cols: expectedCols, rows: expectedRows });
@@ -46,10 +49,10 @@ describe("clampPaneSize", () => {
test.each([
[120.9, 40.9, 120, 40],
- [79.9, 23.9, 80, 24],
+ [79.9, 23.9, 79, 24],
[9_999.9, 50.9, 9_999, 50],
[80.9, 9_999.9, 80, 9_999],
- [-120.9, -40.9, 80, 24],
+ [-120.9, -40.9, 40, 24],
])("%s × %s truncates and clamps to %s × %s", (cols, rows, expectedCols, expectedRows) => {
expect(clampPaneSize(cols, rows)).toEqual({ cols: expectedCols, rows: expectedRows });
});
@@ -68,11 +71,11 @@ describe("U9: magmux size bounds", () => {
expect(clampPaneSize(1_000, 50).cols).toBe(1_000);
});
- test("exports magmux limits and the 80 × 24 minimum", () => {
+ test("exports magmux limits and the 40 × 24 minimum", () => {
expect(MAX_PANE_COLS).toBe(9_999);
expect(MAX_PANE_ROWS).toBe(9_999);
expect(MAX_PANE_CELLS).toBe(4_000_000);
- expect(MIN_PANE_COLS).toBe(80);
+ expect(MIN_PANE_COLS).toBe(40);
expect(MIN_PANE_ROWS).toBe(24);
});
});
diff --git a/packages/cli/src/pane/screen-classifier-sizes.test.ts b/packages/cli/src/pane/screen-classifier-sizes.test.ts
index 8f4c5703..c094a5fc 100644
--- a/packages/cli/src/pane/screen-classifier-sizes.test.ts
+++ b/packages/cli/src/pane/screen-classifier-sizes.test.ts
@@ -7,6 +7,7 @@ import {
hasEcho,
inputBox,
isWorking,
+ nameBootScreen,
readBoot,
screenAnswer,
} from "./screen-classifier.js";
@@ -31,12 +32,17 @@ const STATES = [
] as const;
for (const [cols, rows] of [
+ [40, 24],
[80, 24],
[120, 40],
[250, 60],
] as const) {
describe(`${cols}x${rows} real Claude Code captures`, () => {
- test.each([...STATES])("%s", (state) => {
+ test.each(
+ STATES.filter(
+ (state) => cols !== 40 || (state !== "dialog-trust" && state !== "echo-submitted")
+ )
+ )("%s", (state) => {
const screen = loadScreen(`size-${cols}x${rows}-${state}`);
expect(screen.cols).toBe(cols);
expect(screen.rows).toBe(rows);
@@ -72,6 +78,30 @@ for (const [cols, rows] of [
});
}
+test("40x24 bash permission identifies a permission dialog", () => {
+ const screen = loadScreen("size-40x24-permission-bash");
+ expect(choiceDialog(screen)?.kind).toBe("permission");
+});
+
+test("40x24 wrapped question footer identifies a choice screen", () => {
+ const screen = loadScreen("size-40x24-ask-user-question");
+ // The footer wraps after "Esc", with "to cancel" on the next row.
+ expect(choiceDialog(screen)?.kind).toBe("question");
+ expect(nameBootScreen(screen).kind).toBe("choice");
+});
+
+test.each(["size-40x24-working", "size-40x24-answer-short"])(
+ "%s echo matches the 36-character submitted prompt prefix",
+ (name) => {
+ const screen = loadScreen(name);
+ expect(echoHeadLength(40)).toBe(36);
+ const head = echoHead(SUBMITTED_PROMPT, 40);
+ expect(head).toBe(SUBMITTED_PROMPT.slice(0, 36));
+ expect(head.length).toBe(36);
+ expect(hasEcho(screen.lines, head)).toBe(true);
+ }
+);
+
test("80x24 working-tail", () => {
expect(isWorking(loadScreen("size-80x24-working-tail"))).toBe(true);
});
@@ -98,12 +128,12 @@ test("80x24 wrapped permission header identifies a permission dialog", () => {
});
describe("echoHeadLength", () => {
- test.each([80, 120, 160, 250])("%i columns use min(40, cols - 4)", (cols) => {
+ test.each([40, 80, 120, 160, 250])("%i columns use min(40, cols - 4)", (cols) => {
expect(echoHeadLength(cols)).toBe(Math.min(40, cols - 4));
});
- // Supported pane widths all hit the 40-character cap. Exercise the helper's
- // width-dependent branch separately, without inventing a screen fixture.
+ // At the supported 40-column minimum, the echo prefix is 36 characters.
+ // Exercise a narrower helper input separately, without inventing a screen fixture.
test("32 columns shorten the echo prefix to 28 characters", () => {
expect(echoHeadLength(32)).toBe(28);
expect(echoHead(SUBMITTED_PROMPT, 32)).toBe(SUBMITTED_PROMPT.slice(0, 28));