fix(cmux-tui-core): set-layout-sizes takes a value only as exactly one pair and refuses a non-finite ratio; tests and docs (#34928 review follow-ups)

Merged
LA
2d ago
+279-23

Summary

Follow-ups from the review of #34928 (set-layout-sizes, merged), points A to E of "Review (claude-reviewer-rds-batch): SHIP at ca012e6b6f5". No app path sends the command yet (STATUS 11385), so nothing a person sees changes.

  • A. A value is exactly one pair. LayoutSizeWire keeps its two struct variants, now with #[serde(untagged, deny_unknown_fields)] on the enum. A value with both {split, ratio} and {pane, width}, or with any other field, is refused as a malformed request (bad request: ..., no error_code). Before, it decoded as a ratio, and the width was dropped silently, so the command answered ok:true for a half-applied value. An array value stays refused: serde gives untagged struct variants no sequence form. (My first version used newtypes over structs, which accept arrays; the review found it.)
  • B. A NaN ratio is refused. An in-process caller of Mux::set_layout_sizes_in_transaction_checked_as with a NaN ratio got layout-sizes-not-persisted (the clamp keeps a NaN, and the store cannot persist one; JSON cannot carry a NaN). Now it gets LayoutSizesError::NanRatio (invalid-argument). An infinite ratio (JSON 1e39 reads as f32 infinity) clamps to 0.95, as set-split-ratio clamps it, which keeps commands.md's "same clamping and ranges". (My first version refused infinity too; the review found it.)
  • C. Tests for the paths that had none: the ratio arm with the implied width from the batch's own earlier width, two screens, a batch of the current sizes (no change, no event), exactly one layout-changed event with the transaction echo, the capability in identify, a ratio value on the wire, and the refused shapes (both pairs, an array) with their bad request error.
  • D. Docs. events.md lists set-layout-sizes among the commands whose transaction the layout-changed event echoes. commands.md states the strict value shape.
  • E. LayoutSizeWire and its From impl move from server.rs to server/cmd_panes.rs (server.rs 3022 -> 3006 lines; still over its warn-only ceiling of 2978). The Command field keeps the type name, so check-sdk-schema.py maps it as before.

Testing

Focused commands: ./scripts/verify-cmux-tui-hosted.sh --filter layout_sizes and --filter a_non_finite_ratio_on_a_tree_split_is_refused (Linux test (linux)).

Compile: fleet job ccc2b1a688d28cedf0989108 at the head d64337c60b8: CmuxNext, app and cmux-tui passed (also 3d21132e0b1438b79e4e91d9 at d80a3c7f088 and 6817893c5323186f269cdb2d at 6002a223237).

Observed / Not run

  • Observed: the hosted runs, the schema and binding checks, and the fleet compile above. At the head lint (linux) passed. Before the feat merge it was red only on base findings: cmux-cloud-environment/src/lib.rs:262 (from #35133, fixed on feat by #35222) and the panic ratchet cmux-tui indexing_slicing 841 > 831 (all hits in crates/cmux-tui/src). clippy (changed cmux-tui packages) is red on crates/cmux-tui/src/cloud_environment.rs:22 (base); it checked cmux-tui-core with no error.
  • Not run: macOS execution of the focused tests; the app side (KEYS owner).

Changelog

none

Proof

No capture: daemon command only; no app path sends it yet.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Implements the review follow-ups for set-layout-sizes from #34928 and #35261: a value must be exactly one pair, and a non-finite ratio is refused. No app path sends the command yet, so nothing a person sees changes.

  • A value with both {split, ratio} and {pane, width}, any other field, or an array is refused as malformed; previously it decoded as a ratio and silently dropped other fields.
  • In-process callers get LayoutSizesError::NanRatio (invalid-argument) for a NaN ratio; an infinite ratio clamps to 0.95, matching set-split-ratio.
  • LayoutSizeWire moves from server.rs to server/cmd_panes.rs.
  • commands.md documents the strict value shape and events.md lists set-layout-sizes among commands whose transaction the layout-changed event echoes.