Skip to content

Open source CapCut alternative.

TypeScript

Refine notch composer focus and follow-up styling

David Le70ff4908c773
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
index fc04faa2..da7f12b5 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
@@ -20,6 +20,8 @@ struct DocumentFormFillReviewRequest: Equatable, Sendable {
protocol PointerPromptCommandHandling: Sendable {
func handleSubmittedCommand(_ command: String) async -> PointerPromptCommandHandlingResult
+ func pauseCurrentCommand() async
+ func resumeCurrentCommand() async
}
struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
@@ -115,6 +117,14 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
}
+ func pauseCurrentCommand() async {
+ await coordinator.pause(reason: "Pointer prompt paused current task")
+ }
+
+ func resumeCurrentCommand() async {
+ await coordinator.resume(reason: "Pointer prompt resumed current task")
+ }
+
private func retrieveSemanticMemory(
command: String,
resolution: LocalAppTaskCatalogResolution
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
index fd038d7c..8fce1fef 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
@@ -18,6 +18,7 @@ final class PointerPromptOverlayController {
private var timer: Timer?
private var globalActivationMonitor: Any?
private var localActivationMonitor: Any?
+ private var appDeactivationObserver: Any?
private var activationTapStartedAt: Date?
private var activationTapIsClean = false
private var completedActivationTapCount = 0
@@ -55,6 +56,7 @@ final class PointerPromptOverlayController {
self.inputPanel = inputPanel
self.statusPanel = statusPanel
startActivationMonitoring()
+ startAppDeactivationMonitoring()
positionStatusPanel()
centerInputPanel()
inputPanel.orderOut(nil)
@@ -119,7 +121,7 @@ final class PointerPromptOverlayController {
statusHostingView = hostingView
lastStatusViewSnapshot = statusViewSnapshot(metrics: metrics)
- let panel = NSPanel(
+ let panel = PointerPromptPanel(
contentRect: CGRect(origin: .zero, size: metrics.surfaceSize),
styleMask: [.borderless],
backing: .buffered,
@@ -135,6 +137,9 @@ final class PointerPromptOverlayController {
panel.isReleasedWhenClosed = false
panel.becomesKeyOnlyIfNeeded = true
panel.ignoresMouseEvents = false
+ panel.mouseDownHandler = { [weak self] in
+ self?.focusStatusComposerTextInputIfEmpty()
+ }
panel.level = .statusBar
panel.collectionBehavior = [
.canJoinAllSpaces,
@@ -157,6 +162,7 @@ final class PointerPromptOverlayController {
statusHostShrinkWorkItem = nil
statusHoverPhase = .collapsed
stopActivationMonitoring()
+ stopAppDeactivationMonitoring()
microphoneWaveformMeter.stop()
inputPanel?.close()
inputPanel = nil
@@ -202,9 +208,25 @@ final class PointerPromptOverlayController {
}
}
- private func activateInputFromStatusCommand() {
- resetActivationTapSequence()
- activateInputAtScreenCenter()
+ private func startAppDeactivationMonitoring() {
+ stopAppDeactivationMonitoring()
+
+ appDeactivationObserver = NotificationCenter.default.addObserver(
+ forName: NSApplication.didResignActiveNotification,
+ object: NSApp,
+ queue: .main
+ ) { [weak self] _ in
+ Task { @MainActor in
+ self?.dismissActivePromptFromAppDeactivation()
+ }
+ }
+ }
+
+ private func stopAppDeactivationMonitoring() {
+ if let appDeactivationObserver {
+ NotificationCenter.default.removeObserver(appDeactivationObserver)
+ self.appDeactivationObserver = nil
+ }
}
private func handleActivationEvent(_ event: NSEvent) {
@@ -464,7 +486,12 @@ final class PointerPromptOverlayController {
private func updateStatusPanelView() {
let metrics = notchMetrics()
let snapshot = statusViewSnapshot(metrics: metrics)
- guard snapshot != lastStatusViewSnapshot else { return }
+ let previousSnapshot = lastStatusViewSnapshot
+ guard snapshot != previousSnapshot else { return }
+
+ if snapshot.surfaceSize != previousSnapshot?.surfaceSize {
+ positionStatusPanel()
+ }
lastStatusViewSnapshot = snapshot
statusHostingView?.rootView = notchStatusView(metrics: metrics)
@@ -478,6 +505,10 @@ final class PointerPromptOverlayController {
surfaceSize: metrics.surfaceSize,
isExpanded: isStatusExpanded,
isHostExpanded: isStatusHostExpanded,
+ isCurrentTaskPaused: model.isCurrentTaskPaused,
+ notchCommandText: model.notchCommandText,
+ notchCommandInputTextHeight: model.notchCommandInputTextHeight,
+ isNotchCommandInputExpanded: model.isNotchCommandInputExpanded,
accentIndex: model.notchAccentIndex
)
}
@@ -490,9 +521,32 @@ final class PointerPromptOverlayController {
surfaceWidth: metrics.surfaceSize.width,
surfaceHeight: metrics.surfaceSize.height,
isExpanded: isStatusExpanded,
+ isCurrentTaskPaused: model.isCurrentTaskPaused,
+ commandText: Binding(
+ get: { [weak self] in
+ self?.model.notchCommandText ?? ""
+ },
+ set: { [weak self] text in
+ self?.model.notchCommandText = text
+ }
+ ),
+ commandInputTextHeight: model.notchCommandInputTextHeight,
+ isCommandInputExpanded: model.isNotchCommandInputExpanded,
accentIndex: model.notchAccentIndex,
- commandRequested: { [weak self] in
- self?.activateInputFromStatusCommand()
+ commandSubmitted: { [weak self] text in
+ self?.model.handle(.messageSubmitted(text: text))
+ },
+ commandInputTextHeightChanged: { [weak self] height in
+ self?.model.updateNotchCommandInputTextHeight(height)
+ },
+ commandInputExpansionChanged: { [weak self] isExpanded in
+ self?.model.updateNotchCommandInputExpansion(isExpanded)
+ },
+ pauseRequested: { [weak self] in
+ self?.model.pauseCurrentTask()
+ },
+ resumeRequested: { [weak self] in
+ self?.model.resumeCurrentTask()
},
updateRequested: { [weak self] in
self?.openAvailableUpdate()
@@ -550,6 +604,7 @@ final class PointerPromptOverlayController {
self.statusHoverPhase = .expanded
self.statusExpansionWorkItem = nil
self.updateStatusPanelView()
+ self.focusStatusComposerTextInputIfEmpty()
}
statusExpansionWorkItem = workItem
DispatchQueue.main.asyncAfter(
@@ -663,6 +718,7 @@ final class PointerPromptOverlayController {
return NotchMetrics(
voidWidth: NotchMetrics.fallbackVoidWidth,
voidHeight: NotchMetrics.fallbackVoidHeight,
+ expandedContentHeight: statusExpandedContentHeight,
isExpanded: isStatusExpanded,
isHostExpanded: isStatusHostExpanded,
screenWidth: NotchMetrics.defaultScreenWidth
@@ -687,12 +743,30 @@ final class PointerPromptOverlayController {
return NotchMetrics(
voidWidth: voidWidth,
voidHeight: voidHeight,
+ expandedContentHeight: statusExpandedContentHeight,
isExpanded: isStatusExpanded,
isHostExpanded: isStatusHostExpanded,
screenWidth: screen.frame.width
)
}
+ private var statusExpandedContentHeight: CGFloat {
+ if hasStatusTaskDisplayText || model.updateState.headerButtonTitle != nil {
+ return NotchMetrics.expandedTaskContentHeight
+ }
+
+ return model.notchCommandInputSurfaceHeight + NotchMetrics.compactCommandContentPadding
+ }
+
+ private var hasStatusTaskDisplayText: Bool {
+ let text = model.promptState.promptText
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ .split(whereSeparator: \.isWhitespace)
+ .joined(separator: " ")
+
+ return !text.isEmpty && text != "Make this so" && text != "Resting"
+ }
+
private func inferredVoidWidth(for screen: NSScreen, safeTop: CGFloat) -> CGFloat {
guard safeTop > 0 else { return 0 }
@@ -827,6 +901,16 @@ final class PointerPromptOverlayController {
}
private func dismissActivePromptFromKeyboard() {
+ dismissActivePrompt()
+ }
+
+ private func dismissActivePromptFromAppDeactivation() {
+ resetActivationTapSequence()
+ dismissActivePrompt()
+ inputPanel?.orderOut(nil)
+ }
+
+ private func dismissActivePrompt() {
guard model.promptState.isActive else { return }
model.handle(.dismissed)
@@ -927,11 +1011,43 @@ final class PointerPromptOverlayController {
return panel.firstResponder === textView ||
textView.window?.firstResponder === textView
}
+
+ private func focusStatusComposerTextInput(attempt: Int = 0) {
+ guard isStatusExpanded,
+ let statusPanel,
+ let textView = firstComposerTextView(in: statusPanel.contentView) else {
+ return
+ }
+
+ NSApp.activate(ignoringOtherApps: true)
+ statusPanel.orderFrontRegardless()
+ statusPanel.makeKeyAndOrderFront(nil)
+ statusPanel.makeFirstResponder(textView)
+ textView.window?.makeFirstResponder(textView)
+
+ guard attempt < 8,
+ (!NSApp.isActive ||
+ !statusPanel.isKeyWindow ||
+ !isComposerTextInputFocused(in: statusPanel)) else {
+ return
+ }
+
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.025) {
+ self.focusStatusComposerTextInput(attempt: attempt + 1)
+ }
+ }
+
+ private func focusStatusComposerTextInputIfEmpty() {
+ guard !hasStatusTaskDisplayText else { return }
+
+ focusStatusComposerTextInput()
+ }
}
private final class PointerPromptPanel: NSPanel {
var dragRegionProvider: (() -> [CGRect])?
var escapeKeyHandler: (() -> Void)?
+ var mouseDownHandler: (() -> Void)?
override var canBecomeKey: Bool {
true
@@ -954,6 +1070,10 @@ private final class PointerPromptPanel: NSPanel {
return
}
+ if event.type == .leftMouseDown {
+ mouseDownHandler?()
+ }
+
super.sendEvent(event)
}
}
@@ -966,6 +1086,7 @@ private struct NotchMetrics {
var voidWidth: CGFloat
var voidHeight: CGFloat
+ var expandedContentHeight: CGFloat
var isExpanded: Bool
var isHostExpanded: Bool
var screenWidth: CGFloat
@@ -1044,7 +1165,7 @@ private struct NotchMetrics {
x: Self.expandedContentDesignFrame.minX,
y: expandedContentTopInset,
width: Self.expandedContentDesignFrame.width,
- height: Self.expandedContentDesignFrame.height
+ height: expandedContentHeight
)
}
@@ -1068,11 +1189,18 @@ private struct NotchMetrics {
}
private var expandedSurfaceHeight: CGFloat {
- Self.expandedContentDesignFrame.height + expandedContentTopInset
+ expandedContentHeight + 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 expandedContentDesignFrame = CGRect(
+ x: 0,
+ y: 0,
+ width: PointerPromptLayout.composerInputSurfaceWidth + 48,
+ height: 280
+ )
+ static let expandedTaskContentHeight: CGFloat = 280
+ static let compactCommandContentPadding: CGFloat = 52
private static let collapsedSideLaneWidth: CGFloat = 34
private static let collapsedCornerRadius: CGFloat = 14
private static let expandedCornerRadius: CGFloat = 26
@@ -1088,6 +1216,10 @@ private struct StatusPanelViewSnapshot: Equatable {
var surfaceSize: CGSize
var isExpanded: Bool
var isHostExpanded: Bool
+ var isCurrentTaskPaused: Bool
+ var notchCommandText: String
+ var notchCommandInputTextHeight: CGFloat
+ var isNotchCommandInputExpanded: Bool
var accentIndex: Int
}
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
index 7e1df4d0..2935e001 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
@@ -10,7 +10,11 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
@Published var placement: PointerPromptPlacement = .bottomRight
@Published var inputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
@Published var isInputExpanded = false
+ @Published var notchCommandText = ""
+ @Published private(set) var notchCommandInputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
+ @Published private(set) var isNotchCommandInputExpanded = true
@Published private(set) var notchAccentIndex = Int.random(in: 0..<8)
+ @Published private(set) var isCurrentTaskPaused = false
@Published private(set) var updateState: PointerPromptUpdateState
private let commandHandler: any PointerPromptCommandHandling
@@ -79,6 +83,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
promptState.leadingSignalLevel = .ready
promptState.promptText = "Listening..."
case .primaryActionRequested:
+ isCurrentTaskPaused = false
promptState.leadingSignalLevel = .thinking
case .messageSubmitted(let text):
let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
@@ -136,6 +141,10 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
messageText = ""
inputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
isInputExpanded = false
+ notchCommandText = ""
+ notchCommandInputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
+ isNotchCommandInputExpanded = true
+ isCurrentTaskPaused = false
notchAccentIndex = Self.nextAccentIndex(after: notchAccentIndex)
promptState.isActive = false
promptState.leadingSignalLevel = .thinking
@@ -144,6 +153,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
let result = await commandHandler.handleSubmittedCommand(text)
await MainActor.run {
guard let self else { return }
+ self.isCurrentTaskPaused = false
self.promptState.leadingSignalLevel = result.status == .completed ? .ready : .idle
self.promptState.promptText = result.taskLabel ?? result.summary
if let documentReviewRequest = result.documentReviewRequest {
@@ -153,6 +163,45 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
}
}
+ func pauseCurrentTask() {
+ guard promptState.leadingSignalLevel == .thinking,
+ !isCurrentTaskPaused else {
+ return
+ }
+
+ isCurrentTaskPaused = true
+ Task { [commandHandler] in
+ await commandHandler.pauseCurrentCommand()
+ }
+ }
+
+ func resumeCurrentTask() {
+ guard isCurrentTaskPaused else { return }
+
+ isCurrentTaskPaused = false
+ Task { [commandHandler] in
+ await commandHandler.resumeCurrentCommand()
+ }
+ }
+
+ func updateNotchCommandInputTextHeight(_ height: CGFloat) {
+ let clampedHeight = PointerPromptLayout.clampedComposerInputTextHeight(height)
+ guard abs(notchCommandInputTextHeight - clampedHeight) > 0.5 else { return }
+
+ notchCommandInputTextHeight = clampedHeight
+ }
+
+ func updateNotchCommandInputExpansion(_ isExpanded: Bool) {
+ let shouldExpand = true
+ guard isNotchCommandInputExpanded != shouldExpand else { return }
+
+ isNotchCommandInputExpanded = shouldExpand
+ }
+
+ var notchCommandInputSurfaceHeight: CGFloat {
+ max(92, notchCommandInputTextHeight + 60)
+ }
+
private static func nextAccentIndex(after currentIndex: Int) -> Int {
let accentCount = 8
var nextIndex = Int.random(in: 0..<accentCount)
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift
index dfdc8500..8ef10aa6 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift
@@ -8,8 +8,16 @@ public struct PointerPromptNotchStatusView: View {
private let surfaceWidth: CGFloat
private let surfaceHeight: CGFloat
private let isExpanded: Bool
+ private let isCurrentTaskPaused: Bool
+ @Binding private var commandText: String
+ private let commandInputTextHeight: CGFloat
+ private let isCommandInputExpanded: Bool
private let accentIndex: Int
- private let commandRequested: @MainActor () -> Void
+ private let commandSubmitted: @MainActor (String) -> Void
+ private let commandInputTextHeightChanged: @MainActor (CGFloat) -> Void
+ private let commandInputExpansionChanged: @MainActor (Bool) -> Void
+ private let pauseRequested: @MainActor () -> Void
+ private let resumeRequested: @MainActor () -> Void
private let updateRequested: @MainActor () -> Void
public init(
@@ -19,8 +27,16 @@ public struct PointerPromptNotchStatusView: View {
surfaceWidth: CGFloat,
surfaceHeight: CGFloat,
isExpanded: Bool,
+ isCurrentTaskPaused: Bool,
+ commandText: Binding<String>,
+ commandInputTextHeight: CGFloat,
+ isCommandInputExpanded: Bool,
accentIndex: Int,
- commandRequested: @escaping @MainActor () -> Void,
+ commandSubmitted: @escaping @MainActor (String) -> Void,
+ commandInputTextHeightChanged: @escaping @MainActor (CGFloat) -> Void,
+ commandInputExpansionChanged: @escaping @MainActor (Bool) -> Void,
+ pauseRequested: @escaping @MainActor () -> Void,
+ resumeRequested: @escaping @MainActor () -> Void,
updateRequested: @escaping @MainActor () -> Void
) {
self.state = state
@@ -29,8 +45,16 @@ public struct PointerPromptNotchStatusView: View {
self.surfaceWidth = surfaceWidth
self.surfaceHeight = surfaceHeight
self.isExpanded = isExpanded
+ self.isCurrentTaskPaused = isCurrentTaskPaused
+ _commandText = commandText
+ self.commandInputTextHeight = commandInputTextHeight
+ self.isCommandInputExpanded = isCommandInputExpanded
self.accentIndex = accentIndex
- self.commandRequested = commandRequested
+ self.commandSubmitted = commandSubmitted
+ self.commandInputTextHeightChanged = commandInputTextHeightChanged
+ self.commandInputExpansionChanged = commandInputExpansionChanged
+ self.pauseRequested = pauseRequested
+ self.resumeRequested = resumeRequested
self.updateRequested = updateRequested
}
@@ -65,6 +89,15 @@ public struct PointerPromptNotchStatusView: View {
isExpanded ? Self.expandedContentAnimation : Self.expandedContentDismissAnimation,
value: isExpanded
)
+
+ if !hasTaskDisplayText {
+ expandedNotchArrow
+ .opacity(isExpanded ? 1 : 0)
+ .animation(
+ isExpanded ? Self.expandedContentAnimation : Self.expandedContentDismissAnimation,
+ value: isExpanded
+ )
+ }
}
.frame(width: animatingSurfaceWidth, height: animatingSurfaceHeight, alignment: .top)
.clipShape(notchSurfaceShape(cornerRadius: animatingSurfaceCornerRadius))
@@ -152,18 +185,12 @@ public struct PointerPromptNotchStatusView: View {
}
private var expandedContent: some View {
- VStack(spacing: 0) {
- expandedHeader
-
- currentTaskRow
- .padding(.horizontal, 14)
- .padding(.top, 10)
-
- Spacer(minLength: 8)
-
- commandRow
- .padding(.horizontal, 14)
- .padding(.bottom, 10)
+ Group {
+ if hasTaskDisplayText {
+ expandedTaskContent
+ } else {
+ expandedCommandOnlyContent
+ }
}
.frame(
width: layout.expandedContentFrame.width,
@@ -177,19 +204,47 @@ public struct PointerPromptNotchStatusView: View {
.clipped()
}
- private var expandedHeader: some View {
- HStack(spacing: 10) {
- TaskArrowMark(color: accentColor)
- .frame(width: 15, height: 15)
+ private var expandedTaskContent: some View {
+ VStack(spacing: 0) {
+ if updateState.headerButtonTitle != nil {
+ expandedUpdateHeader
+ }
- Text("Current task")
- .font(.system(size: 13, weight: .regular))
- .foregroundStyle(Color.white.opacity(0.92))
+ ScrollView(.vertical, showsIndicators: false) {
+ currentTaskRow
+ .padding(.horizontal, 14)
+ .padding(.top, 10)
+ }
- Text(statusLabel)
- .font(.system(size: 12, weight: .regular))
- .foregroundStyle(Color.white.opacity(0.42))
+ Spacer(minLength: 8)
+
+ commandRow
+ .padding(.horizontal, 24)
+ .padding(.bottom, 24)
+ }
+ }
+ private var expandedCommandOnlyContent: some View {
+ VStack(spacing: 0) {
+ if updateState.headerButtonTitle != nil {
+ expandedUpdateHeader
+ }
+
+ commandRow
+ .padding(.horizontal, 24)
+ .padding(.top, 16)
+ .padding(.bottom, 24)
+ }
+ }
+
+ private var expandedNotchArrow: some View {
+ TaskArrowMark(color: accentColor)
+ .frame(width: 15, height: 15)
+ .position(x: expandedNotchArrowX, y: expandedNotchArrowY)
+ }
+
+ private var expandedUpdateHeader: some View {
+ HStack {
Spacer()
if let updateTitle = updateState.headerButtonTitle {
@@ -210,17 +265,6 @@ public struct PointerPromptNotchStatusView: View {
}
.buttonStyle(.plain)
}
-
- Button(action: commandRequested) {
- HStack(spacing: 6) {
- Image(systemName: "plus")
- .font(.system(size: 13, weight: .regular))
- Text("new")
- .font(.system(size: 13, weight: .regular))
- }
- .foregroundStyle(Color.white.opacity(0.46))
- }
- .buttonStyle(.plain)
}
.padding(.horizontal, 18)
.frame(height: 40)
@@ -231,11 +275,18 @@ public struct PointerPromptNotchStatusView: View {
}
}
+ private var expandedNotchArrowX: CGFloat {
+ 24
+ }
+
+ private var expandedNotchArrowY: CGFloat {
+ max(14, layout.collapsedVisibleHeight / 2)
+ }
+
private var currentTaskRow: some View {
- HStack(spacing: 10) {
- Circle()
- .fill(accentColor)
- .frame(width: 7, height: 7)
+ HStack(spacing: 12) {
+ TaskArrowMark(color: accentColor)
+ .frame(width: 14, height: 14)
VStack(alignment: .leading, spacing: 4) {
Text(taskTitle)
@@ -250,7 +301,9 @@ public struct PointerPromptNotchStatusView: View {
Spacer()
- if isWorking {
+ if isActiveTask {
+ activeTaskControls
+ } else if isWorking {
activityBars(color: accentColor)
}
}
@@ -261,24 +314,75 @@ public struct PointerPromptNotchStatusView: View {
}
private var commandRow: some View {
- Button(action: commandRequested) {
- HStack(spacing: 10) {
- Image(systemName: "sparkles")
- .font(.system(size: 14, weight: .regular))
- .foregroundStyle(Color.white.opacity(0.42))
+ PointerPromptComposer(
+ state: commandInputState,
+ messageText: $commandText,
+ inputTextHeight: commandInputTextHeight,
+ isInputExpanded: isCommandInputExpanded,
+ surfaceFill: Color.white.opacity(0.085),
+ forceExpandedSurface: true,
+ toolbarStyle: .followUp,
+ sizeProfile: .compact,
+ submit: submitCommandText,
+ inputTextHeightChanged: commandInputTextHeightChanged,
+ inputExpansionChanged: commandInputExpansionChanged
+ )
+ }
- Text("Type a task...")
- .font(.system(size: 13, weight: .regular))
- .foregroundStyle(Color.white.opacity(0.42))
+ private func submitCommandText() {
+ let text = commandText.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard !text.isEmpty else { return }
- Spacer()
- }
- .padding(.horizontal, 12)
- .frame(height: 42)
- .background(Color.white.opacity(0.055))
- .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
+ commandText = ""
+ commandSubmitted(text)
+ }
+
+ private var commandInputState: PointerPromptState {
+ PointerPromptState(
+ promptText: "Ask for follow-up changes",
+ isPrimaryActionEnabled: true,
+ leadingSignalLevel: .ready,
+ isActive: isExpanded,
+ theme: state.theme,
+ voiceWaveformLevels: state.voiceWaveformLevels
+ )
+ }
+
+ private var activeTaskControls: some View {
+ HStack(spacing: 6) {
+ statusControlButton(
+ systemName: "play.fill",
+ label: "Resume",
+ isEnabled: isCurrentTaskPaused,
+ action: resumeRequested
+ )
+
+ statusControlButton(
+ systemName: "pause.fill",
+ label: "Pause",
+ isEnabled: !isCurrentTaskPaused,
+ action: pauseRequested
+ )
+ }
+ }
+
+ private func statusControlButton(
+ systemName: String,
+ label: String,
+ isEnabled: Bool,
+ action: @escaping @MainActor () -> Void
+ ) -> some View {
+ Button(action: action) {
+ Image(systemName: systemName)
+ .font(.system(size: 10, weight: .regular))
+ .foregroundStyle(Color.white.opacity(isEnabled ? 0.88 : 0.3))
+ .frame(width: 24, height: 24)
+ .background(Color.white.opacity(isEnabled ? 0.12 : 0.055))
+ .clipShape(Circle())
}
.buttonStyle(.plain)
+ .disabled(!isEnabled)
+ .accessibilityLabel(label)
}
private func activityBars(color: Color, height: CGFloat = 18) -> some View {
@@ -293,38 +397,32 @@ public struct PointerPromptNotchStatusView: View {
}
private var taskTitle: String {
- switch state.leadingSignalLevel {
- case .idle:
- let text = state.promptText.trimmingCharacters(in: .whitespacesAndNewlines)
- return text.isEmpty || text == "Make this so" ? "Resting" : text
- case .ready:
- let text = state.promptText.trimmingCharacters(in: .whitespacesAndNewlines)
- return text.isEmpty ? "Ready" : text
- case .thinking:
- let text = state.promptText.trimmingCharacters(in: .whitespacesAndNewlines)
- return text.isEmpty ? "Working" : text
+ if let taskDisplayText {
+ return taskDisplayText
}
- }
- private var statusLabel: String {
switch state.leadingSignalLevel {
case .idle:
- return "resting"
+ return "Resting"
case .ready:
- return "ready"
+ return "Ready"
case .thinking:
- return "working"
+ return "Working"
}
}
private var statusDescription: String {
+ if isCurrentTaskPaused {
+ return "Paused"
+ }
+
switch state.leadingSignalLevel {
case .idle:
- return "Waiting for a task"
+ return hasTaskDisplayText ? "Needs attention" : "Idle"
case .ready:
- return "Ready for the next task"
+ return "Ready"
case .thinking:
- return "Classifying and running"
+ return "Running"
}
}
@@ -332,8 +430,28 @@ public struct PointerPromptNotchStatusView: View {
state.leadingSignalLevel == .thinking
}
+ private var isActiveTask: Bool {
+ isWorking || isCurrentTaskPaused
+ }
+
+ private var hasTaskDisplayText: Bool {
+ taskDisplayText != nil
+ }
+
+ private var taskDisplayText: String? {
+ let text = state.promptText
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ .split(whereSeparator: \.isWhitespace)
+ .joined(separator: " ")
+ guard !text.isEmpty, text != "Make this so", text != "Resting" else {
+ return nil
+ }
+
+ return text
+ }
+
private var isResting: Bool {
- state.leadingSignalLevel == .idle && taskTitle == "Resting"
+ state.leadingSignalLevel == .idle && !hasTaskDisplayText
}
private var accentColor: Color {
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
index cee9048c..9d9d6e60 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
@@ -99,25 +99,50 @@ public struct PointerPromptStageView: View {
}
}
-private struct PointerPromptComposer: View {
- private static let rendersToolbarControls = false
-
+struct PointerPromptComposer: View {
let state: PointerPromptState
@Binding var messageText: String
let inputTextHeight: CGFloat
let isInputExpanded: Bool
+ let surfaceFill: Color
+ let forceExpandedSurface: Bool
+ let toolbarStyle: PointerPromptComposerToolbarStyle
+ let sizeProfile: PointerPromptComposerSizeProfile
let submit: @MainActor () -> Void
let inputTextHeightChanged: @MainActor (CGFloat) -> Void
let inputExpansionChanged: @MainActor (Bool) -> Void
+ init(
+ state: PointerPromptState,
+ messageText: Binding<String>,
+ inputTextHeight: CGFloat,
+ isInputExpanded: Bool,
+ surfaceFill: Color = .black,
+ forceExpandedSurface: Bool = false,
+ toolbarStyle: PointerPromptComposerToolbarStyle = .waveformOnly,
+ sizeProfile: PointerPromptComposerSizeProfile = .standard,
+ submit: @escaping @MainActor () -> Void,
+ inputTextHeightChanged: @escaping @MainActor (CGFloat) -> Void,
+ inputExpansionChanged: @escaping @MainActor (Bool) -> Void
+ ) {
+ self.state = state
+ _messageText = messageText
+ self.inputTextHeight = inputTextHeight
+ self.isInputExpanded = isInputExpanded
+ self.surfaceFill = surfaceFill
+ self.forceExpandedSurface = forceExpandedSurface
+ self.toolbarStyle = toolbarStyle
+ self.sizeProfile = sizeProfile
+ self.submit = submit
+ self.inputTextHeightChanged = inputTextHeightChanged
+ self.inputExpansionChanged = inputExpansionChanged
+ }
+
var body: some View {
promptSurface
.frame(
width: PointerPromptLayout.composerInputSurfaceWidth,
- height: PointerPromptLayout.composerInputHeight(
- inputTextHeight: inputTextHeight,
- isExpanded: isExpanded
- ),
+ height: composerHeight,
alignment: .topLeading
)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
@@ -125,7 +150,7 @@ private struct PointerPromptComposer: View {
@ViewBuilder
private var promptSurface: some View {
- if isExpanded {
+ if usesExpandedSurface {
expandedPromptSurface
} else {
promptCapsule
@@ -147,14 +172,11 @@ private struct PointerPromptComposer: View {
.padding(.trailing, PointerPromptLayout.composerInputTrailingContentPadding)
.frame(
width: PointerPromptLayout.composerInputSurfaceWidth,
- height: PointerPromptLayout.composerInputHeight(
- inputTextHeight: inputTextHeight,
- isExpanded: isExpanded
- )
+ height: composerHeight
)
.background {
Capsule(style: .continuous)
- .fill(Color.black)
+ .fill(surfaceFill)
}
.overlay {
Capsule(style: .continuous)
@@ -173,7 +195,7 @@ private struct PointerPromptComposer: View {
VStack(spacing: 0) {
textInput
.frame(width: PointerPromptLayout.composerExpandedTextWidth)
- .padding(.top, PointerPromptLayout.composerExpandedTextTopPadding)
+ .padding(.top, sizeProfile.expandedTextTopPadding)
.padding(.horizontal, PointerPromptLayout.composerExpandedTextHorizontalPadding)
.frame(
width: PointerPromptLayout.composerInputSurfaceWidth,
@@ -185,24 +207,23 @@ private struct PointerPromptComposer: View {
}
.frame(
width: PointerPromptLayout.composerInputSurfaceWidth,
- height: PointerPromptLayout.composerInputHeight(
- inputTextHeight: inputTextHeight,
- isExpanded: isExpanded
- )
+ height: composerHeight
)
.background {
RoundedRectangle(
cornerRadius: PointerPromptLayout.composerCornerRadius,
style: .continuous
)
- .fill(Color.black)
+ .fill(surfaceFill)
}
.overlay {
- RoundedRectangle(
- cornerRadius: PointerPromptLayout.composerCornerRadius,
- style: .continuous
- )
- .stroke(Color.white.opacity(0.28), lineWidth: 1)
+ if showsSurfaceStroke {
+ RoundedRectangle(
+ cornerRadius: PointerPromptLayout.composerCornerRadius,
+ style: .continuous
+ )
+ .stroke(Color.white.opacity(0.28), lineWidth: 1)
+ }
}
.shadow(
color: Color.black.opacity(state.isActive ? 0.2 : 0.08),
@@ -215,48 +236,38 @@ private struct PointerPromptComposer: View {
private var promptToolbar: some View {
HStack {
- if Self.rendersToolbarControls {
- toolbarControls
- }
-
Spacer(minLength: 0)
- VoiceWaveformView(levels: state.voiceWaveformLevels)
- .frame(
- width: PointerPromptLayout.composerWaveformSize.width,
- height: PointerPromptLayout.composerWaveformSize.height
- )
+ switch toolbarStyle {
+ case .waveformOnly:
+ VoiceWaveformView(levels: state.voiceWaveformLevels)
+ .frame(
+ width: PointerPromptLayout.composerWaveformSize.width,
+ height: PointerPromptLayout.composerWaveformSize.height
+ )
+ case .followUp:
+ followUpTrailingControls
+ }
}
- .padding(.horizontal, PointerPromptLayout.composerExpandedTextHorizontalPadding)
+ .padding(.horizontal, toolbarHorizontalPadding)
+ .padding(.bottom, toolbarBottomPadding)
.frame(
width: PointerPromptLayout.composerInputSurfaceWidth,
- height: PointerPromptLayout.composerExpandedToolbarHeight
+ height: sizeProfile.toolbarHeight
)
}
- private var toolbarControls: some View {
- HStack(spacing: 12) {
- toolbarIcon(systemName: "plus")
-
- HStack(spacing: 8) {
- Image(systemName: "hand.raised")
- .font(.system(size: 15, weight: .medium))
-
- Text("Default permissions")
- .font(.system(size: 14, weight: .medium))
-
- Image(systemName: "chevron.down")
- .font(.system(size: 11, weight: .semibold))
- }
- .foregroundStyle(Color.white.opacity(0.6))
+ private var followUpTrailingControls: some View {
+ Button(action: submit) {
+ Image(systemName: "arrow.up")
+ .font(.system(size: 13, weight: .semibold))
+ .foregroundStyle(Color.black.opacity(0.75))
+ .frame(width: 32, height: 32)
+ .background(Color.white.opacity(0.9))
+ .clipShape(Circle())
}
- }
-
- private func toolbarIcon(systemName: String) -> some View {
- Image(systemName: systemName)
- .font(.system(size: 18, weight: .regular))
- .foregroundStyle(Color.white.opacity(0.62))
- .frame(width: 24, height: 24)
+ .buttonStyle(.plain)
+ .disabled(messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
}
private var textInput: some View {
@@ -273,19 +284,93 @@ private struct PointerPromptComposer: View {
}
private var expandedSurfaceHeight: CGFloat {
- PointerPromptLayout.composerInputHeight(inputTextHeight: inputTextHeight, isExpanded: true)
+ composerHeight
}
private var expandedTextAreaHeight: CGFloat {
max(
- inputTextHeight + PointerPromptLayout.composerExpandedTextTopPadding,
- expandedSurfaceHeight - PointerPromptLayout.composerExpandedToolbarHeight
+ inputTextHeight + sizeProfile.expandedTextTopPadding,
+ expandedSurfaceHeight - sizeProfile.toolbarHeight
)
}
+ private var toolbarHorizontalPadding: CGFloat {
+ switch toolbarStyle {
+ case .waveformOnly:
+ PointerPromptLayout.composerExpandedTextHorizontalPadding
+ case .followUp:
+ 16
+ }
+ }
+
+ private var toolbarBottomPadding: CGFloat {
+ switch toolbarStyle {
+ case .waveformOnly:
+ 0
+ case .followUp:
+ 16
+ }
+ }
+
private var isExpanded: Bool {
isInputExpanded || messageText.contains("\n")
}
+
+ private var usesExpandedSurface: Bool {
+ forceExpandedSurface || isExpanded
+ }
+
+ private var showsSurfaceStroke: Bool {
+ toolbarStyle != .followUp
+ }
+
+ var composerHeight: CGFloat {
+ if usesExpandedSurface {
+ return max(
+ sizeProfile.expandedMinimumHeight,
+ inputTextHeight + sizeProfile.expandedTextTopPadding + sizeProfile.toolbarHeight
+ )
+ }
+
+ return PointerPromptLayout.composerInputMinimumHeight
+ }
+}
+
+enum PointerPromptComposerToolbarStyle {
+ case waveformOnly
+ case followUp
+}
+
+enum PointerPromptComposerSizeProfile {
+ case standard
+ case compact
+
+ var expandedTextTopPadding: CGFloat {
+ switch self {
+ case .standard:
+ PointerPromptLayout.composerExpandedTextTopPadding
+ case .compact:
+ 12
+ }
+ }
+
+ var toolbarHeight: CGFloat {
+ switch self {
+ case .standard:
+ PointerPromptLayout.composerExpandedToolbarHeight
+ case .compact:
+ 48
+ }
+ }
+
+ var expandedMinimumHeight: CGFloat {
+ switch self {
+ case .standard:
+ PointerPromptLayout.composerExpandedMinimumHeight
+ case .compact:
+ 92
+ }
+ }
}
private struct VoiceWaveformView: View {
diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.md
index fdbf3459..f04921e1 100644
--- a/docs/guides/pointer-prompt-overlay.md
+++ b/docs/guides/pointer-prompt-overlay.md
@@ -25,6 +25,7 @@ Donkey supports a floating macOS pointer prompt overlay:
- 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
- accepts mouse clicks in the notch status panel so expanded header and command-row controls can invoke their actions
+- shows pause and resume controls for an active task in the expanded notch panel and routes them through the pointer-prompt command handler
- 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
- places the waveform in a bottom toolbar that blends with the input background when the prompt is expanded
@@ -55,13 +56,14 @@ This is a visual, typed-command, and voice-command UI capability. Typed submissi
- The active prompt modal should use a capsule shape and keep transparent active overlay space passing clicks through to windows underneath after it dismisses.
- 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.
+- 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 expanded surface with the arrow anchored left of the notch void in the same row as the physical notch. When no task text exists, the expanded surface should render the shared double-Command prompt composer in-place as a padded follow-up editor with a darker gray rounded-rectangle fill, normal macOS text scale, only a small circular send button in the toolbar, and multiline resizing up to the shared composer text-height cap before the text view scrolls. Opening or clicking the expanded status panel should focus the composer input. When task text exists, it should show the colored arrow, task title, status, active pause/resume controls when running, a scrollable task-item area, and the shared composer row.
- 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, render the collapsed notch once in that expanded host, then flip SwiftUI expansion state on the next frame; 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.
+- Expanded notch pause/resume controls should call the model/controller boundary and route through `PointerPromptCommandHandling`, keeping run coordination outside SwiftUI rendering.
- 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.
- Double-Command is the prompt activation shortcut through `PointerPromptActivationShortcut.doubleCommand`.
@@ -81,7 +83,7 @@ swift build
swift 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. 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. Submit a command, expand the notch while it is running, and confirm pause/resume controls update the task state. 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 Points