Skip to content

Open source CapCut alternative.

TypeScript

feat(app): replace the notch overlay with a menu bar status item [rebuild]

David Lef631314cc1ed
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swift
index dc013f44..dc1a5ca1 100644
--- a/apps/Donkey/Package.swift
+++ b/apps/Donkey/Package.swift
@@ -81,6 +81,8 @@ let package = Package(
resources: [
.copy("Resources/donkey-app-icon.png"),
.copy("Resources/google-continue-dark-rounded.png"),
+ .copy("Resources/menu-bar-icon.png"),
+ .copy("Resources/[email protected]"),
.copy("Resources/theme.json")
],
swiftSettings: [
diff --git a/apps/Donkey/Sources/Donkey/Donkey.swift b/apps/Donkey/Sources/Donkey/Donkey.swift
index e84fb68b..0abcc8fa 100644
--- a/apps/Donkey/Sources/Donkey/Donkey.swift
+++ b/apps/Donkey/Sources/Donkey/Donkey.swift
@@ -1,6 +1,6 @@
import AppKit
-// Donkey runs on the AppKit lifecycle: every surface — the notch overlay, onboarding,
+// Donkey runs on the AppKit lifecycle: every surface — the menu bar status item, onboarding,
// login, and the application menu — is built and owned by DonkeyAppDelegate. There is no
// SwiftUI scene, so nothing injects a "Settings…" item or competes with the delegate's
// own main menu (which already exposes Permissions Setup, Sign Out, and Show Onboarding).
diff --git a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
index 1740619b..3c90458b 100644
--- a/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
+++ b/apps/Donkey/Sources/Donkey/DonkeyAppDelegate.swift
@@ -13,16 +13,15 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
private var authCoordinator: DonkeyAuthCoordinator?
private var onboardingWindowController: OnboardingWindowController?
private var permissionSetupController: MacPermissionSetupWindowController?
- private var overlayController: UserQueryOverlayController?
+ /// The menu bar surface: the status item whose menu carries Go to App / Log in / Log out.
+ private var statusItemController: DonkeyStatusItemController?
+ /// Sparkle, running windowless. A background check that finds an update surfaces the status
+ /// menu's "Install Update" item; choosing it downloads, installs, and relaunches silently.
+ private var updateChecker: (any DonkeyUpdateChecking)?
private var uiUnderstandingCoordinator: UIUnderstandingCoordinator?
- /// Mirrors the auth coordinator's session phase into the overlay's `needsLogin`, so the notch
- /// flips to/from the login call-to-action as the session is established or expires.
+ /// Mirrors the auth coordinator's session phase into the process-wide session gate and the
+ /// session heartbeat for the whole run; the status menu reads the phase directly when it opens.
private var authStateCancellable: AnyCancellable?
- /// Periodically reconciles the out-of-credits reload CTA against the real balance, so it clears once the
- /// user tops up rather than lingering until relaunch. Paired with an app-reactivation observer for the
- /// common "topped up in the browser, came back" path. Both are torn down on sign-out.
- private var creditReloadPollTimer: Timer?
- private var creditReloadActiveObserver: NSObjectProtocol?
/// Periodically reconciles the app's session against the server, so a sign-out performed on the website
/// (or another device) takes effect here without a relaunch. A periodic tick plus an app-reactivation
/// observer fire a cheap auth-gated probe; a 401 routes through the usual session-expiry handling. Both
@@ -47,30 +46,46 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
let authCoordinator = DonkeyAuthCoordinator()
self.authCoordinator = authCoordinator
- // Seed the process-wide session gate before any surface is built, so the warm cache, Live
- // session, and auto-resume all see the real auth state on their first tick instead of the
- // optimistic default. The phase observer keeps it current from here on.
+ // Seed the process-wide session gate before any surface is built, so every backend consumer
+ // sees the real auth state on its first tick instead of the optimistic default. The phase
+ // observer keeps it current from here on.
BackendSessionGate.shared.update(isAuthenticated: authCoordinator.isAuthenticated)
authCoordinator.authenticationCompleted = { [weak self] _ in
- // Sign-in may have happened on the onboarding card's sign-in slide; close it before bringing
- // up the authenticated surfaces. `close()` clears the retain via onDismiss, and this is a
- // no-op when the card isn't showing (e.g. notch re-auth).
+ // Sign-in may have happened on the onboarding card's sign-in slide; close it. `close()`
+ // clears the retain via onDismiss, and this is a no-op when the card isn't showing
+ // (e.g. sign-in from the status menu).
self?.onboardingWindowController?.close()
- self?.startAuthenticatedAppSurfaces()
}
registerAuthCallbackHandler()
installMainMenu()
+ installStatusItem(authCoordinator: authCoordinator)
+ startUpdateChecker()
let cutEngineSupervisor = DonkeyCutEngineSupervisor()
self.cutEngineSupervisor = cutEngineSupervisor
cutEngineSupervisor.start()
- // First install (never signed in) opens the onboarding card on its sign-in landing. A returning
- // user whose session has expired skips it: the notch comes up in login mode (driven by the auth
- // phase observer) and carries them back through sign-in inline.
- if authCoordinator.isAuthenticated || authCoordinator.hasEverSignedIn {
- startAuthenticatedAppSurfaces()
- } else {
+ // The UI-understanding engine exists only to draw the developer debug overlay; the agent does
+ // not read from it. It parses the screen solely to render that overlay, so it is built only in
+ // debug-overlay builds and never in production.
+ #if DONKEY_DEBUG_OVERLAY
+ uiUnderstandingCoordinator = UIUnderstandingCoordinator(
+ overlayController: DebugUIInspectionOverlayController(),
+ rendersOverlay: true
+ )
+ #endif
+
+ // Drive the session gate, heartbeat, and debug overlay engine from the auth phase for the
+ // whole run. `$phase` replays the current value on subscription, so this also applies the
+ // launch state.
+ authStateCancellable = authCoordinator.$phase
+ .sink { [weak self] phase in
+ self?.applySessionState(isSignedIn: phase.isSignedIn)
+ }
+
+ // First install (never signed in) opens the onboarding card on its sign-in landing. A
+ // returning user signs in from the status menu instead.
+ if !authCoordinator.isAuthenticated && !authCoordinator.hasEverSignedIn {
presentOnboardingCard(entry: .signIn)
}
}
@@ -82,12 +97,12 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
}
func applicationDidBecomeActive(_ notification: Notification) {
- // The donkey:// sign-in callback can be serviced by a different app instance than the one rendering
- // the notch (LaunchServices cold-launching a second copy of this bundle id, which shares this
- // UserDefaults domain). That copy persists the session and exits, leaving this instance's in-memory
- // phase signed-out and the notch stuck on the login CTA. Clicking "Open Donkey" activates us, so
- // reconciling from the durable session here flips the phase — and the $phase observer flips the
- // notch — without a relaunch. A no-op when already signed in or when no session is on disk.
+ // The donkey:// sign-in callback can be serviced by a different app instance than this one
+ // (LaunchServices cold-launching a second copy of this bundle id, which shares this
+ // UserDefaults domain). That copy persists the session and exits, leaving this instance's
+ // in-memory phase signed-out and the status menu stuck on "Log in". Clicking "Open Donkey"
+ // activates us, so reconciling from the durable session here flips the phase — and the menu —
+ // without a relaunch. A no-op when already signed in or when no session is on disk.
authCoordinator?.reconcileWithPersistedSession()
}
@@ -97,8 +112,6 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
) -> Bool {
if authCoordinator?.isAuthenticated != true {
presentOnboardingCard(entry: .signIn)
- } else if overlayController == nil {
- startAuthenticatedAppSurfaces()
}
return true
}
@@ -112,7 +125,6 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
forEventClass: AEEventClass(kInternetEventClass),
andEventID: AEEventID(kAEGetURL)
)
- overlayController?.stop()
uiUnderstandingCoordinator?.stop()
cutEngineSupervisor?.stop()
}
@@ -178,106 +190,52 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
)
}
- private func startAuthenticatedAppSurfaces() {
- guard overlayController == nil else { return }
-
- onboardingWindowController?.close()
- NSApp.setActivationPolicy(.regular)
-
- // Launch never opens the permission setup window: many users install Donkey only for Cut and
- // need none of these grants. A task that needs a permission asks in the notch mid-conversation
- // (the harness permission gate), and the window stays reachable via the Permissions Setup menu.
- startOverlaySurfaces()
+ // MARK: - Status item
+
+ private func installStatusItem(authCoordinator: DonkeyAuthCoordinator) {
+ statusItemController = DonkeyStatusItemController(
+ isSignedIn: { [weak authCoordinator] in
+ authCoordinator?.isAuthenticated == true
+ },
+ logIn: { [weak authCoordinator] in
+ authCoordinator?.beginGoogleSignIn()
+ },
+ logOut: { [weak self] in
+ self?.signOut()
+ },
+ checkForUpdates: { [weak self] in
+ self?.updateChecker?.checkForUpdatesInBackground()
+ },
+ installUpdate: { [weak self] in
+ self?.updateChecker?.installAvailableUpdate()
+ }
+ )
}
- private func startOverlaySurfaces() {
- guard overlayController == nil else { return }
-
- // Voice button transcription: Apple's on-device speech is preferred; Gemini is
- // the automatic fallback when the local path is unavailable or fails.
- let voiceTranscriber = LocalVoiceTranscriptionAdapter(
- runtime: FallbackVoiceTranscriptionRuntime(runtimes: [
- AppleSpeechVoiceTranscriptionRuntime(),
- GeminiVoiceTranscriptionRuntime()
- ])
- )
- let model = UserQueryOverlayModel(voiceTranscriber: voiceTranscriber)
+ // MARK: - Updates
- // The notch Login button starts the real Google sign-in; the auth phase drives whether the
- // notch shows the login call-to-action, so an expired session surfaces here without a window.
- model.loginActionRequested = { [weak self] in
- self?.authCoordinator?.beginGoogleSignIn()
- }
- // A mid-run 401 expired the session: sign out (clears the dead cookie, flips phase to signedOut)
- // so the $phase observer below sets needsLogin — surfacing the notch login WITHOUT tearing down
- // the overlay or opening the window, so running tasks stay put and re-auth happens inline. The
- // server already revoked this session (that's what the 401 means), so this is local cleanup only.
- model.sessionExpired = { [weak self] in
- self?.authCoordinator?.signOut(revokingRemoteSessions: false)
+ private func startUpdateChecker() {
+ let updateChecker = SparkleUpdateController()
+ self.updateChecker = updateChecker
+ updateChecker.updateStateChanged = { [weak self] state in
+ self?.statusItemController?.updateState = state
}
- if let authCoordinator {
- model.updateNeedsLogin(!authCoordinator.isAuthenticated)
- authStateCancellable = authCoordinator.$phase
- .sink { [weak self, weak model] phase in
- model?.updateNeedsLogin(!phase.isSignedIn)
- self?.applySessionState(isSignedIn: phase.isSignedIn, model: model)
- }
- }
-
- // Keep the out-of-credits CTA honest: poll the balance while any task is credit-blocked and clear
- // the CTA the moment a top-up lands, so it doesn't linger until the next relaunch.
- startCreditReloadReconciler(model: model)
-
- // Warm the on-device speech model in the background so the first voice command
- // isn't blocked behind a model download.
- AppleSpeechVoiceTranscriptionRuntime.prewarm()
- let controller = UserQueryOverlayController(model: model)
- overlayController = controller
- controller.show()
-
- // Now that the notch surface is live, kick off the first-run download of the bundled CLI tools
- // (ffmpeg/yt-dlp/...). It surfaces as a system-driven conversation the user can watch but not stop,
- // and no-ops once the current version is installed or when nothing is published — so this is cheap
- // to call on every launch and re-sign-in. Tools are only used by agent tasks (which need sign-in),
- // so downloading once the authenticated notch is up — rather than before login — is the right time.
- model.startSystemToolsSetupIfNeeded()
-
- // Run as a regular app so Donkey keeps a Dock icon and its menu bar (including Sign Out)
- // while the overlay surfaces are live, instead of receding into an accessory agent.
- NSApp.setActivationPolicy(.regular)
-
- // The UI-understanding engine exists only to draw the developer debug overlay; the agent does
- // not read from it. It parses the screen solely to render that overlay, so it is built only in
- // debug-overlay builds and never in production. The agent's only vision source is the on-demand
- // `vision.capture` tool inside a live run.
- #if DONKEY_DEBUG_OVERLAY
- let uiUnderstandingCoordinator = UIUnderstandingCoordinator(
- overlayController: DebugUIInspectionOverlayController(),
- rendersOverlay: true
- )
- self.uiUnderstandingCoordinator = uiUnderstandingCoordinator
- #endif
-
- // Start the debug overlay engine (if any) only while signed in; the phase observer above stops
- // and restarts it as the session changes (its parse pass would otherwise 401 while signed out).
- applySessionState(isSignedIn: authCoordinator?.isAuthenticated == true, model: model)
+ updateChecker.start()
}
- /// Drive the process-wide session gate, the debug overlay engine, and the Live session from the auth
- /// phase. Signed out: close the gate (every backend call short-circuits to `.authenticationRequired`
- /// with no network round trip) and suspend the overlay engine and Live session, so a logged-out app
- /// stops issuing guaranteed-401 requests. Signed in: reopen the gate and restart them. Idempotent —
- /// `start()`/`stop()` are safe to call repeatedly, and the coordinator is nil outside debug-overlay
- /// builds.
- private func applySessionState(isSignedIn: Bool, model: UserQueryOverlayModel?) {
+ /// Drive the process-wide session gate, the debug overlay engine, and the session heartbeat from
+ /// the auth phase. Signed out: close the gate (every backend call short-circuits to
+ /// `.authenticationRequired` with no network round trip) and suspend the overlay engine, so a
+ /// logged-out app stops issuing guaranteed-401 requests. Signed in: reopen the gate and restart
+ /// them. Idempotent — `start()`/`stop()` are safe to call repeatedly, and the coordinator is nil
+ /// outside debug-overlay builds.
+ private func applySessionState(isSignedIn: Bool) {
BackendSessionGate.shared.update(isAuthenticated: isSignedIn)
if isSignedIn {
uiUnderstandingCoordinator?.start()
- model?.resumeLiveSession()
- if let model { startSessionHeartbeat(model: model) }
+ startSessionHeartbeat()
} else {
uiUnderstandingCoordinator?.stop()
- model?.suspendLiveSession()
stopSessionHeartbeat()
}
}
@@ -287,29 +245,27 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
/// Starts the session heartbeat: a periodic tick plus an app-reactivation observer, each firing a cheap
/// session-validity probe, plus one immediate probe. Idempotent — a no-op while already running, so the
/// auth-phase observer can call it freely. Torn down by `stopSessionHeartbeat` on sign-out.
- private func startSessionHeartbeat(model: UserQueryOverlayModel) {
+ private func startSessionHeartbeat() {
guard sessionHeartbeatTimer == nil else { return }
- sessionHeartbeatTimer = Timer.scheduledTimer(withTimeInterval: 60, repeats: true) { [weak self, weak model] _ in
+ sessionHeartbeatTimer = Timer.scheduledTimer(withTimeInterval: 60, repeats: true) { [weak self] _ in
Task { @MainActor in
- guard let self, let model else { return }
- self.probeSessionValidity(model: model)
+ self?.probeSessionValidity()
}
}
sessionHeartbeatActiveObserver = NotificationCenter.default.addObserver(
forName: NSApplication.didBecomeActiveNotification,
object: nil,
queue: .main
- ) { [weak self, weak model] _ in
+ ) { [weak self] _ in
Task { @MainActor in
- guard let self, let model else { return }
- self.probeSessionValidity(model: model)
+ self?.probeSessionValidity()
}
}
- // A locally-stored session can already be dead server-side; probe right away so the notch shows
- // login immediately instead of only on the first real query's 401.
- probeSessionValidity(model: model)
+ // A locally-stored session can already be dead server-side; probe right away so the status menu
+ // shows "Log in" immediately instead of only on the first real query's 401.
+ probeSessionValidity()
}
private func stopSessionHeartbeat() {
@@ -322,18 +278,20 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
}
/// Confirms the session is still valid server-side. Fires one cheap, auth-gated GET
- /// (`/api/inference/models/`); a 401 routes through the model's session-expiry handling (sign out →
- /// notch login) via the inference client's auth-expiry callback. Network or other errors are ignored
- /// so a transient hiccup never signs the user out.
- private func probeSessionValidity(model: UserQueryOverlayModel) {
+ /// (`/api/inference/models/`); a 401 clears the dead local session — the server already revoked it,
+ /// so this is local cleanup only — which flips the status menu to "Log in" via the phase observer.
+ /// Network or other errors are ignored so a transient hiccup never signs the user out.
+ private func probeSessionValidity() {
guard authCoordinator?.isAuthenticated == true,
let configuration = try? DonkeyBackendInferenceConfiguration.fromEnvironment()
else { return }
let backend = DonkeyBackendInferenceClient(
configuration: configuration,
- onAuthenticationRequired: { [weak model] in
- Task { @MainActor in model?.handleSessionExpired() }
+ onAuthenticationRequired: { [weak self] in
+ Task { @MainActor in
+ self?.authCoordinator?.signOut(revokingRemoteSessions: false)
+ }
}
)
Task {
@@ -341,67 +299,6 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
}
}
- // MARK: - Credit reload reconciliation
-
- /// Once a task is flagged out-of-credits, nothing in-app retries after the user tops up, so the notch's
- /// reload CTA would linger until relaunch. Reconcile it against the real balance: a periodic tick while any
- /// task carries the flag (and only then — the tick is a free no-op otherwise), plus an app-reactivation
- /// trigger so returning from the billing page in the browser clears the CTA right away.
- private func startCreditReloadReconciler(model: UserQueryOverlayModel) {
- creditReloadPollTimer?.invalidate()
- creditReloadPollTimer = Timer.scheduledTimer(withTimeInterval: 30, repeats: true) { [weak self, weak model] _ in
- Task { @MainActor in
- guard let self, let model else { return }
- self.reconcileCreditReload(model: model)
- }
- }
- if let creditReloadActiveObserver {
- NotificationCenter.default.removeObserver(creditReloadActiveObserver)
- }
- creditReloadActiveObserver = NotificationCenter.default.addObserver(
- forName: NSApplication.didBecomeActiveNotification,
- object: nil,
- queue: .main
- ) { [weak self, weak model] _ in
- Task { @MainActor in
- guard let self, let model else { return }
- self.reconcileCreditReload(model: model)
- }
- }
- }
-
- private func stopCreditReloadReconciler() {
- creditReloadPollTimer?.invalidate()
- creditReloadPollTimer = nil
- if let creditReloadActiveObserver {
- NotificationCenter.default.removeObserver(creditReloadActiveObserver)
- self.creditReloadActiveObserver = nil
- }
- }
-
- /// One reconciliation pass: skip entirely unless a task is credit-blocked and the session is usable, then
- /// fetch the balance and clear the CTA across every flagged task once it goes positive. A 401 routes
- /// through the same session-expiry handling as every other backend call; any other error is ignored so a
- /// transient hiccup leaves the CTA in place for the next pass.
- private func reconcileCreditReload(model: UserQueryOverlayModel) {
- guard model.hasPendingCreditReload,
- BackendSessionGate.shared.isAuthenticated,
- let configuration = try? DonkeyBackendInferenceConfiguration.fromEnvironment()
- else { return }
-
- let backend = DonkeyBackendInferenceClient(
- configuration: configuration,
- onAuthenticationRequired: { [weak model] in
- Task { @MainActor in model?.handleSessionExpired() }
- }
- )
- Task { @MainActor [weak model] in
- guard let balanceMicros = try? await backend.fetchCreditBalanceMicros(),
- balanceMicros > 0 else { return }
- model?.clearPendingCreditReload()
- }
- }
-
// MARK: - Sign out
@objc private func signOutMenuAction(_ sender: Any?) {
@@ -414,8 +311,7 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
// MARK: - Permissions setup
- /// Opens the Accessibility / screenshot / microphone permission walkthrough on demand — the only
- /// way this window appears besides a task's in-notch permission request.
+ /// Opens the Accessibility / screenshot / microphone permission walkthrough on demand.
@objc private func permissionsSetupMenuAction(_ sender: Any?) {
let controller = MacPermissionSetupWindowController()
permissionSetupController = controller
@@ -427,22 +323,9 @@ final class DonkeyAppDelegate: NSObject, NSApplicationDelegate {
private func signOut() {
// User-initiated: revoke every session for this user so the website (and any other device) signs
- // out too, then tear down local surfaces and surface the onboarding card on its sign-in landing.
+ // out too. The phase observer tears down the session-bound machinery, and the status menu flips
+ // to "Log in" the next time it opens.
authCoordinator?.signOut(revokingRemoteSessions: true)
- teardownAuthenticatedSurfaces()
- presentOnboardingCard(entry: .signIn)
- }
-
- /// Tears down the live overlay/runtime surfaces so a later sign-in can rebuild them cleanly.
- /// `startAuthenticatedAppSurfaces()` guards on these being nil, so they must be reset here.
- private func teardownAuthenticatedSurfaces() {
- authStateCancellable = nil
- stopCreditReloadReconciler()
- stopSessionHeartbeat()
- uiUnderstandingCoordinator?.stop()
- uiUnderstandingCoordinator = nil
- overlayController?.stop()
- overlayController = nil
}
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
diff --git a/apps/Donkey/Sources/Donkey/DonkeyStatusItemController.swift b/apps/Donkey/Sources/Donkey/DonkeyStatusItemController.swift
new file mode 100644
index 00000000..4a017030
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/DonkeyStatusItemController.swift
@@ -0,0 +1,129 @@
+import AppKit
+import DonkeyContracts
+
+/// The menu bar entry point: a status item with the Donkey glyph whose menu follows the
+/// session — "Go to App" and "Log out" while signed in, "Log in" while signed out — plus an
+/// install item whenever a Sparkle background check has an update waiting. The menu is rebuilt
+/// each time it opens, so it always reflects the current auth and update state without push
+/// updates from the app delegate.
+@MainActor
+final class DonkeyStatusItemController: NSObject, NSMenuDelegate {
+ /// The hosted app "Go to App" opens — the Cut app, same destination as the billing page's host.
+ private static let appURL = URL(string: "https://donkeycut.com/app")!
+
+ private let statusItem: NSStatusItem
+ private let isSignedIn: () -> Bool
+ private let logIn: () -> Void
+ private let logOut: () -> Void
+ private let checkForUpdates: () -> Void
+ private let installUpdate: () -> Void
+
+ /// Latest update-checker state; drives the update section of the menu.
+ var updateState: UserQueryUpdateState?
+
+ init(
+ isSignedIn: @escaping () -> Bool,
+ logIn: @escaping () -> Void,
+ logOut: @escaping () -> Void,
+ checkForUpdates: @escaping () -> Void,
+ installUpdate: @escaping () -> Void
+ ) {
+ self.isSignedIn = isSignedIn
+ self.logIn = logIn
+ self.logOut = logOut
+ self.checkForUpdates = checkForUpdates
+ self.installUpdate = installUpdate
+ statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
+ super.init()
+
+ statusItem.button?.image = Self.menuBarIcon()
+ let menu = NSMenu()
+ menu.delegate = self
+ statusItem.menu = menu
+ }
+
+ deinit {
+ MainActor.assumeIsolated {
+ NSStatusBar.system.removeStatusItem(statusItem)
+ }
+ }
+
+ func menuNeedsUpdate(_ menu: NSMenu) {
+ menu.removeAllItems()
+
+ if isSignedIn() {
+ menu.addItem(makeItem(title: "Go to App", action: #selector(goToAppAction)))
+ menu.addItem(makeItem(title: "Log out", action: #selector(logOutAction)))
+ } else {
+ menu.addItem(makeItem(title: "Log in", action: #selector(logInAction)))
+ }
+
+ menu.addItem(.separator())
+ menu.addItem(updateItem())
+
+ menu.addItem(.separator())
+ menu.addItem(makeItem(title: "Quit Donkey", action: #selector(quitAction), keyEquivalent: "q"))
+ }
+
+ private func makeItem(title: String, action: Selector, keyEquivalent: String = "") -> NSMenuItem {
+ let item = NSMenuItem(title: title, action: action, keyEquivalent: keyEquivalent)
+ item.target = self
+ return item
+ }
+
+ /// The update section's single item, following the checker state: "Check for Updates" at rest,
+ /// a disabled progress line while checking or installing, and "Update App" once a check has an
+ /// update waiting — choosing it downloads, installs, quits, and relaunches automatically.
+ private func updateItem() -> NSMenuItem {
+ switch updateState?.status {
+ case .available:
+ let title = updateState?.latestVersion.map { "Update App (\($0))" } ?? "Update App"
+ return makeItem(title: title, action: #selector(installUpdateAction))
+ case .checking:
+ return NSMenuItem(title: "Checking for Updates…", action: nil, keyEquivalent: "")
+ case .installing:
+ return NSMenuItem(title: "Updating…", action: nil, keyEquivalent: "")
+ default:
+ return makeItem(title: "Check for Updates", action: #selector(checkForUpdatesAction))
+ }
+ }
+
+ @objc private func goToAppAction(_ sender: Any?) {
+ NSWorkspace.shared.open(Self.appURL)
+ }
+
+ @objc private func logInAction(_ sender: Any?) {
+ logIn()
+ }
+
+ @objc private func logOutAction(_ sender: Any?) {
+ logOut()
+ }
+
+ @objc private func checkForUpdatesAction(_ sender: Any?) {
+ checkForUpdates()
+ }
+
+ @objc private func installUpdateAction(_ sender: Any?) {
+ installUpdate()
+ }
+
+ @objc private func quitAction(_ sender: Any?) {
+ NSApp.terminate(nil)
+ }
+
+ /// The donkey glyph as a template image: pure black plus alpha, so the system recolors it
+ /// for light/dark menu bars and the selected state (Apple's status-item guideline).
+ private static func menuBarIcon() -> NSImage {
+ let image = NSImage(size: NSSize(width: 21, height: 21))
+ for resource in ["menu-bar-icon", "menu-bar-icon@2x"] {
+ guard let url = Bundle.module.url(forResource: resource, withExtension: "png"),
+ let data = try? Data(contentsOf: url),
+ let representation = NSBitmapImageRep(data: data) else { continue }
+ representation.size = image.size
+ image.addRepresentation(representation)
+ }
+ image.isTemplate = true
+ return image
+ }
+}
diff --git a/apps/Donkey/Sources/Donkey/Resources/menu-bar-icon.png b/apps/Donkey/Sources/Donkey/Resources/menu-bar-icon.png
new file mode 100644
index 00000000..2d1ea5ff
Binary files /dev/null and b/apps/Donkey/Sources/Donkey/Resources/menu-bar-icon.png differ
diff --git a/apps/Donkey/Sources/Donkey/Resources/[email protected] b/apps/Donkey/Sources/Donkey/Resources/[email protected]
new file mode 100644
index 00000000..5ac05bbf
Binary files /dev/null and b/apps/Donkey/Sources/Donkey/Resources/[email protected] differ
diff --git a/docs/README.md b/docs/README.md
index 95a51c86..dd5c2cc1 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -26,8 +26,8 @@ Supported product and engineering guides live in `docs/guides/`. This list is th
**Mac app surfaces**
-- [Notch](guides/notch.md) — the always-on top-center surface: task states, controls, and streaming narration.
-- [User Query Overlay](guides/user-query-overlay.md) — the floating prompt composer and agent cursors, and their grounded-only, cosmetic contract.
+- [Notch](guides/notch.md) — the top-center surface: task states, controls, and streaming narration. Currently disabled; the app runs as a menu bar app.
+- [User Query Overlay](guides/user-query-overlay.md) — the floating prompt composer and agent cursors, and their grounded-only, cosmetic contract. Currently disabled with the notch.
- [Permission Pre-Gate](guides/permission-gate.md) — how macOS permissions are approved in the notch before the system dialog appears.
**Extending the agent**
diff --git a/docs/guides/notch.md b/docs/guides/notch.md
index c5ea8183..0dc4e53a 100644
--- a/docs/guides/notch.md
+++ b/docs/guides/notch.md
@@ -1,5 +1,10 @@
# Notch
+> **Disabled.** The Mac app now runs as a menu bar app: a status item with
+> Go to App / Log in / Log out. The app delegate no longer builds the notch
+> overlay; the subsystem below stays in the codebase but is not shown in any
+> build. This guide describes the surface as it behaves when wired in.
+
The notch is Donkey's always-on surface at the top center of the screen. It
works at two scales: a small bar you glance at, and a panel you open to see
every task and type a new one. This guide is the anatomy and behavior contract
diff --git a/docs/guides/user-query-overlay.md b/docs/guides/user-query-overlay.md
index 6c0aa2e6..5c56e86f 100644
--- a/docs/guides/user-query-overlay.md
+++ b/docs/guides/user-query-overlay.md
@@ -1,5 +1,10 @@
# User Query Overlay
+> **Disabled.** The Mac app now runs as a menu bar app; the app delegate no
+> longer builds the overlay. The subsystem below stays in the codebase but is
+> not shown in any build. This guide describes the surface as it behaves when
+> wired in.
+
The user query overlay is Donkey's floating macOS surface: a top-center notch
status area, a centered prompt composer, and spawned agent cursors that show
what each task is doing. It is how every typed, voice, and follow-up turn