Skip to content

Open source CapCut alternative.

TypeScript

feat(app): content-driven collapsed notch lanes

David Lea880d37ce7e5
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
index 04fd46ac..312ea3c2 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
@@ -999,6 +999,16 @@ final class UserQueryOverlayController {
}
private func notchMetrics(for screen: NSScreen? = nil) -> NotchMetrics {
+ // Size the collapsed side lanes from the same conversation state the notch view renders, so each
+ // lane expands for its content (the trailing lane for the live clock, the leading lane for a
+ // multi-pointer cluster) and collapses back when unused. `notchConversations.first` is the view's
+ // primary; the trailing gutter matches `collapsedRightSlot`'s precedence (failure → status → update).
+ let trailingSlot = NotchMetrics.collapsedTrailingSlot(
+ primaryStatus: model.notchConversations.first?.status,
+ hasSurfacedError: model.notchSurfacedConversations.contains { $0.status == .failed },
+ isUpdateActionable: model.updateState.isActionable
+ )
+ let leadingPointerCount = model.notchSurfacedConversations.count
let screen = screen ?? activeScreen()
guard let screen else {
return NotchMetrics(
@@ -1008,7 +1018,9 @@ final class UserQueryOverlayController {
isExpanded: isStatusExpanded,
isHostExpanded: isStatusHostExpanded,
screenWidth: NotchMetrics.defaultScreenWidth,
- needsLogin: model.needsLogin
+ needsLogin: model.needsLogin,
+ collapsedTrailingSlot: trailingSlot,
+ collapsedLeadingPointerCount: leadingPointerCount
)
}
@@ -1038,7 +1050,9 @@ final class UserQueryOverlayController {
isHostExpanded: isStatusHostExpanded,
screenWidth: screen.frame.width,
chinHeight: 0,
- needsLogin: model.needsLogin
+ needsLogin: model.needsLogin,
+ collapsedTrailingSlot: trailingSlot,
+ collapsedLeadingPointerCount: leadingPointerCount
)
let collapsedWidth = widthProbe.layout.collapsedSurfaceFrame.width
let chinTextWidth = collapsedWidth - Self.statusChinHorizontalInset
@@ -1055,7 +1069,9 @@ final class UserQueryOverlayController {
collapsedWidth: collapsedWidth,
hasNotch: hasNotch
),
- needsLogin: model.needsLogin
+ needsLogin: model.needsLogin,
+ collapsedTrailingSlot: trailingSlot,
+ collapsedLeadingPointerCount: leadingPointerCount
)
}
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryNotchLayout.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryNotchLayout.swift
index 2a247b6e..95f79aa8 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryNotchLayout.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryNotchLayout.swift
@@ -1,6 +1,26 @@
import CoreGraphics
import Foundation
+/// What the collapsed notch's trailing (right) lane shows. One source of truth for the gutter: the
+/// layout sizes the lane from this — only the live clock needs the widened lane; a glyph or the update
+/// icon fits the original width; nothing collapses it back — and the view renders the matching content
+/// by switching on the very same value, so the lane width and what sits in it can never drift.
+public enum CollapsedTrailingSlot: String, Equatable, Sendable {
+ /// Nothing in the gutter — the lane collapses to its original width.
+ case empty
+ /// The waiting-on-user attention mark (clarification, review, or permission). Fits the original width.
+ case attentionGlyph
+ /// A surfaced failure's red warning mark. Fits the original width.
+ case errorGlyph
+ /// An available app update. Fits the original width.
+ case updateIcon
+ /// The live elapsed timer ("Nh Nm Ns") — the only gutter content that needs the widened lane.
+ case clock
+
+ /// Only the live clock needs the wide lane; every glyph/icon and the empty lane keep the original width.
+ public var needsWideLane: Bool { self == .clock }
+}
+
public struct UserQueryNotchLayout: Equatable, Sendable {
public static let expandedCommandOnlyTopPaddingBelowPhysicalVoid: CGFloat = 16
@@ -25,6 +45,9 @@ public struct UserQueryNotchLayout: Equatable, Sendable {
public var chinHeight: CGFloat
/// Logged out: render the login call-to-action instead of the task surface.
public var needsLogin: Bool
+ /// What the collapsed trailing lane shows. The view renders its gutter by switching on this, the
+ /// same value that sized the lane — so the content and the width it sits in are one decision.
+ public var collapsedTrailingSlot: CollapsedTrailingSlot
public init(
voidWidth: CGFloat,
@@ -41,7 +64,8 @@ public struct UserQueryNotchLayout: Equatable, Sendable {
canRenderTextInTopRow: Bool,
collapsedVoidLeadingInset: CGFloat = 0,
chinHeight: CGFloat = 0,
- needsLogin: Bool = false
+ needsLogin: Bool = false,
+ collapsedTrailingSlot: CollapsedTrailingSlot = .empty
) {
self.voidWidth = voidWidth
self.voidHeight = voidHeight
@@ -58,6 +82,7 @@ public struct UserQueryNotchLayout: Equatable, Sendable {
self.collapsedVoidLeadingInset = collapsedVoidLeadingInset
self.chinHeight = chinHeight
self.needsLogin = needsLogin
+ self.collapsedTrailingSlot = collapsedTrailingSlot
}
public var shouldRenderExpandedTopRowVoidMarker: Bool {
@@ -98,6 +123,15 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
/// Logged out: render the login call-to-action instead of the task surface. Collapsed shows just
/// the "Login to use Donkey" line; expanding reveals a wide, short bar with the Login button.
public var needsLogin: Bool
+ /// What the collapsed trailing lane shows. The lane expands only for the live clock and collapses
+ /// back to the original width for a glyph, the update icon, or nothing — so the width tracks the
+ /// content. Built with `collapsedTrailingSlot(primaryStatus:hasSurfacedError:isUpdateActionable:)`
+ /// from the same conversation state the notch view renders.
+ public var collapsedTrailingSlot: CollapsedTrailingSlot
+ /// How many pointers the collapsed leading lane holds (the surfaced-conversation cluster). The lane
+ /// widens to fit a multi-pointer cluster and collapses back to the original width for one or none,
+ /// so both side lanes are sized by their content rather than a fixed literal.
+ public var collapsedLeadingPointerCount: Int
/// Height of the short collapsed login band that seats the "Login to use Donkey" line below the
/// void on a real notch. No-notch displays render the line inline in the top row.
@@ -116,7 +150,9 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
screenWidth: CGFloat,
chinHeight: CGFloat = 0,
collapsedTopRowExtraHeight: CGFloat = 0,
- needsLogin: Bool = false
+ needsLogin: Bool = false,
+ collapsedTrailingSlot: CollapsedTrailingSlot = .empty,
+ collapsedLeadingPointerCount: Int = 0
) {
self.voidWidth = voidWidth
self.voidHeight = voidHeight
@@ -127,6 +163,33 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
self.chinHeight = chinHeight
self.collapsedTopRowExtraHeight = collapsedTopRowExtraHeight
self.needsLogin = needsLogin
+ self.collapsedTrailingSlot = collapsedTrailingSlot
+ self.collapsedLeadingPointerCount = collapsedLeadingPointerCount
+ }
+
+ /// Classify what the collapsed trailing lane shows, matching the notch view's gutter exactly so the
+ /// lane width (sized from this) and the rendered content (the view's `collapsedRightSlot`) stay one
+ /// decision. A surfaced failure wins first; then the primary conversation's status — running shows
+ /// the clock, a waiting-on-user state shows the attention mark, anything else is empty; an app
+ /// update shows only when no conversation is primary.
+ public static func collapsedTrailingSlot(
+ primaryStatus: UserQueryConversationStatus?,
+ hasSurfacedError: Bool,
+ isUpdateActionable: Bool
+ ) -> CollapsedTrailingSlot {
+ if hasSurfacedError { return .errorGlyph }
+ if let primaryStatus {
+ switch primaryStatus {
+ case .waitingForClarification, .waitingForReview, .waitingForPermission:
+ return .attentionGlyph
+ case .running:
+ return .clock
+ case .chatting, .paused, .completed, .interrupted, .needsAttention, .failed, .timedOut:
+ return .empty
+ }
+ }
+ if isUpdateActionable { return .updateIcon }
+ return .empty
}
public var surfaceSize: CGSize {
@@ -162,7 +225,8 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
canRenderTextInTopRow: canRenderTextInTopRow,
collapsedVoidLeadingInset: collapsedVoidLeadingInset,
chinHeight: effectiveChinHeight,
- needsLogin: needsLogin
+ needsLogin: needsLogin,
+ collapsedTrailingSlot: collapsedTrailingSlot
)
}
@@ -181,7 +245,7 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
/// nominal ratio, keeping the void's seat stable.
private var collapsedVoidLeadingInset: CGFloat {
let laneTotal = max(0, collapsedSurfaceWidth - voidWidth)
- return laneTotal * (Self.collapsedLeadingLaneWidth / Self.collapsedSideLaneTotal)
+ return laneTotal * (collapsedLeadingLaneWidth / collapsedSideLaneTotal)
}
/// Only the real notch (with a void) grows a chin; no-notch displays show the
@@ -254,14 +318,14 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
Self.expandedContentDesignFrame.width,
max(
Self.minimumCollapsedSurfaceFrame.width,
- Self.commonCollapsedSurfaceFrame.width,
- voidWidth + Self.collapsedSideLaneTotal
+ commonCollapsedSurfaceFrame.width,
+ voidWidth + collapsedSideLaneTotal
)
)
}
private var collapsedVisibleHeight: CGFloat {
- max(Self.minimumCollapsedSurfaceFrame.height, Self.commonCollapsedSurfaceFrame.height, voidHeight)
+ max(Self.minimumCollapsedSurfaceFrame.height, commonCollapsedSurfaceFrame.height, voidHeight)
}
private var expandedVisibleHeight: CGFloat {
@@ -282,7 +346,7 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
private var expandedSurfaceTopInset: CGFloat {
guard !canRenderTextInTopRow else {
- return Self.commonCollapsedSurfaceFrame.height
+ return commonCollapsedSurfaceFrame.height
}
return min(max(0, voidHeight), Self.maximumExpandedContentTopInset)
@@ -293,25 +357,49 @@ public struct UserQueryNotchMetrics: Equatable, Sendable {
}
private static let minimumCollapsedSurfaceFrame = CGRect(x: 0, y: 0, width: 110, height: 28)
- private static let commonCollapsedSurfaceFrame = CGRect(
- x: 0,
- y: 0,
- width: Self.fallbackVoidWidth + Self.collapsedSideLaneTotal,
- height: Self.fallbackVoidHeight
- )
+ private var commonCollapsedSurfaceFrame: CGRect {
+ CGRect(
+ x: 0,
+ y: 0,
+ width: Self.fallbackVoidWidth + collapsedSideLaneTotal,
+ height: Self.fallbackVoidHeight
+ )
+ }
private static let expandedContentDesignFrame = CGRect(
x: 0,
y: 0,
width: UserQueryLayout.composerInputSurfaceWidth + Self.inputHorizontalMargin * 2,
height: 280
)
- /// The collapsed surface's side lanes flank the void. The trailing (right) lane is wider than the
- /// leading (left) one so the live elapsed clock — up to "Nh Nm Ns" — fits beside the camera; the
- /// leading lane only carries the pointer. The void seats off-center between them (see
+ /// The collapsed surface's side lanes flank the void, and each is sized by what it holds. The
+ /// original (unused) lane width is `collapsedOriginalLaneWidth`; a lane expands past it only for
+ /// content that needs the room — the trailing lane for the live clock, the leading lane for a
+ /// multi-pointer cluster — and collapses back when that content is gone. When both sit at the
+ /// original width the void is centered; an expanded lane seats it off-center (see
/// `surfaceVoidCenterX`), which the host positioning compensates for.
- private static let collapsedLeadingLaneWidth: CGFloat = 34
- private static let collapsedTrailingLaneWidth: CGFloat = 64
- private static var collapsedSideLaneTotal: CGFloat { collapsedLeadingLaneWidth + collapsedTrailingLaneWidth }
+ public static let collapsedOriginalLaneWidth: CGFloat = 34
+ /// The trailing lane width while the live elapsed clock ("Nh Nm Ns") shows beside the camera.
+ public static let collapsedClockLaneWidth: CGFloat = 64
+ /// Pointer-cluster geometry, shared with the notch view's `pointerCluster` so the leading lane is
+ /// sized to the exact cascade it renders: a base pointer plus a fixed step per extra pointer, capped.
+ public static let collapsedPointerSize: CGFloat = 14
+ public static let collapsedPointerStepX: CGFloat = 8
+ public static let collapsedMaxClusterPointers: Int = 3
+
+ /// Width of the rendered pointer cascade for `pointerCount` surfaced conversations (capped at the
+ /// cluster max). One or none is a single pointer; each extra pointer adds one cascade step.
+ public static func collapsedPointerClusterWidth(_ pointerCount: Int) -> CGFloat {
+ let visible = max(1, min(pointerCount, collapsedMaxClusterPointers))
+ return collapsedPointerSize + collapsedPointerStepX * CGFloat(visible - 1)
+ }
+
+ private var collapsedLeadingLaneWidth: CGFloat {
+ max(Self.collapsedOriginalLaneWidth, Self.collapsedPointerClusterWidth(collapsedLeadingPointerCount))
+ }
+ private var collapsedTrailingLaneWidth: CGFloat {
+ collapsedTrailingSlot.needsWideLane ? Self.collapsedClockLaneWidth : Self.collapsedOriginalLaneWidth
+ }
+ private var collapsedSideLaneTotal: CGFloat { collapsedLeadingLaneWidth + collapsedTrailingLaneWidth }
private static let collapsedCornerRadius: CGFloat = 14
// Prototype spec: the expanded notch window and its input box both use a 14px radius.
private static let expandedCornerRadius: CGFloat = 14
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
index e444712d..f807e370 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
@@ -406,7 +406,7 @@ public struct UserQueryNotchStatusView: View {
TimelineView(.periodic(from: Self.chinRotationAnchor, by: Self.chinRotationInterval)) { context in
let speaker = rotatingChinConversation(at: context.date)
HStack(spacing: 7) {
- pointerCluster(size: 14, speaker: speaker)
+ pointerCluster(size: UserQueryNotchMetrics.collapsedPointerSize, speaker: speaker)
// While a conversation waits on the user, its pointer stays lit and pulses for attention — the
// same cue the expanded row gives — so the blocked thread reads at a glance.
.modifier(AttentionPulse(active: isPrimaryWaitingOnUser))
@@ -449,7 +449,7 @@ public struct UserQueryNotchStatusView: View {
TimelineView(.periodic(from: Self.chinRotationAnchor, by: Self.chinRotationInterval)) { context in
let speaker = rotatingChinConversation(at: context.date)
ZStack {
- pointerCluster(size: 14, speaker: speaker)
+ pointerCluster(size: UserQueryNotchMetrics.collapsedPointerSize, speaker: speaker)
.modifier(AttentionPulse(active: isPrimaryWaitingOnUser))
.position(x: collapsedLeadingLaneCenterX, y: layout.collapsedVisibleHeight / 2)
@@ -1415,40 +1415,31 @@ public struct UserQueryNotchStatusView: View {
/// lonely clock; every state's full elapsed total lives in the expanded row.
@ViewBuilder
private var collapsedRightSlot: some View {
- if surfacedErrorConversation != nil {
+ // Render exactly what the layout sized the lane to hold — the same `CollapsedTrailingSlot` value —
+ // so the gutter content and the lane width around it are one decision and can never disagree (a
+ // running conversation gets the wide clock lane; a glyph/icon or nothing keeps the original width).
+ switch layout.collapsedTrailingSlot {
+ case .errorGlyph:
// A surfaced failure (e.g. an auth error) raises the red warning glyph here while its message
// holds the chin, until the user expands to acknowledge it.
attentionGlyph(color: Self.chinErrorColor)
- } else if let conversation = primaryConversation {
- switch conversation.status {
- case .waitingForClarification, .waitingForReview:
- // Attention: the agent is blocked waiting for the user to answer or review something.
- attentionGlyph()
- case .waitingForPermission:
- // Waiting on the user, same as a clarification or review — show the attention glyph.
- attentionGlyph()
- case .running:
+ case .attentionGlyph:
+ // The agent is blocked waiting on the user — a question, a review, or a permission to approve.
+ attentionGlyph()
+ case .clock:
+ if let conversation = primaryConversation {
fullLiveTime(for: conversation)
- case .completed, .paused, .interrupted, .failed, .chatting, .needsAttention, .timedOut:
- // The gutter only ever carries the waiting-on-user icons or the live clock — a completed
- // conversation keeps surfacing as a colored pointer + chin line, and the rest (including a benign
- // needsAttention or a retryable timed-out run) surface in the list without nagging the
- // collapsed gutter.
- EmptyView()
}
- } else if updateState.isActionable {
+ case .updateIcon:
// App update available.
slotIcon("icloud.and.arrow.down")
- } else {
+ case .empty:
+ // A completed conversation keeps surfacing as a colored pointer + chin line, and a benign
+ // needsAttention or retryable timed-out run surfaces in the list — neither nags the gutter.
EmptyView()
}
}
- /// The surfaced failure currently holding the chin, if any — drives the right-rail warning glyph.
- private var surfacedErrorConversation: UserQueryConversation? {
- surfacedConversations.first { $0.status == .failed }
- }
-
private func slotIcon(_ systemName: String, color: Color = Color.white.opacity(0.85)) -> some View {
Image(systemName: systemName)
.font(.system(size: 11, weight: .regular))
@@ -1566,9 +1557,10 @@ public struct UserQueryNotchStatusView: View {
/// the row tail-truncates only after five rendered lines.
private static let conversationSubtextLineLimit = 5
/// The collapsed leading lane shows at most this many overlapping pointers; extra surfaced conversations
- /// are still listed when the notch is expanded.
- private static let maxClusterPointers = 3
- private static let clusterStepX: CGFloat = 8
+ /// are still listed when the notch is expanded. The cap and the horizontal step come from the layout so
+ /// the leading lane (sized in `UserQueryNotchMetrics`) and the cascade rendered here use one geometry.
+ private static let maxClusterPointers = UserQueryNotchMetrics.collapsedMaxClusterPointers
+ private static let clusterStepX = UserQueryNotchMetrics.collapsedPointerStepX
private static let clusterStepY: CGFloat = 3
/// Chin text metrics, matching the band geometry the controller sizes (10pt on a 12pt line with an
/// 8pt bottom margin). The text is seated above that bottom margin so it stays constant as the band
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryNotchMetricsTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryNotchMetricsTests.swift
index b1b70f55..4b2e35e4 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryNotchMetricsTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryNotchMetricsTests.swift
@@ -84,7 +84,8 @@ struct UserQueryNotchMetricsTests {
expandedContentHeight: UserQueryNotchMetrics.expandedConversationContentHeight,
isExpanded: false,
isHostExpanded: false,
- screenWidth: UserQueryNotchMetrics.defaultScreenWidth
+ screenWidth: UserQueryNotchMetrics.defaultScreenWidth,
+ collapsedTrailingSlot: .clock
)
let layout = metrics.layout
let leading = layout.collapsedVoidLeadingInset
@@ -97,6 +98,117 @@ struct UserQueryNotchMetricsTests {
#expect(metrics.surfaceVoidCenterX < metrics.surfaceSize.width / 2)
}
+ @Test
+ func collapsedRealNotchIsSymmetricWhenClockIsIdle() {
+ let metrics = UserQueryNotchMetrics(
+ voidWidth: UserQueryNotchMetrics.fallbackVoidWidth,
+ voidHeight: UserQueryNotchMetrics.fallbackVoidHeight,
+ expandedContentHeight: UserQueryNotchMetrics.expandedConversationContentHeight,
+ isExpanded: false,
+ isHostExpanded: false,
+ screenWidth: UserQueryNotchMetrics.defaultScreenWidth,
+ collapsedTrailingSlot: .empty
+ )
+ let layout = metrics.layout
+ let leading = layout.collapsedVoidLeadingInset
+ let trailing = layout.collapsedSurfaceFrame.width - leading - metrics.voidWidth
+
+ // With nothing in the gutter, the trailing lane sits at its original size (34), matching the
+ // leading lane (34) — so the lanes are symmetric and the void is centered.
+ #expect(trailing == leading)
+ #expect(leading == UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ #expect(trailing == UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ #expect(metrics.surfaceVoidCenterX == leading + metrics.voidWidth / 2)
+ #expect(metrics.surfaceVoidCenterX == metrics.surfaceSize.width / 2)
+ }
+
+ @Test
+ func collapsedTrailingLaneCollapsesForAGlyphAndExpandsOnlyForTheClock() {
+ func laneWidths(_ slot: CollapsedTrailingSlot) -> (leading: CGFloat, trailing: CGFloat) {
+ let metrics = UserQueryNotchMetrics(
+ voidWidth: UserQueryNotchMetrics.fallbackVoidWidth,
+ voidHeight: UserQueryNotchMetrics.fallbackVoidHeight,
+ expandedContentHeight: UserQueryNotchMetrics.expandedConversationContentHeight,
+ isExpanded: false,
+ isHostExpanded: false,
+ screenWidth: UserQueryNotchMetrics.defaultScreenWidth,
+ collapsedTrailingSlot: slot
+ )
+ let layout = metrics.layout
+ let leading = layout.collapsedVoidLeadingInset
+ return (leading, layout.collapsedSurfaceFrame.width - leading - metrics.voidWidth)
+ }
+
+ // The bug this fixes: a conversation waiting on the user (or a failure, or an available update) shows
+ // a glyph, not the clock, so the trailing lane must collapse back to the original width — only the
+ // live clock widens it. So the notch no longer jitters its void on a running → waiting transition.
+ for glyphSlot: CollapsedTrailingSlot in [.attentionGlyph, .errorGlyph, .updateIcon, .empty] {
+ #expect(laneWidths(glyphSlot).trailing == UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ }
+ #expect(laneWidths(.clock).trailing == UserQueryNotchMetrics.collapsedClockLaneWidth)
+ }
+
+ @Test
+ func collapsedLeadingLaneExpandsForAPointerClusterAndCollapsesBack() {
+ func leadingLane(pointerCount: Int) -> CGFloat {
+ UserQueryNotchMetrics(
+ voidWidth: UserQueryNotchMetrics.fallbackVoidWidth,
+ voidHeight: UserQueryNotchMetrics.fallbackVoidHeight,
+ expandedContentHeight: UserQueryNotchMetrics.expandedConversationContentHeight,
+ isExpanded: false,
+ isHostExpanded: false,
+ screenWidth: UserQueryNotchMetrics.defaultScreenWidth,
+ collapsedLeadingPointerCount: pointerCount
+ ).layout.collapsedVoidLeadingInset
+ }
+
+ // One or no pointer keeps the leading lane at its original width; the lane only ever grows to fit
+ // the cascade, never shrinks below the original, and the width tracks the same cluster geometry the
+ // view renders (so it can't clip the pointers it draws).
+ #expect(leadingLane(pointerCount: 0) == UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ #expect(leadingLane(pointerCount: 1) == UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ #expect(leadingLane(pointerCount: 3) >= UserQueryNotchMetrics.collapsedOriginalLaneWidth)
+ #expect(
+ leadingLane(pointerCount: 3) >=
+ UserQueryNotchMetrics.collapsedPointerClusterWidth(3)
+ )
+ }
+
+ @Test
+ func collapsedTrailingSlotMatchesTheNotchGutterPrecedence() {
+ // A surfaced failure wins the gutter over everything else.
+ #expect(
+ UserQueryNotchMetrics.collapsedTrailingSlot(
+ primaryStatus: .running, hasSurfacedError: true, isUpdateActionable: true
+ ) == .errorGlyph
+ )
+ // Otherwise the primary conversation's status drives it: running → clock, waiting → attention glyph.
+ #expect(
+ UserQueryNotchMetrics.collapsedTrailingSlot(
+ primaryStatus: .running, hasSurfacedError: false, isUpdateActionable: false
+ ) == .clock
+ )
+ for waiting: UserQueryConversationStatus in [.waitingForClarification, .waitingForReview, .waitingForPermission] {
+ #expect(
+ UserQueryNotchMetrics.collapsedTrailingSlot(
+ primaryStatus: waiting, hasSurfacedError: false, isUpdateActionable: false
+ ) == .attentionGlyph
+ )
+ }
+ // A terminal/benign status leaves the gutter empty even when a conversation is primary.
+ #expect(
+ UserQueryNotchMetrics.collapsedTrailingSlot(
+ primaryStatus: .completed, hasSurfacedError: false, isUpdateActionable: true
+ ) == .empty
+ )
+ // The update icon shows only when no conversation is primary.
+ #expect(
+ UserQueryNotchMetrics.collapsedTrailingSlot(
+ primaryStatus: nil, hasSurfacedError: false, isUpdateActionable: true
+ ) == .updateIcon
+ )
+ }
+
@Test
func expandedAndNoVoidSurfacesPositionByTheirCenter() {
// Expanded host: the void sits mid-surface, so it positions by the surface center (no offset).