From e114d41c5ff74e3e66a1dc5974c817bd80bd686e Mon Sep 17 00:00:00 2001 From: austinywang Date: Thu, 1 Oct 2026 04:53:50 +0000 Subject: [PATCH 1/2] Select active cloud workspace in machines sidebar --- Sources/Cloud/MachinesPanelView.swift | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Sources/Cloud/MachinesPanelView.swift b/Sources/Cloud/MachinesPanelView.swift index c7590d792a5a..dee9a1742557 100644 --- a/Sources/Cloud/MachinesPanelView.swift +++ b/Sources/Cloud/MachinesPanelView.swift @@ -24,6 +24,9 @@ struct MachinesPanelView: View { /// it is starting, waiting for the extension approval, up, or failed. @State private var tunnelStatus = CloudTunnelStatusModel() @State private var devBackend = DevBackendStartup() + /// The main workspace selection is the authority for the tree projection. + /// Keep this request window-local so another window cannot move this tree. + @State private var selectionReveal: CloudTreeRevealRequest? @State private var bannerDismissals: CloudBannerDismissalStore /// The tree's visual preset; the debug gallery's "Use" buttons write this, /// and @AppStorage re-renders the live panel the moment it changes. @@ -125,6 +128,8 @@ struct MachinesPanelView: View { } } .onAppear { syncPolling(for: authState) } + .onAppear { refreshSelectionReveal() } + .onChange(of: tabManager?.selectedTabId) { _, _ in refreshSelectionReveal() } .onChange(of: devicesModel.preferences?.discoveryEnabled) { _, _ in syncPolling(for: authState) } .onChange(of: cloudBetaEnabled) { _, _ in syncPolling(for: authState) } .onReceive(NotificationCenter.default.publisher(for: DeviceSurfaceProviderRegistry.revealDeviceNotification)) { _ in @@ -162,6 +167,25 @@ struct MachinesPanelView: View { .accessibilityIdentifier("CloudMachinesPanel") } + /// Project the selected workspace by stable machine/workspace identity. + /// Names are intentionally absent: duplicate workspace names are valid. + private func refreshSelectionReveal() { + guard let workspace = tabManager?.selectedWorkspace, + let machineID = workspace.cloudVMID else { + selectionReveal = nil + return + } + let machine = SurfaceMachineID.cloud(machineID) + let nodeID: String + if let remoteWorkspaceID = workspace.cloudVMBinding?.remoteWorkspaceID, + !remoteWorkspaceID.isEmpty { + nodeID = CloudTreeNodeBuilder.nodeID(workspace: remoteWorkspaceID, machine: machine) + } else { + nodeID = CloudTreeNodeBuilder.nodeID(machine: machine) + } + selectionReveal = CloudTreeRevealRequest(token: UUID(), nodeID: nodeID) + } + @ViewBuilder private var authenticatedContent: some View { if includesCloud { @@ -458,7 +482,7 @@ struct MachinesPanelView: View { showsCloudVPNWarning: tunnelStatus.status?.state == .off, canCreateCloudMachine: includesCloud, cloudMachinesUsage: includesCloud ? viewModel.visibleUsage : nil, - reveal: devicesModel.revealRequest, + reveal: selectionReveal ?? devicesModel.revealRequest, creationReveal: SurfaceCatalog.shared.cloudWorkspaceCreationCoordinator.reveals.reveal(for: tabManager) ) .accessibilityIdentifier("CloudMachinesTree") From 79d1cfe223c8ed3e477c3ce48a275d7d98cedc0e Mon Sep 17 00:00:00 2001 From: austinywang Date: Thu, 1 Oct 2026 05:43:02 +0000 Subject: [PATCH 2/2] Harden cloud sidebar reveal updates --- Sources/Cloud/MachinesPanelView.swift | 10 ++++++++-- Sources/Update/NotificationPopoverRow.swift | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Cloud/MachinesPanelView.swift b/Sources/Cloud/MachinesPanelView.swift index dee9a1742557..dfb2c5af3277 100644 --- a/Sources/Cloud/MachinesPanelView.swift +++ b/Sources/Cloud/MachinesPanelView.swift @@ -103,6 +103,12 @@ struct MachinesPanelView: View { private var treeSource: CloudTreeMachineSource { .cloudWithDevicesSection } + private var selectedCloudIdentity: String? { + guard let workspace = tabManager?.selectedWorkspace, + let machineID = workspace.cloudVMID else { return nil } + return [machineID, workspace.cloudVMBinding?.remoteWorkspaceID ?? ""].joined(separator: "\u{1f}") + } + private var treeSnapshot: SurfaceCatalogSnapshot { viewModel.visibleCatalog.applyingDeviceVisibility( includesCloud: includesCloud, @@ -129,7 +135,7 @@ struct MachinesPanelView: View { } .onAppear { syncPolling(for: authState) } .onAppear { refreshSelectionReveal() } - .onChange(of: tabManager?.selectedTabId) { _, _ in refreshSelectionReveal() } + .onChange(of: selectedCloudIdentity) { _, _ in refreshSelectionReveal() } .onChange(of: devicesModel.preferences?.discoveryEnabled) { _, _ in syncPolling(for: authState) } .onChange(of: cloudBetaEnabled) { _, _ in syncPolling(for: authState) } .onReceive(NotificationCenter.default.publisher(for: DeviceSurfaceProviderRegistry.revealDeviceNotification)) { _ in @@ -482,7 +488,7 @@ struct MachinesPanelView: View { showsCloudVPNWarning: tunnelStatus.status?.state == .off, canCreateCloudMachine: includesCloud, cloudMachinesUsage: includesCloud ? viewModel.visibleUsage : nil, - reveal: selectionReveal ?? devicesModel.revealRequest, + reveal: devicesModel.revealRequest ?? selectionReveal, creationReveal: SurfaceCatalog.shared.cloudWorkspaceCreationCoordinator.reveals.reveal(for: tabManager) ) .accessibilityIdentifier("CloudMachinesTree") diff --git a/Sources/Update/NotificationPopoverRow.swift b/Sources/Update/NotificationPopoverRow.swift index 7c39e3064882..116fe12cd6e3 100644 --- a/Sources/Update/NotificationPopoverRow.swift +++ b/Sources/Update/NotificationPopoverRow.swift @@ -97,7 +97,7 @@ struct NotificationPopoverRow: View, Equatable { private var rowContent: some View { HStack(spacing: 0) { Rectangle() - .fill(notification.isRead ? Color.clear : cmuxAccent.color) + .fill(notification.isRead ? Color.clear : cmuxAccent) .frame(width: 2.5) .padding(.vertical, 6)