Drag a sidebar tab onto another project to move it#93
Open
thdxg wants to merge 6 commits into
Open
Conversation
Closes #91. Lets a tab — with its live panes and running shells — be relocated from one project to another via the sidebar tab context menu, for the common case of starting work in the wrong project. The tab object is reused as-is so surfaces stay valid, and the destination becomes active with the moved tab selected.
The merged Move to Project command only added a context-menu entry; the issue asked to drag a tab between projects directly. Make each sidebar tab row a drag source carrying its UUID and each project row a drop target, reusing the existing AppState.moveTab path so the tab's live panes and shells move intact. Mirrors the pane drag-and-drop pattern (custom UTType + DropDelegate, payload read off the drag pasteboard).
SwiftUI ignores .onDrop for views inside a List on macOS, so the project-row drop target never fired and dragging a tab between projects did nothing. Switch to the List-native .onInsert hook on each project's tab ForEach (the same family as the .onMove that already reorders tabs within a project), fed by the tab row's existing .onDrag payload. Drop the unusable TabDropDelegate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes sidebar tabs draggable onto projects: drag a tab row and drop it on any project to move that tab — with its live panes and running shells — into that project. The target project highlights while a tab hovers over it.
Why
Follow-up to #92 (issue #91). That PR added a Move to Project context-menu command, but the original issue asked to drag a tab from one project into another, which was never wired up. This adds the direct-manipulation path; the context menu stays as a keyboard/right-click fallback.
How
Mirrors the existing pane drag-and-drop pattern (
PaneDragDrop.swift):Macterm/Views/TabDragDrop.swiftdefines acom.thdxg.macterm.tab-idUTType, anNSItemProviderfactory carrying the tab's UUID bytes, and aTabDropDelegatethat reads the payload synchronously off the drag pasteboard (the drag never leaves the app).SidebarTabRowgains.onDrag;SidebarProjectRowgains.onDropplus a drop-target highlight.AppState.moveTab, so theTerminalTabobject (and its surfaces) is reused — no shell restarts. A newAppState.projectID(containingTab:)resolves the source project from the dragged tab's ID (the drop only knows the destination).Info.plistalongside the pane one.Verified
projectID(containingTab:)(lookup + tracking a moved tab); existingmoveTabtests still cover the move itself.mise run format,mise run lint,mise run test— not run; this session's environment is Linux with no Xcode/Swift toolchain, so the macOS suite can't run here. Please run locally before merge.Notes for reviewers
I couldn't runtime-test the drag here. The one interaction worth confirming in
mise run run: that adding.onDragto tab rows doesn't disturb the existing.onMovetab-reordering (SwiftUIListcan be finicky about combining the two). Please verify both drag-to-reorder within a project and drag-to-move across projects. If reordering regresses, the fallback is to drive the tab drag through an AppKitNSDraggingSourceexactly like the panes do, rather than SwiftUI.onDrag.🤖 Generated with Claude Code
Generated by Claude Code