Repository navigation
Enforce divider range for default splits and drifted dividers - #169
Conversation
Two follow-ups to #167's dividerPositionRange contract: - A nil initialDividerPosition fell through to the internal 0.5 fallback, bypassing a configured range that excludes 0.5. The default is now clamped exactly like an explicit position. - syncPosition compared a pre-clamped current ratio, so a divider that physically drifted outside the range (non-drag AppKit resize) satisfied the early return and stayed out of range. The comparison now uses the raw pixel ratio so the re-assert path restores the model position.
📝 WalkthroughWalkthroughDivider initialization now respects configured bounds, while synchronization corrects physical divider drift outside those bounds without changing the stored model position. ChangesDivider range correction
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 keeps split dividers inside the configured range.
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "Enforce divider range for default splits..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/Bonsplit/Public/BonsplitController.swift`:
- Around line 601-608: Update the movingTab split path to pass the normalized
divider position into splitPaneWithTab, using
normalizedInitialDividerPosition(_:) before the call, so configured
dividerPositionRange is enforced instead of relying on the internal 0.5 default.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3d993cd4-ae76-4fcc-bed9-446217a5ad17
📒 Files selected for processing (4)
Sources/Bonsplit/Internal/Views/SplitContainerView.swiftSources/Bonsplit/Public/BonsplitController.swiftTests/BonsplitTests/BonsplitTests.swiftTests/BonsplitTests/EmbeddedConfigurationTests.swift
Follow-up to manaflow-ai#169: the movingTab overload called splitPaneWithTab without an initialDividerPosition, so the internal 0.5 default bypassed a configured dividerPositionRange that excludes it. Forward the clamped default like the tab-creating overloads.
Addresses the two remaining CodeRabbit findings on #167:
normalizedInitialDividerPositionnow clamps the implicit 0.5 default intodividerPositionRangeinstead of passing nil through to the internal hardcoded fallback.syncPositionnow compares the rawcurrentDividerPixels / availableSizeratio, so a divider that physically drifted outside the configured range (non-drag AppKit resize) is re-asserted to the model position instead of early-returning.Both fixes verified red/green:
testDefaultSplitPositionRespectsConfiguredDividerRangefails at 0.5 andtestSyncRestoresDividerThatDriftedOutsideConfiguredRangefails at 0.2 without the fixes. Full suite: 184/184 pass.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Enforces
dividerPositionRangefor default split position and restores dividers that drift outside the range after non-drag resizes. Prevents bypassing the configured range and keeps the view in sync with the model.dividerPositionRangeinnormalizedInitialDividerPosition.syncPosition, compare the raw ratio (currentDividerPixels / availableSize) and re-assert the clamped model position when the divider drifts out of range.Written for commit 4b46851. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests