Skip to content

Open source CapCut alternative.

TypeScript

Update guidelines

David Le777d0c6adcb7
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
index befa5754..ad030c4a 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
@@ -7,20 +7,12 @@ final class PointerPromptOverlayController {
static let contentSize = PointerPromptLayout.contentSize
private let model: PointerPromptOverlayModel
- private let screenPadding: CGFloat = 8
- private let routeStepInterval: TimeInterval = 0.15
- private let followSmoothing: CGFloat = 0.34
- private let flipSmoothing: CGFloat = 0.22
+ private let fixedPlacement: PointerPromptPlacement = .bottomRight
private var panel: NSPanel?
private var timer: Timer?
private var globalCommandClickMonitor: Any?
private var localCommandClickMonitor: Any?
- private var currentFrame: CGRect?
- private var displayPlacement: PointerPromptPlacement = .bottomRight
- private var finalPlacement: PointerPromptPlacement = .bottomRight
- private var pendingPlacements: [PointerPromptPlacement] = []
- private var lastRouteStepAt = Date.distantPast
init(model: PointerPromptOverlayModel) {
self.model = model
@@ -112,10 +104,6 @@ final class PointerPromptOverlayController {
}
private func positionAtCurrentMouseLocation() {
- currentFrame = nil
- displayPlacement = .bottomRight
- finalPlacement = .bottomRight
- pendingPlacements = []
tick(mouseLocation: NSEvent.mouseLocation)
}
@@ -123,10 +111,6 @@ final class PointerPromptOverlayController {
guard let panel else { return }
model.activate()
- currentFrame = nil
- displayPlacement = .bottomRight
- finalPlacement = .bottomRight
- pendingPlacements = []
tick(mouseLocation: mouseLocation)
NSApp.activate(ignoringOtherApps: true)
@@ -149,122 +133,16 @@ final class PointerPromptOverlayController {
updateMouseEventPassthrough(for: panel)
if model.promptState.isActive, explicitMouseLocation == nil {
- currentFrame = panel.frame
return
}
let mouseLocation = explicitMouseLocation ?? NSEvent.mouseLocation
- guard let screen = screen(containing: mouseLocation) else { return }
-
- let now = Date()
- let targetPlacement = preferredPlacement(
- for: mouseLocation,
- visibleFrame: screen.visibleFrame
- )
- if explicitMouseLocation == nil {
- updateRoute(to: targetPlacement, now: now)
- advanceRoute(now: now)
- } else {
- displayPlacement = targetPlacement
- finalPlacement = targetPlacement
- pendingPlacements = []
- }
-
- let targetFrame = clampedFrame(
- frame(for: displayPlacement, mouseLocation: mouseLocation),
- placement: displayPlacement,
- in: screen.visibleFrame
- )
- let nextFrame = smoothedFrame(
- toward: targetFrame,
- placement: displayPlacement,
- in: screen.visibleFrame
- )
- currentFrame = nextFrame
- panel.setFrame(nextFrame, display: true)
+ let targetFrame = frame(for: fixedPlacement, mouseLocation: mouseLocation)
+ panel.setFrame(targetFrame, display: true)
updateMouseEventPassthrough(for: panel)
- if model.placement != displayPlacement {
- model.placement = displayPlacement
- }
- }
-
- private func updateRoute(to targetPlacement: PointerPromptPlacement, now: Date) {
- guard targetPlacement != finalPlacement else { return }
-
- finalPlacement = targetPlacement
- pendingPlacements = route(from: displayPlacement, to: targetPlacement)
- lastRouteStepAt = now.addingTimeInterval(-routeStepInterval)
- }
-
- private func advanceRoute(now: Date) {
- guard !pendingPlacements.isEmpty else { return }
- guard now.timeIntervalSince(lastRouteStepAt) >= routeStepInterval else { return }
-
- displayPlacement = pendingPlacements.removeFirst()
- lastRouteStepAt = now
- }
-
- private func route(
- from currentPlacement: PointerPromptPlacement,
- to targetPlacement: PointerPromptPlacement
- ) -> [PointerPromptPlacement] {
- guard currentPlacement != targetPlacement else { return [] }
-
- if currentPlacement.placesContentOnLeft != targetPlacement.placesContentOnLeft,
- currentPlacement.placesContentAbovePointer != targetPlacement.placesContentAbovePointer {
- let horizontalFirst = placement(
- left: targetPlacement.placesContentOnLeft,
- above: currentPlacement.placesContentAbovePointer
- )
- return [horizontalFirst, targetPlacement]
- }
-
- return [targetPlacement]
- }
-
- private func preferredPlacement(
- for mouseLocation: CGPoint,
- visibleFrame: CGRect
- ) -> PointerPromptPlacement {
- let preferredFrame = frame(for: .bottomRight, mouseLocation: mouseLocation)
- let preferredContentFrame = screenContentFrame(
- for: preferredFrame,
- placement: .bottomRight
- )
- let overflowsRight = preferredContentFrame.maxX > visibleFrame.maxX - screenPadding
- let overflowsBottom = preferredContentFrame.minY < visibleFrame.minY + screenPadding
-
- let preferredPlacement = placement(left: overflowsRight, above: overflowsBottom)
- let candidates = [
- preferredPlacement,
- PointerPromptPlacement.bottomRight,
- .bottomLeft,
- .topRight,
- .topLeft
- ]
-
- for candidate in candidates where fits(
- frame(for: candidate, mouseLocation: mouseLocation),
- placement: candidate,
- in: visibleFrame
- ) {
- return candidate
- }
-
- return preferredPlacement
- }
-
- private func placement(left: Bool, above: Bool) -> PointerPromptPlacement {
- switch (left, above) {
- case (false, false):
- .bottomRight
- case (true, false):
- .bottomLeft
- case (true, true):
- .topLeft
- case (false, true):
- .topRight
+ if model.placement != fixedPlacement {
+ model.placement = fixedPlacement
}
}
@@ -326,28 +204,6 @@ final class PointerPromptOverlayController {
PointerPromptLayout.pointerSlotSize.width - PointerPromptLayout.pointerVisualSize.width
}
- private func pointerVisualFrame(for placement: PointerPromptPlacement) -> CGRect {
- let pointerSlotX: CGFloat
- if placement.placesContentOnLeft {
- pointerSlotX = stageHorizontalInset +
- PointerPromptLayout.stageHorizontalPadding +
- PointerPromptLayout.composerSize.width +
- PointerPromptLayout.pointerComposerSpacing
- } else {
- pointerSlotX = stageHorizontalInset + PointerPromptLayout.stageHorizontalPadding
- }
-
- return CGRect(
- x: pointerSlotX + pointerVisualInsetX(for: placement),
- y: Self.contentSize.height - pointerVisualTopFromPanelTop - PointerPromptLayout.pointerVisualSize.height,
- width: PointerPromptLayout.pointerVisualSize.width,
- height: PointerPromptLayout.pointerVisualSize.height
- ).insetBy(
- dx: -PointerPromptLayout.pointerStrokeWidth,
- dy: -PointerPromptLayout.pointerStrokeWidth
- )
- }
-
private var stageHorizontalInset: CGFloat {
(Self.contentSize.width - stageContentWidth) / 2
}
@@ -368,27 +224,20 @@ final class PointerPromptOverlayController {
PointerPromptLayout.composerSize.height
}
- private var pointerCenterYFromTop: CGFloat {
- stageVerticalInset +
- PointerPromptLayout.stageVerticalPadding +
- PointerPromptLayout.composerSize.height / 2
- }
-
private var pointerTipYFromTop: CGFloat {
- pointerCenterYFromTop -
- PointerPromptLayout.pointerVisualSize.height / 2 +
+ pointerVisualTopFromPanelTop +
PointerPromptLayout.pointerVisualSize.height *
PointerPromptLayout.pointerTipUnitPoint.y
}
private var pointerVisualTopFromPanelTop: CGFloat {
- pointerCenterYFromTop - PointerPromptLayout.pointerVisualSize.height / 2
+ composerTopFromPanelTop
}
private func composerDragRegions() -> [CGRect] {
guard model.promptState.isActive else { return [] }
- let composerFrame = composerFrame(for: displayPlacement)
+ let composerFrame = composerFrame(for: fixedPlacement)
let dragThickness = PointerPromptLayout.composerDragBorderThickness
let closeButtonClearance = PointerPromptLayout.closeButtonInset * 2 +
PointerPromptLayout.closeButtonSize
@@ -444,25 +293,6 @@ final class PointerPromptOverlayController {
stageVerticalInset + PointerPromptLayout.stageVerticalPadding
}
- private func visibleContentBounds(for placement: PointerPromptPlacement) -> CGRect {
- let pointerFrame = pointerVisualFrame(for: placement)
- guard model.promptState.isActive else {
- return pointerFrame
- }
-
- return pointerFrame.union(composerFrame(for: placement))
- }
-
- private func screenContentFrame(
- for panelFrame: CGRect,
- placement: PointerPromptPlacement
- ) -> CGRect {
- visibleContentBounds(for: placement).offsetBy(
- dx: panelFrame.minX,
- dy: panelFrame.minY
- )
- }
-
private func updateMouseEventPassthrough(for panel: NSPanel) {
guard model.promptState.isActive else {
panel.ignoresMouseEvents = true
@@ -470,73 +300,7 @@ final class PointerPromptOverlayController {
}
let mouseLocationInPanel = panel.convertPoint(fromScreen: NSEvent.mouseLocation)
- panel.ignoresMouseEvents = !composerFrame(for: displayPlacement).contains(mouseLocationInPanel)
- }
-
- private func fits(
- _ frame: CGRect,
- placement: PointerPromptPlacement,
- in visibleFrame: CGRect
- ) -> Bool {
- let contentFrame = screenContentFrame(for: frame, placement: placement)
- return contentFrame.minX >= visibleFrame.minX + screenPadding &&
- contentFrame.maxX <= visibleFrame.maxX - screenPadding &&
- contentFrame.minY >= visibleFrame.minY + screenPadding &&
- contentFrame.maxY <= visibleFrame.maxY - screenPadding
- }
-
- private func clampedFrame(
- _ frame: CGRect,
- placement: PointerPromptPlacement,
- in visibleFrame: CGRect
- ) -> CGRect {
- var origin = frame.origin
- let size = frame.size
- let contentBounds = visibleContentBounds(for: placement)
-
- let minX = visibleFrame.minX + screenPadding - contentBounds.minX
- let maxX = visibleFrame.maxX - screenPadding - contentBounds.maxX
- let minY = visibleFrame.minY + screenPadding - contentBounds.minY
- let maxY = visibleFrame.maxY - screenPadding - contentBounds.maxY
-
- if minX <= maxX {
- origin.x = min(max(origin.x, minX), maxX)
- } else {
- origin.x = visibleFrame.midX - contentBounds.midX
- }
-
- if minY <= maxY {
- origin.y = min(max(origin.y, minY), maxY)
- } else {
- origin.y = visibleFrame.midY - contentBounds.midY
- }
-
- return CGRect(origin: origin, size: size)
- }
-
- private func smoothedFrame(
- toward targetFrame: CGRect,
- placement: PointerPromptPlacement,
- in visibleFrame: CGRect
- ) -> CGRect {
- guard let currentFrame else { return targetFrame }
-
- let smoothing = pendingPlacements.isEmpty ? followSmoothing : flipSmoothing
- let origin = CGPoint(
- x: currentFrame.origin.x + (targetFrame.origin.x - currentFrame.origin.x) * smoothing,
- y: currentFrame.origin.y + (targetFrame.origin.y - currentFrame.origin.y) * smoothing
- )
- return clampedFrame(
- CGRect(origin: origin, size: targetFrame.size),
- placement: placement,
- in: visibleFrame
- )
- }
-
- private func screen(containing point: CGPoint) -> NSScreen? {
- NSScreen.screens.first { screen in
- screen.frame.contains(point)
- } ?? NSScreen.main ?? NSScreen.screens.first
+ panel.ignoresMouseEvents = !composerFrame(for: fixedPlacement).contains(mouseLocationInPanel)
}
}
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
index 27f234ea..c532ec73 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
@@ -30,12 +30,12 @@ public struct PointerPromptStageView: View {
@ViewBuilder
private var promptContent: some View {
if placement.placesContentOnLeft {
- HStack(alignment: .center, spacing: PointerPromptLayout.pointerComposerSpacing) {
+ HStack(alignment: .top, spacing: PointerPromptLayout.pointerComposerSpacing) {
activeComposer
pointer
}
} else {
- HStack(alignment: .center, spacing: PointerPromptLayout.pointerComposerSpacing) {
+ HStack(alignment: .top, spacing: PointerPromptLayout.pointerComposerSpacing) {
pointer
activeComposer
}
@@ -180,23 +180,16 @@ private struct ComposerCloseButton: View {
var body: some View {
Button(action: action) {
- Image(systemName: "xmark")
- .font(.system(size: 9, weight: .bold))
- .foregroundStyle(Color.white)
+ Image(systemName: "xmark.circle.fill")
+ .font(.system(size: PointerPromptLayout.closeButtonSize, weight: .regular))
+ .symbolRenderingMode(.palette)
+ .foregroundStyle(Color.white, Color.red)
.frame(
width: PointerPromptLayout.closeButtonSize,
height: PointerPromptLayout.closeButtonSize
)
- .background {
- Circle()
- .fill(Color.red)
- }
- .overlay {
- Circle()
- .stroke(Color.black.opacity(0.16), lineWidth: 0.5)
- }
}
- .buttonStyle(.plain)
+ .buttonStyle(.borderless)
.accessibilityLabel("Close prompt")
}
}
@@ -224,7 +217,7 @@ private struct ComposerIconButton: View {
.stroke(borderColor, lineWidth: isProminent ? 0 : 1.4)
}
}
- .buttonStyle(.plain)
+ .buttonStyle(.borderless)
.disabled(isDisabled)
.opacity(isDisabled ? 0.38 : 1)
.accessibilityLabel(label)
@@ -267,7 +260,7 @@ private struct ComposerSignalButton: View {
.stroke(Color(promptColor: theme.accent).opacity(0.28), lineWidth: 1.4)
}
}
- .buttonStyle(.plain)
+ .buttonStyle(.borderless)
.accessibilityLabel("Voice input")
}
@@ -327,7 +320,10 @@ private struct AgentPointerView: View {
}
private var shapeAlignment: Alignment {
- placement.placesContentOnLeft ? .leading : .trailing
+ Alignment(
+ horizontal: placement.placesContentOnLeft ? .leading : .trailing,
+ vertical: .top
+ )
}
}
diff --git a/docs/README.md b/docs/README.md
index b6c78f9a..167ddd40 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -6,7 +6,7 @@ Plans describe what we might build. Guides describe what Donkey currently suppor
## Product Guides
-- [Pointer Prompt Overlay](guides/pointer-prompt-overlay.md): command-click agent pointer and ChatGPT-style `Make this so` composer that follows the mouse and stays on screen.
+- [Pointer Prompt Overlay](guides/pointer-prompt-overlay.md): command-click agent pointer and ChatGPT-style `Make this so` composer that follows the mouse at a fixed offset.
## Engineering Guides
diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.md
index dfc689ec..bc4dff92 100644
--- a/docs/guides/pointer-prompt-overlay.md
+++ b/docs/guides/pointer-prompt-overlay.md
@@ -12,10 +12,8 @@ Donkey supports a floating macOS pointer prompt overlay:
- closes the active composer with a top-left close button and returns to the inactive following pointer
- supports dragging the active composer by its border areas
- lets normal clicks pass through the inactive pointer-only overlay and transparent active overlay space
-- follows the user mouse at a 45-degree bottom-right diagonal by default
-- stays fully inside the current screen visible frame
-- flips to the left, top, or top-left side when the default position would leave the screen
-- animates side changes along an invisible box around the user pointer
+- follows the user mouse at a fixed 45-degree bottom-right diagonal
+- keeps that fixed offset at screen edges instead of flipping or clamping to the visible screen bounds
- renders a shadow underneath the agent pointer when active
- supports user-accessible theme customization through `apps/Donkey/Sources/Donkey/Resources/theme.json`
- keeps runtime and AI harness behavior behind explicit integration boundaries
@@ -31,10 +29,10 @@ This is a visual UI capability. It does not capture the screen, send input, call
- Composer controls should emit typed `PointerPromptIntent` values instead of reaching into runtime, AI, or controller code.
- Pointer colors load from JSON into `PointerPromptTheme`; views must not hard-code product colors.
- The active composer should use a normal system-window corner radius, expose a top-left close control, and keep controls/content areas interactive while only border regions drag the window. Transparent active overlay space must pass clicks through to windows underneath.
+- The active composer top edge should align with the highest visible point of the agent pointer.
- The agent pointer should remain close to native cursor size, use the mirrored SVG cursor silhouette from the Noun Project pointer asset, point in the same up-left direction as the native macOS cursor, and keep its tip 48px from the real pointer on an equal x/y diagonal.
-- Placement is one of `bottomRight`, `bottomLeft`, `topLeft`, or `topRight`.
-- The controller must clamp visible pointer/composer bounds to `NSScreen.visibleFrame` before applying the panel frame, because inactive mode uses a larger transparent panel than its visible pointer.
-- Diagonal placement changes should route through a side placement first, so bottom-right overflow can animate to left and then top-left.
+- Runtime placement is fixed to `bottomRight`; alternate `PointerPromptPlacement` values are only rendering variants.
+- The controller must not clamp visible pointer/composer bounds to `NSScreen.visibleFrame`; cursor positioning is a direct fixed-offset calculation.
- Launch positioning and command-click focus handling belong in `PointerPromptOverlayController`, not the SwiftUI view.
- Keep the overlay non-invasive: no capture loop, input execution, Accessibility prompt, or LLM call in this feature.
@@ -47,7 +45,7 @@ swift build
swift run Donkey
```
-Launch Donkey and confirm only the small agent pointer appears and follows the main pointer. Command-click anywhere to show the composer with keyboard focus, then move the mouse and confirm the active pointer and composer stay pinned. Click through transparent overlay space into another desktop window, drag the composer from border areas, close it with the top-left close button, and confirm the inactive pointer resumes following the main pointer. Type a message, confirm the send control enables, and activate near the bottom-right screen edge to confirm the prompt chooses a non-clipping placement.
+Launch Donkey and confirm only the small agent pointer appears and follows the main pointer at a fixed bottom-right diagonal offset. Command-click anywhere to show the composer with keyboard focus, then move the mouse and confirm the active pointer and composer stay pinned. Click through transparent overlay space into another desktop window, drag the composer from border areas, close it with the top-left close button, and confirm the inactive pointer resumes following the main pointer. Type a message, confirm the send control enables, and activate near the bottom-right screen edge to confirm the prompt keeps the same fixed offset instead of flipping or clamping.
To verify color customization, edit `apps/Donkey/Sources/Donkey/Resources/theme.json`, rebuild, and run Donkey.