Repository navigation
Route keyboard/menu equalize_splits through v2ProportionalEqualize so 3+ panes split evenly - #4400
Conversation
|
@mvanhorn is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdded ChangesProportional split equalization
Sequence Diagram(s)sequenceDiagram
participant TabManager
participant TerminalController
participant BonsplitController
participant ExternalTreeNode
TabManager->>TerminalController: equalizeSplitsProportionally(tabId, controller, fromExternal: true)
TerminalController->>ExternalTreeNode: traverse node (split/pane)
alt node is split
TerminalController->>BonsplitController: setDividerPosition(ratio, forSplit: uuid, fromExternal: true)
BonsplitController-->>TerminalController: Bool success
end
TerminalController-->>TabManager: EqualizeSplitsResult(foundSplit, allSucceeded)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 16 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (16 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR consolidates two divergent "equalize splits" code paths — the keyboard/menu path (which always set every divider to
Confidence Score: 5/5Safe to merge; the core algorithm change is correct and both call sites are properly unified through the shared helper. The leaf-proportional algorithm is mathematically correct for all tree shapes. Both call sites now go through the same static helper, eliminating the divergence that caused the 50/25/25 bug. The only finding is a minor ordering issue where Sources/TerminalController.swift — specifically the ordering of Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Keyboard Cmd+Ctrl+=] --> B[TabManager.equalizeSplits]
C[SwiftUI Menu / Command Palette] --> B
D[CLI: cmux rpc workspace.equalize_splits] --> E[v2WorkspaceEqualizeSplits]
B --> F[equalizeSplitsOnce\nfromExternal: true]
E --> G[equalizeSplitsProportionally\nfromExternal: true\norientationFilter: optional]
F --> H[TerminalController.equalizeSplitsProportionally static]
G --> H
H --> I{for each split node depth-first}
I --> J[count leaves left/right - position = leftLeaves / total]
J --> K[setDividerPosition]
K --> L[EqualizeSplitsResult: foundSplit / allSucceeded]
L --> M{caller}
M -->|TabManager checks didFullyEqualize| N[scheduleFollowUp if foundSplit]
M -->|v2 RPC| O[equalized: foundSplit]
Reviews (5): Last reviewed commit: "Clean equalize split leaf-count guard" | Re-trigger Greptile |
… 3+ panes split evenly Fixes manaflow-ai#4378
98d0740 to
1de4cd7
Compare
|
Good catch from Greptile -- the original push added the proportional helper but never wired it into the call site. Fixed in 1de4cd7: |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Resolved conflicts by keeping main's pane-resize extraction in TabManager.swift/TerminalControllerPaneResizeSupport.swift and porting the PR's equalize reroute into the new TabManager+EqualizeSplits.swift shape. Verification: - Verified TabManager+EqualizeSplits.swift now calls TerminalController.equalizeSplitsProportionally for the keyboard/menu/command-palette path. - Verified v2WorkspaceEqualizeSplits calls the same helper with fromExternal: true and preserves the orientationFilter parameter. - Verified no setDividerPosition(0.5, ...) call remains in the equalize path and no conflict markers remain. - Identified equalize-related tests in cmuxTests/ and tests/; local test/build execution was skipped per repo policy and the explicit no-xcodebuild/no-reload constraint.
Keep v2WorkspaceEqualizeSplits on the shared proportional helper while returning true when a matching split was found, matching the prior v2ProportionalEqualize response contract. The keyboard/menu path still uses didFullyEqualize so failed divider updates remain visible there. Verification: - Verified both v2 and TabManager equalize paths still call TerminalController.equalizeSplitsProportionally. - Verified no setDividerPosition(0.5, ...) or duplicate v2ProportionalEqualize/v2CountLeaves implementation remains. - Ran git diff --check only; no local build/test/reload per constraints.
Addresses low-priority Greptile feedback by removing the unreachable totalLeafCount > 0 check in the proportional equalize helper. Verification: - git diff --check passed. - Both TabManager+EqualizeSplits and v2WorkspaceEqualizeSplits still call TerminalController.equalizeSplitsProportionally. - No setDividerPosition(0.5, ...) calls remain in the equalize path.
|
@austinywang appreciate the merge. Lifting the recursive leaf-count walk into the shared helper makes equalize_splits behave consistently for 3+ panes instead of falling back to the older path. |
Summary
Extract the proportional algorithm. In
Sources/TerminalController.swiftaround lines 5141-5160,v2ProportionalEqualizealready implements the correct algorithm (recursive leaf-count walk → divider ratio). Lift the core loop into a shared helper (e.g.TerminalController.equalizeSplitsProportionally(in:)or a free function in a newEqualizeSplitsCore.swift) that takes a split tree root and applies the leaf-proportional divider for each node. Both call sites then go through the helper.Reroute the legacy call site. In
Sources/TabManager+EqualizeSplits.swift:47-79, replace the body ofequalizeSplits(in:controller:foundSplit:allSucceeded:)so instead of recursing with a hard-coded0.5, it invokes the new shared helper against the same split tree, threading the existingfoundSplit/allSucceededaccounting through. Leave the public signature and call sites untouched so the keyboard binding, SwiftUI menu, and command-palette path all keep working.Keep v2 path intact.
v2ProportionalEqualizecontinues to be the CLI RPC entry. After the helper extraction, both paths must call the same code. Confirm there is no diverging state (e.g. animation flag, controller routing) by reading the two callers side-by-side.No schema, no settings change. This is a pure layout-calculation fix; no persisted state, no CLI surface area changes.
Why this matters
cmux 0.64.7 has two equalize-splits code paths that disagree. The keyboard shortcut (default
Cmd+Ctrl+=) and SwiftUI menu route throughTabManager+EqualizeSplits.swift, which unconditionally callssetDividerPosition(0.5, ...)on every split. The v2 RPC path (cmux rpc workspace.equalize_splits) routes throughTerminalController.swift'sv2ProportionalEqualize, which counts leaves on each side of every split and sets the divider toleftLeafCount / (leftLeafCount + rightLeafCount).For any pane count that is not a power of two, the split tree is asymmetric (e.g. 3 panes =
A | (B | C)). The 0.5-per-split implementation then ships layout 50/25/25 instead of 33/33/33. The v2 RPC path gives correct 33/33/33. The bug is purely that the keyboard / menu / command-palette paths never adopted the v2 algorithm.Reporter (branch10480) verified both paths on the same workspace at cmux 0.64.7 and pinpointed the divergent files and line ranges.
Testing
A | (B | C), drag dividers to uneven sizes, pressCmd+Ctrl+=. Expected widths: 33/33/33 ± 1%. Today: 50/25/25.((A | B) | (C | D)). Expected: 25/25/25/25 (no regression — both algorithms agree on power-of-two trees).A | (B | (C | (D | E)))or similar deep right-chained tree, pressCmd+Ctrl+=. Expected: 20/20/20/20/20. Today: deeply skewed.A | (B / C)(vertical split inside right side). Expected: A occupies 1/3 width, B/C each occupy 1/3 width and 50% height of right column. Today: A occupies 50% width.cmux rpc workspace.equalize_splitson the same 3-pane workspace must continue to return{"equalized": true}with the same final layout the keyboard shortcut produces.Fixes #4378
AI was used for assistance.
Need help on this PR? Tag
@codesmithwith what you need.Summary by cubic
Routes the keyboard, menu, and command-palette “Equalize Splits” to the same leaf‑proportional algorithm as v2 RPC so 3+ panes split evenly. Fixes uneven layouts like 50/25/25 by setting dividers based on leaf counts.
Written for commit d2398b5. Summary will update on new commits. Review in cubic
Summary by CodeRabbit