Skip to content

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

feat(mcp): lower resize_session's minimum width from 80 to 40 columns

Jack Rudenko75945c6513d5
diff --git a/ai-docs/architecture/mcp-sessions.md b/ai-docs/architecture/mcp-sessions.md
index c8979f22..b517cd5b 100644
--- a/ai-docs/architecture/mcp-sessions.md
+++ b/ai-docs/architecture/mcp-sessions.md
@@ -343,7 +343,7 @@ what a caller cannot see from the model id.
answers the session's current screen `{seq, cols, rows, cursor, lines, final, spans?}` (160×50 at
launch), or `{unchanged:true, seq, final}` when `since_seq` is still current — a memory read, meant
for polling at about 1 Hz. `resize_session` answers `{session_id, cols, rows, changed, seq,
-pending?}`: the size actually set after clamping to 80–9999 × 24–9999 and at most 4 000 000 cells, and the screen `seq` once the
+pending?}`: the size actually set after clamping to 40–9999 × 24–9999 and at most 4 000 000 cells, and the screen `seq` once the
redraw at that size has landed, so a capture with that `since_seq` already sees it. Their errors
are a JSON `ContractError`; `resize` is the only verb that emits the two codes it added,
`resize_unsupported` (the magmux has no `resize` op) and `delivery_unavailable` (magmux refused, or
diff --git a/ai-docs/architecture/pane-session.md b/ai-docs/architecture/pane-session.md
index ab28b435..2addc227 100644
--- a/ai-docs/architecture/pane-session.md
+++ b/ai-docs/architecture/pane-session.md
@@ -709,10 +709,26 @@ inline 400 and the slot is FAILED `api_error`.
**The size is the viewer's, not ours.** Every pane used to be born 160×50 and stay there, so a
docked viewer either showed empty rows below the screen or cut every line. 160×50 is now only the
launch default (`pane/pane-size.ts`); `resize_session` and `team(mode:"resize")` set it at any time,
-mid-turn included, clamped to cols 80–9999 × rows 24–9999 and at most 4 000 000 cells. The floor is
-claudish's and is not arbitrary: at 80 columns every closed-list dialog marker still fits one row's
-width, and 24 rows still hold a full permission or trust dialog, so boot and blocked-screen
-detection keep working. The ceiling is magmux's own (`mux/size.go`), so a clamped size can never
+mid-turn included, clamped to cols 40–9999 × rows 24–9999 and at most 4 000 000 cells. The floor is
+claudish's and is measured, not arbitrary. It was 80, the width at which every closed-list marker
+still fit one row. MTL-140 lowered it to 40 on real Claude Code 2.1.304 screens in magmux 0.18.0
+(`size-40x24-*`):
+
+- magmux's gate still answers `dialog:permission` (Write and Bash) and `dialog:question`, a ready
+ empty box, and `box_not_empty` for a typed line. Claude Code shortens what it prints in a narrow
+ dialog (`Do you want to create hello.txt?`, not the path), so the runtime markers stay on one row.
+- The gate's `dismissable` drops for the question dialog, whose footer wraps as
+ `Enter to select · ↑/↓ to navigate · Esc` / `to cancel`, so magmux's one-row `Esc to cancel`
+ check fails. claudish never reads that flag: it sends Escape itself from its `QUESTION` or
+ `PERMISSION` phase.
+- A boot marker such as `Is this a project you created or one you trust` (46 characters) cannot
+ fit one 40-column row, so magmux's per-row marker table misses it. claudish names it from the
+ flattened screen (`nameBootScreen`), which is the path `bootBlock` takes when the gate has no
+ boot kind. Not captured live at 40 columns: the capturing account trusts `/`, so no trust
+ prompt appears.
+- 24 rows still hold the tallest captured dialog (Bash permission, rows 5–22).
+
+The ceiling is magmux's own (`mux/size.go`), so a clamped size can never
earn its `too_small`/`too_large`: the `resize` op refuses a side over 10 000, but the launch size it
parses from `COLUMNS`/`LINES` is EXCLUSIVE of 10 000, and a size requested while the pane is
starting goes through those variables, so 9 999 is the largest side valid on both paths; the
@@ -757,7 +773,7 @@ as `since_seq` never reads a pre-resize frame as current.
at other widths its checks are width-proof: echo prefixes are `min(40, cols − 4)` long and compared
against box text with row breaks removed, dialog markers match the dialog region joined into one
string, and the working row tolerates a wrapped tail. They are validated on real Claude Code screens
-captured at 80, 120 and 250 columns; `locateBox` also at 350 and 500 (`box-locate.test.ts`). A
+captured at 40, 80, 120 and 250 columns; `locateBox` also at 350 and 500 (`box-locate.test.ts`). A
resize redraw moves the above-box region, which only DELAYS settle (it restarts its quiet clocks)
and never completes it; during the redraw the cursor can be stale for a frame, and the answer for
that frame is "box not located", an unknown, never a wrong box. A resize during an admission only
diff --git a/docs/usage/magmux.md b/docs/usage/magmux.md
index bb3da582..f8650bca 100644
--- a/docs/usage/magmux.md
+++ b/docs/usage/magmux.md
@@ -90,7 +90,7 @@ has finished, and closes the pane when the slot or session ends.
A capture carries a `seq` that grows with every visible change; pass it back as `since_seq` and an
unchanged screen answers `{unchanged: true}`, so polling about once a second is cheap.
-A pane starts at 160×50. A viewer can resize it at any time (cols 80–9999, rows 24–9999,
+A pane starts at 160×50. A viewer can resize it at any time (cols 40–9999, rows 24–9999,
at most 4 000 000 cells, clamped);
the next capture carries the new `cols`/`rows`. Resizing needs a magmux that ships the `resize`
verb (MIN_MAGMUX_VERSION); an older magmux answers `resize_unsupported` and the pane stays 160×50.
diff --git a/docs/usage/mcp-server.md b/docs/usage/mcp-server.md
index 1adf1b75..32a8342e 100644
--- a/docs/usage/mcp-server.md
+++ b/docs/usage/mcp-server.md
@@ -451,7 +451,7 @@ Code's input box and stopped its turns from ending. `list_sessions` and
**Parameters:**
- `session_id` (required) - Session ID from `create_session`
-- `cols` (required) - Columns, an integer; clamped to 80–9999
+- `cols` (required) - Columns, an integer; clamped to 40–9999
- `rows` (required) - Rows, an integer; clamped to 24–9999, then lowered so that `cols × rows` is at
most 4 000 000 (magmux's own limits; 9999 columns leave 400 rows)
diff --git a/packages/cli/src/mcp-server.ts b/packages/cli/src/mcp-server.ts
index b096d036..6cbb14a2 100644
--- a/packages/cli/src/mcp-server.ts
+++ b/packages/cli/src/mcp-server.ts
@@ -1498,7 +1498,7 @@ function defineTools(sessionManager: SessionManager, nested: boolean): ToolDefin
cols: {
type: "integer",
description:
- "For 'resize' (required): the terminal width in columns, clamped to 80–9999. The " +
+ "For 'resize' (required): the terminal width in columns, clamped to 40–9999. The " +
"answer {run_id, path, slot, cols, rows, changed, seq} reports the size set.",
},
rows: {
@@ -2308,7 +2308,8 @@ function defineTools(sessionManager: SessionManager, nested: boolean): ToolDefin
description:
"Set a session's terminal size: the child gets a real SIGWINCH and Claude Code reflows. " +
"Allowed at any time, mid-turn included; the last call wins. The size is clamped to " +
- "cols 80–9999, rows 24–9999 and at most 4 000 000 cells (magmux's limits); the answer " +
+ "cols 40–9999, rows 24–9999 and at most 4 000 000 cells (claudish's floor, magmux's " +
+ "ceiling); the answer " +
"{session_id, cols, rows, changed, seq, pending?} reports the size set. `seq` is the screen's seq after the resize: the next capture_session " +
"shows the new cols/rows. `changed:false` = already that size. `pending:true` = the pane " +
"is starting or its socket is reconnecting; the size is applied then. A finished session " +
@@ -2318,7 +2319,7 @@ function defineTools(sessionManager: SessionManager, nested: boolean): ToolDefin
type: "object",
properties: {
session_id: { type: "string", description: "Session ID from create_session" },
- cols: { type: "integer", description: "Terminal width in columns (clamped to 80–9999)" },
+ cols: { type: "integer", description: "Terminal width in columns (clamped to 40–9999)" },
rows: {
type: "integer",
description: "Terminal height in rows (clamped to 24–9999 and 4 000 000 cells)",
diff --git a/packages/cli/src/pane/contract.ts b/packages/cli/src/pane/contract.ts
index fdf65a1b..b5edb257 100644
--- a/packages/cli/src/pane/contract.ts
+++ b/packages/cli/src/pane/contract.ts
@@ -262,7 +262,7 @@ export interface CaptureUnchanged {
}
/**
- * F — `resize_session`. `cols`/`rows` are the size SET (the request clamped to cols 80–9999,
+ * F — `resize_session`. `cols`/`rows` are the size SET (the request clamped to cols 40–9999,
* rows 24–9999 and at most 4 000 000 cells, magmux's limits: `clampPaneSize`); `changed` = the pane's size moved; `seq` = the screen's seq after the
* resize (the first capture at the new size once `changed`). `pending: true` = the socket
* is reconnecting (or the pane is still starting): the size is stored and applied on the
diff --git a/packages/cli/src/pane/pane-size.ts b/packages/cli/src/pane/pane-size.ts
index f83f2d44..c1319a6d 100644
--- a/packages/cli/src/pane/pane-size.ts
+++ b/packages/cli/src/pane/pane-size.ts
@@ -17,16 +17,19 @@
* - the product: `maxScreenCells` = 4 000 000. When `cols × rows` exceeds it, `rows` drops to
* `floor(4 000 000 / cols)`, so a clamped size never earns magmux's `too_large`.
*
- * The floor is claudish's (plan review H1, L4): at 80 columns every closed-list dialog marker
- * the classifier matches still fits one row, and 24 rows hold a whole permission or trust
- * dialog. A smaller screen would turn a dialog into "no input box, no dialog" — an honest
- * unknown that never settles.
+ * The floor is claudish's (MTL-140). At 40 columns, real Claude Code 2.1.304 screens
+ * (`size-40x24-*`) still give magmux's gate `dialog:permission` and `dialog:question`, a
+ * ready empty box and a located box; the classifier matches every marker against the
+ * dialog region flattened into one string, so a marker wrapped across rows still names its
+ * dialog. 24 rows still hold the tallest captured dialog (Bash permission, rows 5–22).
+ * A smaller screen would turn a dialog into "no input box, no dialog": an honest unknown
+ * that never settles.
*/
export const DEFAULT_PANE_COLS = 160;
export const DEFAULT_PANE_ROWS = 50;
-export const MIN_PANE_COLS = 80;
+export const MIN_PANE_COLS = 40;
export const MAX_PANE_COLS = 9_999;
export const MIN_PANE_ROWS = 24;
export const MAX_PANE_ROWS = 9_999;