Skip to content

feat: make workspaces list scrollable on overflow #197

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 24 additions & 20 deletions Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,32 @@ struct Agents<VPN: VPNService>: View {
if vpn.state == .connected {
let items = vpn.menuState.sorted
let visibleItems = viewAll ? items[...] : items.prefix(defaultVisibleRows)
ForEach(visibleItems, id: \.id) { agent in
MenuItemView(
item: agent,
baseAccessURL: state.baseAccessURL!,
expandedItem: $expandedItem,
userInteracted: $hasToggledExpansion
)
.padding(.horizontal, Theme.Size.trayMargin)
}.onChange(of: visibleItems) {
// If no workspaces are online, we should expand the first one to come online
if visibleItems.filter({ $0.status != .off }).isEmpty {
hasToggledExpansion = false
return
ScrollView(showsIndicators: false) {
ForEach(visibleItems, id: \.id) { agent in
MenuItemView(
item: agent,
baseAccessURL: state.baseAccessURL!,
expandedItem: $expandedItem,
userInteracted: $hasToggledExpansion
)
.padding(.horizontal, Theme.Size.trayMargin)
}.onChange(of: visibleItems) {
// If no workspaces are online, we should expand the first one to come online
if visibleItems.filter({ $0.status != .off }).isEmpty {
hasToggledExpansion = false
return
}
if hasToggledExpansion {
return
}
withAnimation(.snappy(duration: Theme.Animation.collapsibleDuration)) {
expandedItem = visibleItems.first?.id
}
hasToggledExpansion = true
}
if hasToggledExpansion {
return
}
withAnimation(.snappy(duration: Theme.Animation.collapsibleDuration)) {
expandedItem = visibleItems.first?.id
}
hasToggledExpansion = true
}
.scrollBounceBehavior(.basedOnSize)
.frame(maxHeight: 400)
if items.count == 0 {
Text("No workspaces!")
.font(.body)
Expand Down
31 changes: 16 additions & 15 deletions Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,25 @@ struct MenuItemView: View {
MenuItemIcons(item: item, wsURL: wsURL)
}
if isExpanded {
switch (loadingApps, hasApps) {
case (true, _):
CircularProgressView(value: nil, strokeWidth: 3, diameter: 15)
.padding(.top, 5)
case (false, true):
MenuItemCollapsibleView(apps: apps)
case (false, false):
HStack {
Text(item.status == .off ? "Workspace is offline." : "No apps available.")
.font(.body)
.foregroundColor(.secondary)
.padding(.horizontal, Theme.Size.trayInset)
.padding(.top, 7)
Group {
switch (loadingApps, hasApps) {
case (true, _):
CircularProgressView(value: nil, strokeWidth: 3, diameter: 15)
.padding(.top, 5)
case (false, true):
MenuItemCollapsibleView(apps: apps)
case (false, false):
HStack {
Text(item.status == .off ? "Workspace is offline." : "No apps available.")
.font(.body)
.foregroundColor(.secondary)
.padding(.horizontal, Theme.Size.trayInset)
.padding(.top, 7)
}
}
}
}.task { await loadApps() }
Copy link
Member Author

@ethanndickson ethanndickson Jul 7, 2025

Choose a reason for hiding this comment

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

Previously, we were fetching the apps when the menu bar row was rendered (this was before we had a dropdown). Now, we fetch when the dropdown is expanded.

}
}
.task { await loadApps() }
}

func loadApps() async {
Expand Down
Loading