Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: pointer cursor on all buttons in non-key notification panel

Louis Beaumont453948c5b84b
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
index eccdddf06..59acbeca8 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift
@@ -115,6 +115,49 @@ private enum Brand {
// MARK: - SwiftUI Views
+/// NSView-based cursor override that works in non-key NSPanel windows.
+/// SwiftUI's .onHover + NSCursor.push/pop doesn't reliably fire in
+/// non-activating panels, so we use resetCursorRects instead.
+struct PointerCursorView: NSViewRepresentable {
+ func makeNSView(context: Context) -> NSView {
+ let v = PointerNSView()
+ return v
+ }
+ func updateNSView(_ nsView: NSView, context: Context) {}
+}
+
+private class PointerNSView: NSView {
+ override func resetCursorRects() {
+ addCursorRect(bounds, cursor: .pointingHand)
+ }
+ override func updateTrackingAreas() {
+ super.updateTrackingAreas()
+ // Force cursor rect refresh
+ window?.invalidateCursorRects(for: self)
+ }
+}
+
+/// Button that always shows pointer cursor, even in non-key panels.
+@available(macOS 13.0, *)
+struct PointerCursorButton<Label: View>: View {
+ let action: () -> Void
+ let label: () -> Label
+
+ init(action: @escaping () -> Void, @ViewBuilder label: @escaping () -> Label) {
+ self.action = action
+ self.label = label
+ }
+
+ var body: some View {
+ Button(action: action) {
+ label()
+ }
+ .buttonStyle(.plain)
+ .overlay(PointerCursorView())
+ .contentShape(Rectangle())
+ }
+}
+
/// Button with brand-compliant hover: color inversion, sharp corners, 1px border
@available(macOS 13.0, *)
struct BrandButton: View {
@@ -141,9 +184,9 @@ struct BrandButton: View {
Rectangle()
.stroke(Color.primary.opacity(0.12), lineWidth: 1)
)
+ .overlay(PointerCursorView())
.contentShape(Rectangle())
.onHover { hovering in
- if hovering { NSCursor.pointingHand.push() } else { NSCursor.pop() }
withAnimation(.linear(duration: Brand.animDuration)) {
isHovered = hovering
}
@@ -166,9 +209,9 @@ struct BrandTextButton: View {
.foregroundColor(isHovered ? .primary.opacity(0.8) : .primary.opacity(0.3))
}
.buttonStyle(.plain)
+ .overlay(PointerCursorView())
.contentShape(Rectangle())
.onHover { hovering in
- if hovering { NSCursor.pointingHand.push() } else { NSCursor.pop() }
withAnimation(.linear(duration: Brand.animDuration)) {
isHovered = hovering
}
@@ -194,15 +237,13 @@ struct NotificationContentView: View {
.font(Brand.swiftUIMonoFont(size: 10, weight: .medium))
.foregroundColor(.primary.opacity(0.4))
Spacer()
- Button(action: onDismiss) {
+ PointerCursorButton(action: onDismiss) {
Text("✕")
.font(Brand.swiftUIMonoFont(size: 12))
.foregroundColor(closeHovered ? .primary.opacity(0.9) : .primary.opacity(0.35))
+ .frame(width: 20, height: 20)
}
- .buttonStyle(.plain)
- .contentShape(Rectangle())
.onHover { h in
- if h { NSCursor.pointingHand.push() } else { NSCursor.pop() }
withAnimation(.linear(duration: Brand.animDuration)) { closeHovered = h }
}
}