Skip to content
Closed
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
97a0eb3
Rebuild sidebar workspace reorder on a SwiftUI DragGesture
lawrencecchen Jun 2, 2026
f81905f
Keep reorder gesture host stable during drag
lawrencecchen Jun 2, 2026
e120bfd
Sidebar workspace group animations + rollup + focus fixes
lawrencecchen Jun 10, 2026
d5757a2
Sidebar drag: Escape-cancel via HID poll + remove end-of-list drop line
lawrencecchen Jun 10, 2026
44910a1
Sidebar drag: animated drop gap (rows shift apart) instead of an indi…
lawrencecchen Jun 10, 2026
79798c1
Sidebar drag: true live reorder (row travels through the list)
lawrencecchen Jun 10, 2026
6740893
Sidebar live reorder: fix stationary-pointer oscillation
lawrencecchen Jun 10, 2026
dc419f0
Sidebar drag: restore fully on every non-commit end; fix review findings
lawrencecchen Jun 11, 2026
d6fc3f6
Move SidebarGroupAnimation into its own file
lawrencecchen Jun 11, 2026
2ef6b60
Refresh Swift file length budgets for the drag-restore work
lawrencecchen Jun 11, 2026
c4c6513
Sidebar live reorder: let autoscroll reorder under a stationary pointer
lawrencecchen Jun 11, 2026
99ca472
Sidebar drop: nil indicator over a row commits as a no-op
lawrencecchen Jun 11, 2026
beed2dd
Sidebar drag: capture the rollback snapshot synchronously; arm the lo…
lawrencecchen Jun 11, 2026
ad1f7b6
Sidebar drag: stop scroll-follow fighting the live reorder; tighter m…
lawrencecchen Jun 11, 2026
534c21c
Sidebar live reorder: arm the loop-breaker on an actual order change,…
lawrencecchen Jun 11, 2026
651dd4d
Sidebar live reorder: kill the animation-feedback cascade
lawrencecchen Jun 12, 2026
60f2c58
Merge gesture-driven sidebar reorder (PR #5226) onto the group-animat…
lawrencecchen Jun 12, 2026
003fb27
Sidebar gesture reorder: stop the drop-target gate from killing the drag
lawrencecchen Jun 12, 2026
d405d1b
Fix test patterns for the workspace render item's effectiveGroupId pa…
lawrencecchen Jun 12, 2026
2644626
Sidebar gesture reorder: derive the cursor from translation, not loca…
lawrencecchen Jun 12, 2026
c8502da
Sidebar gesture reorder: clamp members to their group, drop-into head…
lawrencecchen Jun 12, 2026
58e9614
Sidebar gesture reorder: animate the follower's indent across group b…
lawrencecchen Jun 12, 2026
9bb0325
Sidebar gesture reorder: one-step drag into and out of groups, X axis…
lawrencecchen Jun 12, 2026
796a9c4
Sidebar gesture reorder: fix the full edge-case audit (ultracode sweep)
lawrencecchen Jun 12, 2026
214e22f
Sidebar gesture reorder: expand collapsed groups on join, unpin on le…
lawrencecchen Jun 12, 2026
834fbfe
Sidebar gesture reorder: stacked hitboxes at group bottoms; animate f…
lawrencecchen Jun 12, 2026
6efee48
Sidebar gesture reorder: actually animate the follower indent and width
lawrencecchen Jun 12, 2026
3bf1196
Sidebar gesture reorder: deterministic indent animation + midpoint bo…
lawrencecchen Jun 12, 2026
954d39c
Sidebar gesture reorder: animate the follower indent at its single mu…
lawrencecchen Jun 12, 2026
0135770
Sidebar gesture reorder: touch-triggered slots, spring-loaded collaps…
lawrencecchen Jun 12, 2026
256728d
Sidebar gesture reorder: one reference point for slot + membership, h…
lawrencecchen Jun 12, 2026
a831f01
Sidebar reorder: replace the direction-flag probe with a continuous c…
lawrencecchen Jun 14, 2026
ce61759
Sidebar: group header hover background; spring-load auto-collapses on…
lawrencecchen Jun 14, 2026
615bfe7
Sidebar: highlight the whole group region (header + member rows), not…
lawrencecchen Jun 14, 2026
e968159
Sidebar: hovering a nested member also highlights its whole group
lawrencecchen Jun 14, 2026
fc4bc75
Sidebar: draw the group highlight as one backdrop behind the rows, no…
lawrencecchen Jun 14, 2026
ccb582b
WIP: isolated animated group backdrop + sooner last-member catch
lawrencecchen Jun 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
32576 CLI/cmux.swift
22034 Sources/TerminalController.swift
19875 Sources/Workspace.swift
19072 Sources/ContentView.swift
17919 Sources/AppDelegate.swift
19642 Sources/ContentView.swift
17920 Sources/AppDelegate.swift
16503 Sources/GhosttyTerminalView.swift
13589 Sources/Panels/BrowserPanel.swift
11756 cmuxTests/AppDelegateShortcutRoutingTests.swift
9995 Sources/TabManager.swift
10124 Sources/TabManager.swift
8494 cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
7737 Sources/Panels/BrowserPanelView.swift
7214 cmuxTests/WorkspaceUnitTests.swift
Expand Down Expand Up @@ -66,6 +66,7 @@
1380 cmuxUITests/MenuKeyEquivalentRoutingUITests.swift
1376 cmuxTests/KeyboardShortcutSettingsFileStoreStartupTests.swift
1372 cmuxTests/AppDelegateIssue2907RoutingTests.swift
1372 cmuxTests/WorkspaceGroupTests.swift
1365 Sources/Feed/FeedButtonStyleDebugWindowController.swift
1362 Sources/CMUXInstalledExtensionSidebarHostView.swift
1313 cmuxTests/MobileHostAuthorizationTests.swift
Expand All @@ -82,7 +83,6 @@
1006 cmuxTests/CmuxSSHURLRequestTests.swift
1000 cmuxTests/CmuxTopSnapshotScopeTests.swift
969 cmuxUITests/TerminalCmdClickUITests.swift
959 cmuxTests/WorkspaceGroupTests.swift
949 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/TerminalInputTextView.swift
947 Sources/TerminalNotificationPolicy.swift
945 Sources/SessionIndexRegisteredAgents.swift
Expand Down
5 changes: 3 additions & 2 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14609,8 +14609,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
return false
}
// No name prompt: TabManager auto-names ("Group N"). Rename via the
// header context menu.
tabManager.createWorkspaceGroup(name: "", childWorkspaceIds: eligibleIds)
// header context menu. selectAnchor: false keeps the user focused on
// the workspace they were already in rather than the new empty anchor.
tabManager.createWorkspaceGroup(name: "", childWorkspaceIds: eligibleIds, selectAnchor: false)
return true
}

Expand Down
794 changes: 682 additions & 112 deletions Sources/ContentView.swift

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions Sources/Sidebar/SidebarGroupAnimation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import SwiftUI

/// Shared animation timings for workspace-group structure changes in the
/// sidebar (promote-in-place, ungroup, collapse/expand, member join/leave,
/// drag-reorder settle).
///
/// One source of truth so every entrypoint that mutates group structure
/// (keyboard shortcut, context menu, group-header buttons, drag-and-drop,
/// socket/CLI) animates identically. The `TabManager` group mutation methods
/// wrap their structural changes in `withAnimation(SidebarGroupAnimation.<case>)`,
/// and the sidebar rows carry `.transition(.sidebarGroupRow)` so inserted or
/// removed rows fade while their siblings reflow within the same transaction.
enum SidebarGroupAnimation {
/// Workspace row morphs into a group header (and back), member rows join or
/// leave a group, drag-reorder drops settle.
static let structure: Animation = .snappy(duration: 0.26)

/// Group collapse / expand: member rows slide+fade and the chevron rotates.
static let collapse: Animation = .snappy(duration: 0.24)

/// Mid-drag row crossing during the live reorder. Deliberately faster
/// than `structure`: the row is chasing the pointer, and a 0.26s spring
/// reads as input lag when crossings come several per second. No bounce —
/// overshoot under a moving pointer looks like jitter.
static let liveReorder: Animation = .snappy(duration: 0.15, extraBounce: 0)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

extension AnyTransition {
/// Transition for a sidebar row appearing or disappearing because of a
/// group-structure change. A plain opacity fade keeps the morph between a
/// workspace row and a group header (same ForEach identity, swapped
/// `_ConditionalContent` branch) reading as a crossfade, while the
/// surrounding `withAnimation` transaction animates the list reflow so
/// collapse/expand and member join/leave feel like a slide for free.
static var sidebarGroupRow: AnyTransition {
.opacity
}
}
91 changes: 91 additions & 0 deletions Sources/Sidebar/SidebarReorderFollowerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import SwiftUI

/// The floating copy of the picked-up workspace row that tracks the cursor
/// during a gesture-driven reorder. For a group-header drag the follower
/// carries the WHOLE visible block (header + member rows) so the group reads
/// as one object traveling with the cursor.
///
/// This is the ONLY view that reads `SidebarDragState.followerCursorY`, the
/// per-frame cursor position. Because it is a sibling overlay over the list (not
/// a row inside the `LazyVStack`/`ForEach`), its per-frame updates repaint just
/// this one view and never invalidate the list body — the property that keeps
/// the drag off the https://github.com/manaflow-ai/cmux/issues/2586 thrash path.
/// Implicit animations are disabled so the follower snaps to the cursor with
/// zero lag while the list rows animate the gap open underneath it — except the
/// group-membership indent, which animates on its own axis (see below).
struct SidebarReorderFollowerView: View {
let dragState: SidebarDragState
/// The committed render list, used to find the picked-up row's content
/// (and, for a header drag, the member rows that follow it).
let sourceItems: [SidebarWorkspaceRenderItem]
/// Spacing between the header and member rows in a group-block follower,
/// matching the list's row spacing.
let rowSpacing: CGFloat
/// Extra leading indent previewed for the dragged row at its current
/// landing slot, RELATIVE to its committed indent (positive tucking into
/// a group, negative pulling out, 0 unchanged). Derived by the parent
/// from the resolved membership, so it only changes when the resolved
/// membership does.
let previewExtraIndent: CGFloat
let rowContent: (SidebarWorkspaceRenderItem) -> AnyView

var body: some View {
if let draggedId = dragState.draggedTabId,
let cursorY = dragState.followerCursorY,
let frame = dragState.draggedRowFrame,
frame.width > 0,
frame.height > 0,
let itemIndex = sourceItems.firstIndex(where: { $0.representedWorkspaceId == draggedId }) {
let topY = cursorY - dragState.grabOffsetY
let blockItems = followerBlockItems(startingAt: itemIndex)
// The indent is applied INSIDE the position-tracked container, on
// its own animation keyed to the indent value: the row slides
// right and narrows when the landing slot crosses into a group
// (and back out), while Y stays glued to the cursor with
// animations disabled. The container is sized to the picked-up
// row's frame and top-aligned, so a group block overflows below
// it without disturbing the cursor anchor math.
VStack(alignment: .leading, spacing: rowSpacing) {
ForEach(blockItems, id: \.representedWorkspaceId) { item in
rowContent(item)
}
}
// Width and X are BOTH explicit functions of the previewed
// indent: tucking into a group slides the row right by the
// indent AND narrows it by the same amount (the trailing edge
// stays fixed), animated together on the indent's own axis while
// Y tracking below stays animation-free.
.frame(width: max(frame.width - previewExtraIndent, 0), height: frame.height, alignment: .topLeading)
.padding(.leading, previewExtraIndent)
.animation(.snappy(duration: 0.15, extraBounce: 0), value: previewExtraIndent)
.frame(width: frame.width, height: frame.height, alignment: .topLeading)
.position(x: frame.midX, y: topY + frame.height / 2)
.shadow(color: Color.black.opacity(0.18), radius: 11, x: 0, y: 5)
.opacity(0.97)
.allowsHitTesting(false)
.accessibilityHidden(true)
.zIndex(1000)
.transaction { transaction in
transaction.disablesAnimations = true
transaction.animation = nil
}
}
}

/// The dragged item plus, for a group header, the visible member rows
/// that follow it in the committed list (capped so enormous groups don't
/// turn the per-frame follower into a wall of rows).
private func followerBlockItems(startingAt itemIndex: Int) -> [SidebarWorkspaceRenderItem] {
let item = sourceItems[itemIndex]
guard case .groupHeader(let group, _) = item else { return [item] }
var block: [SidebarWorkspaceRenderItem] = [item]
var index = itemIndex + 1
while index < sourceItems.count, block.count < 7 {
guard case .workspace(let workspace, _) = sourceItems[index],
workspace.groupId == group.id else { break }
block.append(sourceItems[index])
index += 1
}
return block
}
}
115 changes: 115 additions & 0 deletions Sources/Sidebar/SidebarReorderIndicatorResolver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import CoreGraphics
import Foundation

/// Maps a drag cursor position to a ``SidebarDropIndicator`` for the gesture
/// driven workspace reorder, with hysteresis so the gap does not flicker when
/// the cursor hovers exactly on a row's midpoint.
///
/// Pure and self-contained so it is unit-testable without a running app: the
/// caller passes the reorder-scope rows as vertical bands (already resolved
/// from the live row frames) plus the current cursor Y, all in one coordinate
/// space. Edge/insertion/pinned-tier legality is delegated to
/// ``SidebarDropPlanner``; this type only adds hit-testing and stickiness.
enum SidebarReorderIndicatorResolver {
/// One reorder-scope item's vertical extent in list space. For a top-level
/// group drag, a band spans the group header plus all its member rows so
/// the whole group reads as one target.
struct Band: Equatable {
let id: UUID
let minY: CGFloat
let maxY: CGFloat

var midY: CGFloat { (minY + maxY) / 2 }
var height: CGFloat { max(maxY - minY, 0) }
}

/// Resolves the drop indicator for `cursorY`.
///
/// - Parameters:
/// - cursorY: cursor Y in the same list space as the band extents.
/// - bands: reorder-scope bands in scope order, contiguous and sorted.
/// - draggedId: the workspace being dragged.
/// - pinnedIds: pinned ids within the scope (tier constraint).
/// - current: the indicator currently shown, used for hysteresis.
/// - hysteresisMargin: half-width of the dead-zone around a band midpoint
/// within which the current edge is kept (points).
/// - Returns: the indicator to show, or nil for a no-op move.
static func resolve(
cursorY: CGFloat,
bands: [Band],
draggedId: UUID,
pinnedIds: Set<UUID>,
current: SidebarDropIndicator?,
hysteresisMargin: CGFloat
) -> SidebarDropIndicator? {
guard !bands.isEmpty else { return nil }
let scopeIds = bands.map(\.id)

// Below every row: append to the end of the scope.
guard let lastBand = bands.last, cursorY <= lastBand.maxY else {
return SidebarDropPlanner.indicator(
draggedTabId: draggedId,
targetTabId: nil,
tabIds: scopeIds,
pinnedTabIds: pinnedIds
)
}

// First band whose bottom edge is below the cursor is the target; this
// also assigns the inter-row spacing gap to the lower band.
let targetBand = bands.first(where: { cursorY < $0.maxY }) ?? lastBand
let pointerY = cursorY - targetBand.minY

let effectivePointerY = stickyPointerY(
pointerY: pointerY,
band: targetBand,
scopeIds: scopeIds,
current: current,
margin: hysteresisMargin
)

return SidebarDropPlanner.indicator(
draggedTabId: draggedId,
targetTabId: targetBand.id,
tabIds: scopeIds,
pinnedTabIds: pinnedIds,
pointerY: effectivePointerY,
targetHeight: targetBand.height
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

/// Biases `pointerY` toward the current edge while the cursor sits within
/// `margin` of the band midpoint, so the indicator does not oscillate on
/// sub-pixel jitter at the 50% split.
private static func stickyPointerY(
pointerY: CGFloat,
band: Band,
scopeIds: [UUID],
current: SidebarDropIndicator?,
margin: CGFloat
) -> CGFloat {
let mid = band.height / 2
guard margin > 0, abs(pointerY - mid) < margin else { return pointerY }
guard let edge = currentEdge(for: band, scopeIds: scopeIds, current: current) else {
return pointerY
}
return edge == .top ? mid - margin : mid + margin
}

/// The edge of `band` that the current indicator represents, if any. The
/// planner canonicalizes "after row i" to "top of row i+1" (or the end
/// sentinel), so both forms are matched here.
private static func currentEdge(
for band: Band,
scopeIds: [UUID],
current: SidebarDropIndicator?
) -> SidebarDropEdge? {
guard let current else { return nil }
if current.tabId == band.id, current.edge == .top { return .top }
guard let index = scopeIds.firstIndex(of: band.id) else { return nil }
let afterId: UUID? = index + 1 < scopeIds.count ? scopeIds[index + 1] : nil
if let afterId, current.tabId == afterId, current.edge == .top { return .bottom }
if afterId == nil, current.tabId == nil, current.edge == .bottom { return .bottom }
return nil
}
}
39 changes: 39 additions & 0 deletions Sources/Sidebar/SidebarReorderRowFrameKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import SwiftUI

/// Collects the live frames of the workspace sidebar rows (and group headers),
/// keyed by represented workspace id, in the list's `"sidebarReorderList"`
/// coordinate space.
///
/// The gesture-driven reorder reads these via `.onPreferenceChange` to hit-test
/// the drag cursor against the rows. Resolving concrete `CGRect`s (rather than
/// `Anchor<CGRect>`) lets the value flow straight into `SidebarDragState`'s
/// non-observed geometry without a `GeometryProxy`, so the push never happens
/// inside a view-body computation.
struct SidebarReorderRowFrameKey: PreferenceKey {
static let defaultValue: [UUID: CGRect] = [:]

static func reduce(value: inout [UUID: CGRect], nextValue: () -> [UUID: CGRect]) {
value.merge(nextValue(), uniquingKeysWith: { _, new in new })
}
}

extension View {
/// Reports this row's frame in the reorder list coordinate space under
/// `workspaceId`.
func sidebarReorderRowFrame(_ workspaceId: UUID) -> some View {
background(
GeometryReader { proxy in
Color.clear.preference(
key: SidebarReorderRowFrameKey.self,
value: [workspaceId: proxy.frame(in: .named(SidebarReorderListCoordinateSpace.name))]
)
}
)
}
}

/// The named coordinate space the reorder gesture and row frames share, so the
/// gesture location and the measured row frames are guaranteed to align.
enum SidebarReorderListCoordinateSpace {
static let name = "sidebarReorderList"
}
Loading
Loading