Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
test(pane): pin resize bounds, wrapped screens and the 15-tool surface
Jack Rudenkof43677837352
diff --git a/packages/cli/src/mcp-blackbox/resize.blackbox.test.ts b/packages/cli/src/mcp-blackbox/resize.blackbox.test.tsnew file mode 100644index 00000000..4cb32ce7--- /dev/null+++ b/packages/cli/src/mcp-blackbox/resize.blackbox.test.ts@@ -0,0 +1,79 @@+import { afterEach, beforeEach, describe, expect, test } from "bun:test";+import { join } from "node:path";+import type { ContractError } from "../pane/contract.js";+import { useBlackboxEnv } from "../test-helpers/blackbox-env.js";+import { McpServer, paneOrphans, serverEnv } from "../test-helpers/contract-mcp.js";+import { type TempLayout, makeTempLayout } from "../test-helpers/contract-records.js";++useBlackboxEnv();++let layout: TempLayout;+let server: McpServer;++beforeEach(async () => {+ layout = makeTempLayout("bbresize");+ server = await McpServer.start({ env: serverEnv(layout), cwd: layout.cwd });+});++afterEach(async () => {+ await server.close();+ const report = await paneOrphans(layout);+ layout.cleanup();+ expect(report).toEqual({ processes: [], files: [] });+});++describe("resize verbs: contract error codes without a pane", () => {+ const cases: Array<{+ name: string;+ tool: string;+ args: Record<string, unknown>;+ code: ContractError["error"]["code"];+ }> = [+ {+ name: "resize_session missing cols",+ tool: "resize_session",+ args: { session_id: "missing", rows: 30 },+ code: "invalid_args",+ },+ {+ name: "resize_session fractional rows",+ tool: "resize_session",+ args: { session_id: "missing", cols: 120, rows: 30.5 },+ code: "invalid_args",+ },+ {+ name: "resize_session string rows",+ tool: "resize_session",+ args: { session_id: "missing", cols: 120, rows: "30" },+ code: "invalid_args",+ },+ {+ name: "resize_session unknown session_id",+ tool: "resize_session",+ args: { session_id: "missing", cols: 120, rows: 30 },+ code: "unknown_session",+ },+ {+ name: "team resize missing slot",+ tool: "team",+ args: { mode: "resize", cols: 120, rows: 30 },+ code: "invalid_args",+ },+ {+ name: "team resize path has no run",+ tool: "team",+ args: { mode: "resize", slot: "01", cols: 120, rows: 30 },+ code: "unknown_run",+ },+ ];++ for (const { name, tool, args, code } of cases) {+ test(name, async () => {+ const result = await server.callTool(tool, {+ ...args,+ ...(tool === "team" ? { path: join(layout.cwd, "no-run") } : {}),+ });+ expect((result.json as unknown as ContractError)?.error?.code).toBe(code);+ });+ }+});diff --git a/packages/cli/src/mcp-blackbox/tool-surface.blackbox.test.ts b/packages/cli/src/mcp-blackbox/tool-surface.blackbox.test.tsindex ed8d5cf1..5c59818b 100644--- a/packages/cli/src/mcp-blackbox/tool-surface.blackbox.test.ts+++ b/packages/cli/src/mcp-blackbox/tool-surface.blackbox.test.ts@@ -38,6 +38,7 @@ const ALL_TOOLS = ["list_sessions","preflight","report_error",+ "resize_session","run_prompt","search_models","send_input",@@ -50,6 +51,7 @@ const SESSION_TOOLS = ["get_diagnostics","get_output","list_sessions",+ "resize_session","send_input",];const TOOL_GROUPS: Array<{ value: string | undefined; names: string[] }> = [@@ -236,7 +238,7 @@ describe("CLAUDISH_MCP_TOOLS startup warnings", () => {.filter((line) => line.includes("CLAUDISH_MCP_TOOLS"));if (value === "channel" || value === "lowlevel") {expect(tools.map((tool) => tool.name).sort()).toEqual(ALL_TOOLS);- expect(tools).toHaveLength(14);+ expect(tools).toHaveLength(15);expect(warnings).toHaveLength(1);expect(warnings[0]).toContain(value);expect(warnings[0]).toContain("all, low-level, agentic, session, debug");@@ -254,11 +256,11 @@ describe("CLAUDISH_MCP_TOOLS startup warnings", () => {// REQ-20 (TEST-21–TEST-26): preserve the existing pane-free session/team regressions.describe("tool list (FR11, §4)", () => {useStandardServer();- test("14 tools, capture_session among them, team modes are exactly the seven", async () => {+ test("15 tools, resize_session among them, team modes are exactly the eight", async () => {const tools = await server.listTools();const names = tools.map((t) => t.name);- expect(names.length).toBe(14);- expect(new Set(names).size).toBe(14);+ expect(names.length).toBe(15);+ expect(new Set(names).size).toBe(15);for (const n of ["team","create_session",@@ -268,6 +270,7 @@ describe("tool list (FR11, §4)", () => {"list_sessions","get_diagnostics","capture_session",+ "resize_session",])expect(names).toContain(n);// FR8: run_prompt / compare_models are out of scope and stay@@ -277,7 +280,7 @@ describe("tool list (FR11, §4)", () => {const teamTool = tools.find((t) => t.name === "team");const props = (teamTool?.inputSchema?.properties ?? {}) as Record<string, Json>;expect(((props.mode as Json).enum as string[]).slice().sort()).toEqual(- ["run", "judge", "run-and-judge", "status", "cancel", "list", "capture"].sort()+ ["run", "judge", "run-and-judge", "status", "cancel", "list", "capture", "resize"].sort());expect(teamTool?.inputSchema?.required).toEqual(["mode"]);for (const p of [@@ -459,6 +462,7 @@ describe("nested MCP server over stdio", () => {"list_sessions","get_diagnostics","capture_session",+ "resize_session","preflight","report_error",];@@ -537,11 +541,11 @@ describe("nested MCP server over stdio", () => {expect(await paneOrphans(layout)).toEqual({ processes: [], files: [] });}, 30_000);- test("T-MCP-5: without the flag all still exposes 14 tools without an experimental capability", async () => {+ test("T-MCP-5: without the flag all still exposes 15 tools without an experimental capability", async () => {const c = await connect("all", false);const tools = (await c.listTools()).tools;- expect(tools).toHaveLength(14);- expect(new Set(tools.map((tool) => tool.name)).size).toBe(14);+ expect(tools).toHaveLength(15);+ expect(new Set(tools.map((tool) => tool.name)).size).toBe(15);expect(c.getServerCapabilities()).toHaveProperty("tools");expect(c.getServerCapabilities()).not.toHaveProperty("experimental");expect(c.getInstructions()).not.toContain("## Nested mode — no sessions");diff --git a/packages/cli/src/mcp-session/e2e-sessions.test.ts b/packages/cli/src/mcp-session/e2e-sessions.test.tsindex 67f8cc05..6eb7677e 100644--- a/packages/cli/src/mcp-session/e2e-sessions.test.ts+++ b/packages/cli/src/mcp-session/e2e-sessions.test.ts@@ -100,6 +100,7 @@ describe("Group 1: MCP Protocol — session tools", () => {"list_sessions","preflight","report_error",+ "resize_session","run_prompt","search_models","send_input",@@ -254,7 +255,7 @@ describe("Group 1b: MCP Protocol — session-only tools", () => {} catch {}});- test("lists only the 7 session tools when CLAUDISH_MCP_TOOLS=session", async () => {+ test("lists only the 8 session tools when CLAUDISH_MCP_TOOLS=session", async () => {const result = await client.listTools();const names = result.tools.map((t) => t.name).sort();expect(names).toEqual([@@ -264,6 +265,7 @@ describe("Group 1b: MCP Protocol — session-only tools", () => {"get_diagnostics","get_output","list_sessions",+ "resize_session","send_input",]);});diff --git a/packages/cli/src/pane/pane-size.test.ts b/packages/cli/src/pane/pane-size.test.tsnew file mode 100644index 00000000..e48f5f77--- /dev/null+++ b/packages/cli/src/pane/pane-size.test.ts@@ -0,0 +1,37 @@+import { describe, expect, test } from "bun:test";+import { clampPaneSize, samePaneSize } from "./pane-size.js";++describe("clampPaneSize", () => {+ test.each([+ [80, 24, 80, 24],+ [120, 40, 120, 40],+ [250, 60, 250, 60],+ [500, 200, 500, 200],+ [1, 1, 80, 24],+ [501, 201, 500, 200],+ [79, 60, 80, 60],+ [501, 60, 500, 60],+ [250, 23, 250, 24],+ [250, 201, 250, 200],+ [79, 201, 80, 200],+ [501, 23, 500, 24],+ ])("%i × %i clamps to %i × %i", (cols, rows, expectedCols, expectedRows) => {+ expect(clampPaneSize(cols, rows)).toEqual({ cols: expectedCols, rows: expectedRows });+ });+});++describe("samePaneSize", () => {+ test("equal dimensions match, each differing axis does not", () => {+ const size = { cols: 120, rows: 40 };+ expect(samePaneSize(size, { ...size })).toBe(true);+ expect(samePaneSize(size, { cols: 121, rows: 40 })).toBe(false);+ expect(samePaneSize(size, { cols: 120, rows: 41 })).toBe(false);+ });++ test("null means unknown, including when both sizes are null", () => {+ const size = { cols: 120, rows: 40 };+ expect(samePaneSize(null, size)).toBe(false);+ expect(samePaneSize(size, null)).toBe(false);+ expect(samePaneSize(null, null)).toBe(false);+ });+});diff --git a/packages/cli/src/pane/screen-classifier-sizes.test.ts b/packages/cli/src/pane/screen-classifier-sizes.test.tsnew file mode 100644index 00000000..f755d034--- /dev/null+++ b/packages/cli/src/pane/screen-classifier-sizes.test.ts@@ -0,0 +1,107 @@+import { describe, expect, test } from "bun:test";+import {+ choiceDialog,+ echoHead,+ echoHeadLength,+ hasChoiceDialog,+ hasEcho,+ inputBox,+ isWorking,+ readBoot,+ screenAnswer,+} from "./screen-classifier.js";+import { loadScreen } from "./test-helpers/fixtures.js";++const TYPED_LINE =+ "Please summarise the purpose of this directory in two sentences, then list three improvements you would make to its layout and naming";+const SUBMITTED_PROMPT = "Reply with exactly the word pear and nothing else, thank you.";+const WRAPPED_PROMPT =+ "Reply with exactly the word pear and nothing else; this prompt is padded so its echo wraps past eighty columns.";+const WRITE_LONG_PATH_PROMPT =+ "Use the Write tool to create the file deeply/nested/directory/structure/for/the/resize/fixture/capture/run/with/a/very/long/path/name/hello.txt containing the word hi. Do nothing else.";+const squash = (text: string): string => text.replace(/\s+/g, "");+const STATES = [+ "repl-boot-empty",+ "repl-typed-long",+ "dialog-trust",+ "permission-write-long-path",+ "working",+ "echo-submitted",+ "answer-short",+] as const;++for (const [cols, rows] of [[80, 24], [120, 40], [250, 60]] as const) {+ describe(`${cols}x${rows} real Claude Code captures`, () => {+ test.each(STATES)("%s", (state) => {+ const screen = loadScreen(`size-${cols}x${rows}-${state}`);+ expect(screen.cols).toBe(cols);+ expect(screen.rows).toBe(rows);+ switch (state) {+ case "repl-boot-empty":+ expect(inputBox(screen)).not.toBeNull();+ expect(readBoot(screen)).toEqual({ kind: "repl" });+ break;+ case "repl-typed-long": {+ const box = inputBox(screen);+ expect(box).not.toBeNull();+ expect(squash(box?.text ?? "")).toContain(squash(TYPED_LINE));+ break;+ }+ case "dialog-trust":+ expect(readBoot(screen)).toMatchObject({ kind: "dialog", name: "trust" });+ break;+ case "permission-write-long-path":+ expect(hasChoiceDialog(screen)).toBe(true);+ expect(choiceDialog(screen)?.kind).toBe("permission");+ break;+ case "working":+ expect(isWorking(screen)).toBe(true);+ break;+ case "echo-submitted":+ expect(hasEcho(screen.lines, echoHead(SUBMITTED_PROMPT, cols))).toBe(true);+ break;+ case "answer-short":+ expect(screenAnswer(screen, SUBMITTED_PROMPT).trim().length).toBeGreaterThan(0);+ break;+ }+ });+ });+}++test("80x24 working-tail", () => {+ expect(isWorking(loadScreen("size-80x24-working-tail"))).toBe(true);+});++test("80x24 wrapped echo matches the submitted prompt", () => {+ const screen = loadScreen("size-80x24-echo-wrapped");+ expect(WRAPPED_PROMPT.length).toBe(111);+ expect(hasEcho(screen.lines, echoHead(WRAPPED_PROMPT, 80))).toBe(true);+ // The 40-character echoHead fits on row one; the full prompt crosses the wrap.+ expect(hasEcho(screen.lines, WRAPPED_PROMPT)).toBe(true);+});++test.each([80, 120])("%i-column wrapped long-path echo matches the submitted prompt", (cols) => {+ const screen = loadScreen(`size-${cols}x${cols === 80 ? 24 : 40}-permission-write-long-path`);+ expect(hasEcho(screen.lines, echoHead(WRITE_LONG_PATH_PROMPT, cols))).toBe(true);+ // At 80 columns the path wraps mid-word beyond echoHead's 40-character cap.+ expect(hasEcho(screen.lines, WRITE_LONG_PATH_PROMPT)).toBe(true);+});++test("80x24 wrapped permission header identifies a permission dialog", () => {+ const screen = loadScreen("size-80x24-permission-header-wrapped");+ expect(hasChoiceDialog(screen)).toBe(true);+ expect(choiceDialog(screen)?.kind).toBe("permission");+});++describe("echoHeadLength", () => {+ test.each([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.+ 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));+ });+});diff --git a/packages/cli/src/pane/test-fixtures/screens/size-80x24-echo-wrapped.json b/packages/cli/src/pane/test-fixtures/screens/size-80x24-echo-wrapped.jsonnew file mode 100644index 00000000..9dd60141--- /dev/null+++ b/packages/cli/src/pane/test-fixtures/screens/size-80x24-echo-wrapped.json@@ -0,0 +1,257 @@+{+ "source": "resize H1 live capture wrap-80x24/echo-wrapped",+ "claudeCode": "2.1.299",+ "magmux": "0.14.0",+ "rows": 24,+ "cols": 80,+ "alt": true,+ "cursor": {+ "x": 2,+ "y": 21+ },+ "lines": [+ "",+ " ▐▛███▛█ Claude Code v2.1.299",+ "▝▜██████▀ Haiku 5.5 · Claude API",+ " ▝▝ ▝▝ /private/tmp/rsz/wrap-80x24/cwd",+ "",+ "",+ "❯ Reply with exactly the word pear and nothing else; this prompt is padded so",+ " its echo wraps past eighty columns.",+ "",+ "",+ "",+ "",+ "",+ "",+ "",+ "",+ "",+ "",+ "✽ Creating…",+ " ◐ medium · /effort",+ "────────────────────────────────────────────────────────────────────────────────",+ "❯",+ "────────────────────────────────────────────────────────────────────────────────",+ " ⏸ manual mode on · esc to interrupt · ← for agents"+ ],+ "spans": [+ [],+ [+ [+ 0,+ 2,+ 174,+ -1,+ 0+ ],+ [+ 2,+ 6,+ 174,+ 16,+ 0+ ],+ [+ 11,+ 11,+ -1,+ -1,+ 1+ ],+ [+ 23,+ 8,+ 246,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 2,+ 174,+ -1,+ 0+ ],+ [+ 2,+ 5,+ 174,+ 16,+ 0+ ],+ [+ 7,+ 2,+ 174,+ -1,+ 0+ ],+ [+ 11,+ 22,+ 246,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 9,+ 174,+ -1,+ 0+ ],+ [+ 11,+ 31,+ 246,+ -1,+ 0+ ]+ ],+ [],+ [],+ [+ [+ 0,+ 2,+ 246,+ 237,+ 0+ ],+ [+ 2,+ 76,+ 231,+ 237,+ 0+ ],+ [+ 78,+ 2,+ -1,+ 237,+ 0+ ]+ ],+ [+ [+ 0,+ 2,+ -1,+ 237,+ 0+ ],+ [+ 2,+ 35,+ 231,+ 237,+ 0+ ],+ [+ 37,+ 43,+ -1,+ 237,+ 0+ ]+ ],+ [],+ [],+ [],+ [],+ [],+ [],+ [],+ [],+ [],+ [],+ [+ [+ 0,+ 1,+ 174,+ -1,+ 0+ ],+ [+ 2,+ 3,+ 174,+ -1,+ 0+ ],+ [+ 5,+ 3,+ 216,+ -1,+ 0+ ],+ [+ 8,+ 4,+ 174,+ -1,+ 0+ ]+ ],+ [+ [+ 60,+ 18,+ 246,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 80,+ 244,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 2,+ 246,+ -1,+ 0+ ],+ [+ 2,+ 1,+ -1,+ -1,+ 16+ ]+ ],+ [+ [+ 0,+ 80,+ 244,+ -1,+ 0+ ]+ ],+ [+ [+ 2,+ 50,+ 246,+ -1,+ 0+ ]+ ]+ ]+}diff --git a/packages/cli/src/pane/test-fixtures/screens/size-80x24-permission-header-wrapped.json b/packages/cli/src/pane/test-fixtures/screens/size-80x24-permission-header-wrapped.jsonnew file mode 100644index 00000000..e902d6e1--- /dev/null+++ b/packages/cli/src/pane/test-fixtures/screens/size-80x24-permission-header-wrapped.json@@ -0,0 +1,291 @@+{+ "source": "resize H1 live capture wrap-80x24/permission-header",+ "claudeCode": "2.1.299",+ "magmux": "0.14.0",+ "rows": 24,+ "cols": 80,+ "alt": true,+ "cursor": {+ "x": 1,+ "y": 18+ },+ "lines": [+ "",+ "",+ "✻ Sautéed for 1s · done 11:26 pm",+ "",+ "❯ Use the Write tool to create the file",+ " a-deliberately-very-long-file-name-for-wrapping-the-permission-header.txt",+ " containing the word hi. Do nothing else.",+ "",+ "⏺ Write(…eliberately-very-long-file-name-for-wrapping-the-permission-header.txt)",+ "",+ "────────────────────────────────────────────────────────────────────────────────",+ " Create file",+ " a-deliberately-very-long-file-name-for-wrapping-the-permission-header.txt",+ "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌",+ " 1 hi",+ "╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌",+ " Do you want to create",+ " a-deliberately-very-long-file-name-for-wrapping-the-permission-header.txt?",+ " ❯ 1. Yes",+ " 2. Yes, and switch to accept edits (auto-approve file edits and common file",+ " commands) for this session (shift+tab)",+ " 3. No",+ "",+ " Esc to cancel · Tab to amend"+ ],+ "spans": [+ [],+ [],+ [+ [+ 0,+ 1,+ 246,+ -1,+ 0+ ],+ [+ 2,+ 30,+ 246,+ -1,+ 0+ ]+ ],+ [],+ [+ [+ 0,+ 2,+ 246,+ 237,+ 0+ ],+ [+ 2,+ 38,+ 231,+ 237,+ 0+ ],+ [+ 40,+ 40,+ -1,+ 237,+ 0+ ]+ ],+ [+ [+ 0,+ 2,+ -1,+ 237,+ 0+ ],+ [+ 2,+ 74,+ 231,+ 237,+ 0+ ],+ [+ 76,+ 4,+ -1,+ 237,+ 0+ ]+ ],+ [+ [+ 0,+ 2,+ -1,+ 237,+ 0+ ],+ [+ 2,+ 40,+ 231,+ 237,+ 0+ ],+ [+ 42,+ 38,+ -1,+ 237,+ 0+ ]+ ],+ [],+ [+ [+ 0,+ 1,+ 246,+ -1,+ 0+ ],+ [+ 2,+ 5,+ -1,+ -1,+ 1+ ]+ ],+ [],+ [+ [+ 0,+ 80,+ 153,+ -1,+ 0+ ]+ ],+ [+ [+ 1,+ 11,+ 153,+ -1,+ 1+ ]+ ],+ [+ [+ 1,+ 73,+ 246,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 80,+ 239,+ -1,+ 0+ ]+ ],+ [+ [+ 1,+ 3,+ 231,+ -1,+ 2+ ],+ [+ 4,+ 2,+ 231,+ -1,+ 0+ ]+ ],+ [+ [+ 0,+ 80,+ 239,+ -1,+ 0+ ]+ ],+ [],+ [+ [+ 1,+ 73,+ -1,+ -1,+ 1+ ]+ ],+ [+ [+ 1,+ 1,+ 153,+ -1,+ 0+ ],+ [+ 3,+ 3,+ 246,+ -1,+ 0+ ],+ [+ 6,+ 3,+ 153,+ -1,+ 0+ ]+ ],+ [+ [+ 3,+ 3,+ 246,+ -1,+ 0+ ],+ [+ 25,+ 54,+ -1,+ -1,+ 1+ ]+ ],+ [+ [+ 6,+ 9,+ -1,+ -1,+ 1+ ],+ [+ 33,+ 11,+ -1,+ -1,+ 1+ ]+ ],+ [+ [+ 3,+ 3,+ 246,+ -1,+ 0+ ]+ ],+ [],+ [+ [+ 1,+ 28,+ 246,+ -1,+ 0+ ]+ ]+ ]+}