Skip to content

Open source CapCut alternative.

TypeScript

Finalize local runtime onboarding plan

David Le24786784a6d6
diff --git a/apps/Donkey/Package.resolved b/apps/Donkey/Package.resolved
new file mode 100644
index 00000000..a8818c73
--- /dev/null
+++ b/apps/Donkey/Package.resolved
@@ -0,0 +1,15 @@
+{
+ "originHash" : "2aa2e05fa9a24bf3e206f1d4e34be7bdd685b7a408f4625d51c0a47ff5c526db",
+ "pins" : [
+ {
+ "identity" : "sparkle",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/sparkle-project/Sparkle",
+ "state" : {
+ "revision" : "6276ba2b404829d139c45ff98427cf90e2efc59b",
+ "version" : "2.9.2"
+ }
+ }
+ ],
+ "version" : 3
+}
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swift
index 102853dc..99e15f04 100644
--- a/apps/Donkey/Package.swift
+++ b/apps/Donkey/Package.swift
@@ -17,6 +17,9 @@ let package = Package(
targets: ["DonkeyContracts"]
)
],
+ dependencies: [
+ .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.9.0")
+ ],
targets: [
.target(
name: "DonkeyContracts"
@@ -42,7 +45,8 @@ let package = Package(
"DonkeyAI",
"DonkeyContracts",
"DonkeyRuntime",
- "DonkeyUI"
+ "DonkeyUI",
+ .product(name: "Sparkle", package: "Sparkle")
],
resources: [
.copy("Resources/theme.json")
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
index 52988f08..594e768c 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift
@@ -1,24 +1,34 @@
import AppKit
+import Carbon.HIToolbox
import DonkeyContracts
+import DonkeyUI
import SwiftUI
@MainActor
final class PointerPromptOverlayController {
+ private static let commandKHotKeySignature: OSType = 0x444B4559
+ private static let commandKHotKeyID: UInt32 = 1
+
private let model: PointerPromptOverlayModel
private let fixedPlacement: PointerPromptPlacement = .bottomRight
private let activationShortcut: PointerPromptActivationShortcut
private let microphoneWaveformMeter = MicrophoneWaveformMeter()
- private var panel: NSPanel?
+ private var statusPanel: NSPanel?
+ private var statusHostingView: NSHostingView<PointerPromptNotchStatusView>?
+ private var inputPanel: NSPanel?
private var timer: Timer?
private var globalActivationMonitor: Any?
private var localActivationMonitor: Any?
+ private var commandKHotKeyRef: EventHotKeyRef?
+ private var commandKEventHandlerRef: EventHandlerRef?
private var activationTapStartedAt: Date?
private var activationTapIsClean = false
private var completedActivationTapCount = 0
private var lastActivationTapCompletedAt: Date?
private var activationHoldStartedAt: Date?
private var isVoiceInputActive = false
+ private var isStatusExpanded = false
init(
model: PointerPromptOverlayModel,
@@ -32,18 +42,23 @@ final class PointerPromptOverlayController {
}
func show() {
- let initialContentSize = currentContentSize
- let hostingView = makeHostingView(size: initialContentSize)
- let panel = makePanel(size: initialContentSize, hostingView: hostingView)
+ let initialInputSize = currentContentSize
+ let inputHostingView = makeInputHostingView(size: initialInputSize)
+ let inputPanel = makeInputPanel(size: initialInputSize, hostingView: inputHostingView)
+ let statusPanel = makeStatusPanel()
- self.panel = panel
+ self.inputPanel = inputPanel
+ self.statusPanel = statusPanel
startActivationMonitoring()
- positionAtCurrentMouseLocation()
- panel.orderFrontRegardless()
+ startCommandKHotKeyMonitoring()
+ positionStatusPanel()
+ centerInputPanel()
+ inputPanel.orderOut(nil)
+ statusPanel.orderFrontRegardless()
startTimer()
}
- private func makeHostingView(size: CGSize) -> NSHostingView<PointerPromptOverlayRootView> {
+ private func makeInputHostingView(size: CGSize) -> NSHostingView<PointerPromptOverlayRootView> {
let hostingView = NSHostingView(rootView: PointerPromptOverlayRootView(model: model))
hostingView.frame = CGRect(origin: .zero, size: size)
hostingView.autoresizingMask = [.width, .height]
@@ -53,7 +68,7 @@ final class PointerPromptOverlayController {
return hostingView
}
- private func makePanel(
+ private func makeInputPanel(
size: CGSize,
hostingView: NSHostingView<PointerPromptOverlayRootView>
) -> PointerPromptPanel {
@@ -72,11 +87,47 @@ final class PointerPromptOverlayController {
panel.hidesOnDeactivate = false
panel.isReleasedWhenClosed = false
panel.becomesKeyOnlyIfNeeded = false
- panel.ignoresMouseEvents = true
+ panel.ignoresMouseEvents = false
panel.dragRegionProvider = { [weak self] in
self?.composerDragRegions() ?? []
}
- panel.level = .floating
+ panel.level = .statusBar
+ panel.collectionBehavior = [
+ .canJoinAllSpaces,
+ .fullScreenAuxiliary,
+ .ignoresCycle,
+ .stationary
+ ]
+
+ return panel
+ }
+
+ private func makeStatusPanel() -> NSPanel {
+ let metrics = notchMetrics()
+ let hostingView = NSHostingView(rootView: notchStatusView(metrics: metrics))
+ hostingView.frame = CGRect(origin: .zero, size: metrics.surfaceSize)
+ hostingView.autoresizingMask = [.width, .height]
+ hostingView.wantsLayer = true
+ hostingView.layer?.backgroundColor = NSColor.clear.cgColor
+ statusHostingView = hostingView
+
+ let panel = NSPanel(
+ contentRect: CGRect(origin: .zero, size: metrics.surfaceSize),
+ styleMask: [.borderless],
+ backing: .buffered,
+ defer: false
+ )
+
+ panel.title = "Donkey Status"
+ panel.contentView = hostingView
+ panel.backgroundColor = .clear
+ panel.isOpaque = false
+ panel.hasShadow = false
+ panel.hidesOnDeactivate = false
+ panel.isReleasedWhenClosed = false
+ panel.becomesKeyOnlyIfNeeded = true
+ panel.ignoresMouseEvents = true
+ panel.level = .statusBar
panel.collectionBehavior = [
.canJoinAllSpaces,
.fullScreenAuxiliary,
@@ -91,9 +142,13 @@ final class PointerPromptOverlayController {
timer?.invalidate()
timer = nil
stopActivationMonitoring()
+ stopCommandKHotKeyMonitoring()
microphoneWaveformMeter.stop()
- panel?.close()
- panel = nil
+ inputPanel?.close()
+ inputPanel = nil
+ statusPanel?.close()
+ statusPanel = nil
+ statusHostingView = nil
}
private func startActivationMonitoring() {
@@ -107,18 +162,14 @@ final class PointerPromptOverlayController {
.otherMouseDown
]
globalActivationMonitor = NSEvent.addGlobalMonitorForEvents(matching: activationEventMask) { [weak self] event in
- let eventType = event.type
- let modifierFlags = event.modifierFlags
Task { @MainActor in
- self?.handleActivationEvent(type: eventType, modifierFlags: modifierFlags)
+ self?.handleActivationEvent(event)
}
}
localActivationMonitor = NSEvent.addLocalMonitorForEvents(matching: activationEventMask) { [weak self] event in
- let eventType = event.type
- let modifierFlags = event.modifierFlags
Task { @MainActor in
- self?.handleActivationEvent(type: eventType, modifierFlags: modifierFlags)
+ self?.handleActivationEvent(event)
}
return event
}
@@ -136,15 +187,94 @@ final class PointerPromptOverlayController {
}
}
- private func handleActivationEvent(
- type: NSEvent.EventType,
- modifierFlags: NSEvent.ModifierFlags
- ) {
- switch type {
+ private func startCommandKHotKeyMonitoring() {
+ stopCommandKHotKeyMonitoring()
+
+ var eventType = EventTypeSpec(
+ eventClass: OSType(kEventClassKeyboard),
+ eventKind: UInt32(kEventHotKeyPressed)
+ )
+ let userData = UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
+ InstallEventHandler(
+ GetApplicationEventTarget(),
+ { _, event, userData in
+ guard let event,
+ let userData else {
+ return noErr
+ }
+
+ var hotKeyID = EventHotKeyID()
+ let status = GetEventParameter(
+ event,
+ EventParamName(kEventParamDirectObject),
+ EventParamType(typeEventHotKeyID),
+ nil,
+ MemoryLayout<EventHotKeyID>.size,
+ nil,
+ &hotKeyID
+ )
+ guard status == noErr,
+ hotKeyID.signature == PointerPromptOverlayController.commandKHotKeySignature,
+ hotKeyID.id == PointerPromptOverlayController.commandKHotKeyID else {
+ return noErr
+ }
+
+ let controller = Unmanaged<PointerPromptOverlayController>
+ .fromOpaque(userData)
+ .takeUnretainedValue()
+ Task { @MainActor in
+ controller.handleCommandKHotKey()
+ }
+ return noErr
+ },
+ 1,
+ &eventType,
+ userData,
+ &commandKEventHandlerRef
+ )
+
+ let hotKeyID = EventHotKeyID(
+ signature: Self.commandKHotKeySignature,
+ id: Self.commandKHotKeyID
+ )
+ RegisterEventHotKey(
+ UInt32(kVK_ANSI_K),
+ UInt32(cmdKey),
+ hotKeyID,
+ GetApplicationEventTarget(),
+ 0,
+ &commandKHotKeyRef
+ )
+ }
+
+ private func stopCommandKHotKeyMonitoring() {
+ if let commandKHotKeyRef {
+ UnregisterEventHotKey(commandKHotKeyRef)
+ self.commandKHotKeyRef = nil
+ }
+
+ if let commandKEventHandlerRef {
+ RemoveEventHandler(commandKEventHandlerRef)
+ self.commandKEventHandlerRef = nil
+ }
+ }
+
+ private func handleCommandKHotKey() {
+ resetActivationTapSequence()
+ activateInputAtScreenCenter()
+ }
+
+ private func handleActivationEvent(_ event: NSEvent) {
+ switch event.type {
case .flagsChanged:
- handleModifierFlagsChanged(modifierFlags)
+ handleModifierFlagsChanged(event.modifierFlags)
case .keyDown, .leftMouseDown, .rightMouseDown, .otherMouseDown:
- if type != .keyDown, dismissActivePromptIfClickIsOutside() {
+ if event.type == .keyDown, activateFromCommandKIfNeeded(event) {
+ resetActivationTapSequence()
+ return
+ }
+
+ if event.type != .keyDown, dismissActivePromptIfClickIsOutside() {
resetActivationTapSequence()
return
}
@@ -155,6 +285,19 @@ final class PointerPromptOverlayController {
}
}
+ private func activateFromCommandKIfNeeded(_ event: NSEvent) -> Bool {
+ let flags = event.modifierFlags
+ .intersection(.deviceIndependentFlagsMask)
+ .subtracting(.capsLock)
+ guard flags == .command,
+ event.charactersIgnoringModifiers?.lowercased() == "k" else {
+ return false
+ }
+
+ activateInputAtScreenCenter()
+ return true
+ }
+
private func handleModifierFlagsChanged(_ modifierFlags: NSEvent.ModifierFlags) {
let flags = modifierFlags
.intersection(.deviceIndependentFlagsMask)
@@ -230,7 +373,7 @@ final class PointerPromptOverlayController {
}
resetActivationTapSequence()
- activateAtCurrentMouseLocation()
+ activateInputAtScreenCenter()
}
private func resetActivationTapSequence() {
@@ -261,24 +404,25 @@ final class PointerPromptOverlayController {
}
resetActivationTapSequence()
- activateVoiceInputAtCurrentMouseLocation()
+ activateVoiceInputAtScreenCenter()
}
- private func activateAtCurrentMouseLocation() {
+ private func activateInputAtScreenCenter() {
guard !model.promptState.isActive else {
- if let panel {
- activateForKeyboardInput(panel)
+ if let inputPanel {
+ centerInputPanel()
+ activateForKeyboardInput(inputPanel)
}
focusComposerTextInput()
microphoneWaveformMeter.start()
return
}
- activate(at: NSEvent.mouseLocation)
+ activateInput()
}
- private func activateVoiceInputAtCurrentMouseLocation() {
- activateAtCurrentMouseLocation()
+ private func activateVoiceInputAtScreenCenter() {
+ activateInputAtScreenCenter()
isVoiceInputActive = true
microphoneWaveformMeter.startAudioCapture()
model.handle(.voiceInputRequested)
@@ -292,18 +436,14 @@ final class PointerPromptOverlayController {
model.submitVoiceAudio(audio)
}
- private func positionAtCurrentMouseLocation() {
- tick(mouseLocation: NSEvent.mouseLocation)
- }
-
- private func activate(at mouseLocation: CGPoint) {
- guard let panel else { return }
+ private func activateInput() {
+ guard let inputPanel else { return }
model.activate()
microphoneWaveformMeter.start()
- tick(mouseLocation: mouseLocation)
+ centerInputPanel()
- activateForKeyboardInput(panel)
+ activateForKeyboardInput(inputPanel)
focusComposerTextInput()
}
@@ -318,87 +458,147 @@ final class PointerPromptOverlayController {
self.timer = timer
}
- private func tick(mouseLocation explicitMouseLocation: CGPoint? = nil) {
- guard let panel else { return }
+ private func tick() {
+ guard let inputPanel else { return }
if !model.promptState.isActive {
microphoneWaveformMeter.stop()
+ inputPanel.orderOut(nil)
}
activateVoiceInputIfNeeded()
- updateMouseEventPassthrough(for: panel)
- if model.promptState.isActive, explicitMouseLocation == nil {
- resizeActivePanelIfNeeded(panel)
- updateMouseEventPassthrough(for: panel)
- return
- }
-
- let mouseLocation = explicitMouseLocation ?? NSEvent.mouseLocation
- let targetFrame = frame(for: fixedPlacement, mouseLocation: mouseLocation)
- panel.setFrame(targetFrame, display: true)
- updateMouseEventPassthrough(for: panel)
+ positionStatusPanel()
+ updateStatusPanelView()
+ resizeActivePanelIfNeeded(inputPanel)
+ updateMouseEventPassthrough(for: inputPanel)
if model.placement != fixedPlacement {
model.placement = fixedPlacement
}
}
- private func frame(
- for placement: PointerPromptPlacement,
- mouseLocation: CGPoint
- ) -> CGRect {
+ private func centerInputPanel() {
+ guard let inputPanel,
+ let screen = activeScreen() else {
+ return
+ }
+
let size = currentContentSize
- let anchor = agentPointerTipAnchor(for: placement)
- let agentPointerTipLocation = agentPointerTipLocation(
- for: placement,
- mouseLocation: mouseLocation
+ inputPanel.setFrame(
+ CGRect(
+ x: screen.frame.midX - size.width / 2,
+ y: screen.frame.midY - size.height / 2,
+ width: size.width,
+ height: size.height
+ ),
+ display: true
+ )
+ }
+
+ private func positionStatusPanel() {
+ 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)
+ }
+
+ 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
)
+ }
- return CGRect(
- x: agentPointerTipLocation.x - anchor.x,
- y: agentPointerTipLocation.y - anchor.y,
- width: size.width,
- height: size.height
+ private func updateStatusPanelView() {
+ let metrics = notchMetrics()
+ statusHostingView?.rootView = notchStatusView(metrics: metrics)
+ }
+
+ private func notchStatusView(metrics: NotchMetrics) -> PointerPromptNotchStatusView {
+ PointerPromptNotchStatusView(
+ state: model.promptState,
+ updateState: model.updateState,
+ layout: metrics.layout,
+ surfaceWidth: metrics.surfaceSize.width,
+ surfaceHeight: metrics.surfaceSize.height,
+ isExpanded: isStatusExpanded,
+ hoverChanged: { [weak self] isHovering in
+ self?.setStatusExpanded(isHovering)
+ },
+ commandRequested: { [weak self] in
+ self?.handleCommandKHotKey()
+ },
+ updateRequested: { [weak self] in
+ self?.openAvailableUpdate()
+ }
)
}
- private func agentPointerTipLocation(
- for placement: PointerPromptPlacement,
- mouseLocation: CGPoint
- ) -> CGPoint {
- let xDirection: CGFloat = placement.placesContentOnLeft ? -1 : 1
- let yDirection: CGFloat = placement.placesContentAbovePointer ? 1 : -1
+ private func openAvailableUpdate() {
+ model.showUpdateUI()
+ }
+
+ private func setStatusExpanded(_ isExpanded: Bool) {
+ guard isStatusExpanded != isExpanded else { return }
- return CGPoint(
- x: mouseLocation.x + PointerPromptLayout.pointerDiagonalComponent * xDirection,
- y: mouseLocation.y + PointerPromptLayout.pointerDiagonalComponent * yDirection
- )
+ isStatusExpanded = isExpanded
+ positionStatusPanel()
+ updateStatusPanelView()
}
- private func agentPointerTipAnchor(for placement: PointerPromptPlacement) -> CGPoint {
- let pointerSlotX: CGFloat
- if placement.placesContentOnLeft {
- pointerSlotX = stageHorizontalInset +
- PointerPromptLayout.stageHorizontalPadding +
- PointerPromptLayout.composerWidth +
- PointerPromptLayout.pointerComposerSpacing
+ private func activeScreen() -> NSScreen? {
+ inputPanel?.screen ?? statusPanel?.screen ?? NSScreen.main ?? NSScreen.screens.first
+ }
+
+ private func notchMetrics(for screen: NSScreen? = nil) -> NotchMetrics {
+ let screen = screen ?? activeScreen()
+ guard let screen else {
+ return NotchMetrics(
+ voidWidth: NotchMetrics.fallbackVoidWidth,
+ voidHeight: NotchMetrics.fallbackVoidHeight,
+ isExpanded: isStatusExpanded,
+ screenWidth: NotchMetrics.defaultScreenWidth
+ )
+ }
+
+ let safeTop = max(0, screen.safeAreaInsets.top)
+ let measuredVoidWidth: CGFloat
+ if let leftArea = screen.auxiliaryTopLeftArea,
+ let rightArea = screen.auxiliaryTopRightArea {
+ measuredVoidWidth = max(
+ 0,
+ screen.frame.width - leftArea.width - rightArea.width
+ )
} else {
- pointerSlotX = stageHorizontalInset + PointerPromptLayout.stageHorizontalPadding
+ measuredVoidWidth = 0
}
- let pointerVisualX = pointerSlotX + pointerVisualInsetX(for: placement)
- let pointerTipX = pointerVisualX +
- PointerPromptLayout.pointerVisualSize.width *
- PointerPromptLayout.pointerTipUnitPoint.x
+ let hasNotch = safeTop > 0 || measuredVoidWidth > 0
+ let voidHeight = hasNotch ? max(safeTop, NotchMetrics.fallbackVoidHeight) : 0
+ let voidWidth = hasNotch ? max(measuredVoidWidth, inferredVoidWidth(for: screen, safeTop: safeTop)) : 0
- return CGPoint(
- x: pointerTipX,
- y: currentContentSize.height - pointerTipYFromTop
+ return NotchMetrics(
+ voidWidth: voidWidth,
+ voidHeight: voidHeight,
+ isExpanded: isStatusExpanded,
+ screenWidth: screen.frame.width
)
}
- private func pointerVisualInsetX(for placement: PointerPromptPlacement) -> CGFloat {
- placement.placesContentOnLeft ? 0 :
- PointerPromptLayout.pointerSlotSize.width - PointerPromptLayout.pointerVisualSize.width
+ private func inferredVoidWidth(for screen: NSScreen, safeTop: CGFloat) -> CGFloat {
+ guard safeTop > 0 else { return 0 }
+
+ return min(
+ max(NotchMetrics.fallbackVoidWidth, screen.frame.width * 0.095),
+ NotchMetrics.maximumInferredVoidWidth
+ )
}
private var stageHorizontalInset: CGFloat {
@@ -411,8 +611,6 @@ final class PointerPromptOverlayController {
private var stageContentWidth: CGFloat {
PointerPromptLayout.stageHorizontalPadding * 2 +
- PointerPromptLayout.pointerSlotSize.width +
- PointerPromptLayout.pointerComposerSpacing +
PointerPromptLayout.composerWidth
}
@@ -421,16 +619,6 @@ final class PointerPromptOverlayController {
currentComposerHeight
}
- private var pointerTipYFromTop: CGFloat {
- pointerVisualTopFromPanelTop +
- PointerPromptLayout.pointerVisualSize.height *
- PointerPromptLayout.pointerTipUnitPoint.y
- }
-
- private var pointerVisualTopFromPanelTop: CGFloat {
- composerTopFromPanelTop
- }
-
private func composerDragRegions() -> [CGRect] {
guard model.promptState.isActive else { return [] }
@@ -452,15 +640,7 @@ final class PointerPromptOverlayController {
}
private func composerFrame(for placement: PointerPromptPlacement) -> CGRect {
- let x: CGFloat
- if placement.placesContentOnLeft {
- x = stageHorizontalInset + PointerPromptLayout.stageHorizontalPadding
- } else {
- x = stageHorizontalInset +
- PointerPromptLayout.stageHorizontalPadding +
- PointerPromptLayout.pointerSlotSize.width +
- PointerPromptLayout.pointerComposerSpacing
- }
+ let x = stageHorizontalInset + PointerPromptLayout.stageHorizontalPadding
return CGRect(
x: x,
@@ -541,11 +721,11 @@ final class PointerPromptOverlayController {
private func dismissActivePromptIfClickIsOutside() -> Bool {
guard model.promptState.isActive,
- let panel else {
+ let inputPanel else {
return false
}
- let mouseLocationInPanel = panel.convertPoint(fromScreen: NSEvent.mouseLocation)
+ let mouseLocationInPanel = inputPanel.convertPoint(fromScreen: NSEvent.mouseLocation)
guard !composerFrame(for: fixedPlacement).contains(mouseLocationInPanel) else {
return false
}
@@ -580,8 +760,8 @@ final class PointerPromptOverlayController {
panel.setFrame(
CGRect(
- x: frame.minX,
- y: frame.maxY - size.height,
+ x: frame.midX - size.width / 2,
+ y: frame.midY - size.height / 2,
width: size.width,
height: size.height
),
@@ -590,7 +770,7 @@ final class PointerPromptOverlayController {
}
private func focusComposerTextInput(attempt: Int = 0) {
- guard let panel else { return }
+ guard let panel = inputPanel else { return }
activateForKeyboardInput(panel)
@@ -673,6 +853,55 @@ private final class PointerPromptPanel: NSPanel {
}
}
+private struct NotchMetrics {
+ static let fallbackVoidWidth: CGFloat = 180
+ static let fallbackVoidHeight: CGFloat = 32
+ static let maximumInferredVoidWidth: CGFloat = 220
+ static let defaultScreenWidth: CGFloat = 1512
+
+ var voidWidth: CGFloat
+ var voidHeight: CGFloat
+ var isExpanded: Bool
+ var screenWidth: CGFloat
+
+ var surfaceSize: CGSize {
+ return CGSize(
+ width: surfaceWidth,
+ height: max(layout.visibleHeight, voidHeight + layout.visibleHeight)
+ )
+ }
+
+ var layout: PointerPromptNotchLayout {
+ PointerPromptNotchLayout(
+ voidHeight: voidHeight,
+ contentHorizontalInset: max(12, surfaceWidth * 0.035),
+ visibleHeight: visibleHeight,
+ cornerRadius: isExpanded ? 28 : 14
+ )
+ }
+
+ private var surfaceWidth: CGFloat {
+ if isExpanded {
+ return min(max(360, screenWidth - 48), 690)
+ }
+
+ let contentAllowance: CGFloat = 170
+ return min(max(voidWidth + contentAllowance, 300), min(420, screenWidth - 24))
+ }
+
+ private var visibleHeight: CGFloat {
+ if isExpanded {
+ let headerHeight: CGFloat = 52
+ let rosterHeight = CGFloat(5 * 58 + 4 * 10)
+ let verticalPadding: CGFloat = 12 + 10 + 52 + 12
+
+ return headerHeight + rosterHeight + verticalPadding
+ }
+
+ return max(40, voidHeight + 14)
+ }
+}
+
private extension PointerPromptActivationModifier {
var eventModifierFlag: NSEvent.ModifierFlags {
switch self {
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
index 933d8cb0..6b0b25c9 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
@@ -10,9 +10,11 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
@Published var placement: PointerPromptPlacement = .bottomRight
@Published var inputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
@Published var isInputExpanded = false
+ @Published private(set) var updateState: PointerPromptUpdateState
private let commandHandler: any PointerPromptCommandHandling
private let voiceTranscriber: LocalVoiceTranscriptionAdapter
+ private var updateChecker: any DonkeyUpdateChecking
init(
aiProvider: any AIHarnessSnapshotProviding = AIHarnessBoundary(),
@@ -20,10 +22,15 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
voiceTranscriber: LocalVoiceTranscriptionAdapter = LocalVoiceTranscriptionAdapter(
runtime: ProcessBackedParakeetTranscriptionRuntime()
),
+ updateChecker: any DonkeyUpdateChecking = SparkleUpdateController(),
theme: PointerPromptTheme = PointerPromptOverlayModel.bundledTheme()
) {
self.commandHandler = commandHandler
self.voiceTranscriber = voiceTranscriber
+ self.updateChecker = updateChecker
+ updateState = PointerPromptUpdateState(
+ currentVersion: updateChecker.currentVersion
+ )
let aiSnapshot = aiProvider.snapshot()
promptState = PointerPromptState(
promptText: aiSnapshot.suggestedPromptText,
@@ -32,6 +39,11 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
isActive: false,
theme: theme
)
+ self.updateChecker.updateStateChanged = { [weak self] state in
+ self?.updateState = state
+ }
+ updateChecker.start()
+ checkForUpdates()
}
func activate() {
@@ -47,6 +59,14 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
promptState.voiceWaveformLevels = normalizedLevels
}
+ func checkForUpdates() {
+ updateChecker.checkForUpdatesInBackground()
+ }
+
+ func showUpdateUI() {
+ updateChecker.showUpdateUI()
+ }
+
func handle(_ intent: PointerPromptIntent) {
switch intent {
case .addContextRequested:
@@ -111,6 +131,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
messageText = ""
inputTextHeight = PointerPromptLayout.composerInputTextMinimumHeight
isInputExpanded = false
+ promptState.isActive = false
promptState.leadingSignalLevel = .thinking
promptState.promptText = "Working..."
Task { [weak self, commandHandler] in
diff --git a/apps/Donkey/Sources/Donkey/SparkleUpdateController.swift b/apps/Donkey/Sources/Donkey/SparkleUpdateController.swift
new file mode 100644
index 00000000..72e661ca
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/SparkleUpdateController.swift
@@ -0,0 +1,102 @@
+import DonkeyContracts
+import Foundation
+import Sparkle
+
+@MainActor
+protocol DonkeyUpdateChecking: AnyObject {
+ var currentVersion: String { get }
+ var updateStateChanged: ((PointerPromptUpdateState) -> Void)? { get set }
+
+ func start()
+ func checkForUpdatesInBackground()
+ func showUpdateUI()
+}
+
+@MainActor
+final class SparkleUpdateController: NSObject, DonkeyUpdateChecking, SPUUpdaterDelegate {
+ private var updaterController: SPUStandardUpdaterController?
+
+ var updateStateChanged: ((PointerPromptUpdateState) -> Void)?
+
+ var currentVersion: String {
+ Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ??
+ "0.1.0"
+ }
+
+ func start() {
+ guard updaterController == nil else { return }
+ guard isSparkleConfigured else {
+ updateStateChanged?(
+ PointerPromptUpdateState(
+ status: .unavailable,
+ currentVersion: currentVersion,
+ message: "Sparkle feed not configured"
+ )
+ )
+ return
+ }
+
+ updaterController = SPUStandardUpdaterController(
+ startingUpdater: true,
+ updaterDelegate: self,
+ userDriverDelegate: nil
+ )
+ }
+
+ func checkForUpdatesInBackground() {
+ guard let updaterController else {
+ updateStateChanged?(
+ PointerPromptUpdateState(
+ status: .unavailable,
+ currentVersion: currentVersion,
+ message: "Updater unavailable"
+ )
+ )
+ return
+ }
+
+ updateStateChanged?(
+ PointerPromptUpdateState(
+ status: .checking,
+ currentVersion: currentVersion
+ )
+ )
+ updaterController.updater.checkForUpdatesInBackground()
+ }
+
+ func showUpdateUI() {
+ guard let updaterController else {
+ checkForUpdatesInBackground()
+ return
+ }
+
+ updaterController.checkForUpdates(nil)
+ }
+
+ private var isSparkleConfigured: Bool {
+ let feedURL = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String
+ let publicKey = Bundle.main.object(forInfoDictionaryKey: "SUPublicEDKey") as? String
+
+ return feedURL?.isEmpty == false && publicKey?.isEmpty == false
+ }
+
+ func updater(_ updater: SPUUpdater, didFindValidUpdate item: SUAppcastItem) {
+ updateStateChanged?(
+ PointerPromptUpdateState(
+ status: .available,
+ currentVersion: currentVersion,
+ latestVersion: item.displayVersionString
+ )
+ )
+ }
+
+ func updaterDidNotFindUpdate(_ updater: SPUUpdater, error: any Error) {
+ updateStateChanged?(
+ PointerPromptUpdateState(
+ status: .upToDate,
+ currentVersion: currentVersion,
+ message: error.localizedDescription
+ )
+ )
+ }
+}
diff --git a/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift b/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
index 4a8c887f..c505cae4 100644
--- a/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
+++ b/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
@@ -108,7 +108,7 @@ public struct AIModelRegistry: Codable, Equatable, Sendable {
role: .taskIntent,
provider: .localRuntime,
modelID: "qwen3:8b",
- endpoint: URL(string: "local://qwen3:8b/task-intent")!,
+ endpoint: URL(string: "local://qwen3-8b/task-intent")!,
capabilities: [.textInput, .structuredOutputs],
timeoutMS: 4_000,
promptVersion: "task-intent-v1",
diff --git a/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift b/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
index 795a5e5f..3a9eeac6 100644
--- a/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
+++ b/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
@@ -430,6 +430,14 @@ public struct LocalModelTaskIntentResolver: Sendable {
)
guard let intent = result.intent else {
+ if let fallbackIntent = LocalAppTaskIntentParser(taskDefinitions: catalog.taskDefinitions).parse(command) {
+ var fallbackTrace = result.trace
+ fallbackTrace.validationStatus = "deterministicFallback"
+ fallbackTrace.metadata["fallback.parser"] = "local-app-task-deterministic-v1"
+ fallbackTrace.metadata["fallback.reason"] = "localModelIntentUnavailable"
+ return (catalog.resolve(intent: fallbackIntent), fallbackTrace)
+ }
+
return (
LocalAppTaskCatalogResolution(
status: .unsupportedCommand,
diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift
index 4c14cfcd..de38fa2b 100644
--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptLayout.swift
@@ -1,7 +1,7 @@
import CoreGraphics
public enum PointerPromptLayout {
- public static let contentWidth: CGFloat = 684
+ public static let contentWidth: CGFloat = 592
public static let contentExtraHeight: CGFloat = 8
public static let stageHorizontalPadding: CGFloat = 8
public static let stageVerticalPadding: CGFloat = 10
diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift
new file mode 100644
index 00000000..edf4737f
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptNotchLayout.swift
@@ -0,0 +1,20 @@
+import CoreGraphics
+
+public struct PointerPromptNotchLayout: Equatable, Sendable {
+ public var voidHeight: CGFloat
+ public var contentHorizontalInset: CGFloat
+ public var visibleHeight: CGFloat
+ public var cornerRadius: CGFloat
+
+ public init(
+ voidHeight: CGFloat,
+ contentHorizontalInset: CGFloat,
+ visibleHeight: CGFloat,
+ cornerRadius: CGFloat
+ ) {
+ self.voidHeight = voidHeight
+ self.contentHorizontalInset = contentHorizontalInset
+ self.visibleHeight = visibleHeight
+ self.cornerRadius = cornerRadius
+ }
+}
diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptUpdateContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptUpdateContracts.swift
new file mode 100644
index 00000000..af43b8e9
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptUpdateContracts.swift
@@ -0,0 +1,43 @@
+import Foundation
+
+public enum PointerPromptUpdateStatus: String, Equatable, Sendable {
+ case notChecked
+ case checking
+ case upToDate
+ case available
+ case unavailable
+ case failed
+}
+
+public struct PointerPromptUpdateState: Equatable, Sendable {
+ public var status: PointerPromptUpdateStatus
+ public var currentVersion: String
+ public var latestVersion: String?
+ public var message: String?
+
+ public init(
+ status: PointerPromptUpdateStatus = .notChecked,
+ currentVersion: String,
+ latestVersion: String? = nil,
+ message: String? = nil
+ ) {
+ self.status = status
+ self.currentVersion = currentVersion
+ self.latestVersion = latestVersion
+ self.message = message
+ }
+
+ public var isActionable: Bool {
+ status == .available
+ }
+
+ public var headerButtonTitle: String? {
+ guard isActionable else { return nil }
+
+ if let latestVersion, !latestVersion.isEmpty {
+ return "Update \(latestVersion)"
+ }
+
+ return "Update"
+ }
+}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
index 3b563ae0..552ef08e 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
@@ -424,6 +424,13 @@ public struct LocalModelRuntimeSetupManager: Sendable {
return packageDirectory
}
+ private func bundledPackageManifest(for runtimeID: LocalModelRuntimeID) throws -> LocalModelRuntimePackageManifest? {
+ guard let packageDirectory = bundledPackageDirectory(runtimeID) else { return nil }
+ let manifestURL = packageDirectory.appendingPathComponent("manifest.json", isDirectory: false)
+ let manifestData = try Data(contentsOf: manifestURL)
+ return try Self.decoder().decode(LocalModelRuntimePackageManifest.self, from: manifestData)
+ }
+
public func instructions() -> [LocalModelRuntimeInstallInstruction] {
specs.map { spec in
LocalModelRuntimeInstallInstruction(
@@ -450,6 +457,20 @@ public struct LocalModelRuntimeSetupManager: Sendable {
)
}
+ if let bundledManifest = try? bundledPackageManifest(for: runtimeID),
+ bundledManifest.runtimeVersion != installation.runtimeVersion {
+ return LocalModelRuntimeStatus(
+ spec: spec,
+ state: .notInstalled,
+ installation: installation,
+ metadata: [
+ "reason": "bundledRuntimeUpdateAvailable",
+ "installedRuntimeVersion": installation.runtimeVersion ?? "",
+ "bundledRuntimeVersion": bundledManifest.runtimeVersion
+ ]
+ )
+ }
+
let state: LocalModelRuntimeInstallState = isExecutableFile(installation.executablePath)
? .installed
: .invalidExecutable
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift
new file mode 100644
index 00000000..ef0f2dd0
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift
@@ -0,0 +1,396 @@
+import DonkeyContracts
+import SwiftUI
+
+public struct PointerPromptNotchStatusView: View {
+ private let state: PointerPromptState
+ private let updateState: PointerPromptUpdateState
+ private let layout: PointerPromptNotchLayout
+ private let surfaceWidth: CGFloat
+ private let surfaceHeight: CGFloat
+ private let isExpanded: Bool
+ private let hoverChanged: @MainActor (Bool) -> Void
+ private let commandRequested: @MainActor () -> Void
+ private let updateRequested: @MainActor () -> Void
+
+ public init(
+ state: PointerPromptState,
+ updateState: PointerPromptUpdateState,
+ layout: PointerPromptNotchLayout,
+ surfaceWidth: CGFloat,
+ surfaceHeight: CGFloat,
+ isExpanded: Bool,
+ hoverChanged: @escaping @MainActor (Bool) -> Void,
+ commandRequested: @escaping @MainActor () -> Void,
+ updateRequested: @escaping @MainActor () -> Void
+ ) {
+ self.state = state
+ self.updateState = updateState
+ self.layout = layout
+ self.surfaceWidth = surfaceWidth
+ self.surfaceHeight = surfaceHeight
+ self.isExpanded = isExpanded
+ self.hoverChanged = hoverChanged
+ self.commandRequested = commandRequested
+ self.updateRequested = updateRequested
+ }
+
+ public var body: some View {
+ ZStack(alignment: .top) {
+ UnevenRoundedRectangle(
+ cornerRadii: RectangleCornerRadii(
+ topLeading: 0,
+ bottomLeading: cornerRadius,
+ bottomTrailing: cornerRadius,
+ topTrailing: 0
+ ),
+ style: .continuous
+ )
+ .fill(Color.black)
+
+ content
+ .offset(y: max(0, layout.voidHeight))
+ }
+ .frame(width: surfaceWidth, height: surfaceHeight, alignment: .top)
+ .clipped()
+ .onHover { isHovering in
+ Task { @MainActor in
+ hoverChanged(isHovering)
+ }
+ }
+ .animation(.smooth(duration: 0.24), value: isExpanded)
+ .accessibilityElement(children: .contain)
+ }
+
+ @ViewBuilder
+ private var content: some View {
+ if isExpanded {
+ expandedContent
+ } else {
+ collapsedContent
+ }
+ }
+
+ private var collapsedContent: some View {
+ HStack(spacing: 10) {
+ agentIcon(agent: activeAgent, size: 25, symbolSize: 11)
+
+ Text("\(activeAgent.name) · \(activeAgent.subtitle)")
+ .font(.system(size: 13, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.92))
+ .lineLimit(1)
+ .truncationMode(.tail)
+
+ Spacer(minLength: 0)
+
+ if activeAgent.isRunning {
+ activityBars(color: activeAgent.color)
+ }
+ }
+ .padding(.horizontal, max(12, layout.contentHorizontalInset))
+ .frame(
+ width: surfaceWidth,
+ height: layout.visibleHeight,
+ alignment: .center
+ )
+ }
+
+ private var expandedContent: some View {
+ VStack(spacing: 0) {
+ expandedHeader
+
+ VStack(spacing: 10) {
+ ForEach(displayAgentRows) { agent in
+ expandedAgentRow(agent)
+ }
+ }
+ .padding(.horizontal, 14)
+ .padding(.top, 12)
+
+ Spacer(minLength: 10)
+
+ commandRow
+ .padding(.horizontal, 14)
+ .padding(.bottom, 12)
+ }
+ .frame(
+ width: surfaceWidth,
+ height: max(0, surfaceHeight - layout.voidHeight),
+ alignment: .top
+ )
+ }
+
+ private var expandedHeader: some View {
+ HStack(spacing: 12) {
+ ZStack {
+ Circle()
+ .fill(activeAgent.color.opacity(0.92))
+
+ Image(systemName: "face.smiling")
+ .font(.system(size: 10.5, weight: .semibold))
+ .foregroundStyle(Color.white)
+ }
+ .frame(width: 22, height: 22)
+
+ Text("Donkey")
+ .font(.system(size: 15, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.92))
+
+ Text("\(runningAgentCount) of 5 running")
+ .font(.system(size: 13, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.42))
+
+ Spacer()
+
+ if let updateTitle = updateState.headerButtonTitle {
+ Button(action: updateRequested) {
+ HStack(spacing: 7) {
+ Circle()
+ .fill(Color(red: 0.94, green: 0.62, blue: 0.15))
+ .frame(width: 7, height: 7)
+
+ Text(updateTitle)
+ .font(.system(size: 12, weight: .semibold))
+ }
+ .foregroundStyle(Color.white.opacity(0.9))
+ .padding(.horizontal, 11)
+ .frame(height: 28)
+ .background(Color(red: 0.94, green: 0.62, blue: 0.15).opacity(0.22))
+ .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+
+ Button(action: commandRequested) {
+ HStack(spacing: 6) {
+ Image(systemName: "plus")
+ .font(.system(size: 13, weight: .regular))
+ Text("new task")
+ .font(.system(size: 13, weight: .medium))
+ }
+ .foregroundStyle(Color.white.opacity(0.46))
+ }
+ .buttonStyle(.plain)
+ }
+ .padding(.horizontal, 22)
+ .frame(height: 52)
+ .overlay(alignment: .bottom) {
+ Rectangle()
+ .fill(Color.white.opacity(0.08))
+ .frame(height: 1)
+ }
+ }
+
+ private func expandedAgentRow(_ agent: NotchAgentDisplay) -> some View {
+ HStack(spacing: 14) {
+ agentIcon(agent: agent, size: 32, symbolSize: 15)
+
+ VStack(alignment: .leading, spacing: 4) {
+ HStack(spacing: 8) {
+ Text(agent.name)
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.9))
+
+ Text(agent.statusLabel)
+ .font(.system(size: 11, weight: .medium))
+ .foregroundStyle(agent.isRunning ? agent.color : Color.white.opacity(0.44))
+ .padding(.horizontal, 5)
+ .padding(.vertical, 2)
+ .background(agent.isRunning ? agent.color.opacity(0.18) : Color.clear)
+ .clipShape(RoundedRectangle(cornerRadius: 4, style: .continuous))
+ }
+
+ Text(agent.isRunning ? agent.subtitle : "No active task")
+ .font(.system(size: 13, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .lineLimit(1)
+ }
+
+ Spacer()
+
+ if agent.isRunning {
+ activityBars(color: agent.color)
+ } else {
+ Image(systemName: "play.fill")
+ .font(.system(size: 16, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.42))
+ }
+ }
+ .padding(.horizontal, 12)
+ .frame(height: 58)
+ .background {
+ if agent.isRunning {
+ RoundedRectangle(cornerRadius: 10, style: .continuous)
+ .fill(agent.color.opacity(0.1))
+ .overlay(alignment: .leading) {
+ RoundedRectangle(cornerRadius: 2, style: .continuous)
+ .fill(agent.color)
+ .frame(width: 3)
+ }
+ }
+ }
+ }
+
+ private var commandRow: some View {
+ Button(action: commandRequested) {
+ HStack(spacing: 13) {
+ Image(systemName: "sparkles")
+ .font(.system(size: 16, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.42))
+
+ Text("Tell donkey what to do...")
+ .font(.system(size: 14, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.42))
+
+ Spacer()
+
+ Text("⌘ K")
+ .font(.system(size: 12, weight: .semibold, design: .monospaced))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .padding(.horizontal, 10)
+ .frame(height: 28)
+ .background(Color.white.opacity(0.06))
+ .overlay {
+ RoundedRectangle(cornerRadius: 7, style: .continuous)
+ .stroke(Color.white.opacity(0.13), lineWidth: 1)
+ }
+ .clipShape(RoundedRectangle(cornerRadius: 7, style: .continuous))
+ }
+ .padding(.horizontal, 16)
+ .frame(height: 52)
+ .background(Color.white.opacity(0.055))
+ .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+
+ private func agentIcon(
+ agent: NotchAgentDisplay,
+ size: CGFloat,
+ symbolSize: CGFloat
+ ) -> some View {
+ ZStack {
+ RoundedRectangle(cornerRadius: size * 0.24, style: .continuous)
+ .fill(agent.color)
+
+ Image(systemName: agent.symbolName)
+ .font(.system(size: symbolSize, weight: .semibold))
+ .foregroundStyle(Color.white)
+ }
+ .frame(width: size, height: size)
+ }
+
+ private func activityBars(color: Color) -> some View {
+ HStack(spacing: 3) {
+ ForEach([0.44, 0.82, 0.58], id: \.self) { scale in
+ Capsule(style: .continuous)
+ .fill(color)
+ .frame(width: 3, height: 18 * scale)
+ }
+ }
+ .frame(width: 18, height: 18)
+ }
+
+ private var activeAgent: NotchAgentDisplay {
+ displayAgentRows[0]
+ }
+
+ private var activeSubtitle: String {
+ switch state.leadingSignalLevel {
+ case .idle:
+ return "resting"
+ case .ready:
+ let text = state.promptText.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard !text.isEmpty else { return "ready" }
+ return text
+ case .thinking:
+ return "ranking models on SWE-bench"
+ }
+ }
+
+ private var activeStatusLabel: String {
+ switch state.leadingSignalLevel {
+ case .idle:
+ return "idle"
+ case .ready:
+ return "done"
+ case .thinking:
+ return "running"
+ }
+ }
+
+ private var runningAgentCount: Int {
+ displayAgentRows.filter(\.isRunning).count
+ }
+
+ private var displayAgentRows: [NotchAgentDisplay] {
+ var rows = baseAgentRows
+ rows[0].subtitle = activeSubtitle
+ rows[0].statusLabel = activeStatusLabel
+ rows[0].isRunning = state.leadingSignalLevel == .thinking
+ return rows
+ }
+
+ private var baseAgentRows: [NotchAgentDisplay] {
+ [
+ NotchAgentDisplay(
+ id: "coder",
+ name: "Coder",
+ subtitle: "Ranking models on SWE-bench",
+ statusLabel: "running",
+ symbolName: "chevron.left.forwardslash.chevron.right",
+ color: Color(red: 0.114, green: 0.62, blue: 0.46),
+ isRunning: true
+ ),
+ NotchAgentDisplay(
+ id: "browser",
+ name: "Browser",
+ subtitle: "Pulling pricing from 3 sites",
+ statusLabel: "idle",
+ symbolName: "globe",
+ color: Color(red: 0.94, green: 0.62, blue: 0.15),
+ isRunning: false
+ ),
+ NotchAgentDisplay(
+ id: "researcher",
+ name: "Researcher",
+ subtitle: "Reading 12 ArXiv papers",
+ statusLabel: "idle",
+ symbolName: "magnifyingglass",
+ color: Color(red: 0.83, green: 0.33, blue: 0.49),
+ isRunning: false
+ ),
+ NotchAgentDisplay(
+ id: "inbox",
+ name: "Inbox",
+ subtitle: "Drafting reply to recruiter",
+ statusLabel: "idle",
+ symbolName: "envelope",
+ color: Color(red: 0.22, green: 0.54, blue: 0.87),
+ isRunning: false
+ ),
+ NotchAgentDisplay(
+ id: "scheduler",
+ name: "Scheduler",
+ subtitle: "Finding slots across KST/PT",
+ statusLabel: "idle",
+ symbolName: "calendar",
+ color: Color(red: 0.5, green: 0.47, blue: 0.87),
+ isRunning: false
+ )
+ ]
+ }
+
+ private var cornerRadius: CGFloat {
+ layout.cornerRadius
+ }
+}
+
+private struct NotchAgentDisplay: Identifiable {
+ var id: String
+ var name: String
+ var subtitle: String
+ var statusLabel: String
+ var symbolName: String
+ var color: Color
+ var isRunning: Bool
+}
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
index 8530edfe..fa6e2af2 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
@@ -29,28 +29,13 @@ public struct PointerPromptStageView: View {
}
public var body: some View {
- promptContent
+ activeComposer
.padding(.horizontal, PointerPromptLayout.stageHorizontalPadding)
.padding(.vertical, PointerPromptLayout.stageVerticalPadding)
.background(Color.clear)
.accessibilityElement(children: .contain)
}
- @ViewBuilder
- private var promptContent: some View {
- if placement.placesContentOnLeft {
- HStack(alignment: .top, spacing: PointerPromptLayout.pointerComposerSpacing) {
- activeComposer
- pointerSlot
- }
- } else {
- HStack(alignment: .top, spacing: PointerPromptLayout.pointerComposerSpacing) {
- pointerSlot
- activeComposer
- }
- }
- }
-
@ViewBuilder
private var pointerSlot: some View {
if Self.rendersAgentPointer {
diff --git a/plans/22-local-runtime-onboarding.md b/plans/22-local-runtime-onboarding.md
deleted file mode 100644
index e444db74..00000000
--- a/plans/22-local-runtime-onboarding.md
+++ /dev/null
@@ -1,180 +0,0 @@
-# Local Runtime Onboarding Plan
-
-This plan captures the installer and onboarding work Donkey should borrow from OpenWhispr's local model setup, adapted to Donkey's generic sidecar architecture.
-
-OpenWhispr is stronger today at productized local transcription setup: it has packaged native binaries, a settings/control-panel flow, first-use model download, model choices, installation rechecks, and clear troubleshooting. Donkey should borrow those product patterns without copying the speech-app architecture. Donkey's local runtimes must remain generic sidecars that produce transcripts, observations, masks, memory proposals, or planner hints, never direct input actions.
-
-## Goal
-
-Make local model runtime setup feel like a normal post-install app flow:
-
-1. Donkey ships without model weights.
-2. The app exposes one setup action that downloads the compatible runtime packages.
-3. Donkey validates expected executables, records them in Application Support, and health-checks them.
-4. Users do not need to choose model folders or understand runtime-specific setup.
-5. Sidecar execution works without users exporting shell environment variables.
-6. If setup fails, users can retry the same setup action; already completed runtime installs are kept, failed or not-yet-attempted runtimes are retried, and repair, upgrade, and support diagnostics can exist behind that simple flow rather than as first-run choices.
-
-## Borrow From OpenWhispr
-
-- First-run setup UI for local model runtimes.
-- One first-run setup button that performs download, validation, installation, registration, and health checks.
-- Internal model/package status states for diagnostics: missing, downloading, installed, invalid, health-check failed, upgrade available.
-- Checksum and signature validation for downloaded packages.
-- Automatic installation recheck as part of setup and repair.
-- Published runtime packages separate from the main app.
-- Explicit cache/package locations.
-- Troubleshooting copy for permissions, disk space, stale binaries, and slow performance.
-
-## Donkey-Specific Design
-
-Donkey should keep its current generic sidecar boundary:
-
-- Parakeet sidecar returns transcript text only.
-- YOLO sidecar returns segmentation masks only.
-- UI-understanding sidecar returns visible text, controls, form fields, and confidence only.
-- Sidecar output feeds observation, transcript, memory proposal, or planner-hint paths only.
-- The action engine remains the only owner of OS input.
-
-The app-managed runtime registry remains under:
-
-```text
-~/Library/Application Support/Donkey/LocalModelRuntimes/runtime-installations.json
-```
-
-Developer environment variables remain supported as overrides:
-
-```text
-DONKEY_PARAKEET_TRANSCRIBER
-DONKEY_YOLO_SEGMENTER
-DONKEY_UI_UNDERSTANDER
-```
-
-## Implementation Slices
-
-### 1. Runtime Package Manifest
-
-Define a signed manifest format for each runtime package:
-
-- runtime id
-- runtime version
-- model id/version
-- platform and architecture
-- executable relative path
-- model file relative paths
-- expected SHA-256 hashes
-- minimum Donkey version
-- sidecar protocol version
-- download URL
-- release notes URL
-
-Donkey rejects a package when the manifest is missing, unsigned, unsupported, mismatched, missing its executable, or hash-invalid. The current implementation enforces SHA-256 checksums and requires signature metadata. Cryptographic signature verification can be strengthened once the release signing key is finalized.
-
-### 2. First-Run Setup UI
-
-Add a small runtime setup surface reachable on first launch and from settings:
-
-- Shows one overall setup state and one primary setup button.
-- The setup button downloads, verifies, installs, registers, and health-checks all required runtimes.
-- Failed setup returns to a retryable state with the same single button. Retry keeps completed runtimes and resumes at failed or not-yet-attempted runtimes.
-- Explains that model weights are not bundled with the app.
-- Does not expose per-runtime controls during first-run setup.
-- Does not block typed-command MVP unless the requested feature needs the missing runtime.
-
-### 3. Download And Install Flow
-
-Support app-driven downloads where possible:
-
-- Download to a temporary Application Support staging directory.
-- Verify checksum and required signature metadata before registration.
-- Move verified package files into a managed runtime directory.
-- Mark executable permissions when needed.
-- Record the installation in the runtime registry.
-- Delete partial downloads after failure.
-
-Manual folder registration remains available through developer launch arguments only.
-
-### 4. Health Checks
-
-Each runtime package should expose a cheap health command through the same process boundary:
-
-```json
-{"operation":"healthCheck","protocolVersion":"v1"}
-```
-
-Expected response:
-
-```json
-{
- "status": "ok",
- "runtimeID": "...",
- "runtimeVersion": "...",
- "modelID": "...",
- "protocolVersion": "v1",
- "metadata": {}
-}
-```
-
-Health-check failures produce actionable status metadata and do not silently fall back.
-
-### 5. Upgrade And Repair
-
-Add runtime lifecycle operations:
-
-- check for updates from the manifest channel
-- download update
-- verify before replacing current runtime
-- keep one previous good runtime until new runtime health-checks pass
-- rollback on failed install
-- remove runtime and clear registry entry
-
-### 6. Reporting And Support
-
-Expose setup evidence in reports:
-
-- installed runtime versions
-- health-check status
-- executable path source: env override or app registry
-- package hash status
-- model version
-- protocol version
-
-Add a support/debug export that omits user data and includes runtime setup status.
-
-## Acceptance Criteria
-
-- A fresh Donkey install can show local runtime setup instructions without Terminal env vars. Supported.
-- A user can start app-managed runtime setup from one first-run button. Supported.
-- Donkey refuses missing, non-executable, mismatched, unsigned, or hash-invalid runtime packages. Supported for executable presence, signature metadata, platform/architecture/runtime mismatch, and SHA-256 file hashes.
-- Sidecar calls resolve registered executables from Application Support when env vars are absent. Supported.
-- The first-run setup window avoids per-runtime customization and reports one overall ready or needs-attention state. Supported.
-- `swift test` covers manifest validation, package download, checksum/signature enforcement, managed cache install, registration, health recheck, and app-registry sidecar resolution. Supported.
-- Docs explain that model weights are downloaded after install and are not bundled in the app. Supported.
-
-## Current Code Boundary
-
-Already supported:
-
-- `LocalModelRuntimeSetupManager` runtime specs, setup instructions, registration, status, and app-managed executable resolution.
-- First-run local runtime setup window with one setup button that drives download, validation, install, registration, and health checks.
-- Package-time bundled sidecar runner packages embedded under `Donkey.app/Contents/Resources/LocalRuntimePackages/`.
-- Shared packaged runner entrypoint for local LLM, Parakeet, YOLO, and UI-understanding sidecars, with real backend hooks and explicit missing-backend states instead of hardcoded fake runtime output.
-- Setup manager installation from bundled package manifests before remote manifest download.
-- Setup-time `prepareModelWeights` sidecar operation that downloads/caches configured model files into Application Support before health checks.
-- Setup-managed `local-llm` sidecar for the command parser; it pulls `qwen3:8b` through Ollama by default and submitted commands route through this sidecar.
-- Manifest-backed package download and managed cache install under Application Support.
-- SHA-256 package file validation and required signature metadata.
-- Sidecar health-check protocol through the existing JSON process runner.
-- `ProcessBackedLocalJSONSidecarRunner` env-first then app-registry executable lookup.
-- Debug commands:
- - `--local-runtime-instructions`
- - `--install-local-runtime --runtime-id <id> --runtime-source <folder>`
- - `--local-runtime-status`
-
-Still needed:
-
-- Package or bootstrap the remaining local backend dependencies behind the one setup button: NVIDIA NeMo/Python for Parakeet, Ultralytics-compatible execution for YOLO, a real local UI-understanding backend, and either an accepted Ollama prerequisite or a self-contained local LLM runner.
-- Finalize cryptographic signature verification with release signing keys.
-- Settings-menu entry to reopen the setup window after first launch.
-- Behind-the-scenes upgrade/repair/remove flows.
-- Support/debug export.
diff --git a/plans/done/22-local-runtime-onboarding.md b/plans/done/22-local-runtime-onboarding.md
new file mode 100644
index 00000000..4467d56e
--- /dev/null
+++ b/plans/done/22-local-runtime-onboarding.md
@@ -0,0 +1,36 @@
+# Local Runtime Onboarding Plan
+
+Completed. This plan is historical context for Donkey's first-run local runtime
+setup flow.
+
+## Supported Outcome
+
+Donkey now supports a normal post-install runtime setup boundary:
+
+- first-launch setup window with one primary setup button
+- app-managed runtime registry under Application Support
+- bundled runner packages embedded in `Donkey.app`
+- manifest validation for runtime id, platform, architecture, executable path,
+ required signature metadata, and SHA-256 file hashes
+- package install into managed Application Support directories
+- setup-time model preparation before health checks
+- sidecar `healthCheck` protocol
+- retryable setup that keeps completed installs and resumes failed or missing
+ runtimes
+- app-registry sidecar resolution when shell environment variables are absent
+- developer debug commands for setup instructions, status, and manual runtime
+ registration
+
+The supported behavior is documented in:
+
+- `docs/architecture.md`
+- `docs/guides/install-donkey.md`
+- `docs/guides/minimal-run-coordinator.md`
+
+## Follow-Up Work
+
+Remaining release hardening is tracked by `plans/master-plan.md`, not this
+completed plan. That includes offline wheelhouse artifacts, final backend
+packaging, cryptographic release-key verification, runtime repair/remove flows,
+a settings entry to reopen setup, support export, and the final command-parser
+LLM prerequisite decision.
diff --git a/plans/master-plan.md b/plans/master-plan.md
index 03c8e51a..dc33065d 100644
--- a/plans/master-plan.md
+++ b/plans/master-plan.md
@@ -28,7 +28,6 @@ tasks such as media playback and review-first document form fill.
- `plans/03-fast-controller.md`
- `plans/05-action-engine.md`
- `plans/06-benchmarking.md`
-- `plans/22-local-runtime-onboarding.md`
Treat other `plans/` files as background unless this plan names them.
@@ -57,6 +56,8 @@ not self-contained.
- verify runtime manifests with release-key cryptographic signatures, not
signature metadata alone
- add behind-the-scenes repair/remove flows for broken runtime installs
+ - add a settings entry to reopen runtime setup and a user-data-free support
+ export for runtime status
- keep the first-run setup button retryable without exposing per-runtime user
customization