Repository navigation
Fix horizontal tab insertion positions - #202
Conversation
📝 WalkthroughWalkthroughThe PR replaces SwiftUI tab drop handling with a native AppKit destination. It adds centralized tab and file drop handling, geometry-based insertion resolution, reorder notification changes, SwiftUI integration, and updated native drop coverage. ChangesTab-bar drag and drop
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DragSource
participant TabBarDropDestinationNSView
participant TabBarDropHandler
participant BonsplitController
DragSource->>TabBarDropDestinationNSView: Send tab or file drag
TabBarDropDestinationNSView->>TabBarDropHandler: Validate payload and insertion index
TabBarDropHandler->>BonsplitController: Reorder or move tab
TabBarDropDestinationNSView-->>DragSource: Return drag operation and clear indicator
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
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/Internal/Views/TabBarDropHandler.swift`:
- Around line 41-45: Update the hasTabTransfer branch in TabBarDropHandler to
return .move only when the transfer source pane differs from the destination
pane and onExternalTabDrop is non-nil; otherwise return an empty result. Add a
regression test covering a same-process transfer with no live drag state and no
external handler, asserting it is rejected.
🪄 Autofix
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 Plus
Run ID: 672e3528-41ff-4b04-beb9-f4f36747facd
📒 Files selected for processing (10)
Sources/Bonsplit/Internal/Views/TabBarDropDestinationNSView.swiftSources/Bonsplit/Internal/Views/TabBarDropDestinationView.swiftSources/Bonsplit/Internal/Views/TabBarDropHandler.swiftSources/Bonsplit/Internal/Views/TabBarView.swiftSources/Bonsplit/Internal/Views/TabDropIndexResolver.swiftSources/Bonsplit/Public/BonsplitController.swiftTests/BonsplitTests/BonsplitTests.swiftTests/BonsplitTests/TabBarDropHandlerTests.swiftTests/BonsplitTests/TabDropDelegateSamePaneFallbackTests.swiftTests/BonsplitTests/TabDropIndexResolverTests.swift
💤 Files with no reviewable changes (1)
- Tests/BonsplitTests/TabDropDelegateSamePaneFallbackTests.swift
|
Review follow-up:
Validation: 216 XCTest cases plus 7 Swift Testing cases pass on arm64 Swift, with no warnings observed. |
…-tab-insert # Conflicts: # Sources/Bonsplit/Internal/Views/TabBarView.swift
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Sources/Bonsplit/Internal/Views/TabBarView.swift (1)
1017-1028: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winKeep accepted targets visible in full-width tab mode.
When
isFullWidthTabModeis true,Sources/Bonsplit/Internal/Views/TabBarDropDestinationNSView.swiftresolves the right half of the selected tab toselectedIndex + 1because it uses the fullpane.tabs.countwith the selected tab’s frame.TabBarViewstores that index, but it omitsdropZoneAfterTabsin full-width mode and only renders the leading indicator for the visible tab. A valid cross-pane drop can therefore have no insertion indicator. Render an after-selected indicator for this slot, or reject the slot in full-width mode. Add a regression test for both sides of a full-width tab.Also applies to: 1157-1157
🤖 Prompt for 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. In `@Sources/Bonsplit/Internal/Views/TabBarView.swift` around lines 1017 - 1028, Update TabBarView’s full-width tab rendering to handle the accepted target index dropTargetIndex == selectedIndex + 1 by displaying the corresponding after-selected insertion indicator, or explicitly reject that slot before storing it. Preserve valid indicators for both sides of the selected tab and add regression coverage for drops on each side in full-width mode.
🤖 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.
Outside diff comments:
In `@Sources/Bonsplit/Internal/Views/TabBarView.swift`:
- Around line 1017-1028: Update TabBarView’s full-width tab rendering to handle
the accepted target index dropTargetIndex == selectedIndex + 1 by displaying the
corresponding after-selected insertion indicator, or explicitly reject that slot
before storing it. Preserve valid indicators for both sides of the selected tab
and add regression coverage for drops on each side in full-width mode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 835dfbab-b300-4b0c-8eea-e412f1450fb7
📒 Files selected for processing (7)
Sources/Bonsplit/Internal/Views/TabBarDropDestinationNSView.swiftSources/Bonsplit/Internal/Views/TabBarDropHandler.swiftSources/Bonsplit/Internal/Views/TabBarView.swiftSources/Bonsplit/Internal/Views/TabDropIndexResolver.swiftTests/BonsplitTests/BonsplitTests.swiftTests/BonsplitTests/TabBarDropHandlerTests.swiftTests/BonsplitTests/TabDropIndexResolverTests.swift
🚧 Files skipped from review as they are similar to previous changes (4)
- Sources/Bonsplit/Internal/Views/TabBarDropHandler.swift
- Tests/BonsplitTests/TabDropIndexResolverTests.swift
- Tests/BonsplitTests/TabBarDropHandlerTests.swift
- Tests/BonsplitTests/BonsplitTests.swift
Summary
Regression coverage
The first commit adds failing pointer-to-index regression tests. The second commit adds the implementation plus behavior coverage for middle insertion, cross-pane insertion, drag pasteboard publication races, inactive workspaces, and translated AppKit hit testing.
The review follow-up rejects stale pasteboard-only transfers that cannot complete and validates the linear model/visual frame-order contract.
Testing
arch -arm64 "$(xcrun --find swift)" testRelated cmux issue: manaflow-ai/cmux#9746
Summary by CodeRabbit
New Features
Bug Fixes
Tests