Skip to content

Fix split divider drag tracking during multi-split resize#89

Merged
austinywang merged 1 commit intomainfrom
fix-multi-split-divider-drag
Apr 6, 2026
Merged

Fix split divider drag tracking during multi-split resize#89
austinywang merged 1 commit intomainfrom
fix-multi-split-divider-drag

Conversation

@austinywang
Copy link
Copy Markdown

@austinywang austinywang commented Apr 6, 2026

Summary

  • make divider hit testing use the same expanded effective rect as the split view
  • treat divider boundary points as inside so drag tracking latches reliably
  • write divider position updates synchronously to avoid stale ratio replay during fast drags

Verification

  • consumed from cmux tagged Debug build during multi-split resize debugging

Notes

  • no local tests run

Summary by cubic

Fixes unreliable divider drag tracking during multi-split resizes. Expands the hit area and writes divider updates synchronously to prevent missed drags and snap-backs.

  • Bug Fixes
    • Match the divider’s expanded hit rect with the split view and treat boundary points as inside to latch drags reliably.
    • Update divider position synchronously (no deferred Task) to avoid stale ratio replays during fast drags.

Written for commit 0e7b0b8. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Improved divider hit-detection accuracy for more precise boundary recognition during interactive resizing.
    • Enhanced divider position updates to provide more responsive behavior during drag operations.

@austinywang austinywang merged commit b2788b1 into main Apr 6, 2026
5 of 6 checks passed
@austinywang austinywang deleted the fix-multi-split-divider-drag branch April 6, 2026 00:38
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a9a92517-389f-4e44-bea1-29f1f86c5294

📥 Commits

Reviewing files that changed from the base of the PR and between aff9f70 and 0e7b0b8.

📒 Files selected for processing (1)
  • Sources/Bonsplit/Internal/Views/SplitContainerView.swift

📝 Walkthrough

Walkthrough

Modified hit-testing and state update logic in the split container divider handler. Added an inclusive boundary check helper function, adjusted divider hit rect inset from -4 to -5 pixels, and replaced asynchronous state updates with synchronous direct assignments in the drag delegate callback.

Changes

Cohort / File(s) Summary
Divider Hit-Testing & State Management
Sources/Bonsplit/Internal/Views/SplitContainerView.swift
Added dividerHitRectContains(_:rect:) helper for inclusive boundary checks using explicit min/max comparisons. Expanded divider hit rect inset to -5 and switched to custom hit-test function. Removed async Task wrapper around divider position persistence; state updates now execute synchronously in delegate callback. Adjusted DEBUG logging placement accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ A rabbit hops with precision keen,
Where boundaries blur at the in-between.
No async dance, just sync and true,
Five pixels inset, the cleaner view.
Hit-testing refined, the divider now gleams! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-multi-split-divider-drag

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

You’re at about 94% of the monthly review limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR fixes multi-split divider drag tracking with three coordinated changes: expanding the hit rect from -4 to -5 to match the existing effectiveRect/additionalEffectiveRect delegate expansion, replacing NSRect.contains (exclusive max edge) with a custom inclusive comparison dividerHitRectContains(_:rect:) to latch boundary-point drags, and removing a Task { @MainActor in } wrapper so divider position writes happen synchronously on the already-main-thread delegate callback — preventing stale ratio replays during fast drags.

Confidence Score: 5/5

Safe to merge — all three fixes are narrowly targeted and consistent with the surrounding delegate pattern.

No P0/P1 issues found. The -4→-5 alignment closes a hit-area mismatch between checkDividerDrag and the two AppKit delegate methods (effectiveRect/additionalEffectiveRect) that already used -5. The inclusive boundary check (>=/<=) directly fixes the known AppKit edge case where a point reported exactly on maxX/maxY would fail NSRect.contains. Removing the Task { @mainactor in } wrapper is safe because NSSplitViewDelegate callbacks always execute on the main thread; the isSyncingProgrammatically guard already prevents re-entrant feedback loops, and synchronous writes are consistent with the non-drag path that already calls syncPosition and onGeometryChange? synchronously.

No files require special attention.

Important Files Changed

Filename Overview
Sources/Bonsplit/Internal/Views/SplitContainerView.swift Three targeted fixes: hit rect aligned to -5 expansion, inclusive boundary hit testing, synchronous divider position writes

Sequence Diagram

sequenceDiagram
    participant User as User (Mouse)
    participant AppKit as NSSplitView (AppKit)
    participant Delegate as SplitCoordinator
    participant State as splitState

    User->>AppKit: leftMouseDown / leftMouseDragged
    AppKit->>Delegate: splitViewWillResizeSubviews
    Delegate->>Delegate: checkDividerDrag(event)<br/>hitRect = dividerRect.insetBy(-5,-5)<br/>dividerHitRectContains → inclusive boundary
    Delegate-->>Delegate: isDragging = true
    AppKit->>Delegate: splitViewDidResizeSubviews
    Delegate->>Delegate: wasDragging = isDragging && leftDown
    Delegate->>State: splitState.dividerPosition = normalizedPosition (synchronous, main thread)
    Delegate->>Delegate: onGeometryChange?(wasDragging)
    User->>AppKit: leftMouseUp
    AppKit->>Delegate: splitViewDidResizeSubviews
    Delegate->>Delegate: leftDown=false → wasDragging=false, isDragging=false
    Delegate->>Delegate: syncPosition(statePosition) — re-assert model
Loading

Reviews (1): Last reviewed commit: "Fix split divider drag tracking during m..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant