Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
26a545f
test: cover sidebar empty-area overflow
austinywang May 26, 2026
3cb31e6
fix: size sidebar empty area to remaining space
austinywang May 26, 2026
c13e02c
fix: derive sidebar scroller state from row layout
austinywang May 26, 2026
0468a3b
fix: invalidate sidebar row measurements by workspace ids
austinywang May 26, 2026
6932dc1
fix: handle partial sidebar row layout measurements
austinywang May 26, 2026
720759e
fix: handle zero-height sidebar row measurements
austinywang May 26, 2026
d89366f
Merge remote-tracking branch 'origin/main' into issue-3241-sidebar-sc…
austinywang May 26, 2026
b59e4a3
fix: address sidebar scroller review feedback
austinywang May 26, 2026
7ee70b4
Merge remote-tracking branch 'origin/main' into issue-3241-sidebar-sc…
austinywang May 26, 2026
40728e8
Merge remote-tracking branch 'origin/main' into issue-3241-sidebar-sc…
austinywang May 26, 2026
41501bf
Merge remote-tracking branch 'origin/main' into issue-3241-sidebar-sc…
austinywang Jun 6, 2026
4e5d6ae
fix: measure visible sidebar rows
austinywang Jun 6, 2026
52d7795
Merge origin/main; reconcile sidebar scroll fix with #5708
austinywang Jun 9, 2026
c77cb05
Use a stable overlay scroller config so the sidebar knob fades when idle
austinywang Jun 9, 2026
a6bcdad
Refresh Swift file-length budget for the sidebar scroll fix
austinywang Jun 9, 2026
b43052b
Give sidebar rows-measurement types their own files; use Swift Testin…
austinywang Jun 10, 2026
591c431
ci: retrigger checks (push event for b43052b2f was dropped)
austinywang Jun 10, 2026
4b4c870
ci: retrigger checks again (Actions dropped events during API throttl…
austinywang Jun 10, 2026
358c1f4
merge: resolve swift-file-length-budget conflict with origin/main
austinywang Jun 10, 2026
e806c53
Add failing test: sidebar scroller re-config must not rewrite NSScrol…
austinywang Jun 10, 2026
603202a
Guard sidebar scroller config writes so re-applies never disturb the …
austinywang Jun 10, 2026
808530f
merge: resolve ContentView conflict with origin/main (#5612)
austinywang Jun 10, 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
130 changes: 119 additions & 11 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9675,6 +9675,7 @@ struct VerticalTabsSidebar: View {
@State private var frozenShortcutHintsValue: Bool = false
@State private var terminalScrollBarVisibilityGeneration: UInt64 = 0
@State private var laidOutWorkspaceRowIds: Set<UUID> = []
@State private var workspaceRowsMeasurement: SidebarWorkspaceRowsMeasurement<UUID>?
@State private var pendingSelectedWorkspaceScrollId: UUID?
@State private var collapsedExtensionSidebarSectionIds: Set<String> = []
@State private var extensionSidebarWorktreeCreationInFlightSectionIds: Set<String> = []
Expand Down Expand Up @@ -9961,18 +9962,43 @@ struct VerticalTabsSidebar: View {
private func workspaceScrollArea(renderContext: WorkspaceListRenderContext) -> some View {
let scrollInsets = SidebarWorkspaceScrollInsets.workspaceList
return GeometryReader { geometryProxy in
let contentMinHeight = SidebarWorkspaceScrollLayout.contentMinHeight(
viewportHeight: geometryProxy.size.height,
insets: scrollInsets
)
let measuredWorkspaceRowsHeight = workspaceRowsMeasurement?.rowsHeight(
for: renderContext.workspaceIds
)
let workspaceRowsLayoutCompleteness = SidebarWorkspaceScrollLayout.rowsLayoutCompleteness(
laidOutRowIds: laidOutWorkspaceRowIds,
workspaceIds: renderContext.workspaceIds
)
let emptyAreaHeight = SidebarWorkspaceScrollLayout.emptyAreaHeight(
contentMinHeight: contentMinHeight,
rowsHeight: measuredWorkspaceRowsHeight,
rowsLayoutCompleteness: workspaceRowsLayoutCompleteness
)
let workspaceContentOverflows = SidebarWorkspaceScrollLayout.rowsOverflow(
rowsHeight: measuredWorkspaceRowsHeight,
contentMinHeight: contentMinHeight,
rowsLayoutCompleteness: workspaceRowsLayoutCompleteness
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

ScrollViewReader { scrollProxy in
ScrollView {
ScrollView(.vertical) {
workspaceScrollContent(
renderContext: renderContext,
minHeight: SidebarWorkspaceScrollLayout.contentMinHeight(
viewportHeight: geometryProxy.size.height,
insets: scrollInsets
)
minHeight: contentMinHeight,
emptyAreaHeight: emptyAreaHeight
)
}
.scrollIndicators(.automatic)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 .scrollIndicators(.automatic) is inconsistent with the extension sidebar and redundant

.automatic is the SwiftUI default, so adding it here is a no-op at the SwiftUI level. More importantly, the extension sidebar's ScrollView doesn't carry this modifier even though both sidebars then manually override hasVerticalScroller via SidebarScrollViewResolver. The inconsistency makes the intent unclear — if the goal is to suppress SwiftUI's own indicator overlay before the NSScrollView override fires, .never would be the correct choice; if there's no intent, the modifier should be removed. Either way both sidebars should agree.

Suggested change
.scrollIndicators(.automatic)
.scrollIndicators(.never)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b59e4a3 by removing the redundant workspace .scrollIndicators(.automatic) modifier so the workspace and extension sidebars both rely on the shared NSScrollView configuration path.

— Claude Code

.background(
SidebarScrollViewResolver { scrollView in
configureSidebarScrollView(
scrollView,
hasVerticalScroller: workspaceContentOverflows
)
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
dragAutoScrollController.attach(scrollView: scrollView)
}
.frame(width: 0, height: 0)
Expand Down Expand Up @@ -10046,6 +10072,8 @@ struct VerticalTabsSidebar: View {
requestSelectedWorkspaceScroll(scrollProxy, workspaceIds: renderContext.workspaceIds)
}
.onChange(of: renderContext.workspaceIds) { oldWorkspaceIds, newWorkspaceIds in
laidOutWorkspaceRowIds = []
workspaceRowsMeasurement = nil
guard shouldRequestSelectedWorkspaceScrollAfterWorkspaceIdsChange(
from: oldWorkspaceIds,
to: newWorkspaceIds
Expand All @@ -10062,10 +10090,47 @@ struct VerticalTabsSidebar: View {
laidOutWorkspaceRowIds = rowIds
flushPendingSelectedWorkspaceScroll(scrollProxy, laidOutWorkspaceRowIds: rowIds)
}
.onPreferenceChange(SidebarWorkspaceRowsHeightPreferenceKey.self) { measurement in
guard let measurement else {
workspaceRowsMeasurement = nil
return
}
let nextMeasurement = SidebarWorkspaceRowsMeasurement(
workspaceIds: measurement.workspaceIds,
rowsHeight: max(0, measurement.rowsHeight)
)
if let workspaceRowsMeasurement,
workspaceRowsMeasurement.isEquivalent(to: nextMeasurement) {
return
}
workspaceRowsMeasurement = nextMeasurement
}
}
}
}

private func configureSidebarScrollView(
_ scrollView: NSScrollView?,
hasVerticalScroller: Bool
) {
guard let scrollView else { return }

scrollView.hasHorizontalScroller = false
scrollView.autohidesScrollers = true
scrollView.scrollerStyle = .overlay
scrollView.hasVerticalScroller = hasVerticalScroller
}

private func configureSidebarScrollViewFromDocument(_ scrollView: NSScrollView?) {
configureSidebarScrollView(
scrollView,
hasVerticalScroller: SidebarWorkspaceScrollLayout.contentOverflows(
contentHeight: scrollView?.documentView?.bounds.height ?? 0,
viewportHeight: scrollView?.contentView.bounds.height ?? 0
)
)
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Comment thread
austinywang marked this conversation as resolved.
Resolved

private func extensionSidebarScrollArea(renderContext: WorkspaceListRenderContext) -> some View {
TimelineView(.periodic(from: .now, by: 30)) { timeline in
let model = extensionSidebarRenderModel(renderContext: renderContext, now: timeline.date)
Expand Down Expand Up @@ -10122,6 +10187,7 @@ struct VerticalTabsSidebar: View {
}
.background(
SidebarScrollViewResolver { scrollView in
configureSidebarScrollViewFromDocument(scrollView)
dragAutoScrollController.attach(scrollView: scrollView)
}
.frame(width: 0, height: 0)
Expand Down Expand Up @@ -10849,7 +10915,8 @@ struct VerticalTabsSidebar: View {

private func workspaceScrollContent(
renderContext: WorkspaceListRenderContext,
minHeight: CGFloat
minHeight: CGFloat,
emptyAreaHeight: CGFloat
) -> some View {
VStack(spacing: 0) {
workspaceRows(renderContext: renderContext)
Expand All @@ -10862,9 +10929,10 @@ struct VerticalTabsSidebar: View {
dragAutoScrollController: dragAutoScrollController,
topDropIndicatorVisible: emptyAreaTopDropIndicatorVisible(),
tabDropDelegate: emptyAreaTabDropDelegate(),
bonsplitDropIndicator: dropIndicatorBinding
bonsplitDropIndicator: dropIndicatorBinding,
expandsVertically: false,
minimumHeight: emptyAreaHeight
)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(minHeight: minHeight, alignment: .top)
}
Expand All @@ -10881,6 +10949,17 @@ struct VerticalTabsSidebar: View {
}
.padding(.vertical, SidebarWorkspaceListMetrics.rowVerticalPadding)
.frame(maxWidth: .infinity, alignment: .leading)
.background {
GeometryReader { proxy in
Color.clear.preference(
key: SidebarWorkspaceRowsHeightPreferenceKey.self,
value: SidebarWorkspaceRowsMeasurement(
workspaceIds: renderContext.workspaceIds,
rowsHeight: proxy.size.height
)
)
}
}
.overlayPreferenceValue(SidebarWorkspaceRowFramePreferenceKey.self) { anchors in
GeometryReader { proxy in
SidebarBonsplitTabWorkspaceDropOverlay(
Expand Down Expand Up @@ -11099,6 +11178,22 @@ private struct SidebarWorkspaceRowFramePreferenceKey: PreferenceKey {
}
}

private struct SidebarWorkspaceRowsHeightPreferenceKey: PreferenceKey {
static let defaultValue: SidebarWorkspaceRowsMeasurement<UUID>? = nil

static func reduce(
value: inout SidebarWorkspaceRowsMeasurement<UUID>?,
nextValue: () -> SidebarWorkspaceRowsMeasurement<UUID>?
) {
guard let next = nextValue() else { return }
guard let current = value else {
value = next
return
}
value = current.rowsHeight >= next.rowsHeight ? current : next
}
}

enum ShortcutHintModifierPolicy {
static let intentionalHoldDelay: TimeInterval = 0.30

Expand Down Expand Up @@ -13282,11 +13377,11 @@ private struct SidebarEmptyArea: View {
let topDropIndicatorVisible: Bool
let tabDropDelegate: SidebarTabDropDelegate
let bonsplitDropIndicator: Binding<SidebarDropIndicator?>
var expandsVertically = true
var minimumHeight: CGFloat? = nil

var body: some View {
Color.clear
.contentShape(Rectangle())
.frame(maxWidth: .infinity, maxHeight: .infinity)
hitTarget
.onTapGesture(count: 2) {
tabManager.addWorkspace(placementOverride: .end)
if let selectedId = tabManager.selectedTabId {
Expand Down Expand Up @@ -13315,6 +13410,19 @@ private struct SidebarEmptyArea: View {
}
}
}

@ViewBuilder
private var hitTarget: some View {
if expandsVertically {
Color.clear
.frame(maxWidth: .infinity, maxHeight: .infinity)
.contentShape(Rectangle())
} else {
Color.clear
.frame(maxWidth: .infinity, minHeight: minimumHeight ?? 0)
.contentShape(Rectangle())
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}
}
}

private struct ExtensionSidebarBrowserStackEmptyArea: View {
Expand Down
73 changes: 72 additions & 1 deletion Sources/WindowChromeMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,77 @@ enum SidebarWorkspaceScrollLayout {
viewportHeight: CGFloat,
insets: SidebarWorkspaceScrollInsets
) -> CGFloat {
max(0, viewportHeight - insets.total)
return max(0, viewportHeight - insets.total)
}

nonisolated static func emptyAreaHeight(
contentMinHeight: CGFloat,
rowsHeight: CGFloat?,
rowsLayoutCompleteness: SidebarWorkspaceRowsLayoutCompleteness = .complete
) -> CGFloat {
guard let rowsHeight, rowsLayoutCompleteness == .complete else { return 0 }
return max(0, contentMinHeight - max(0, rowsHeight))
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

nonisolated static func contentOverflows(
contentHeight: CGFloat,
viewportHeight: CGFloat,
tolerance: CGFloat = 1
) -> Bool {
contentHeight > viewportHeight + tolerance
}

nonisolated static func rowsOverflow(
rowsHeight: CGFloat?,
contentMinHeight: CGFloat,
rowsLayoutCompleteness: SidebarWorkspaceRowsLayoutCompleteness = .complete,
tolerance: CGFloat = 1
) -> Bool {
guard let rowsHeight else { return false }
switch rowsLayoutCompleteness {
case .unmeasured:
return false
case .partial:
return true
case .complete:
break
}
return contentOverflows(
contentHeight: rowsHeight,
viewportHeight: contentMinHeight,
tolerance: tolerance
)
}

nonisolated static func rowsLayoutCompleteness<ID: Hashable>(
laidOutRowIds: Set<ID>,
workspaceIds: [ID]
) -> SidebarWorkspaceRowsLayoutCompleteness {
guard !workspaceIds.isEmpty else { return .complete }
guard !laidOutRowIds.isEmpty else { return .unmeasured }
return laidOutRowIds.isSuperset(of: workspaceIds) ? .complete : .partial
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

enum SidebarWorkspaceRowsLayoutCompleteness: Equatable {
case unmeasured
case partial
case complete
}

struct SidebarWorkspaceRowsMeasurement<ID: Equatable>: Equatable {
let workspaceIds: [ID]
let rowsHeight: CGFloat

nonisolated func rowsHeight(for currentWorkspaceIds: [ID]) -> CGFloat? {
guard workspaceIds == currentWorkspaceIds else { return nil }
return max(0, rowsHeight)
}

nonisolated func isEquivalent(
to other: SidebarWorkspaceRowsMeasurement<ID>,
tolerance: CGFloat = 0.5
) -> Bool {
workspaceIds == other.workspaceIds && abs(rowsHeight - other.rowsHeight) <= tolerance
}
}
Loading
Loading