Repository navigation
[CTX-1483] feat(ui): default new panels to Spiral layout (#2571) - #2582
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 34 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ad74e7c to
f200ce8
Compare
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review verdict — guard cron (agent: bitty-guard-cron, not the implementer)
Verdict: APPROVE (mergeable) — deliberate owner-facing default change, fully pinned by tests, no invariant regressions found.
Checks I ran and observed:
- CI on exact head SHA
f200ce897a5718ebcd9ace02f4ed52531b59e6b1: 18 pass / 0 fail / 0 pending / 2 skipping. IncludesQuality gates (1)+(2),MSRV 1.85 check,Linux Wayland,Linux X11 (xvfb),Windows check and test,macOS ARM64 check and test,Supply chain,Analyze (rust). - Read the whole patch (
git diff origin/main...pull/2582/head, 8 files / +429 −57):#[default]moves fromPanelLayoutMode::BalancedtoSpiral; the enum keeps all four variants, soBalanced/Dwindle/BisectLargestremain reachable throughRuntimeConfig::panel_layout_modeandRuntime::set_panel_layout_mode. An explicit config value still wins (explicit_config_panel_layout_mode_wins_over_spiral_default).- Doc comments on
RuntimeConfig::panel_layout_modeandPanelLayoutModeare rewritten to the new default and keep the "move-to-workspace always bisects" carve-out (CTX-0964/#1698) — that behaviour is not silently changed. layout_focus.rs/workspaces.rschanges are the spiral continuation bookkeeping (phase reset on close and on focus leaving the creation chain); the gap-aware 10x4 minimum (splittable_axis/splittable_rect) is preserved, which is the invariant I most wanted to see unchanged.- Evidence: new golden
tiling-2571-default-spiral.svgplus an eight-press spiral test at 160x64 asserting all nine panes stay ≥ 10x4 and phases cycle0,1,2,3twice; app-levelMod+npath (chrome_keys.rs) covered bychrome_new_panel_default_eight_times_spirals_and_resets_phase.
- Atomicity/UX rules: no direct
LayoutTreemutation added (still routes through the command/new_panelpath), no new public API, no renderer or hot-path surface touched — consistent with UX-INV expectations for a layout-policy default. CHANGELOG.mdupdated underUnreleased.
Accepted residual risk (from the PR body, confirmed by the diff): sub-160x64 windows may refuse the ninth pane once the 10x4 minimum cannot be met — that is the preserved minimum contract, not a regression.
Follow-up owed outside this PR (cross-repo, correctly not bundled): bitty-terminal-docs (reference/configuration-options.md, specifications/workspace-compositor.md entry 18, CHANGELOG.md) and bitty-manual (en/api/panel-workspace.md, en/getting-started/quickstart.md, en/configuration/workspaces-panels.md, en/configuration/actions-catalog.md) still describe Balanced as the 0.0.27 default. Tracked for the guard closeout, not a merge blocker.
Note: CodeRabbit reports pass with "Review rate limited" — not an actual review; this comment is the independent verdict.
f200ce8 to
12fdc13
Compare
Change the owner-facing PanelLayoutMode default from Balanced to Spiral for fresh configs and Mod+n. Balanced, Dwindle, and BisectLargest stay explicit opt-ins through RuntimeConfig and the runtime setter; an explicit config value still wins. Review follow-up (#2582): when the focused Spiral slot can no longer host two 10x4 panes, fall back deterministically to the largest-area Balanced target with a reset chain and one bounded warning, so Mod+n keeps the 0.0.27 capacity on normal 80x24 and 120x40 windows instead of silently dropping. Only the universal gap-aware 10x4 minimum still refuses. Preserve gap-aware 10x4 minimums, focus/close ordering, workspace IDs, and spiral phase reset on close/focus. Add fresh-config capacity tests at 80x24/120x40, eight-press Spiral coverage at 160x64, explicit-config override coverage, and a default-spiral tiling SVG golden. Update CHANGELOG.
Xuepoo
left a comment
There was a problem hiding this comment.
INDEPENDENT REVIEW (guard-tick, agent: guard-review-2582) - head 87ae2e7
Static review of the full diff (gh pr diff 2582), issue #2571, and the touched files read in context at 87ae2e7 (worktree at /tmp/bitty/repo2, no build run). Judgement below covers the default-change safety question, Spiral insert edge cases, the validate-then-commit funnel, hardcoded geometry, MSRV 1.85, and whether the golden proves the shipped default.
Findings
-
HIGH —
crates/bitty-terminal/src/chrome_keys.rs:1622-1645(withcrates/bitty-runtime/src/runtime/layout_focus.rs:2972-2976) — the new default dropsMod+nwhen focus sits on a float or pinned pane.panel_split_plan_forresolves the focused rect with.unwrap_or(self.container), so aViewIdthat is not in the live layout silently inherits the whole container. That rect is splittable, so the Spiral arm returnstarget = focused(the float/pin) with a green finalsplittable_rectcheck;apply_new_leafthen callssplit_focused_leaf, which only walks the layout tree (chrome_keys.rs:616-650) and returnsfalsefor an absent target, so the press ends inwarning: keymap new_panel found no target pane — ignoringand no pane. Under the 0.0.27Balanceddefault this case worked because the plan ignored focus and split the largest tiled leaf. The state is real and already exercised:set_focusexplicitly accepts pinned/float ids outside the tree (layout_focus.rs:2629-2636, CTX-1077/CTX-1147), andcrates/bitty-terminal/src/tests.rs:11560-11592reaches it (two tiles, pane 2 detached to a float, float focused while tile 1 survives). CTX-1338 fixed exactly this shape only forleaf_count() == 0(chrome_keys.rs:1617-1620); the non-empty case is now the default-mode regression. Suggested fix: treat "focused leaf has no allocation in the live layout" like the exhausted-slot case — fall back tolargest_area_leaf(the existing deterministic path) — and add one test for float-focused and pinned-focusedMod+n. -
MEDIUM —
crates/bitty-runtime/src/runtime/layout_focus.rs:3007-3011andcrates/bitty-terminal/src/chrome_keys.rs:1634— the fallback is "largest-area", not "largest feasible", so the documented contract is wrong. The fallback takeslargest_area_leaf(&allocations)?and thensplittable_axis(rect, gap_in)?; it never retries a smaller leaf. A tree can hold a largest leaf that is unsplittable on both axes (e.g. 20x8 atgaps_in = 0, area 160) next to a smaller but splittable one (30x5, area 150, splits horizontally into 15+15), and the plan then returnsNonewhile a usable target exists. The inline comment "Nonehere now means no leaf can host two usable panes" (line 3007-3008), thePanelSplitPlandoc ("largest feasibleBalancedtarget"), and the keymap message "falling back to the largest flexible slot" all assert a guarantee the code does not implement. Either filter bysplittable_axis(...).is_some()over allocations in area order, or soften the wording to "largest-area leaf; if that leaf cannot host two panes the chord is refused". -
MEDIUM —
crates/bitty-runtime/src/runtime/layout_focus.rs:3730—balanced_plan_accounts_for_inner_gapsno longer testsBalanced. The test still buildsRuntimeConfig { gaps_in: 1, ..RuntimeConfig::default() }but never callsset_panel_layout_mode(Balanced), so after the default flip it exercises the Spiral arm (focused leaf,splittable_axis) under a name and comment that promise the Balanced gap-aware contract. This PR audited the other Balanced-pinned tests (eight_balanced_new_panels_keep_usable_geometry,chrome_new_panel_eight_times_...,runtime_plan_matches_balanced_evidence_builderall got the explicit opt-in) and missed this one. Addrt.set_panel_layout_mode(PanelLayoutMode::Balanced)(or rename and keep a Spiral twin), otherwise a regression in Balanced'sgaps_inhandling would now pass. -
MEDIUM —
CHANGELOG.md:37-38— the shipped note promises an opt-out users cannot reach.panel_layout_modeis not part of any user config surface: it has no serde/TOML field and thelayouttable incrates/bitty-config/src/file.rs:1804-1860accepts onlygaps_in,gaps_out,resize_step. So "BalancedandDwindleremain explicit opt-ins throughRuntimeConfig::panel_layout_mode/Runtime::set_panel_layout_mode" describes compile-time Rust APIs, and 0.0.27 users get an unconditional behavior change with no way back short of editing source. The PR body is honest about this ("no TOML/Lua selector exists"), the CHANGELOG as written is not; #2571's acceptance line "existing configs that explicitly select Balanced are unchanged" is also vacuous at the config layer. Related, lower impact:explicit_config_panel_layout_mode_wins_over_spiral_default(layout_focus.rs:4136-4156) proves the precedence with a Rust struct literal, which is the only thing that can set the field today — fine as a seam test, but it does not prove any parsed user config survives. -
LOW —
crates/bitty-runtime/tests/tiling_visual_evidence.rs:560-619— the new golden proves the plan and the solver, not the commit path. The tree is assembled by the test-localsplit()(line 391) and the chain is advanced by a manualnote_panel_split_created, so the artifact would still match ifapply_new_leaf/the keymap arm stopped committingplan.target/plan.spiral_phase. Closure comes fromchrome_new_panel_default_eight_times_spirals_and_resets_phase(chrome_keys.rs:5872-5930), which does drive the real action and asserts the same phase vector, so this is acceptable but worth stating; there is also no golden for the 80x24 fallback path, which is now the common default case. -
LOW —
crates/bitty-runtime/src/runtime/layout_focus.rs:2947-2950—panel_split_axis(focused)can now return the axis of a different leaf. After the fallback it returnsplan.axisfor the largest-area leaf while the caller passedfocused, contradicting the doc on line 2961-2963 ("the axis and target can never disagree") for any caller that pairs the axis getter withfocused. No production caller does that today (only this module and tests), so it is an API-shape hazard rather than a bug; document that the pair is only valid throughpanel_split_plan. -
LOW —
crates/bitty-terminal/src/chrome_keys.rs:1624and:1634— new user-facing diagnostics hardcode "10x4". The real bounds areMIN_PANE_COLS/MIN_PANE_ROWS(crates/bitty-ui/src/layout.rs:1807-1813). If those constants move, the operator-facing text lies. Format them from the constants, or drop the numbers from the message. -
LOW —
crates/bitty-terminal/src/chrome_keys.rs:1628-1636— the fallback notice is per-press and pre-commit. It is emitted on every fallback press (three times in an eight-press 80x24 run), not "one bounded warning" as the comment and CHANGELOG say, and it fires before the commit, so a press that then fails inapply_new_leaf(appearance validation at line 1245, missing target at 1253) still announces a fallback that never happened. Log after the commit with the created id, or gate on a once-per-chain latch.
Verified as sound
- MSRV 1.85: no let-chains (
if let/while let+&&) in any touched file; workspacerust-version = "1.85"/ edition 2024, and theMSRV 1.85 checkjob is green at this head. - Default change is a pure enum-attribute flip (
config.rs:1123/1128-1129); nothing persists, snapshots, or re-serializesPanelLayoutMode, so there is no silent migration or stale on-disk value — the only effect is the compiled default reached throughRuntimeConfig::default()(config.rs:1212,1325). No stale "Balanced is the default" comments remain in tree (only the historical 0.0.27 CHANGELOG entry). - Insert edge cases hold for the in-tree cases: single leaf -> phase 0, right split, no fallback; odd presses (phase 2/3) ->
place_new_firstwith the fresh pane focused bycommit_new_leaf; tiny geometry -> refusal through the universal gap-aware 10x4 minimum; phase reset on close/focus-off-chain unchanged. - Atomicity preserved: the plan is read-only (
panel_split_plannever mutates), and the commit still clones the layout, validatesvalidate_new_view_appearance, then installs (chrome_keys.rs:1235-1255). The fallback rides the same funnel; there is exactly onenew_panelcommit path (keymap arm ->apply_new_leaf), so no second writer was introduced. - No new production geometry constants: the 160x64 / 80x24 / 120x40 values are test-only;
MIN_PANE_COLS/MIN_PANE_ROWSremain compile-time constants (unchanged by this PR) and are referenced symbolically in the new assertions. - The capacity tests are not tautological: they assert
leaf_count == press + 1after every press,fallbacks > 0, and parity with an explicit-Balanced run, so a silently dropped chord fails them.
VERDICT: NEEDS-FIX
Change the owner-facing PanelLayoutMode default from Balanced to Spiral for fresh configs and Mod+n. Balanced, Dwindle, and BisectLargest stay explicit opt-ins through RuntimeConfig and the runtime setter; an explicit config value still wins. Review follow-up (#2582): when the focused Spiral slot can no longer host two 10x4 panes, fall back deterministically to the largest-area Balanced target with a reset chain and one bounded warning, so Mod+n keeps the 0.0.27 capacity on normal 80x24 and 120x40 windows instead of silently dropping. Only the universal gap-aware 10x4 minimum still refuses. Preserve gap-aware 10x4 minimums, focus/close ordering, workspace IDs, and spiral phase reset on close/focus. Add fresh-config capacity tests at 80x24/120x40, eight-press Spiral coverage at 160x64, explicit-config override coverage, and a default-spiral tiling SVG golden. Update CHANGELOG.
704323f to
f627d4e
Compare
Xuepoo
left a comment
There was a problem hiding this comment.
Guard merge verdict (cron tick, agent: bitty-guard-cron — not the implementer)
Prior independent review stands: "INDEPENDENT REVIEW (guard-tick, agent: guard-review-2582) - head 87ae2e7" (2026-10-23T23:02:23Z) plus the earlier APPROVE verdict at 20:54:36Z.
Head delta verified: 87ae2e7f..f627d4ec = six main-integration commits plus the branch's
own head f627d4ec (merge of main); the reviewed layout logic is unchanged.
Checks on head f627d4ec: 18 SUCCESS / 2 SKIPPED / 0 fail (no pending).
Diff scope: 8 files, +636/-75 — PanelLayoutMode default Spiral, deterministic Balanced
fallback, new capacity/visual-evidence tests and SVG golden.
Pattern scan: no hardcoded host paths, no npm/npx/yarn, no new unsafe.
Close directive: Closes #2571.
Merging as --admin --squash --delete-branch; the branch trails main by a few merges and
strict up-to-date protection would otherwise block a normal merge.
Priority: P1 | Area: ui | Labels: feat,P1,area:ui | Milestone: v0.0.28 | RFC: n/a | Task: CTX-1483
Summary
PanelLayoutModedefault fromBalancedtoSpiralfor fresh configs and new panels (Mod+n/new_panel).Balanced,Dwindle, andBisectLargestas explicit opt-ins through the existing seam (RuntimeConfig::panel_layout_modeandRuntime::set_panel_layout_mode). An explicit config value still wins;workspace.layoutstill selects the workspaceLayoutProviderand is untouched.Balancedtarget (first in solver order on ties) withplace_new_first = falseand a reset Spiral chain.Mod+nno longer silently drops; the keymap arm logs one bounded warning when the fallback is used.splittable_axis/splittable_rect), deterministic focus/close ordering, workspace IDs, and the Spiral phase reset on close or focus leaving the creation chain.Balancedcoverage stays as an explicit opt-in, so both policies remain pinned.CHANGELOG.mdunderUnreleased.Behavior and remaining limit
gaps_in = 0) still refusesMod+nwith the minimum-size warning. No layout can satisfy the contract there.Test plan and results (scoped target,
CARGO_BUILD_JOBS=2)cargo fmt --all -- --check— clean.RUSTFLAGS="-D warnings" cargo clippy -p bitty-runtime -p bitty-terminal --all-targets --locked— exit 0, no warnings.cargo test -p bitty-runtime --lib --locked layout_focus— 19 passed, 0 failed.cargo test -p bitty-runtime --lib --locked workspaces::tests::move_bisects_largest_panel_by_default— 1 passed, 0 failed.cargo test -p bitty-runtime --test tiling_visual_evidence --locked— 5 passed, 0 failed.cargo test -p bitty-terminal --bin bitty --locked chrome_new_panel— 9 passed, 0 failed.New coverage highlights:
default_spiral_keeps_balanced_capacity_on_80x24anddefault_spiral_keeps_balanced_capacity_on_120x40: eight default presses land, every intermediate tree validates, every pane stays at or above 10x4, at least one Balanced fallback is used, and the final pane count matches explicit Balanced exactly.chrome_new_panel_default_spiral_keeps_capacity_on_80x24andchrome_new_panel_default_spiral_keeps_capacity_on_120x40: the same capacity contract through the appMod+naction, including the fallback plan and valid-partition assertions.default_spiral_eight_new_panels_keep_minimum_geometry_and_reset_phaseandchrome_new_panel_default_eight_times_spirals_and_resets_phase: the 160x64 pure-Spiral path (all nine panes >= 10x4, phases0,1,2,3twice, close/focus resets).explicit_config_panel_layout_mode_wins_over_spiral_default: an explicitRuntimeConfig::panel_layout_mode = Balancedkeeps its policy.issue_2571_default_spiral_eight_new_panels: renderstiling-2571-default-spiral.svgfrom the shipped plan.Docs delta (separate repos, intentionally not edited here)
bitty-terminal-docs:reference/configuration-options.md— "Adaptive new-panel policy" and the shipped-defaults bullet still callBalancedthe 0.0.27 default. Update both to Spiral in 0.0.28, document the deterministic largest-area Balanced fallback and the universal 10x4 refusal limit, keepBalanced/Dwindle/BisectLargestas runtime-only opt-ins, and advance the 0.0.27 version references.specifications/workspace-compositor.md— entry 18 (PanelLayoutMode::Balancedis the 0.0.27 default) and the shipped-slice non-claim list need the Spiral default, the fallback contract, the new capacity/evidence tests, and the Balanced test reclassified as an explicit opt-in.CHANGELOG.md— add the 0.0.28 default-Spiral entry including the fallback.bitty-manual:en/api/panel-workspace.md— note the Spiral default and fallback while keeping the runtime-only selector statement.en/getting-started/quickstart.md—Alt+nrow wording (Balanced largest-pane split→ Spiral clockwise placement).en/configuration/workspaces-panels.md— new-panel placement and adaptive insertion bullets (0.0.27 default is Balanced,splits the physically largest pane) and the runtime-only note; include the fallback and minimum-size limit.en/configuration/actions-catalog.md—new_panelrow behavior.Residual risk
Balancedthrough the runtime/config seam; no TOML/Lua selector exists (same as 0.0.27).Mod+nwith a diagnostic; that is the preserved minimum-size contract.Closes #2571