Repository navigation
Fix sidebar scrollbar: hide when content fits, fade overlay knob when idle (#3241) #4767
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
Changes from 5 commits
26a545f
3cb31e6
c13e02c
0468a3b
6932dc1
720759e
d89366f
b59e4a3
7ee70b4
40728e8
41501bf
4e5d6ae
52d7795
c77cb05
a6bcdad
b43052b
591c431
4b4c870
358c1f4
e806c53
603202a
808530f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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> = [] | ||||||
|
|
@@ -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 | ||||||
| ) | ||||||
|
|
||||||
| ScrollViewReader { scrollProxy in | ||||||
| ScrollView { | ||||||
| ScrollView(.vertical) { | ||||||
| workspaceScrollContent( | ||||||
| renderContext: renderContext, | ||||||
| minHeight: SidebarWorkspaceScrollLayout.contentMinHeight( | ||||||
| viewportHeight: geometryProxy.size.height, | ||||||
| insets: scrollInsets | ||||||
| ) | ||||||
| minHeight: contentMinHeight, | ||||||
| emptyAreaHeight: emptyAreaHeight | ||||||
| ) | ||||||
| } | ||||||
| .scrollIndicators(.automatic) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
| ) | ||||||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||||||
| dragAutoScrollController.attach(scrollView: scrollView) | ||||||
| } | ||||||
| .frame(width: 0, height: 0) | ||||||
|
|
@@ -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 | ||||||
|
|
@@ -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 | ||||||
| ) | ||||||
| ) | ||||||
| } | ||||||
|
cursor[bot] marked this conversation as resolved.
Resolved
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) | ||||||
|
|
@@ -10122,6 +10187,7 @@ struct VerticalTabsSidebar: View { | |||||
| } | ||||||
| .background( | ||||||
| SidebarScrollViewResolver { scrollView in | ||||||
| configureSidebarScrollViewFromDocument(scrollView) | ||||||
| dragAutoScrollController.attach(scrollView: scrollView) | ||||||
| } | ||||||
| .frame(width: 0, height: 0) | ||||||
|
|
@@ -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) | ||||||
|
|
@@ -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) | ||||||
| } | ||||||
|
|
@@ -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( | ||||||
|
|
@@ -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 | ||||||
|
|
||||||
|
|
@@ -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 { | ||||||
|
|
@@ -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()) | ||||||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private struct ExtensionSidebarBrowserStackEmptyArea: View { | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.