Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e97ef46
test: cloud team chip reports hover through its menu anchor
lucasr1b Oct 7, 2026
f233680
cloud: hover on the team chip and the banner close buttons
lucasr1b Oct 7, 2026
91c8e5e
cloud: team chip drops hover when it leaves its window
lucasr1b Oct 7, 2026
13ca34d
test: cover immediate cloud team hover detach
austinywang Oct 10, 2026
dc6ab32
fix: keep cloud team hover across pointer lifecycle
austinywang Oct 10, 2026
d3de1ca
fix: use window coordinates for cloud hover sync
austinywang Oct 10, 2026
5e718c9
test: keep hover fixture outside the anchor
austinywang Oct 10, 2026
fe6a9db
test: cover stale team hover events across reattachment
austinywang Oct 10, 2026
85a0e84
fix: give cloud hover one lifecycle owner
austinywang Oct 10, 2026
06b07fe
fix: preserve sidebar chip environment
austinywang Oct 10, 2026
2cbe04e
fix: use supported sidebar appearance environment
austinywang Oct 10, 2026
4659066
cloud sidebar: no other devices yet, refresh sits closer to the count
lucasr1b Oct 11, 2026
06e5641
cloud sidebar: the devices row says no devices yet, settings keeps no…
lucasr1b Oct 11, 2026
46354a9
right sidebar: open as pane keeps its slot on dock and feed so tab sw…
lucasr1b Oct 11, 2026
9d733dd
right sidebar: open as pane stays on dock and feed, disabled with a t…
lucasr1b Oct 11, 2026
1da10d6
Merge remote-tracking branch 'origin/cloud-hover' into cloud-devices-…
lucasr1b Oct 11, 2026
2c6cefb
cloud sidebar: empty section lines sit closer to their headers
lucasr1b Oct 11, 2026
b96d540
right sidebar: quicker tab switch, label fade no longer trails the width
lucasr1b Oct 11, 2026
c43a810
cloud sidebar: my devices refresh only refreshes devices, cloud machi…
lucasr1b Oct 11, 2026
a54943a
cloud sidebar: empty section lines sit a little higher
lucasr1b Oct 11, 2026
88a66f9
back out the empty line lifts and the quicker tab switch, trying them…
lucasr1b Oct 11, 2026
727c49c
right sidebar: tab switch glides on the sidebar spring with one slidi…
lucasr1b Oct 11, 2026
66a6976
right sidebar: one selection pill, the old copy leaves at once instea…
lucasr1b Oct 11, 2026
cc7800c
right sidebar: snappier tab switch, labels swap straight away
lucasr1b Oct 11, 2026
360507c
cloud sidebar: empty lines get a real 18pt row instead of centering i…
lucasr1b Oct 11, 2026
dc16f52
Merge main (b8370eadb546) into cloud-typography
lucasr1b Oct 11, 2026
91e1d58
keep the string catalog diff to our keys after merging main
lucasr1b Oct 11, 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public struct CloudBannerDismissButton: View {
}

public let action: () -> Void
@State private var isHovered = false

public var body: some View {
Button(action: action) {
Expand All @@ -19,7 +20,14 @@ public struct CloudBannerDismissButton: View {
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.foregroundStyle(.secondary)
.foregroundStyle(isHovered ? .primary : .secondary)
// The Cloud sidebar's icon-button hover (`MachinesChromeIconButton`):
// a faint fill in the sidebar's 6 pt button shape.
.background(
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(isHovered ? Color.primary.opacity(0.06) : Color.clear)
)
.onHover { isHovered = $0 }
.help(String(localized: "common.close", defaultValue: "Close"))
.accessibilityLabel(String(localized: "common.close", defaultValue: "Close"))
.accessibilityIdentifier("CloudBannerDismissButton")
Expand Down
57 changes: 56 additions & 1 deletion Sources/Cloud/CloudTeamPickerMenuAnchor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import SwiftUI
/// `Menu` cannot do, and a pull-down should track from mouse-down. The overlay
/// takes the pointer; keyboard and VoiceOver presses still reach the trigger
/// button beneath it, which requests the menu through `isPresented` like the
/// palette does.
/// palette does. Because it takes the pointer, the button's own `onHover`
/// never fires, so the overlay reports hover through `isHovered`.
struct CloudTeamPickerMenuAnchor: NSViewRepresentable {
@Binding var isPresented: Bool
@Binding var isHovered: Bool
let helpText: String
/// Receives the anchor, so an item can place follow-up UI on the trigger's
/// window once the menu closes.
Expand All @@ -31,6 +33,7 @@ struct CloudTeamPickerMenuAnchor: NSViewRepresentable {
view.onWillPresent = onWillPresent
view.onOpen = { isPresented = true }
view.onDismiss = { isPresented = false }
view.onHoverChange = { isHovered = $0 }
view.syncPresentation(isPresented)
}

Expand All @@ -49,6 +52,9 @@ final class CloudTeamPickerMenuAnchorView: NSView {
var onWillPresent: (@MainActor () -> Void)?
var onOpen: (@MainActor () -> Void)?
var onDismiss: (@MainActor () -> Void)?
/// Called when the pointer enters or leaves the trigger. Reported whether
/// or not the trigger is enabled; the trigger decides how to draw it.
var onHoverChange: (@MainActor (Bool) -> Void)?
var isRightToLeft = false
var isEnabled = true

Expand All @@ -64,6 +70,8 @@ final class CloudTeamPickerMenuAnchorView: NSView {
private var afterDismissActions: [@MainActor () -> Void] = []
private var isPresentationRequested = false
private var isPresentationScheduled = false
private var hoverTracking: NSTrackingArea?
private var isPointerInside = false

override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
Expand All @@ -80,6 +88,45 @@ final class CloudTeamPickerMenuAnchorView: NSView {
isEnabled ? super.hitTest(point) : nil
}

override func updateTrackingAreas() {
super.updateTrackingAreas()
if let hoverTracking { removeTrackingArea(hoverTracking) }
let area = NSTrackingArea(
rect: .zero,
options: [.mouseEnteredAndExited, .activeInActiveApp, .inVisibleRect],
owner: self
)
addTrackingArea(area)
hoverTracking = area
}

override func mouseEntered(with event: NSEvent) {
super.mouseEntered(with: event)
setPointerInside(true)
}

override func mouseExited(with event: NSEvent) {
super.mouseExited(with: event)
setPointerInside(false)
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

private func setPointerInside(_ inside: Bool) {
guard isPointerInside != inside else { return }
isPointerInside = inside
onHoverChange?(inside)
}

/// The menu's tracking loop swallows enter and exit events, so hover is
/// read from the pointer's position once the menu closes.
private func syncPointerInside() {
guard let window else {
setPointerInside(false)
return
}
let point = convert(window.mouseLocationOutsideOfEventStream, from: nil)
setPointerInside(bounds.contains(point))
}

override func mouseDown(with event: NSEvent) {
guard isEnabled, trackingMenu == nil else { return }
isPresentationRequested = true
Expand All @@ -91,6 +138,13 @@ final class CloudTeamPickerMenuAnchorView: NSView {
super.viewDidMoveToWindow()
if window == nil {
trackingMenu?.cancelTracking()
// Leaving the window sends no exit event. Cleared on a later turn,
// since a removal can land inside a SwiftUI update.
if isPointerInside {
RunLoop.main.perform(inModes: [.default]) { [weak self] in
MainActor.assumeIsolated { self?.setPointerInside(false) }
}
}
} else {
presentIfRequested()
}
Expand Down Expand Up @@ -160,6 +214,7 @@ final class CloudTeamPickerMenuAnchorView: NSView {
_ = menu.popUp(positioning: nil, at: origin, in: self)
trackingMenu = nil
isPresentationRequested = false
syncPointerInside()
onDismiss?()
let actions = afterDismissActions
afterDismissActions.removeAll()
Expand Down
20 changes: 18 additions & 2 deletions Sources/Cloud/CloudTeamPickerRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ struct CloudTeamPickerRow: View {
String(localized: "settings.account.activeTeam", defaultValue: "Active Team")
}

/// Reported by the menu anchor, which sits over the button and takes the
/// pointer (a SwiftUI `onHover` here never fires).
@State private var isHovered = false
@Environment(\.isEnabled) private var isEnabled

/// Hovered, or its menu is open, like a native pull-down.
private var isHighlighted: Bool {
isEnabled && (isHovered || presentation.isPresented)
}

var body: some View {
Button {
Expand All @@ -50,18 +58,26 @@ struct CloudTeamPickerRow: View {
.font(.system(size: 9, weight: .semibold))
}
// Same grey and hover rule as the tab bar's mode labels above.
.foregroundColor(RightSidebarChromeControlStyle.pillForegroundColor(isSelected: false, isHovered: isHovered))
.foregroundColor(RightSidebarChromeControlStyle.pillForegroundColor(isSelected: false, isHovered: isHighlighted))
// Flush with the tree's section chevrons below.
.padding(.leading, 1)
.padding(.trailing, 7)
.frame(height: 22)
// The Invite button's fill, starting where the tree's row
// highlights start so the chip keeps its alignment with the tree.
.background(
RoundedRectangle(cornerRadius: RightSidebarChromeMetrics.buttonCornerRadius, style: .continuous)
.fill(Color.primary.opacity(isHighlighted ? 0.08 : 0))
.frame(height: 20)
.padding(.leading, -CloudTreeHoverStyle.leadingOutset)
)
.contentShape(RoundedRectangle(cornerRadius: RightSidebarChromeMetrics.buttonCornerRadius, style: .continuous))
}
.buttonStyle(.plain)
.onHover { isHovered = $0 }
.overlay {
CloudTeamPickerMenuAnchor(
isPresented: $presentation.isPresented,
isHovered: $isHovered,
helpText: helpText,
makeMenu: makeMenu,
onWillPresent: {
Expand Down
57 changes: 57 additions & 0 deletions cmuxTests/CloudTeamPickerMenuTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,63 @@ struct CloudTeamPickerMenuTests {
#expect(events == ["tracking ended", "dismissed", "follow-up", "closed menu"])
}

/// The anchor overlay takes the pointer from the trigger button beneath
/// it, so the button's own hover never fired. The anchor reports it.
@Test func anchorReportsThePointerEnteringAndLeaving() throws {
var hovers: [Bool] = []
let anchor = CloudTeamPickerMenuAnchorView(
frame: NSRect(x: 0, y: 0, width: 120, height: 22)
)
anchor.onHoverChange = { hovers.append($0) }

anchor.mouseEntered(with: try pointerEvent(.mouseEntered))
anchor.mouseEntered(with: try pointerEvent(.mouseEntered))
anchor.mouseExited(with: try pointerEvent(.mouseExited))

#expect(hovers == [true, false])
}

/// A menu's tracking loop swallows the exit, so closing the menu settles
/// hover from where the pointer is now.
@Test func closingTheMenuClearsHoverWhenThePointerLeft() throws {
var hovers: [Bool] = []
let anchor = CloudTeamPickerMenuAnchorView(
frame: NSRect(x: 0, y: 0, width: 120, height: 22)
)
anchor.onHoverChange = { hovers.append($0) }
anchor.makeMenu = { _ in CloudTeamPickerTestMenu { _ in } }
anchor.mouseEntered(with: try pointerEvent(.mouseEntered))

anchor.mouseDown(with: try #require(NSEvent.mouseEvent(
with: .leftMouseDown,
location: .zero,
modifierFlags: [],
timestamp: 0,
windowNumber: 0,
context: nil,
eventNumber: 0,
clickCount: 1,
pressure: 1
)))

// Windowless, so the pointer is nowhere over the trigger.
#expect(hovers == [true, false])
}

private func pointerEvent(_ type: NSEvent.EventType) throws -> NSEvent {
try #require(NSEvent.enterExitEvent(
with: type,
location: .zero,
modifierFlags: [],
timestamp: 0,
windowNumber: 0,
context: nil,
eventNumber: 0,
trackingNumber: 0,
userData: nil
))
}

/// Run-loop blocks run in FIFO order, so a scheduled open has run by the
/// time this later block does.
private func nextRunLoopTurn() async {
Expand Down
Loading