Repository navigation
Revert "Fix workspace group drag drop intent (#6532)" — crashes app-host on main #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
Packages/macOS/CmuxFoundation/Sources/CmuxFoundation/SidebarDrop/SidebarDropIndicator.swift
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
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
85 changes: 14 additions & 71 deletions
85
.../CmuxFoundation/Sources/CmuxFoundation/SidebarDrop/SidebarTabDropIndicatorPredicate.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,100 +1,43 @@ | ||
| public import Foundation | ||
|
|
||
| /// Pure predicates deciding when a sidebar row (or the empty area below all | ||
| /// rows) should render its drop indicator for a given drag state. | ||
| /// rows) should render its "top" drop indicator for a given drag state. | ||
| public struct SidebarTabDropIndicatorPredicate { | ||
| /// Creates a sidebar drop-indicator predicate evaluator. | ||
| public init() {} | ||
|
|
||
| /// Returns whether the canonical gap indicator should render above a row. | ||
| /// | ||
| /// A resolved `.bottom` edge on the previous visible row represents the | ||
| /// same visual divider as a `.top` edge on this row. The sidebar renders | ||
| /// that divider only here, above the row after the gap, so adjacent rows | ||
| /// cannot both draw competing drop lines. | ||
| /// | ||
| /// - Parameters: | ||
| /// - tabId: The row currently being rendered. | ||
| /// - draggedTabId: The workspace currently being dragged, if any. | ||
| /// - dropIndicator: The resolved sidebar drop indicator. | ||
| /// - tabIds: Visible workspace row identifiers in display order. | ||
| /// - Returns: `true` when the resolved indicator targets the divider above this row. | ||
| public func topVisible( | ||
| forTabId tabId: UUID, | ||
| draggedTabId: UUID?, | ||
| dropIndicator: SidebarDropIndicator?, | ||
| tabIds: [UUID] | ||
| ) -> Bool { | ||
| guard draggedTabId != nil, | ||
| let indicator = dropIndicator, | ||
| let rowIndex = tabIds.firstIndex(of: tabId) else { return false } | ||
|
|
||
| switch indicator.edge { | ||
| case .top: | ||
| return indicator.tabId == tabId | ||
| case .bottom: | ||
| guard let indicatorTabId = indicator.tabId, | ||
| let indicatorIndex = tabIds.firstIndex(of: indicatorTabId) else { | ||
| return false | ||
| } | ||
| return indicatorIndex + 1 == rowIndex | ||
| guard draggedTabId != nil, let indicator = dropIndicator else { return false } | ||
| if indicator.tabId == tabId && indicator.edge == .top { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| /// Returns whether the bottom-edge indicator should render below a row. | ||
| /// | ||
| /// Row-to-row dividers are canonicalized to `topVisible` for the row after | ||
| /// the gap. Root-level final append dividers are rendered by | ||
| /// `emptyAreaTopVisible`; scoped group append dividers can be rendered below | ||
| /// the last visible row in that group. | ||
| /// | ||
| /// - Parameters: | ||
| /// - tabId: The row currently being rendered. | ||
| /// - draggedTabId: The workspace currently being dragged, if any. | ||
| /// - dropIndicator: The resolved sidebar drop indicator. | ||
| /// - tabIds: Visible workspace row identifiers in display order. | ||
| /// - indicatorScope: The visible row scope where the resolved indicator is rendered. | ||
| /// - Returns: `true` when a scoped final append divider should render below this row. | ||
| public func bottomVisible( | ||
| forTabId tabId: UUID, | ||
| draggedTabId: UUID?, | ||
| dropIndicator: SidebarDropIndicator?, | ||
| tabIds: [UUID], | ||
| indicatorScope: SidebarWorkspaceReorderDropIndicatorScope = .raw | ||
| ) -> Bool { | ||
| guard draggedTabId != nil, | ||
| indicatorScope.isGroup, | ||
| let indicator = dropIndicator, | ||
| indicator.edge == .bottom, | ||
| indicator.tabId == tabId, | ||
| tabIds.last == tabId else { | ||
| guard indicator.edge == .bottom, | ||
| let currentIndex = tabIds.firstIndex(of: tabId), | ||
| currentIndex > 0 | ||
| else { | ||
| return false | ||
| } | ||
| return true | ||
| return tabIds[currentIndex - 1] == indicator.tabId | ||
| } | ||
|
|
||
| /// Convenience used by `SidebarEmptyArea`: the empty area's "top" indicator | ||
| /// (drawn above the empty space below all rows) is visible when the drop | ||
| /// indicator targets nothing (end-of-list), or when a `.bottom` indicator | ||
| /// targets the last visible row in the current drag scope. | ||
| /// | ||
| /// - Parameters: | ||
| /// - draggedTabId: The workspace currently being dragged, if any. | ||
| /// - dropIndicator: The resolved sidebar drop indicator. | ||
| /// - lastTabId: The last visible row in the current root/top-level scope. | ||
| /// - indicatorScope: The visible row scope where the resolved indicator is rendered. | ||
| /// - Returns: `true` when the root/top-level empty area should render its divider. | ||
| /// indicator targets nothing (end-of-list) or the bottom edge of the last | ||
| /// row. | ||
| public func emptyAreaTopVisible( | ||
| draggedTabId: UUID?, | ||
| dropIndicator: SidebarDropIndicator?, | ||
| lastTabId: UUID?, | ||
| indicatorScope: SidebarWorkspaceReorderDropIndicatorScope = .raw | ||
| lastTabId: UUID? | ||
| ) -> Bool { | ||
| guard !indicatorScope.isGroup else { return false } | ||
| guard draggedTabId != nil, let indicator = dropIndicator else { return false } | ||
| if indicator.tabId == nil { | ||
| return true | ||
| } | ||
| return indicator.edge == .bottom && indicator.tabId == lastTabId | ||
| guard indicator.edge == .bottom, let lastTabId else { return false } | ||
| return indicator.tabId == lastTabId | ||
| } | ||
| } | ||
15 changes: 0 additions & 15 deletions
15
...CmuxFoundation/Sources/CmuxFoundation/SidebarDrop/SidebarWorkspaceReorderDropAction.swift
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
...dation/Sources/CmuxFoundation/SidebarDrop/SidebarWorkspaceReorderDropIndicatorScope.swift
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...S/CmuxFoundation/Sources/CmuxFoundation/SidebarDrop/SidebarWorkspaceReorderDropPlan.swift
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
...muxFoundation/Sources/CmuxFoundation/SidebarDrop/SidebarWorkspaceReorderDropRequest.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
Avoid the per-row full scan in the drop-indicator predicate.
Line 19 runs
tabIds.firstIndex(of:)from a predicate called by each sidebar row/header render, so a bottom-edge drag indicator turns the render pass into O(n²) over workspace rows. Pass a precomputed predecessor/index lookup from the render context and make this predicate O(1). As per path instructions, “In SwiftUI/body and drag-drop hit-testing/rendering paths, avoid repeated full scans over scalable collections.”🤖 Prompt for AI Agents
Source: Path instructions