Repository navigation
Fix drag-to-split cursor focus reconciliation - #9754
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughMoving-tab splits now use explicit focus intent. The workspace preserves current panel focus or activates the moved tab after reparenting. Split call sites use the shared helper, and serialized tests cover focus transfer and focus preservation. ChangesDrag-Split Focus Synchronization
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant SplitAction
participant Workspace
participant TerminalPanel
participant LayoutFollowUp
SplitAction->>Workspace: Call splitPaneMovingTab with focus intent
Workspace->>TerminalPanel: Move tab and preserve or activate focus
Workspace->>LayoutFollowUp: Suppress conflicting reparent-focus changes
LayoutFollowUp-->>Workspace: Complete geometry reconciliation
Possibly related issues
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 errors)
✅ Passed checks (23 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 |
be79e7d to
e76a4b0
Compare
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 `@cmuxTests/WorkspaceDragSplitFocusTests.swift`:
- Around line 30-31: Update the test setup around makeWindow() to capture the
current key window before calling makeKeyAndOrderFront(nil), then restore that
captured window in the defer cleanup alongside window.orderOut(nil). Ensure the
prior AppKit key-window state is restored even when the test exits early.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4340ea96-9f4c-4f6b-b62e-266b507184f8
📒 Files selected for processing (3)
Sources/Workspace.swiftcmux.xcodeproj/project.pbxprojcmuxTests/WorkspaceDragSplitFocusTests.swift
2a68075 to
515dbe0
Compare
c9c4374 to
66529e0
Compare
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 `@cmuxTests/WorkspaceDragSplitFocusTests.swift`:
- Around line 33-40: Update the split setup in WorkspaceDragSplitFocusTests to
call Workspace.splitPaneMovingTab with focusIntent: .activateMovedTab instead of
invoking bonsplitController.splitPane directly, while preserving the existing
source pane, orientation, moved tab, and insertion order arguments.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: ba89f84e-0845-4462-b210-6f76f5cf43b3
📒 Files selected for processing (9)
Sources/AppDelegate+DockSurfaceMove.swiftSources/AppDelegate.swiftSources/TerminalController+ControlSidebarContext3.swiftSources/TerminalController+MoveTabToNewWorkspace.swiftSources/Workspace+MovingTabSplit.swiftSources/Workspace+SurfaceNavigation.swiftSources/Workspace.swiftcmux.xcodeproj/project.pbxprojcmuxTests/WorkspaceDragSplitFocusTests.swift
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 66529e0. Configure here.
82ebfdd to
9f9df3a
Compare
9f9df3a to
5f19f16
Compare

Summary
Root cause
Bonsplit moves the tab and changes its focused pane synchronously, but that operation emits only
didSplitPane. Workspace therefore did not commit the moved tab through its focus owner, and the following SwiftUI reparent pass could disturb AppKit first responder independently. The model, cursor, and responder layers could diverge even though Bonsplit still tracked only one focused pane.Testing
Audit
Closes #9504
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fix drag-to-split so the moved terminal becomes the only focused cursor when requested, or preserves current focus and agent hibernation when not. Makes focus intent explicit for all moving‑tab splits and reconciles AppKit first responder through SwiftUI reparenting (fixes #9504).
Workspace.splitPaneMovingTab(..., focusIntent: ...)withMovingTabSplitFocusIntent; on preserve, restore previous pane/tab and the panel’s owned responder; suppress Bonsplit delegate activation.activateMovedTabAfterSplit; guard responder churn viasuppressReparentFocusUntilLayoutFollowUp(..., terminalFocusPanelId: ...); ignoredidSelectTab/didFocusPanewhile preserving focus..activateMovedTab; control sidebar andsurface.split_offuse.preserveCurrent. Added DEBUG tests for sole‑cursor activation, reassertion without a previous terminal responder, and non‑focus split hibernation.Written for commit 5f19f16. Summary will update on new commits.
Note
Medium Risk
Changes focus ownership across many split/move entry points and Bonsplit delegate handling; regressions would show up as wrong terminal focus or lost hibernation after drag-to-split, but behavior is covered by new tests.
Overview
Fixes drag-to-split and other move-tab-into-split paths so keyboard focus matches intent: the moved terminal becomes the sole focused cursor when activation is requested, and stays inactive when focus must be preserved.
Introduces
Workspace.splitPaneMovingTabwithMovingTabSplitFocusIntent(activateMovedTabvspreserveCurrent). Call sites in AppDelegate (dock and cross-workspace moves), surface navigation, control sidebar, andsurface.split_offroute through it instead of callingbonsplitController.splitPanedirectly.On
didSplitPanefor moving-tab splits,activateMovedTabAfterSplitapplies tab selection andsuppressReparentFocusUntilLayoutFollowUp(now optionally keyed byterminalFocusPanelId) so AppKit first responder survives SwiftUI reparenting.didSelectTab/didFocusPaneare skipped while preserving focus; preserve mode restores the prior pane, tab, and owned responder (including agent hibernation).Adds
WorkspaceDragSplitFocusTestsfor activation, post-reparent reassertion, and non-focus preservation.Reviewed by Cursor Bugbot for commit 5f19f16. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Tests