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)
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.
LayoutSizeWirekeeps 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: ..., noerror_code). Before, it decoded as a ratio, and the width was dropped silently, so the command answeredok:truefor 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_aswith a NaN ratio gotlayout-sizes-not-persisted(the clamp keeps a NaN, and the store cannot persist one; JSON cannot carry a NaN). Now it getsLayoutSizesError::NanRatio(invalid-argument). An infinite ratio (JSON1e39reads as f32 infinity) clamps to 0.95, asset-split-ratioclamps 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-changedevent with the transaction echo, the capability in identify, a ratio value on the wire, and the refused shapes (both pairs, an array) with theirbad requesterror. - D. Docs.
events.mdlistsset-layout-sizesamong the commands whosetransactionthelayout-changedevent echoes.commands.mdstates the strict value shape. - E.
LayoutSizeWireand itsFromimpl move fromserver.rstoserver/cmd_panes.rs(server.rs 3022 -> 3006 lines; still over its warn-only ceiling of 2978). TheCommandfield keeps the type name, socheck-sdk-schema.pymaps 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)).
-
Red at efe6dbf8b17 (
test/rds-batch-followups-red-never-merge), run https://github.com/manaflow-ai/cmux/actions/runs/41810867146:set_layout_sizes_applies_a_trade_whole_or_refuses_it_wholeFAILED (the both-pairs value was taken); 10 other tests passed. -
My first NaN test used a column split, where the implied-width check already refuses a NaN, so it passed before the fix and proved nothing. The tree-split test covers the path the review named: red at b19c8506508, run https://github.com/manaflow-ai/cmux/actions/runs/41813144619 FAILED; green at c7b04340dab, run https://github.com/manaflow-ai/cmux/actions/runs/41813156656.
-
Review of this PR (SHIP at c7b04340dab with should-dos): red at 20f0fa45e37 (
test/rds-batch-r2-red-never-merge; the array value accepted, an infinite ratio refused), run https://github.com/manaflow-ai/cmux/actions/runs/41821943619; fix at d80a3c7f088, run https://github.com/manaflow-ai/cmux/actions/runs/41821947239 (--filter layout_). -
Green at 6002a223237: runs https://github.com/manaflow-ai/cmux/actions/runs/41811365643 (
layout_sizes, 11 passed), https://github.com/manaflow-ai/cmux/actions/runs/41811373538 (the wire test), https://github.com/manaflow-ai/cmux/actions/runs/41811381409 (the capability test). -
python3 cmux-tui/scripts/check-sdk-schema.py: ok (290 commands).PATH=/usr/local/go/bin:$PATH python3 cmux-tui/bindings/codegen/generate.py --check: ok. -
At the head d64337c60b8 (feat e8ff27a312d merged so that
lint (linux)reaches this PR's crate; own-diff patch-id f97e5f1b4150 unchanged): run https://github.com/manaflow-ai/cmux/actions/runs/41825913708 (--filter layout):test (linux)passed, witha_nan_ratio_on_a_tree_split_is_refused_and_an_infinite_one_clampsandset_layout_sizes_applies_a_trade_whole_or_refuses_it_whole;lint (linux)passed.
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 ratchetcmux-tuiindexing_slicing 841 > 831 (all hits incrates/cmux-tui/src).clippy (changed cmux-tui packages)is red oncrates/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](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
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, matchingset-split-ratio. LayoutSizeWiremoves fromserver.rstoserver/cmd_panes.rs.commands.mddocuments the strict value shape andevents.mdlistsset-layout-sizesamong commands whosetransactionthelayout-changedevent echoes.