Open source CapCut alternative.
TypeScript
Polish spawn label editor interactions
David Le1ffc9232e637
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptSpawnOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptSpawnOverlayController.swiftindex f5eb57f5..4ac40718 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptSpawnOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptSpawnOverlayController.swift@@ -10,6 +10,8 @@ final class PointerPromptSpawnOverlayController {private var surfacesByID: [String: PointerPromptSpawnSurface] = [:]private var viewModelsByID: [String: PointerPromptSpawnOverlayViewModel] = [:]private var windowResolver = MacWindowResolver()+ private var localOutsideClickMonitor: Any?+ private var globalOutsideClickMonitor: Any?var followUpSubmitted: ((String, String, String) -> Void)? {didSet {@@ -57,6 +59,7 @@ final class PointerPromptSpawnOverlayController {}func close() {+ removeOutsideClickMonitoring()for surface in surfacesByID.values {surface.travelWorkItem?.cancel()surface.removalWorkItem?.cancel()@@ -276,6 +279,7 @@ final class PointerPromptSpawnOverlayController {surface.panel.orderFrontRegardless()}self.updateMouseEventPassthrough(for: surface)+ self.updateOutsideClickMonitoring()}surface.viewModel.travelCompleted = { [weak self, weak surface] inguard let self,@@ -456,6 +460,78 @@ final class PointerPromptSpawnOverlayController {DispatchQueue.main.asyncAfter(deadline: .now() + 0.24, execute: workItem)}+ private func updateOutsideClickMonitoring() {+ guard viewModelsByID.values.contains(where: \.isLabelEditing) else {+ removeOutsideClickMonitoring()+ return+ }++ installOutsideClickMonitoringIfNeeded()+ }++ private func installOutsideClickMonitoringIfNeeded() {+ let mask: NSEvent.EventTypeMask = [+ .leftMouseDown,+ .rightMouseDown,+ .otherMouseDown+ ]+ if localOutsideClickMonitor == nil {+ localOutsideClickMonitor = NSEvent.addLocalMonitorForEvents(matching: mask) { [weak self] event in+ let screenPoint = NSEvent.mouseLocation+ Task { @MainActor [weak self] in+ self?.handleOutsideClickCandidate(at: screenPoint)+ }+ return event+ }+ }+ if globalOutsideClickMonitor == nil {+ globalOutsideClickMonitor = NSEvent.addGlobalMonitorForEvents(matching: mask) { [weak self] _ in+ let screenPoint = NSEvent.mouseLocation+ Task { @MainActor [weak self] in+ self?.handleOutsideClickCandidate(at: screenPoint)+ }+ }+ }+ }++ private func removeOutsideClickMonitoring() {+ if let localOutsideClickMonitor {+ NSEvent.removeMonitor(localOutsideClickMonitor)+ self.localOutsideClickMonitor = nil+ }+ if let globalOutsideClickMonitor {+ NSEvent.removeMonitor(globalOutsideClickMonitor)+ self.globalOutsideClickMonitor = nil+ }+ }++ private func handleOutsideClickCandidate(at screenPoint: CGPoint) {+ let activeSurfaces = surfacesByID.values.filter { $0.viewModel.isLabelEditing }+ guard !activeSurfaces.isEmpty else {+ removeOutsideClickMonitoring()+ return+ }++ guard !activeSurfaces.contains(where: { contains(screenPoint, inInteractiveRegionOf: $0) }) else {+ return+ }++ for surface in activeSurfaces {+ surface.viewModel.cancelInlineInput()+ }+ updateOutsideClickMonitoring()+ }++ private func contains(+ _ screenPoint: CGPoint,+ inInteractiveRegionOf surface: PointerPromptSpawnSurface+ ) -> Bool {+ guard surface.panel.frame.contains(screenPoint) else { return false }++ let localPoint = surface.panel.convertPoint(fromScreen: screenPoint)+ return surface.viewModel.localHitTestFrame.contains(localPoint)+ }+private func spawnOrigin(in screen: NSScreen, index: Int) -> CGPoint {let stagger = CGFloat((index % 5) - 2) * 18return CGPoint(x: screen.frame.width / 2 + stagger, y: -24)diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swiftindex 5dfaca22..8c1f734a 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift@@ -387,6 +387,7 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {fileprivate static let inlineEditorHorizontalPadding: CGFloat = 16fileprivate static let inlineEditorVerticalPadding: CGFloat = 14fileprivate static let inlineEditorSpacing: CGFloat = 12+ fileprivate static let labelFontSize: CGFloat = 12public static let inlineEditorMinimumTextHeight: CGFloat = 14public static let inlineEditorMaximumTextHeight: CGFloat = 44fileprivate static let collapsedHaloSize: CGFloat = 40@@ -418,9 +419,10 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)guard !trimmedText.isEmpty else { return 20 }- let font = NSFont.systemFont(ofSize: 13, weight: .bold)+ let font = NSFont.systemFont(ofSize: labelFontSize, weight: .medium)let paragraphStyle = NSMutableParagraphStyle()paragraphStyle.lineBreakMode = .byWordWrapping+ paragraphStyle.alignment = .leftlet attributes: [NSAttributedString.Key: Any] = [.font: font,.paragraphStyle: paragraphStyle@@ -441,10 +443,10 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)guard !trimmedText.isEmpty else { return false }- let font = NSFont.systemFont(ofSize: 10, weight: .medium)+ let font = NSFont.systemFont(ofSize: labelFontSize, weight: .medium)let paragraphStyle = NSMutableParagraphStyle()paragraphStyle.lineBreakMode = .byWordWrapping- paragraphStyle.alignment = .center+ paragraphStyle.alignment = .leftlet attributes: [NSAttributedString.Key: Any] = [.font: font,.paragraphStyle: paragraphStyle@@ -562,7 +564,6 @@ public struct PointerPromptSpawnOverlayView: View {RoundedRectangle(cornerRadius: 8, style: .continuous).fill(accentColor(for: state.accentIndex))}- .shadow(color: Color.black.opacity(0.3), radius: 3, x: 0, y: 1).contentShape(RoundedRectangle(cornerRadius: 8, style: .continuous)).onTapGesture {viewModel.beginInlineInput()@@ -580,14 +581,14 @@ public struct PointerPromptSpawnOverlayView: View {label: state.label))- .font(.system(size: 10, weight: .medium))+ .font(.system(size: PointerPromptSpawnOverlayViewModel.labelFontSize, weight: .medium)).foregroundStyle(.white)- .multilineTextAlignment(.center)+ .multilineTextAlignment(.leading).lineLimit(viewModel.isLabelHovered ? nil : 2).truncationMode(.tail).frame(maxWidth: viewModel.isLabelHovered ? PointerPromptSpawnOverlayViewModel.expandedCollapsedLabelWidth : PointerPromptSpawnOverlayViewModel.collapsedLabelContentWidth,- alignment: .center+ alignment: .leading).padding(.horizontal, PointerPromptSpawnOverlayViewModel.labelHorizontalPadding).padding(.vertical, 3)@@ -596,7 +597,7 @@ public struct PointerPromptSpawnOverlayView: View {private func inlineLabelEditor(state: PointerPromptSpawnState) -> some View {VStack(alignment: .leading, spacing: PointerPromptSpawnOverlayViewModel.inlineEditorSpacing) {Text(state.label)- .font(.system(size: 13, weight: .bold))+ .font(.system(size: PointerPromptSpawnOverlayViewModel.labelFontSize, weight: .medium)).foregroundStyle(.white).multilineTextAlignment(.leading).lineLimit(3)@@ -931,7 +932,7 @@ private final class SpawnLabelInlineTextView: NSTextView {@MainActorprivate enum SpawnLabelInlineTextStyle {static var font: NSFont {- NSFont.systemFont(ofSize: 13, weight: .medium)+ NSFont.systemFont(ofSize: PointerPromptSpawnOverlayViewModel.labelFontSize, weight: .medium)}static func apply(to textView: NSTextView) {diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.mdindex 98daff5f..56129a74 100644--- a/docs/guides/pointer-prompt-overlay.md+++ b/docs/guides/pointer-prompt-overlay.md@@ -11,7 +11,7 @@ quick local-app actions:- When a typed prompt or notch follow-up is submitted, show a task spawn cue: the notch arrow rotates toward the exit direction, moves out of the notch, and a Donkey cursor overlay travels onto the desktop.- Spawned cursors travel to a known safe visible target window when one is available. Otherwise they hold about 250 px below the notch near screen center as a loading/thinking state, then retarget if the destination becomes visible.- Multiple spawned cursors can be present at the same time. The newest spawned cursor is selected by default, and clicking a cursor or its label selects it as the current agent.-- A stationary spawned cursor types the submitted turn first, then compact progress or response text in its label. Conversational responses, clarifications, review waits, failures, and other attention states stay visible so the user can read them and follow up; completed action-only cursors may fade out. Spawn labels clamp to two lines by default, reveal the full label on hover only when the collapsed label would truncate, and select the cursor on click. Clicking a tasked label turns the same agent-colored surface into an inline editor with the agent message above and a lighter color-matched user input area below; Return submits the typed follow-up to that spawn's task, Shift-Return inserts a newline, Escape returns to the label, and an idle editor closes when focus moves elsewhere.+- A stationary spawned cursor types the submitted turn first, then compact progress or response text in its label. Conversational responses, clarifications, review waits, failures, and other attention states stay visible so the user can read them and follow up; completed action-only cursors may fade out. Spawn labels clamp to two lines by default, reveal the full label on hover only when the collapsed label would truncate, and select the cursor on click. Clicking a tasked label turns the same agent-colored surface into an inline editor with the agent message above and a lighter color-matched user input area below; Return submits the typed follow-up to that spawn's task, Shift-Return inserts a newline, Escape returns to the label, and clicking outside the editor closes it.- Double-Command always opens the centered prompt, even when spawned cursors are visible. If a spawned cursor is selected, centered typed or voice input attaches to that task behind the scenes; otherwise Donkey uses the latest interactable spawned cursor before falling back to follow-up resolution.- Keep prompt submissions, voice transcripts, and follow-ups on the same agent-harness path: task-thread routing, context assembly, conversational response, clarification, review, catalog-backed action parsing, task validation, and guarded local-app execution when a turn is actionable.- Resolve model-classified local-item requests against local apps, files, and folders by querying the current Mac with the SQLite-backed agent memory store, Spotlight/`mdfind`, and bounded filesystem fallback. If the requested local item cannot be found, keep the task safe and report that it was not found instead of falling back to a vague clarification.