diff --git a/Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift b/Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift index 33fa71c5..58df8d31 100644 --- a/Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift +++ b/Coder-Desktop/Coder-Desktop/Views/VPN/Agents.swift @@ -16,28 +16,32 @@ struct Agents: 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) diff --git a/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift b/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift index 880241a0..3446429e 100644 --- a/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift +++ b/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenuItem.swift @@ -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() } } } - .task { await loadApps() } } func loadApps() async {