Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(spaces-macos): keep the notch panel's search inside the glass panel (#4847)
ddupont384f0b3b2809
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchContentView.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchContentView.swiftindex 40d933d3c6..e2fcb72291 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchContentView.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchContentView.swift@@ -43,6 +43,26 @@ struct NotchShape: Shape {}}+/// What the panel's content is clipped to: the shape the surface draws,+/// the black notch outline or (without a notch) the glass panel's rounded+/// rectangle.+struct NotchSurfaceShape: Shape {+ var notchStyle: Bool+ var top: CGFloat+ var bottom: CGFloat+ var corner: CGFloat++ var animatableData: AnimatablePair<AnimatablePair<CGFloat, CGFloat>, CGFloat> {+ get { AnimatablePair(AnimatablePair(top, bottom), corner) }+ set { top = newValue.first.first; bottom = newValue.first.second; corner = newValue.second }+ }++ func path(in rect: CGRect) -> Path {+ notchStyle ? NotchShape(top: top, bottom: bottom).path(in: rect)+ : RoundedRectangle(cornerRadius: corner, style: .continuous).path(in: rect)+ }+}+/// The "N Spaces" tab: square on the left (it tucks under the notch), a/// concave ear on the top right and a rounded bottom-right corner, so the/// notch and the tab read as one shape.@@ -125,6 +145,38 @@ struct NotchGeometry: Equatable {case .tiles: return open}}++ /// The glass panel's corner radius (no notch): open, or the closed+ /// capsule.+ static let glassRadius: CGFloat = 20+ func glassCorner(open: Bool) -> CGFloat { open ? Self.glassRadius : notch.height / 2 }++ /// How far the search's hover fill reaches past its glyph, and the+ /// fill's corner radius.+ static let searchReach: CGFloat = 8+ static let searchCorner: CGFloat = 8++ /// The open panel's side padding: the tiles' (and the search glyph's)+ /// left edge.+ func side(radii: (closed: AppNotchRadii, open: AppNotchRadii)) -> CGFloat {+ CGFloat((notchStyle ? radii.open.top : 0) + 15)+ }++ /// Space above the open panel's header row. None beside the notch (the+ /// row sits in the camera housing's band); on the glass panel, enough+ /// that the search's hover fill is as far from the top edge as from the+ /// side, clear of the rounded corner.+ func headerTop(side: CGFloat) -> CGFloat {+ guard !notchStyle else { return 0 }+ return max(0, side - Self.searchReach - (notch.height - NotchPress.minHit) / 2)+ }++ /// The search's hover fill in the open panel's coordinates (its width+ /// follows the row, so only its leading edge, top and height are fixed).+ func searchFill(side: CGFloat, width: CGFloat) -> CGRect {+ CGRect(x: side - Self.searchReach, y: headerTop(side: side) + (notch.height - NotchPress.minHit) / 2,+ width: width, height: NotchPress.minHit)+ }}/// What the notch panel draws: the closed notch with its "N Spaces" tab, the@@ -226,7 +278,8 @@ struct NotchContentView: View {}}.frame(width: size.width, height: size.height, alignment: .top)- .clipShape(NotchShape(top: r.top, bottom: r.bottom))+ .clipShape(NotchSurfaceShape(notchStyle: g.notchStyle, top: r.top, bottom: r.bottom,+ corner: g.glassCorner(open: shape.isOpen)))}.frame(width: g.stage.width, height: g.stage.height, alignment: .top).environment(\.colorScheme, .dark)@@ -303,9 +356,9 @@ struct NotchContentView: View {.fill(.black).shadow(color: .black.opacity(shape.isOpen ? 0.45 : 0), radius: 14, y: 6)} else {- RoundedRectangle(cornerRadius: shape.isOpen ? 20 : g.notch.height / 2, style: .continuous)+ RoundedRectangle(cornerRadius: g.glassCorner(open: shape.isOpen), style: .continuous).fill(.clear)- .glassEffect(.regular, in: .rect(cornerRadius: shape.isOpen ? 20 : g.notch.height / 2))+ .glassEffect(.regular, in: .rect(cornerRadius: g.glassCorner(open: shape.isOpen)))}}@@ -373,7 +426,7 @@ struct NotchContentView: View {@ViewBuilderprivate func contentView(_ c: NotchStage.Shape, _ v: AppNotchView, g: NotchGeometry) -> some View {let inset = g.notchStyle || v.header != nil ? g.notch.height : 0- let side = CGFloat((g.notchStyle ? radii.open.top : 0) + 15)+ let side = g.side(radii: radii)switch c {case .prompt:VStack(spacing: 0) {@@ -387,8 +440,9 @@ struct NotchContentView: View {default:VStack(spacing: 0) {if let h = v.header {- header(h, g: g).frame(height: g.notch.height)- Spacer().frame(height: inset - g.notch.height + 15)+ let top = g.headerTop(side: side)+ header(h, g: g).frame(height: g.notch.height).padding(.top, top)+ Spacer().frame(height: max(0, inset - g.notch.height + 15 - top))} else {Spacer().frame(height: inset + 15)}@@ -423,7 +477,7 @@ struct NotchContentView: View {/// housing, the buttons right of it, nothing under it. Without a notch/// it is one full-width row.private func header(_ h: AppNotchHeader, g: NotchGeometry) -> some View {- let side = CGFloat((g.notchStyle ? radii.open.top : 0) + 15)+ let side = g.side(radii: radii)let gap: CGFloat = 12let zone = g.notchStyle ? max(0, (g.open.width - g.notch.width) / 2 - side - gap) : nillet query = Binding(get: { model.state.query }, set: { model.search($0) })@@ -817,14 +871,14 @@ struct NotchSearchZone<Content: View>: View {var body: some View {let on = hovered || forced?.hovered == trueHStack(spacing: 6) { content }- .padding(.horizontal, 8)+ .padding(.horizontal, NotchGeometry.searchReach).frame(minHeight: NotchPress.minHit)- .background(RoundedRectangle(cornerRadius: 8, style: .continuous)+ .background(RoundedRectangle(cornerRadius: NotchGeometry.searchCorner, style: .continuous).fill(.white.opacity(on ? 0.08 : 0))).contentShape(.rect)// The fill reaches past the glyph; the glyph stays on the tiles'// left edge.- .padding(.horizontal, -8)+ .padding(.horizontal, -NotchGeometry.searchReach).onTapGesture(perform: focus).onHover { hovered = $0 }.pointerStyle(.horizontalText)diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swiftindex 11deebd96e..a66cb45fa9 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift@@ -106,6 +106,43 @@ struct NotchTests {return m.notch.spaces}+ /// The open panel's search sits inside the panel: its hover fill clears+ /// the rounded top-left corner by a margin and, on the glass panel (no+ /// notch), is as far from the top edge as from the side (#4644). Beside+ /// a notch it clears the concave ear (the top edge is the screen's).+ @Test func searchFillClearsThePanelCorner() {+ let r = appNotchRadii()+ let radii = (closed: r[0], open: r[1])+ let margin: CGFloat = 4+ func glass(menuBar: Double) -> NotchGeometry {+ NotchGeometry(appNotchLayout(screen: AppScreenFacts(+ frame: AppLogicalRect(x: 0, y: 0, width: 1440, height: 900),+ visibleFrame: AppLogicalRect(x: 0, y: 0, width: 1440, height: 900 - menuBar),+ safeAreaTop: 0, auxLeftWidth: nil, auxRightWidth: nil), prompt: false))+ }+ let notched = NotchGeometry.fallback+ #expect(notched.notchStyle)+ #expect(notched.searchFill(side: notched.side(radii: radii), width: 120).minX >= CGFloat(radii.open.top) + margin)++ for g in [glass(menuBar: 24), glass(menuBar: 0), glass(menuBar: 30)] {+ #expect(!g.notchStyle)+ let fill = g.searchFill(side: g.side(radii: radii), width: 120)+ let outline = NotchSurfaceShape(notchStyle: g.notchStyle, top: radii.open.top, bottom: radii.open.bottom,+ corner: g.glassCorner(open: true))+ .path(in: CGRect(origin: .zero, size: g.open))+ // The fill's top-left corner grown by the margin: every point of+ // it inside the panel's outline.+ let c = NotchGeometry.searchCorner+ let center = CGPoint(x: fill.minX + c, y: fill.minY + c)+ for deg in stride(from: 180.0, through: 270.0, by: 5.0) {+ let a = deg * .pi / 180+ let p = CGPoint(x: center.x + (c + margin) * cos(a), y: center.y + (c + margin) * sin(a))+ #expect(outline.contains(p), "menu bar \(g.notch.height): \(p) outside the panel")+ }+ #expect(fill.minY == fill.minX, "as far from the top as from the side (\(fill))")+ }+ }+// MARK: - Hover timing (the core's dwell and close delay)@Test func hoverOpensOnlyAfterTheDwell() async {