Open source CapCut alternative.
TypeScript
Use hover phases to coalesce notch expansion
David Le60d055b8df52
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swiftindex e5f328aa..f7634399 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift@@ -2,6 +2,7 @@ import AppKitimport Carbon.HIToolboximport DonkeyContractsimport DonkeyUI+import QuartzCoreimport SwiftUI@MainActor@@ -24,7 +25,12 @@ final class PointerPromptOverlayController {private var activationHoldStartedAt: Date?private var isVoiceInputActive = falseprivate var isStatusExpanded = false+ private var isStatusHostExpanded = false+ private var statusHoverPhase: StatusHoverPhase = .collapsedprivate var statusCollapseWorkItem: DispatchWorkItem?+ private var statusExpansionWorkItem: DispatchWorkItem?+ private var statusHostShrinkWorkItem: DispatchWorkItem?+ private var lastStatusViewSnapshot: StatusPanelViewSnapshot?init(model: PointerPromptOverlayModel,@@ -108,6 +114,7 @@ final class PointerPromptOverlayController {hostingView.wantsLayer = truehostingView.layer?.backgroundColor = NSColor.clear.cgColorstatusHostingView = hostingView+ lastStatusViewSnapshot = statusViewSnapshot(metrics: metrics)let panel = NSPanel(contentRect: CGRect(origin: .zero, size: metrics.surfaceSize),@@ -141,6 +148,11 @@ final class PointerPromptOverlayController {timer = nilstatusCollapseWorkItem?.cancel()statusCollapseWorkItem = nil+ statusExpansionWorkItem?.cancel()+ statusExpansionWorkItem = nil+ statusHostShrinkWorkItem?.cancel()+ statusHostShrinkWorkItem = nil+ statusHoverPhase = .collapsedstopActivationMonitoring()microphoneWaveformMeter.stop()inputPanel?.close()@@ -148,6 +160,7 @@ final class PointerPromptOverlayController {statusPanel?.close()statusPanel = nilstatusHostingView = nil+ lastStatusViewSnapshot = nil}private func startActivationMonitoring() {@@ -382,6 +395,7 @@ final class PointerPromptOverlayController {activateVoiceInputIfNeeded()positionStatusPanel()+ updateStatusHoverExpansion()updateStatusPanelView()resizeActivePanelIfNeeded(inputPanel)updateMouseEventPassthrough(for: inputPanel)@@ -409,33 +423,59 @@ final class PointerPromptOverlayController {)}- private func positionStatusPanel() {+ private func positionStatusPanel(disableAnimations: Bool = true) {guard let statusPanel,let screen = activeScreen() else {return}let metrics = notchMetrics(for: screen)- if statusPanel.frame.size != metrics.surfaceSize {- statusHostingView?.frame = CGRect(origin: .zero, size: metrics.surfaceSize)+ let frame = CGRect(+ x: screen.frame.midX - metrics.surfaceSize.width / 2,+ y: screen.frame.maxY - metrics.surfaceSize.height,+ width: metrics.surfaceSize.width,+ height: metrics.surfaceSize.height+ )++ guard disableAnimations else {+ statusPanel.setFrame(frame, display: true)+ return}- statusPanel.setFrame(- CGRect(- x: screen.frame.midX - metrics.surfaceSize.width / 2,- y: screen.frame.maxY - metrics.surfaceSize.height,- width: metrics.surfaceSize.width,- height: metrics.surfaceSize.height- ),- display: true- )+ NSAnimationContext.runAnimationGroup { context in+ context.duration = 0+ context.allowsImplicitAnimation = false+ CATransaction.begin()+ CATransaction.setDisableActions(true)+ if statusPanel.frame.size != metrics.surfaceSize {+ statusHostingView?.frame = CGRect(origin: .zero, size: metrics.surfaceSize)+ }+ statusPanel.setFrame(frame, display: true)+ CATransaction.commit()+ }}private func updateStatusPanelView() {let metrics = notchMetrics()+ let snapshot = statusViewSnapshot(metrics: metrics)+ guard snapshot != lastStatusViewSnapshot else { return }++ lastStatusViewSnapshot = snapshotstatusHostingView?.rootView = notchStatusView(metrics: metrics)}+ private func statusViewSnapshot(metrics: NotchMetrics) -> StatusPanelViewSnapshot {+ StatusPanelViewSnapshot(+ state: model.promptState,+ updateState: model.updateState,+ layout: metrics.layout,+ surfaceSize: metrics.surfaceSize,+ isExpanded: isStatusExpanded,+ isHostExpanded: isStatusHostExpanded,+ accentIndex: model.notchAccentIndex+ )+ }+private func notchStatusView(metrics: NotchMetrics) -> PointerPromptNotchStatusView {PointerPromptNotchStatusView(state: model.promptState,@@ -445,9 +485,6 @@ final class PointerPromptOverlayController {surfaceHeight: metrics.surfaceSize.height,isExpanded: isStatusExpanded,accentIndex: model.notchAccentIndex,- hoverChanged: { [weak self] isHovering in- self?.setStatusExpanded(isHovering)- },commandRequested: { [weak self] inself?.activateInputFromStatusCommand()},@@ -461,10 +498,26 @@ final class PointerPromptOverlayController {model.showUpdateUI()}+ private func updateStatusHoverExpansion() {+ guard let statusPanel else { return }++ let metrics = notchMetrics(for: statusPanel.screen)+ let mouseLocationInPanel = statusPanel.convertPoint(fromScreen: NSEvent.mouseLocation)++ if metrics.hoverFramesInPanel.contains(where: { $0.contains(mouseLocationInPanel) }) {+ setStatusExpanded(true)+ } else if statusHoverPhase != .collapsed, statusCollapseWorkItem == nil {+ scheduleStatusCollapse()+ }+ }+private func setStatusExpanded(_ isExpanded: Bool) {if isExpanded {statusCollapseWorkItem?.cancel()statusCollapseWorkItem = nil+ statusHostShrinkWorkItem?.cancel()+ statusHostShrinkWorkItem = nil+ guard statusHoverPhase != .preparingOpen, statusHoverPhase != .expanded else { return }applyStatusExpanded(true)return}@@ -473,9 +526,48 @@ final class PointerPromptOverlayController {}private func applyStatusExpanded(_ isExpanded: Bool) {- guard isStatusExpanded != isExpanded else { return }+ if isExpanded {+ guard statusHoverPhase != .preparingOpen, statusHoverPhase != .expanded else { return }++ statusHoverPhase = .preparingOpen+ isStatusExpanded = false+ prepareStatusHostForExpansion()++ let workItem = DispatchWorkItem { [weak self] in+ guard let self,+ self.statusHoverPhase == .preparingOpen,+ self.isStatusHostExpanded,+ !self.isStatusExpanded else { return }+ self.isStatusExpanded = true+ self.statusHoverPhase = .expanded+ self.statusExpansionWorkItem = nil+ self.updateStatusPanelView()+ }+ statusExpansionWorkItem = workItem+ DispatchQueue.main.async(execute: workItem)+ return+ }++ statusExpansionWorkItem?.cancel()+ statusExpansionWorkItem = nil++ guard statusHoverPhase != .collapsed else { return }+ guard statusHoverPhase != .closing else {+ scheduleStatusHostShrink()+ return+ }- isStatusExpanded = isExpanded+ if isStatusExpanded {+ isStatusExpanded = false+ updateStatusPanelView()+ }++ statusHoverPhase = .closing+ scheduleStatusHostShrink()+ }++ private func prepareStatusHostForExpansion() {+ isStatusHostExpanded = truepositionStatusPanel()updateStatusPanelView()}@@ -500,13 +592,35 @@ final class PointerPromptOverlayController {return}- let hoverTolerance: CGFloat = 2- let hoverFrame = statusPanel.frame.insetBy(dx: -hoverTolerance, dy: -hoverTolerance)- guard !hoverFrame.contains(NSEvent.mouseLocation) else { return }+ let metrics = notchMetrics(for: statusPanel.screen)+ let mouseLocationInPanel = statusPanel.convertPoint(fromScreen: NSEvent.mouseLocation)+ guard !metrics.hoverFramesInPanel.contains(where: { $0.contains(mouseLocationInPanel) }) else { return }applyStatusExpanded(false)}+ private func scheduleStatusHostShrink() {+ statusHostShrinkWorkItem?.cancel()++ let workItem = DispatchWorkItem { [weak self] in+ Task { @MainActor in+ self?.shrinkStatusHostIfCollapsed()+ }+ }+ statusHostShrinkWorkItem = workItem+ DispatchQueue.main.asyncAfter(deadline: .now() + NotchMetrics.closeAnimationDuration, execute: workItem)+ }++ private func shrinkStatusHostIfCollapsed() {+ statusHostShrinkWorkItem = nil+ guard !isStatusExpanded, isStatusHostExpanded, statusHoverPhase == .closing else { return }++ isStatusHostExpanded = false+ statusHoverPhase = .collapsed+ positionStatusPanel()+ updateStatusPanelView()+ }+private func activeScreen() -> NSScreen? {inputPanel?.screen ?? statusPanel?.screen ?? NSScreen.main ?? NSScreen.screens.first}@@ -518,6 +632,7 @@ final class PointerPromptOverlayController {voidWidth: NotchMetrics.fallbackVoidWidth,voidHeight: NotchMetrics.fallbackVoidHeight,isExpanded: isStatusExpanded,+ isHostExpanded: isStatusHostExpanded,screenWidth: NotchMetrics.defaultScreenWidth)}@@ -541,6 +656,7 @@ final class PointerPromptOverlayController {voidWidth: voidWidth,voidHeight: voidHeight,isExpanded: isStatusExpanded,+ isHostExpanded: isStatusHostExpanded,screenWidth: screen.frame.width)}@@ -819,13 +935,20 @@ private struct NotchMetrics {var voidWidth: CGFloatvar voidHeight: CGFloatvar isExpanded: Bool+ var isHostExpanded: Boolvar screenWidth: CGFloatvar surfaceSize: CGSize {- return CGSize(- width: surfaceWidth,- height: max(layout.visibleHeight, voidHeight + layout.visibleHeight)- )+ surfaceFrame.size+ }++ var visibleSurfaceFrameInPanel: CGRect {+ frameInPanel(for: visibleSurfaceFrame)+ }++ var hoverFramesInPanel: [CGRect] {+ let tolerance: CGFloat = 2+ return [visibleSurfaceFrameInPanel.insetBy(dx: -tolerance, dy: -tolerance)]}var layout: PointerPromptNotchLayout {@@ -834,41 +957,112 @@ private struct NotchMetrics {voidHeight: voidHeight,collapsedVisibleHeight: collapsedVisibleHeight,expandedVisibleHeight: expandedVisibleHeight,- contentHorizontalInset: max(12, surfaceWidth * 0.035),+ contentHorizontalInset: 14,visibleHeight: visibleHeight,- cornerRadius: isExpanded ? 28 : 13+ cornerRadius: isExpanded ? Self.expandedCornerRadius : Self.collapsedCornerRadius,+ collapsedSurfaceFrame: collapsedSurfaceFrame,+ expandedSurfaceFrame: expandedSurfaceFrame,+ expandedContentFrame: expandedContentFrame,+ collapsedCornerRadius: Self.collapsedCornerRadius,+ expandedCornerRadius: Self.expandedCornerRadius)}- private var surfaceWidth: CGFloat {- if isExpanded {- return min(max(360, screenWidth - 48), 690)- }+ private var visibleHeight: CGFloat {+ visibleSurfaceFrame.height+ }- let contentAllowance: CGFloat = 170- return min(max(voidWidth + contentAllowance, 300), min(420, screenWidth - 24))+ private func frameInPanel(for frame: CGRect) -> CGRect {+ CGRect(+ x: (surfaceSize.width - frame.width) / 2,+ y: surfaceSize.height - frame.height,+ width: frame.width,+ height: frame.height+ )}- private var visibleHeight: CGFloat {- if isExpanded {- return expandedVisibleHeight- }+ private var surfaceFrame: CGRect {+ isHostExpanded ? expandedSurfaceFrame : collapsedSurfaceFrame+ }- return collapsedVisibleHeight+ private var visibleSurfaceFrame: CGRect {+ isExpanded ? expandedSurfaceFrame : collapsedSurfaceFrame+ }++ private var expandedSurfaceFrame: CGRect {+ CGRect(+ x: 0,+ y: 0,+ width: Self.expandedContentDesignFrame.width,+ height: expandedSurfaceHeight+ )+ }++ private var collapsedSurfaceFrame: CGRect {+ CGRect(+ x: 0,+ y: 0,+ width: collapsedSurfaceWidth,+ height: collapsedVisibleHeight+ )+ }++ private var expandedContentFrame: CGRect {+ CGRect(+ x: Self.expandedContentDesignFrame.minX,+ y: expandedContentTopInset,+ width: Self.expandedContentDesignFrame.width,+ height: Self.expandedContentDesignFrame.height+ )+ }++ private var collapsedSurfaceWidth: CGFloat {+ min(+ Self.expandedContentDesignFrame.width,+ max(Self.minimumCollapsedSurfaceFrame.width, voidWidth + Self.collapsedSideLaneWidth * 2)+ )}private var collapsedVisibleHeight: CGFloat {- 26+ voidHeight > 0 ? voidHeight : Self.minimumCollapsedSurfaceFrame.height}private var expandedVisibleHeight: CGFloat {- let headerHeight: CGFloat = 40- let taskRowHeight: CGFloat = 48- let commandRowHeight: CGFloat = 42- let verticalPadding: CGFloat = 10 + 8 + 10+ expandedSurfaceHeight+ }- return headerHeight + taskRowHeight + commandRowHeight + verticalPadding+ private var expandedContentTopInset: CGFloat {+ min(max(0, voidHeight), Self.maximumExpandedContentTopInset)}++ private var expandedSurfaceHeight: CGFloat {+ Self.expandedContentDesignFrame.height + expandedContentTopInset+ }++ private static let minimumCollapsedSurfaceFrame = CGRect(x: 0, y: 0, width: 110, height: 28)+ private static let expandedContentDesignFrame = CGRect(x: 0, y: 0, width: 480, height: 280)+ private static let collapsedSideLaneWidth: CGFloat = 34+ private static let collapsedCornerRadius: CGFloat = 14+ private static let expandedCornerRadius: CGFloat = 26+ static let closeAnimationDuration: TimeInterval = 0.22+ private static let maximumExpandedContentTopInset: CGFloat = 44+}++private struct StatusPanelViewSnapshot: Equatable {+ var state: PointerPromptState+ var updateState: PointerPromptUpdateState+ var layout: PointerPromptNotchLayout+ var surfaceSize: CGSize+ var isExpanded: Bool+ var isHostExpanded: Bool+ var accentIndex: Int+}++private enum StatusHoverPhase {+ case collapsed+ case preparingOpen+ case expanded+ case closing}private extension PointerPromptActivationModifier {diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swiftindex 720dd426..82f5d823 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift@@ -8,6 +8,11 @@ public struct PointerPromptNotchLayout: Equatable, Sendable {public var contentHorizontalInset: CGFloatpublic var visibleHeight: CGFloatpublic var cornerRadius: CGFloat+ public var collapsedSurfaceFrame: CGRect+ public var expandedSurfaceFrame: CGRect+ public var expandedContentFrame: CGRect+ public var collapsedCornerRadius: CGFloat+ public var expandedCornerRadius: CGFloatpublic init(voidWidth: CGFloat,@@ -16,7 +21,12 @@ public struct PointerPromptNotchLayout: Equatable, Sendable {expandedVisibleHeight: CGFloat,contentHorizontalInset: CGFloat,visibleHeight: CGFloat,- cornerRadius: CGFloat+ cornerRadius: CGFloat,+ collapsedSurfaceFrame: CGRect,+ expandedSurfaceFrame: CGRect,+ expandedContentFrame: CGRect,+ collapsedCornerRadius: CGFloat,+ expandedCornerRadius: CGFloat) {self.voidWidth = voidWidthself.voidHeight = voidHeight@@ -25,5 +35,10 @@ public struct PointerPromptNotchLayout: Equatable, Sendable {self.contentHorizontalInset = contentHorizontalInsetself.visibleHeight = visibleHeightself.cornerRadius = cornerRadius+ self.collapsedSurfaceFrame = collapsedSurfaceFrame+ self.expandedSurfaceFrame = expandedSurfaceFrame+ self.expandedContentFrame = expandedContentFrame+ self.collapsedCornerRadius = collapsedCornerRadius+ self.expandedCornerRadius = expandedCornerRadius}}diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swiftindex bedd28f9..ccf82b78 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift@@ -9,7 +9,6 @@ public struct PointerPromptNotchStatusView: View {private let surfaceHeight: CGFloatprivate let isExpanded: Boolprivate let accentIndex: Int- private let hoverChanged: @MainActor (Bool) -> Voidprivate let commandRequested: @MainActor () -> Voidprivate let updateRequested: @MainActor () -> Void@@ -21,7 +20,6 @@ public struct PointerPromptNotchStatusView: View {surfaceHeight: CGFloat,isExpanded: Bool,accentIndex: Int,- hoverChanged: @escaping @MainActor (Bool) -> Void,commandRequested: @escaping @MainActor () -> Void,updateRequested: @escaping @MainActor () -> Void) {@@ -32,113 +30,68 @@ public struct PointerPromptNotchStatusView: View {self.surfaceHeight = surfaceHeightself.isExpanded = isExpandedself.accentIndex = accentIndex- self.hoverChanged = hoverChangedself.commandRequested = commandRequestedself.updateRequested = updateRequested}public var body: some View {- ZStack(alignment: .top) {- collapsedWindow- .opacity(isExpanded ? 0 : 1)-- expandedWindow- .offset(y: isExpanded ? 0 : -expandedSurfaceHeight)- .animation(.smooth(duration: 0.24), value: isExpanded)+ GeometryReader { proxy in+ animatedNotchSurface+ .position(+ x: proxy.size.width / 2,+ y: animatingSurfaceHeight / 2+ )}- .frame(width: surfaceWidth, height: surfaceHeight, alignment: .top)+ .frame(width: surfaceWidth, height: surfaceHeight).clipped()- .onHover { isHovering in- Task { @MainActor in- hoverChanged(isHovering)- }- }.accessibilityElement(children: .contain)}- @ViewBuilder- private var collapsedWindow: some View {- if isResting {- restingCollapsedWindow- } else {- regularCollapsedWindow- }- }-- private var regularCollapsedWindow: some View {+ private var animatedNotchSurface: some View {ZStack(alignment: .top) {- notchSurface(height: collapsedSurfaceHeight, cornerRadius: collapsedCornerRadius)-- physicalNotchDebugOutline+ Color.black- collapsedContent- .offset(y: max(0, layout.voidHeight))- }- .frame(width: surfaceWidth, height: collapsedSurfaceHeight, alignment: .top)- }-- private var restingCollapsedWindow: some View {- ZStack(alignment: .top) {- physicalNotchDebugOutline-- restingCollapsedSurface- .offset(x: restingSurfaceOffsetX, y: 0)- }- .frame(width: surfaceWidth, height: collapsedSurfaceHeight, alignment: .top)- }-- private var restingCollapsedSurface: some View {- ZStack(alignment: .leading) {- notchSurface(- width: restingSurfaceWidth,- height: restingVisibleHeight,- cornerRadius: restingCornerRadius- )+ collapsedContentLayer+ .opacity(isExpanded ? 0 : 1)+ .animation(Self.restContentAnimation, value: isExpanded)- TaskArrowMark(color: accentColor)- .frame(width: 13, height: 13)- .padding(.leading, 10)+ expandedContent+ .opacity(isExpanded ? 1 : 0)+ .animation(+ isExpanded ? Self.expandedContentAnimation : Self.expandedContentDismissAnimation,+ value: isExpanded+ )}- .frame(width: restingSurfaceWidth, height: restingVisibleHeight, alignment: .leading)+ .frame(width: animatingSurfaceWidth, height: animatingSurfaceHeight, alignment: .top)+ .clipShape(notchSurfaceShape(cornerRadius: animatingSurfaceCornerRadius))+ .shadow(+ color: Color.black.opacity(isExpanded ? 0.5 : 0),+ radius: isExpanded ? 24 : 0,+ x: 0,+ y: isExpanded ? 12 : 0+ )+ .animation(isExpanded ? Self.openEnvelopeAnimation : Self.closeEnvelopeAnimation, value: isExpanded)}- private var expandedWindow: some View {- ZStack(alignment: .top) {- notchSurface(height: expandedSurfaceHeight, cornerRadius: expandedCornerRadius)-- physicalNotchDebugOutline-- expandedContent- .offset(y: max(0, layout.voidHeight))+ @ViewBuilder+ private var collapsedContentLayer: some View {+ if isResting {+ restingCollapsedContent+ } else {+ regularCollapsedContent}- .frame(width: surfaceWidth, height: expandedSurfaceHeight, alignment: .top)}- private func notchSurface(- width: CGFloat? = nil,- height: CGFloat,- cornerRadius: CGFloat- ) -> some View {- notchSurfaceShape(cornerRadius: cornerRadius)- .fill(Color.black)- .overlay {- notchSurfaceShape(cornerRadius: cornerRadius)- .stroke(- notchDebugColor,- style: StrokeStyle(lineWidth: 1, dash: [5, 4])- )- }- .frame(width: width ?? surfaceWidth, height: height, alignment: .top)+ private var regularCollapsedContent: some View {+ collapsedContent+ .frame(width: animatingSurfaceWidth, height: animatingSurfaceHeight, alignment: .top)}- private var physicalNotchDebugOutline: some View {- Rectangle()- .stroke(- Color.cyan.opacity(0.85),- style: StrokeStyle(lineWidth: 1, dash: [3, 3])- )- .frame(width: max(1, layout.voidWidth), height: max(1, layout.voidHeight))- .opacity(layout.voidWidth > 0 && layout.voidHeight > 0 ? 1 : 0)+ private var restingCollapsedContent: some View {+ TaskArrowMark(color: accentColor)+ .frame(width: 13, height: 13)+ .padding(.leading, 10)+ .frame(width: animatingSurfaceWidth, height: animatingSurfaceHeight, alignment: .leading)}private func notchSurfaceShape(cornerRadius: CGFloat) -> UnevenRoundedRectangle {@@ -153,44 +106,20 @@ public struct PointerPromptNotchStatusView: View {)}- private var notchDebugColor: Color {- Color(red: 1.0, green: 0.14, blue: 0.58).opacity(0.92)- }-- private var collapsedSurfaceHeight: CGFloat {- layout.voidHeight + layout.collapsedVisibleHeight- }-- private var expandedSurfaceHeight: CGFloat {- layout.voidHeight + layout.expandedVisibleHeight- }-- private var collapsedCornerRadius: CGFloat {- 13- }-- private var expandedCornerRadius: CGFloat {- 28- }-- private var restingVisibleHeight: CGFloat {- layout.voidHeight > 0 ? layout.voidHeight : layout.collapsedVisibleHeight- }-- private var restingCornerRadius: CGFloat {- 9+ private var animatingSurfaceWidth: CGFloat {+ animatingSurfaceFrame.width}- private var restingArrowAllowance: CGFloat {- 34+ private var animatingSurfaceHeight: CGFloat {+ animatingSurfaceFrame.height}- private var restingSurfaceWidth: CGFloat {- max(restingArrowAllowance, layout.voidWidth + restingArrowAllowance * 2)+ private var animatingSurfaceFrame: CGRect {+ isExpanded ? layout.expandedSurfaceFrame : layout.collapsedSurfaceFrame}- private var restingSurfaceOffsetX: CGFloat {- 0+ private var animatingSurfaceCornerRadius: CGFloat {+ isExpanded ? layout.expandedCornerRadius : layout.collapsedCornerRadius}private var collapsedContent: some View {@@ -212,8 +141,8 @@ public struct PointerPromptNotchStatusView: View {}.padding(.horizontal, max(10, layout.contentHorizontalInset)).frame(- width: surfaceWidth,- height: layout.collapsedVisibleHeight,+ width: animatingSurfaceWidth,+ height: animatingSurfaceHeight,alignment: .center)}@@ -233,10 +162,15 @@ public struct PointerPromptNotchStatusView: View {.padding(.bottom, 10)}.frame(- width: surfaceWidth,- height: layout.expandedVisibleHeight,+ width: layout.expandedContentFrame.width,+ height: layout.expandedContentFrame.height,alignment: .top)+ .offset(+ x: layout.expandedContentFrame.minX,+ y: layout.expandedContentFrame.minY+ )+ .clipped()}private var expandedHeader: some View {@@ -416,6 +350,18 @@ public struct PointerPromptNotchStatusView: View {private var cornerRadius: CGFloat {layout.cornerRadius}++ private static let openEnvelopeAnimation = Animation.spring(+ response: 0.55,+ dampingFraction: 0.82,+ blendDuration: 0+ )+ private static let closeEnvelopeAnimation = Animation.easeOut(duration: 0.22)+ private static let restContentAnimation = Animation.easeOut(duration: 0.15)+ private static let expandedContentAnimation = Animation+ .easeOut(duration: 0.3)+ .delay(0.15)+ private static let expandedContentDismissAnimation = Animation.easeOut(duration: 0.1)}private struct TaskArrowMark: View {@@ -435,6 +381,7 @@ private struct TaskArrowMark: View {.fill(color)}.aspectRatio(1, contentMode: .fit)+ .rotationEffect(.degrees(-45)).accessibilityHidden(true)}}diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.mdindex 39646700..212ac58a 100644--- a/docs/guides/pointer-prompt-overlay.md+++ b/docs/guides/pointer-prompt-overlay.md@@ -10,9 +10,19 @@ Donkey supports a floating macOS pointer prompt overlay:- sizes the notch status panel from `NSScreen.safeAreaInsets` and `auxiliaryTopLeftArea` / `auxiliaryTopRightArea`, with fallback dimensions for non-reporting displays- keeps status text below the physical notch void while the black panel visually extends the notch- renders the resting collapsed notch as a slim arrow-only strip beside the physical notch, without adding black padding over the notch void+- starts the resting notch envelope as an arrow lane plus physical notch void plus empty trailing lane, so the arrow remains visible and hover expansion grows from the real collapsed strip+- makes the resting notch envelope height match the detected physical notch height when a notch is present+- only expands from controller-tracked hover over the visible notch surface, not SwiftUI hover over the transparent host panel area+- lets the physical notch void participate in collapsed hover activation while keeping expanded content below the void+- keeps the native status panel collapsed at rest, jumps it to expanded render bounds with AppKit animations disabled before the SwiftUI open spring, and jumps it back after the short non-spring close finishes+- coalesces quick hover enter and exit samples through explicit collapsed, preparing-open, expanded, and closing phases so pending opens and closes do not fight each other+- keeps expanded notch text and controls below the detected physical notch void while allowing the black surface to extend through it, adding vertical surface space instead of squeezing the below-notch content area+- keeps the notch arrow mark pointed up-right at a fixed 45-degree angle- uses regular-weight notch text; collapsed and expanded notch labels should not render bold text-- expands the notch status panel downward on hover to show the current task and a bottom command row-- shows temporary debug outlines around the rendered notch surface and detected physical notch void while notch geometry is being tuned+- expands one notch status surface outward and downward together on hover, with width, height, bottom corner radius, and shadow using one native spring; collapse uses a short ease-out without a spring tail+- matches the `/prototype` notch dimensions while using a native macOS spring envelope: surface `110x28` to `480x280`, interaction container `520x300`, corner radius `14` to `26`, and `spring(response: 0.55, dampingFraction: 0.82)`+- lays out collapsed and expanded notch content inside the animated, clipped surface so content reveals and reflows with the current surface width+- fades collapsed notch content out quickly, then fades expanded content in after the surface has started expanding- shows an update button in the expanded notch header when Sparkle reports a valid appcast update- shows a black prompt modal with text input and a white voice waveform while active- uses a wide pill-shaped prompt for single-line text, then expands to a rounded rectangle when text wraps at the max input width or the user inserts new lines@@ -46,7 +56,11 @@ This is a visual, typed-command, and voice-command UI capability. Typed submissi- Pointer drawing and theme code may remain available for future features, but the prompt overlay should not render a visible cursor.- Runtime placement remains fixed to `bottomRight` for compatibility with the existing view contract; the rendered input panel itself is centered and no longer uses pointer-relative geometry.- The notch status panel should keep its visual language aligned with the `/prototype` route without exposing agent names or implementation roles: a slim arrow-only resting mark beside the physical notch, a minimal one-line task label when collapsed and active, and a compact current-task panel plus command row when expanded.-- Notch expansion should reveal from the top edge downward so the expanded surface feels attached to the physical notch rather than growing from a lower corner.+- SwiftUI notch rendering should consume `PointerPromptNotchLayout` for derived surface/content frames, corner radii, and notch-safe content offsets instead of duplicating screen-geometry constants in the view.+- Hover activation should be bounded to the visible notch surface using controller-side mouse location checks. The transparent host panel and expanded interaction padding must not trigger expansion or keep the notch expanded by themselves.+- The native status panel should not animate its frame while the SwiftUI notch surface animates. When expansion starts, resize the panel to expanded render bounds with AppKit animations disabled before flipping SwiftUI expansion state; after the short non-spring collapse finishes, resize it back to the resting surface bounds with animations disabled.+- Expanded notch content must treat the physical notch void as unavailable layout space. The surface may cover the void, but text, buttons, and task rows should start below the detected void height while retaining the normal below-notch content height.+- Notch expansion should reveal from the top edge, growing width and height together so the expanded surface feels attached to the physical notch rather than growing from a lower corner. Use a single rendered surface with the prototype dimensions and a native spring for opening width, height, bottom corner radius, and shadow; use a short ease-out on close so there is no spring tail. Keep collapsed and expanded content inside that clipped surface so layout follows the animated width. Delay the expanded content fade-in so the surface leads the content.- The expanded notch header may show an update button when `PointerPromptUpdateState` is actionable; clicking it should invoke Sparkle's standard update UI outside the SwiftUI view.- The controller should derive notch geometry from the active `NSScreen`, prefer safe-area and auxiliary-top areas over hardcoded notch sizes, and keep visible status content below the top safe-area inset.- Launch positioning, notch positioning, and double-Command activation handling belong in `PointerPromptOverlayController`, not the SwiftUI view.@@ -67,7 +81,7 @@ swift buildswift run Donkey```-Launch Donkey and confirm the inactive overlay renders as a black notch extension at the top center, with status content below the physical notch area on notched displays. Confirm the debug outlines trace the rendered notch surface and physical notch void. Hover the notch and confirm it expands downward into the current-task panel with a bottom command row, then collapses after the pointer leaves. With Sparkle configured to a local appcast that contains a newer signed update, confirm the expanded header shows an update button and clicking it opens Sparkle's update UI. Double-tap Command and release to confirm the black prompt capsule opens centered on the screen with keyboard focus and no visible close button, grant microphone permission if prompted, then speak or tap near the microphone and confirm the waveform responds to real audio levels. Type enough text to wrap and confirm the prompt changes from a pill into a rounded rectangle and remains centered as it grows. Press Shift-Return and confirm it inserts a newline; press Return and confirm it submits, dismisses the prompt, and shows working/result status in the notch panel. Move the mouse and confirm the active modal stays centered. Double-tap Command again but hold the second Command press, and confirm the same prompt modal appears with voice capture. Press Escape and confirm the active modal dismisses. Click outside the active modal and confirm it dismisses. Reactivate and drag the modal from non-input capsule areas. Confirm Command plus another key, Command-click, and a single Command tap do not activate the modal.+Launch Donkey and confirm the inactive overlay renders as a black notch extension at the top center, with status content below the physical notch area on notched displays. Hover the notch and confirm it expands downward into the current-task panel with a bottom command row, then collapses after the pointer leaves. With Sparkle configured to a local appcast that contains a newer signed update, confirm the expanded header shows an update button and clicking it opens Sparkle's update UI. Double-tap Command and release to confirm the black prompt capsule opens centered on the screen with keyboard focus and no visible close button, grant microphone permission if prompted, then speak or tap near the microphone and confirm the waveform responds to real audio levels. Type enough text to wrap and confirm the prompt changes from a pill into a rounded rectangle and remains centered as it grows. Press Shift-Return and confirm it inserts a newline; press Return and confirm it submits, dismisses the prompt, and shows working/result status in the notch panel. Move the mouse and confirm the active modal stays centered. Double-tap Command again but hold the second Command press, and confirm the same prompt modal appears with voice capture. Press Escape and confirm the active modal dismisses. Click outside the active modal and confirm it dismisses. Reactivate and drag the modal from non-input capsule areas. Confirm Command plus another key, Command-click, and a single Command tap do not activate the modal.## Source Entry Pointsdiff --git a/site/src/app/prototype/_components/Notch.tsx b/site/src/app/prototype/_components/Notch.tsxindex f6f2053a..f6d44142 100644--- a/site/src/app/prototype/_components/Notch.tsx+++ b/site/src/app/prototype/_components/Notch.tsx@@ -1,5 +1,4 @@-import { Plus, Sparkles, Check } from 'lucide-react';-import type { CSSProperties } from 'react';+import { MousePointer2, Plus, Sparkles } from 'lucide-react';import { ActivityBars } from '@/app/prototype/_components/ActivityBars';import { TaskArrow } from '@/app/prototype/_components/TaskArrow';@@ -14,206 +13,99 @@ type Props = {runningTaskIds: TaskId[];};-type RingStyle = CSSProperties & {- '--ring'?: string;-};+const NOTCH = {+ restWidth: 110,+ restHeight: 28,+ cornerRadius: 14,+ expandedWidth: 480,+ expandedHeight: 280,+ expandedRadius: 26,+} as const;++const EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';+const DURATION = '0.55s';export function Notch({ state, activeTaskId, hovering, setHovering, runningTaskIds }: Props) {const activeTask = TASKS[activeTaskId];const isExpanded = hovering || state === 'expanded-pinned';- const expandedWidth = 440;- const expandedHeight = 286;- const prototypeNotchWidth = 180;- const restingArrowAllowance = 34;- const restingSurfaceWidth = prototypeNotchWidth + restingArrowAllowance * 2;- const restingSurfaceLeft = (expandedWidth - prototypeNotchWidth) / 2 - restingArrowAllowance;-- const isComplete = state === 'complete';- const isAttention = state === 'needs-input';- const isMulti = state === 'running-multi';- const isHero = isComplete || isAttention;- const isResting = state === 'idle';-- let collapsedWidthStyle: CSSProperties;- if (isResting) collapsedWidthStyle = { width: `${restingSurfaceWidth}px` };- else if (isHero) collapsedWidthStyle = { width: '360px' };- else if (isMulti) collapsedWidthStyle = { width: '220px' };- else if (state === 'running-single') collapsedWidthStyle = { width: 'fit-content', minWidth: '200px', maxWidth: '420px' };- else collapsedWidthStyle = { width: '200px' };-- const ringColor = isComplete- ? 'rgba(29,158,117,0.55)'- : isAttention- ? 'rgba(212,83,126,0.65)'- : 'transparent';-- const collapsedBodyStyle: RingStyle = {- ...collapsedWidthStyle,- margin: isResting ? `0 0 0 ${restingSurfaceLeft}px` : '0 auto',- borderRadius: isResting ? '0 0 9px 9px' : isHero ? '0 0 22px 22px' : '0 0 14px 14px',- boxShadow: !isExpanded && ringColor !== 'transparent' ? `0 0 0 1.5px ${ringColor}` : 'none',- outline: '1px dashed rgba(255,36,148,0.95)',- outlineOffset: '2px',- opacity: isExpanded ? 0 : 1,- transition: 'opacity 0.12s ease, border-radius 0.24s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.3s ease',- '--ring': ringColor,- };+ const surfaceWidth = isExpanded ? NOTCH.expandedWidth : NOTCH.restWidth;+ const surfaceHeight = isExpanded ? NOTCH.expandedHeight : NOTCH.restHeight;+ const surfaceRadius = isExpanded ? NOTCH.expandedRadius : NOTCH.cornerRadius;return (<divclassName="absolute top-0 left-1/2 -translate-x-1/2 z-20"style={{- width: `${expandedWidth}px`,- height: isExpanded ? `${expandedHeight}px` : undefined,+ width: isExpanded ? `${NOTCH.expandedWidth + 40}px` : `${NOTCH.restWidth + 60}px`,+ height: isExpanded ? `${NOTCH.expandedHeight + 20}px` : `${NOTCH.restHeight + 20}px`,+ transition: `width ${DURATION} ${EASE}, height ${DURATION} ${EASE}`,}}onMouseEnter={() => setHovering(true)}onMouseLeave={() => setHovering(false)}>- <style>{`- @keyframes pulseRing {- 0%,100% { box-shadow: 0 0 0 1.5px var(--ring), 0 0 0 0 rgba(212,83,126,0); }- 50% { box-shadow: 0 0 0 1.5px var(--ring), 0 0 0 6px rgba(212,83,126,0.15); }- }- @keyframes fadeinUp {- from { opacity: 0; transform: translateY(-4px); }- to { opacity: 1; transform: translateY(0); }- }- .pulse-attention { animation: pulseRing 1.6s ease-in-out infinite; }- .fadein-up { animation: fadeinUp 0.3s cubic-bezier(0.32, 0.72, 0, 1) both; }- `}</style><div- className={`relative bg-black text-white overflow-hidden ${isAttention && !isExpanded ? 'pulse-attention' : ''}`}- style={collapsedBodyStyle}- >- {!isExpanded && state === 'idle' && (- <div className="flex h-[18px] items-center pl-2.5">- <TaskArrow color={activeTask.color} size={13} />- </div>- )}-- {!isExpanded && state === 'running-single' && (- <div className="flex items-center justify-center gap-2 pl-3.5 pr-4 py-1.5">- <div- className="w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0"- style={{ background: 'transparent' }}- >- <TaskArrow color={activeTask.color} size={12} />- </div>- <span className="text-[10px] tracking-tight whitespace-nowrap text-white/95">- {`Donkey · ${activeTask.label.toLowerCase()}`}- </span>- <ActivityBars color={activeTask.color} />- </div>- )}-- {!isExpanded && isMulti && (- <div className="flex items-center justify-center gap-2 px-3 py-1.5">- <div className="flex items-center">- {runningTaskIds.slice(0, 4).map((id, i) => (- <div- key={id}- className="w-3 h-3 rounded-full"- style={{- background: TASKS[id].color,- border: '1.5px solid #000',- marginLeft: i === 0 ? 0 : '-4px',- zIndex: 10 - i,- }}- />- ))}- </div>- <span className="text-[10px] text-white/95 whitespace-nowrap">- Donkey gets things done- </span>- <ActivityBars color="rgba(255,255,255,0.85)" />- </div>- )}-- {!isExpanded && isComplete && (- <div className="flex items-center gap-2.5 px-4 pt-1.5 pb-2.5 fadein-up">- <div className="relative flex-shrink-0">- <div className="w-7 h-7 rounded-md flex items-center justify-center">- <TaskArrow color={activeTask.color} size={20} />- </div>- <div className="absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full bg-white flex items-center justify-center">- <Check size={8} color={activeTask.color} strokeWidth={3} />- </div>- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-1.5">- <span className="text-[11px]">Donkey finished</span>- <span className="text-[9px] text-white/50">· 1m 42s</span>- </div>- <div className="text-[10px] text-white/65 truncate">{activeTask.label}</div>- </div>- <button- type="button"- className="text-[10px] px-2 py-1 rounded"- style={{ background: `${activeTask.color}66`, color: '#fff' }}- >- View- </button>- </div>- )}-- {!isExpanded && isAttention && (- <div className="flex items-center gap-2.5 px-4 pt-1.5 pb-2.5 fadein-up">- <div className="relative flex-shrink-0">- <div className="w-7 h-7 rounded-md flex items-center justify-center">- <TaskArrow color={activeTask.color} size={20} />- </div>- <div className="absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full bg-white flex items-center justify-center">- <span style={{ fontSize: '9px', color: activeTask.color, lineHeight: 1 }}>!</span>- </div>- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-1.5">- <span className="text-[11px]">Donkey needs you</span>- <span className="text-[9px] text-white/50">· paused</span>- </div>- <div className="text-[10px] text-white/65 truncate">Pick a source for the search</div>- </div>- <button- type="button"- className="text-[10px] px-2 py-1 rounded"- style={{ background: `${activeTask.color}80`, color: '#fff' }}- >- Answer- </button>- </div>- )}- </div>-- <div- className="absolute left-0 top-0 w-full overflow-hidden"+ className="absolute top-0 left-1/2 overflow-hidden bg-black text-white"style={{- height: `${expandedHeight}px`,- pointerEvents: isExpanded ? 'auto' : 'none',+ width: `${surfaceWidth}px`,+ height: `${surfaceHeight}px`,+ transform: 'translateX(-50%)',+ borderTopLeftRadius: 0,+ borderTopRightRadius: 0,+ borderBottomLeftRadius: `${surfaceRadius}px`,+ borderBottomRightRadius: `${surfaceRadius}px`,+ boxShadow: isExpanded+ ? '0 24px 48px -12px rgba(0,0,0,0.5), 0 8px 16px -8px rgba(0,0,0,0.3)'+ : 'none',+ outline: '1px dashed rgba(255,36,148,0.95)',+ outlineOffset: '-1px',+ transition: [+ `width ${DURATION} ${EASE}`,+ `height ${DURATION} ${EASE}`,+ `border-radius ${DURATION} ${EASE}`,+ `box-shadow ${DURATION} ${EASE}`,+ ].join(', '),+ zIndex: 30,}}><div- className="bg-black text-white overflow-hidden"+ className="absolute inset-0 flex items-center pl-3.5 pr-3.5"style={{- width: '100%',- height: '100%',- borderRadius: '0 0 22px 22px',- outline: '1px dashed rgba(255,36,148,0.95)',- outlineOffset: '-1px',- transform: isExpanded ? 'translateY(0)' : 'translateY(-100%)',- transition: 'transform 0.34s cubic-bezier(0.32, 0.72, 0, 1)',+ opacity: isExpanded ? 0 : 1,+ transition: `opacity 0.15s ${EASE}`,+ pointerEvents: 'none',}}>- <div className="px-3.5 pt-2 pb-2 flex items-center gap-2 border-b border-white/10">- <TaskArrow color={activeTask.color} size={14} />- <span className="text-[11px]">Donkey</span>- <span className="text-[10px] text-white/45 ml-1">gets things done</span>+ <MousePointer2+ size={14}+ color="#fff"+ fill="#fff"+ strokeWidth={0}+ style={{ transform: 'rotate(-8deg)' }}+ />+ </div>++ <div+ className="absolute inset-0 flex flex-col"+ style={{+ opacity: isExpanded ? 1 : 0,+ padding: 18,+ pointerEvents: isExpanded ? 'auto' : 'none',+ transition: isExpanded ? `opacity 0.3s ${EASE} 0.15s` : `opacity 0.1s ${EASE}`,+ }}+ >+ <div className="flex items-center gap-2 border-b border-white/10 pb-2.5">+ <TaskArrow color={activeTask.color} size={14} className="-rotate-45" />+ <span className="text-[12px] text-white/95">Donkey</span>+ <span className="text-[11px] text-white/45 ml-0.5">+ {state === 'idle' ? 'ready' : activeTask.label.toLowerCase()}+ </span><div className="ml-auto flex items-center gap-1 text-[10px] text-white/45 hover:text-white/80 cursor-pointer"><Plus size={11} /><span>new task</span></div></div>- <div className="p-2 flex flex-col gap-1">+ <div className="grid grid-cols-5 gap-2 py-3">{ALL_TASK_IDS.map((id) => {const task = TASKS[id];const isRunning = runningTaskIds.includes(id);@@ -229,40 +121,34 @@ export function Notch({ state, activeTaskId, hovering, setHovering, runningTaskIreturn (<divkey={id}- className="flex items-center gap-2.5 px-2 py-1.5 rounded-md hover:bg-white/5 cursor-pointer"- style={isRunning ? { background: `${task.color}1A`, borderLeft: `2px solid ${task.color}` } : {}}+ className="flex min-w-0 flex-col items-center gap-1.5 rounded-md border border-white/[0.06] bg-white/[0.04] px-1 py-2 transition hover:-translate-y-px hover:bg-white/[0.07]"+ style={isRunning ? { background: `${task.color}1A` } : undefined}>- <div className="w-5 h-5 flex items-center justify-center flex-shrink-0">- <TaskArrow color={task.color} size={16} />- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-1.5">- <span className="text-[10px]">{task.label}</span>- <span- className="text-[9px] px-1 py-px rounded"- style={{- background: `${statusColor}30`,- color: statusColor === 'rgba(255,255,255,0.4)' ? 'rgba(255,255,255,0.5)' : statusColor,- }}- >- {statusLabel}- </span>- </div>- <div className="text-[9px] text-white/50 truncate">{isRunning ? task.detail : 'Ready when needed'}</div>+ <div+ className="flex h-6 w-6 items-center justify-center rounded-md"+ style={{ background: task.color }}+ >+ <TaskArrow color="#fff" size={13} className="-rotate-45" /></div>- {isRunning ? (- <ActivityBars color={task.color} />- ) : (- <span className="h-1.5 w-1.5 rounded-full bg-white/30" />- )}+ <span className="max-w-full truncate text-[10px] text-white/75">{task.label.split(' ')[0]}</span>+ <span+ className="max-w-full truncate rounded px-1 py-px text-[8px]"+ style={{+ background: `${statusColor}30`,+ color: statusColor === 'rgba(255,255,255,0.4)' ? 'rgba(255,255,255,0.5)' : statusColor,+ }}+ >+ {statusLabel}+ </span></div>);})}</div>- <div className="mx-2 mb-2 px-2.5 py-2 bg-white/[0.06] rounded-md flex items-center gap-2">- <Sparkles size={11} color="rgba(255,255,255,0.5)" />- <span className="text-[10px] text-white/40 flex-1">Tell Donkey what to do…</span>+ <div className="mt-auto flex items-center gap-2 rounded-md border border-white/[0.08] bg-white/[0.06] px-3 py-2.5">+ <Sparkles size={12} color="rgba(255,255,255,0.45)" />+ <span className="min-w-0 flex-1 truncate text-[12px] text-white/40">Tell Donkey what to do...</span>+ {state !== 'idle' && <ActivityBars color={activeTask.color} />}</div></div></div>diff --git a/site/src/app/prototype/_components/TaskArrow.tsx b/site/src/app/prototype/_components/TaskArrow.tsxindex 9bdcab2a..97358a41 100644--- a/site/src/app/prototype/_components/TaskArrow.tsx+++ b/site/src/app/prototype/_components/TaskArrow.tsx@@ -1,11 +1,18 @@type Props = {color: string;size?: number;+ className?: string;};-export function TaskArrow({ color, size = 14 }: Props) {+export function TaskArrow({ color, size = 14, className }: Props) {return (- <svg width={size} height={size} viewBox="0 0 14 14" aria-hidden="true" className="flex-shrink-0">+ <svg+ width={size}+ height={size}+ viewBox="0 0 14 14"+ aria-hidden="true"+ className={`flex-shrink-0 ${className ?? ''}`}+ ><path d="M3.1 1.1 12 7l-8.9 5.9L5.2 7 3.1 1.1Z" fill={color} /></svg>);