Open source CapCut alternative.
TypeScript
Support voice-active prompt composer controls
David Le44431eaed276
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swiftindex e1f2f914..ba1d1e03 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift@@ -390,18 +390,24 @@ final class PointerPromptOverlayController {}private func activateVoiceInputIfNeeded() {+ guard !activatePromptVoiceInputIfNeeded() else { return }+activateSpawnVoiceInputIfNeeded()- guard activeSpawnVoiceInputID == nil else { return }+ }++ private func activatePromptVoiceInputIfNeeded() -> Bool {+ guard activeSpawnVoiceInputID == nil else { return false }guard let holdToVoiceInputDuration = activationShortcut.holdToVoiceInputDuration,let activationHoldStartedAt,activationTapIsClean,Date().timeIntervalSince(activationHoldStartedAt) >= holdToVoiceInputDuration else {- return+ return false}resetActivationTapSequence()activateVoiceInputAtScreenCenter()+ return true}private func activateInputAtScreenCenter() {@@ -440,6 +446,7 @@ final class PointerPromptOverlayController {}activeSpawnVoiceInputID = spawnID+ resetActivationTapSequence()microphoneWaveformMeter.startAudioCapture()}@@ -1002,6 +1009,9 @@ final class PointerPromptOverlayController {let composerFrame = composerFrame(for: fixedPlacement)let inputSurfaceFrame = composerInputSurfaceFrame(in: composerFrame)var regions = [inputSurfaceFrame]+ for frame in composerInteractiveFrames(in: inputSurfaceFrame) {+ regions = regions.flatMap { Self.subtract(frame, from: $0) }+ }regions.removeAll { $0.width <= 0 || $0.height <= 0 }return regions@@ -1061,6 +1071,76 @@ final class PointerPromptOverlayController {)}+ private func composerInteractiveFrames(in inputSurfaceFrame: CGRect) -> [CGRect] {+ [+ composerTextInputFrame(in: inputSurfaceFrame).insetBy(dx: -4, dy: -6),+ composerTrailingControlsFrame(in: inputSurfaceFrame).insetBy(dx: -6, dy: -6)+ ]+ }++ private func composerTrailingControlsFrame(in inputSurfaceFrame: CGRect) -> CGRect {+ if model.isInputExpanded {+ return CGRect(+ x: inputSurfaceFrame.maxX -+ PointerPromptLayout.composerExpandedTextHorizontalPadding -+ PointerPromptLayout.composerTrailingControlsWidth,+ y: inputSurfaceFrame.minY,+ width: PointerPromptLayout.composerTrailingControlsWidth,+ height: PointerPromptLayout.composerExpandedToolbarHeight+ )+ }++ return CGRect(+ x: inputSurfaceFrame.maxX -+ PointerPromptLayout.composerInputTrailingContentPadding -+ PointerPromptLayout.composerTrailingControlsWidth,+ y: inputSurfaceFrame.minY,+ width: PointerPromptLayout.composerTrailingControlsWidth,+ height: inputSurfaceFrame.height+ )+ }++ private static func subtract(_ excludedFrame: CGRect, from frame: CGRect) -> [CGRect] {+ let excludedFrame = excludedFrame.intersection(frame)+ guard !excludedFrame.isNull, !excludedFrame.isEmpty else { return [frame] }++ var regions: [CGRect] = []+ if excludedFrame.minY > frame.minY {+ regions.append(CGRect(+ x: frame.minX,+ y: frame.minY,+ width: frame.width,+ height: excludedFrame.minY - frame.minY+ ))+ }+ if excludedFrame.maxY < frame.maxY {+ regions.append(CGRect(+ x: frame.minX,+ y: excludedFrame.maxY,+ width: frame.width,+ height: frame.maxY - excludedFrame.maxY+ ))+ }+ if excludedFrame.minX > frame.minX {+ regions.append(CGRect(+ x: frame.minX,+ y: excludedFrame.minY,+ width: excludedFrame.minX - frame.minX,+ height: excludedFrame.height+ ))+ }+ if excludedFrame.maxX < frame.maxX {+ regions.append(CGRect(+ x: excludedFrame.maxX,+ y: excludedFrame.minY,+ width: frame.maxX - excludedFrame.maxX,+ height: excludedFrame.height+ ))+ }++ return regions.filter { $0.width > 0 && $0.height > 0 }+ }+private func updateMouseEventPassthrough(for panel: NSPanel) {guard model.promptState.isActive else {panel.ignoresMouseEvents = truediff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swiftindex 800e9921..d145cfd6 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift@@ -77,6 +77,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkfunc activate() {promptState.isActive = truepromptState.isPrimaryActionEnabled = true+ promptState.isVoiceInputActive = falsepromptState.leadingSignalLevel = .readypromptState.promptText = PointerPromptCopy.defaultPromptPlaceholder}@@ -102,6 +103,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkpromptState.leadingSignalLevel = .readycase .voiceInputRequested:promptState.leadingSignalLevel = .ready+ promptState.isVoiceInputActive = truepromptState.promptText = "Listening..."case .primaryActionRequested(let promptText):let trimmedText = promptText.trimmingCharacters(in: .whitespacesAndNewlines)@@ -123,11 +125,14 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkisInputExpanded = shouldExpandcase .dismissed:promptState.isPrimaryActionEnabled = false+ promptState.isVoiceInputActive = falsepromptState.isActive = false}}func submitVoiceAudio(_ audio: LocalVoiceAudioBuffer?) {+ promptState.isVoiceInputActive = false+guard let audio else {promptState.leadingSignalLevel = .idlepromptState.promptText = "No voice captured"@@ -207,6 +212,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinklet spawnID = source == .voiceTranscript ? nil : beginSpawn(for: text)clearSubmissionInputs()promptState.isActive = false+ promptState.isVoiceInputActive = falsepromptState.leadingSignalLevel = .thinkingpromptState.promptText = "Routing task"let sourceTraceID = "pointer-prompt-followup-\(UUID().uuidString)"@@ -386,6 +392,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinknotchCommandInputTextHeight = PointerPromptLayout.composerInputTextMinimumHeightisNotchCommandInputExpanded = truepromptState.isActive = false+ promptState.isVoiceInputActive = falsepromptState.leadingSignalLevel = .thinkingpromptState.promptText = task.titlesyncPrimaryTaskPausedFlag()@@ -626,6 +633,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinknotchCommandText = ""notchCommandInputTextHeight = PointerPromptLayout.composerInputTextMinimumHeightisNotchCommandInputExpanded = true+ promptState.isVoiceInputActive = false}private func taskForSubmittedCommand(text: String, matchedTaskID: String?) -> PointerPromptNotchTask {diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swiftindex f977e7c2..40f0dd9e 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift@@ -50,6 +50,7 @@ public struct PointerPromptState: Equatable, Sendable {public var isActive: Boolpublic var theme: PointerPromptThemepublic var voiceWaveformLevels: [Double]+ public var isVoiceInputActive: Boolpublic init(promptText: String,@@ -57,7 +58,8 @@ public struct PointerPromptState: Equatable, Sendable {leadingSignalLevel: SignalLevel = .idle,isActive: Bool = false,theme: PointerPromptTheme = .defaultBlue,- voiceWaveformLevels: [Double] = PointerPromptState.defaultVoiceWaveformLevels+ voiceWaveformLevels: [Double] = PointerPromptState.defaultVoiceWaveformLevels,+ isVoiceInputActive: Bool = false) {self.promptText = promptTextself.isPrimaryActionEnabled = isPrimaryActionEnabled@@ -65,6 +67,7 @@ public struct PointerPromptState: Equatable, Sendable {self.isActive = isActiveself.theme = themeself.voiceWaveformLevels = voiceWaveformLevels+ self.isVoiceInputActive = isVoiceInputActive}public static let productionDefault = PointerPromptState(diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swiftindex 36bf78a6..72d5dcbd 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift@@ -28,6 +28,11 @@ public enum PointerPromptLayout {public static let composerInputTextMaximumHeight: CGFloat = 134.4public static let composerInputTextVerticalPadding: CGFloat = 23.4public static let composerInputVoiceButtonSize: CGFloat = 33.6+ public static let composerMicrophoneIconSize: CGFloat = 28+ public static let composerSendButtonSize: CGFloat = 56+ public static let composerTrailingControlsSpacing: CGFloat = 8+ public static let composerTrailingControlsWidth: CGFloat =+ composerMicrophoneIconSize + composerTrailingControlsSpacing + composerSendButtonSizepublic static let composerExpandedTextTopPadding: CGFloat = 18public static let composerExpandedTextHorizontalPadding: CGFloat = 24public static let composerExpandedToolbarHeight: CGFloat = 54@@ -79,7 +84,7 @@ public enum PointerPromptLayout {composerInputLeadingContentPadding -composerInputTrailingContentPadding -composerTextWaveformSpacing -- composerWaveformSize.width+ composerTrailingControlsWidth}public static var composerExpandedTextWidth: CGFloat {diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swiftindex 95d01504..69df86b8 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift@@ -555,7 +555,8 @@ public struct PointerPromptNotchStatusView: View {leadingSignalLevel: .ready,isActive: isExpanded,theme: state.theme,- voiceWaveformLevels: state.voiceWaveformLevels+ voiceWaveformLevels: state.voiceWaveformLevels,+ isVoiceInputActive: false)}diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swiftindex 0d1a0e5c..76f86434 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift@@ -162,11 +162,7 @@ struct PointerPromptComposer: View {textInput.frame(width: PointerPromptLayout.composerWrappingTextWidth)- VoiceWaveformView(levels: state.voiceWaveformLevels)- .frame(- width: PointerPromptLayout.composerWaveformSize.width,- height: PointerPromptLayout.composerWaveformSize.height- )+ composerTrailingControls}.padding(.leading, PointerPromptLayout.composerInputLeadingContentPadding).padding(.trailing, PointerPromptLayout.composerInputTrailingContentPadding)@@ -240,11 +236,7 @@ struct PointerPromptComposer: View {switch toolbarStyle {case .waveformOnly:- VoiceWaveformView(levels: state.voiceWaveformLevels)- .frame(- width: PointerPromptLayout.composerWaveformSize.width,- height: PointerPromptLayout.composerWaveformSize.height- )+ composerTrailingControlscase .followUp:followUpTrailingControls}@@ -257,17 +249,76 @@ struct PointerPromptComposer: View {)}+ private var composerTrailingControls: some View {+ HStack(spacing: PointerPromptLayout.composerTrailingControlsSpacing) {+ microphoneIcon++ if hasMessageText {+ sendButton(size: PointerPromptLayout.composerSendButtonSize)+ } else if state.isVoiceInputActive {+ VoiceWaveformView(levels: state.voiceWaveformLevels)+ .frame(+ width: PointerPromptLayout.composerWaveformSize.width,+ height: PointerPromptLayout.composerWaveformSize.height+ )+ } else {+ Color.clear+ .frame(+ width: PointerPromptLayout.composerSendButtonSize,+ height: PointerPromptLayout.composerSendButtonSize+ )+ .accessibilityHidden(true)+ }+ }+ .frame(+ width: PointerPromptLayout.composerTrailingControlsWidth,+ height: PointerPromptLayout.composerSendButtonSize,+ alignment: .trailing+ )+ }++ private var microphoneIcon: some View {+ Image(systemName: "mic")+ .font(.system(size: 24, weight: .regular))+ .symbolRenderingMode(.monochrome)+ .foregroundStyle(Color.white.opacity(microphoneOpacity))+ .frame(+ width: PointerPromptLayout.composerMicrophoneIconSize,+ height: PointerPromptLayout.composerMicrophoneIconSize+ )+ .background {+ if isMicrophoneEmphasized {+ Circle()+ .fill(Color.white.opacity(0.14))+ }+ }+ .overlay {+ if isMicrophoneEmphasized {+ Circle()+ .stroke(Color.white.opacity(0.42), lineWidth: 1)+ }+ }+ .accessibilityLabel(state.isVoiceInputActive ? "Voice input active" : "Voice input")+ .help(state.isVoiceInputActive ? "Voice input active" : "Voice input")+ }+private var followUpTrailingControls: some View {+ sendButton(size: 32)+ }++ private func sendButton(size: CGFloat) -> 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))+ .font(.system(size: sendIconSize(for: size), weight: .semibold))+ .foregroundStyle(Color.black.opacity(hasMessageText ? 0.78 : 0.32))+ .frame(width: size, height: size)+ .background(Color.white.opacity(hasMessageText ? 0.94 : 0.34)).clipShape(Circle())}.buttonStyle(.plain)- .disabled(messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)+ .disabled(!hasMessageText)+ .accessibilityLabel("Send")+ .help("Send")}private var textInput: some View {@@ -316,6 +367,30 @@ struct PointerPromptComposer: View {isInputExpanded || messageText.contains("\n")}+ private var hasMessageText: Bool {+ !messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty+ }++ private var microphoneOpacity: Double {+ if hasMessageText {+ return 0.34+ }++ if state.isVoiceInputActive {+ return 0.92+ }++ return 0.52+ }++ private var isMicrophoneEmphasized: Bool {+ state.isVoiceInputActive && !hasMessageText+ }++ private func sendIconSize(for buttonSize: CGFloat) -> CGFloat {+ buttonSize >= 44 ? 26 : 13+ }+private var usesExpandedSurface: Bool {forceExpandedSurface || isExpanded}diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.mdindex e872300c..794bdc17 100644--- a/docs/guides/pointer-prompt-overlay.md+++ b/docs/guides/pointer-prompt-overlay.md@@ -30,6 +30,7 @@ quick local-app actions:- Notch geometry comes from the active `NSScreen`, preferring safe-area and auxiliary-top metrics over hardcoded notch sizes. Content must stay out of the physical notch void; displays without a physical notch should use the same top-center composition without reserving unavailable space.- `PointerPromptNotchLayout` is the shared source for notch surface frames, content frames, corner radii, and notch-safe offsets. `canRenderTextInTopRow` describes whether text can draw in the top row, not whether that row exists.- The prompt is a compact black composer: single-line text is pill-shaped, multiline text becomes a bounded rounded rectangle, Return submits, Shift-Return inserts a newline, Escape and outside clicks dismiss, and non-input capsule areas can drag the modal.+- The centered composer keeps text and voice modes on the same input surface. Double-Command release opens focused text input, double-Command hold opens the same input with voice active, and typed text promotes the send button while the microphone affordance becomes secondary.- Voice capture and transcription remain separate. The controller records bounded local audio and publishes levels; transcription uses the Parakeet-only adapter before submitting transcript text through the agent-harness turn path.- Local item prewarming must run off the main actor. Agent memory is stored in SQLite under Application Support and uses FTS5 plus deterministic local embeddings for retrieval; JSONL is only an explicit export/debug format. Cached local-item hits must still point to an existing path or bundle before they are used as an execution target. Runtime task definitions are loaded from agent memory; Weather, Music, and Preview definitions are benchmark fixtures unless a generated/user-reviewed definition for them is present in memory.- For scriptable apps, prefer app-native AppleScript task commands before falling back to Accessibility or keyboard input. Bounded screenshots and local UI understanding may supplement observation/verification according to task metadata, but screenshots remain context evidence and do not directly drive input.@@ -42,7 +43,7 @@ quick local-app actions:Manually verify:- The notch renders at the top center, respects physical notch safe areas, expands only from visible notch hover, and accepts expanded controls/clicks.-- Double-Command release opens a centered focused text prompt; double-Command hold opens voice mode; unrelated Command use does not activate the overlay.+- Double-Command release opens a centered focused text prompt; double-Command hold opens the same prompt with voice active; typed text shows a primary send button and a secondary microphone affordance; unrelated Command use does not activate the overlay.- Typed, voice, and follow-up submissions create or update durable task threads, answer non-actionable conversation without showing action failure, show action status in the notch when work runs, and preserve per-task pause/resume behavior.- Typed prompt and notch follow-up submissions show the spawn sequence: notch cue, desktop cursor emergence, direct travel to a known target or fallback holding point, typed progress label, retargeting when the target becomes visible, and fade-out for completed conversational turns.- Stationary spawn labels expand on click/focus, accept compact multiline follow-up text, submit with Return or the send button, insert newlines with Shift-Return, collapse with Escape, and keep the cursor from moving while the draft is active.