Skip to content

Open source CapCut alternative.

TypeScript

feat(app): live onboarding slide mocks in a folder

David Le427777521d31
diff --git a/apps/Donkey/Sources/Donkey/Onboarding.swift b/apps/Donkey/Sources/Donkey/Onboarding/Onboarding.swift
similarity index 80%
rename from apps/Donkey/Sources/Donkey/Onboarding.swift
rename to apps/Donkey/Sources/Donkey/Onboarding/Onboarding.swift
index da6cbc14..835a6c75 100644
--- a/apps/Donkey/Sources/Donkey/Onboarding.swift
+++ b/apps/Donkey/Sources/Donkey/Onboarding/Onboarding.swift
@@ -28,8 +28,12 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
/// module bundle.
let stringsBundle: Bundle?
/// Per-slide gradient backdrop rendered behind the artwork. When `nil`, the
- /// slide falls back to the card's flat dark fill.
+ /// slide falls back to the card's flat cream fill.
let background: OnboardingSlideBackground?
+ /// What fills the artwork region: a static image by default, or a live mock
+ /// (the screen edge with the collapsed→expanded notch) on the slides that
+ /// demo the app.
+ let artwork: OnboardingArtwork
init(
id: UUID = UUID(),
@@ -39,7 +43,8 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
description: LocalizedStringKey,
tableName: String? = nil,
stringsBundle: Bundle? = nil,
- background: OnboardingSlideBackground? = nil
+ background: OnboardingSlideBackground? = nil,
+ artwork: OnboardingArtwork = .image
) {
self.id = id
self.imageName = imageName
@@ -49,6 +54,7 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
self.tableName = tableName
self.stringsBundle = stringsBundle
self.background = background
+ self.artwork = artwork
}
/// Bundle used for localized string lookup. Prefers `stringsBundle`, then
@@ -66,11 +72,27 @@ struct OnboardingPage: Identifiable, Hashable, @unchecked Sendable {
}
}
-/// A per-slide gradient backdrop. Every slide shares the same blue wash; only
-/// the spotlight distinguishes them — its position moves and its intensity
-/// visibly brightens and dims as the walkthrough advances.
+/// The onboarding card mirrors the donkeyuse.com landing palette — a warm cream
+/// surface, near-black ink for text and borders, and a coral primary action —
+/// rather than a dark card with a blue glow. Values track `site`'s theme.ts.
+enum OnboardingPalette {
+ /// Page surface — landing `BG` #F5EFE0.
+ static let cream = Color(red: 0.961, green: 0.937, blue: 0.878)
+ /// A lighter cream for the top of the slide wash — landing cream #FAF6EC.
+ static let creamLight = Color(red: 0.980, green: 0.965, blue: 0.925)
+ /// Text, borders, shadows — landing `BLACK` #0F0E0D.
+ static let ink = Color(red: 0.059, green: 0.055, blue: 0.051)
+ /// Secondary body copy — landing body gray #454545.
+ static let bodyGray = Color(red: 0.271, green: 0.271, blue: 0.271)
+ /// Primary action — landing `CORAL` #EC7868.
+ static let coral = Color(red: 0.925, green: 0.471, blue: 0.408)
+}
+
+/// A per-slide backdrop over the shared cream wash. Every slide shares the same
+/// wash; only the spotlight distinguishes them — its position moves and its
+/// intensity brightens and dims as the walkthrough advances.
struct OnboardingSlideBackground: Sendable {
- /// Where the spotlight bloom sits over the shared blue wash.
+ /// Where the spotlight bloom sits over the shared cream wash.
var bloomCenter: UnitPoint
/// Bloom strength, 0...1. Spread widely across slides so the brightness
/// shift reads clearly from one slide to the next.
@@ -78,19 +100,19 @@ struct OnboardingSlideBackground: Sendable {
/// The colour the wash resolves to at the bottom edge — matched to the card
/// fill so the gradient seams invisibly into the text panel below.
- static let baseFill = Color(white: 0.10)
+ static let baseFill = OnboardingPalette.cream
}
struct OnboardingSlideBackgroundView: View {
let background: OnboardingSlideBackground
- /// The shared blue wash. Every slide uses these exact colours; only the
+ /// The shared cream wash. Every slide uses these exact colours; only the
/// spotlight (position + intensity) changes between slides.
- private static let washTop = Color(red: 0.12, green: 0.60, blue: 1.0)
- private static let washMiddle = Color(red: 0.05, green: 0.45, blue: 0.95)
- /// Bright sky-blue spotlight — kept blue rather than white so a strong bloom
- /// glows without washing the hue out.
- private static let bloomColor = Color(red: 0.60, green: 0.82, blue: 1.0)
+ private static let washTop = OnboardingPalette.creamLight
+ private static let washMiddle = OnboardingPalette.cream
+ /// A soft coral spotlight — the landing accent, screened over the cream so a
+ /// strong bloom warms the slide without reading as a glow.
+ private static let bloomColor = OnboardingPalette.coral
var body: some View {
ZStack {
@@ -184,11 +206,11 @@ struct OnboardingSlideshowView: View {
imageSection
bottomPanel
}
- .background(Color(white: 0.10))
+ .background(OnboardingPalette.cream)
.clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))
.overlay {
RoundedRectangle(cornerRadius: 20, style: .continuous)
- .stroke(Color.white.opacity(0.10), lineWidth: 1)
+ .strokeBorder(OnboardingPalette.ink, lineWidth: 2)
}
}
}
@@ -248,9 +270,7 @@ struct OnboardingSlideshowView: View {
.transition(.opacity)
}
- image(for: pages[currentIndex])
- .resizable()
- .scaledToFit()
+ artworkLayer(for: pages[currentIndex])
.frame(width: width, height: imageHeight)
.id(currentIndex)
.transition(.opacity)
@@ -258,10 +278,10 @@ struct OnboardingSlideshowView: View {
LinearGradient(
stops: [
.init(color: .clear, location: 0),
- .init(color: Color(white: 0.10).opacity(0.15), location: 0.25),
- .init(color: Color(white: 0.10).opacity(0.45), location: 0.50),
- .init(color: Color(white: 0.10).opacity(0.80), location: 0.75),
- .init(color: Color(white: 0.10), location: 1.0)
+ .init(color: OnboardingPalette.cream.opacity(0.15), location: 0.25),
+ .init(color: OnboardingPalette.cream.opacity(0.45), location: 0.50),
+ .init(color: OnboardingPalette.cream.opacity(0.80), location: 0.75),
+ .init(color: OnboardingPalette.cream, location: 1.0)
],
startPoint: .top,
endPoint: .bottom
@@ -294,14 +314,15 @@ struct OnboardingSlideshowView: View {
return VStack(spacing: 0) {
Text(currentPage.title, tableName: currentPage.tableName, bundle: currentPage.resolvedStringsBundle)
.font(.system(size: 28, weight: .semibold))
+ .tracking(-0.8)
.multilineTextAlignment(.center)
- .foregroundStyle(.white)
+ .foregroundStyle(OnboardingPalette.ink)
.fixedSize(horizontal: false, vertical: true)
Text(currentPage.description, tableName: currentPage.tableName, bundle: currentPage.resolvedStringsBundle)
.font(.system(size: 18))
.multilineTextAlignment(.center)
- .foregroundStyle(Color.white.opacity(0.70))
+ .foregroundStyle(OnboardingPalette.bodyGray)
.fixedSize(horizontal: false, vertical: true)
.padding(.top, 6)
@@ -414,21 +435,10 @@ struct OnboardingSlideshowView: View {
Button(action: action) {
Text(title, tableName: buttonTableName, bundle: buttonBundle)
.font(.system(size: 15, weight: .semibold))
- .foregroundStyle(.white)
+ .foregroundStyle(OnboardingPalette.ink)
.frame(width: 220, height: Self.capsuleButtonHeight)
- .background(
- Capsule(style: .continuous)
- .fill(
- LinearGradient(
- colors: [
- Color(red: 0.10, green: 0.60, blue: 1.0),
- Color(red: 0.04, green: 0.46, blue: 0.96)
- ],
- startPoint: .top,
- endPoint: .bottom
- )
- )
- )
+ .background(Capsule(style: .continuous).fill(OnboardingPalette.coral))
+ .overlay(Capsule(style: .continuous).strokeBorder(OnboardingPalette.ink, lineWidth: 2))
.clipShape(Capsule(style: .continuous))
.contentShape(Capsule(style: .continuous))
}
@@ -446,7 +456,7 @@ struct OnboardingSlideshowView: View {
.font(.system(size: 10, weight: .semibold))
}
.font(.system(size: 13, weight: .medium))
- .foregroundStyle(.white.opacity(0.72))
+ .foregroundStyle(OnboardingPalette.bodyGray)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
@@ -458,18 +468,12 @@ struct OnboardingSlideshowView: View {
Button(action: action) {
Image(systemName: systemName)
.font(.system(size: 13, weight: .semibold))
- .foregroundStyle(.white.opacity(0.88))
+ .foregroundStyle(OnboardingPalette.ink)
.frame(width: 32, height: 32)
.background {
- if #available(macOS 26.0, iOS 26.0, *) {
- Circle()
- .fill(.ultraThinMaterial)
- .overlay {
- Circle().stroke(Color.white.opacity(0.25), lineWidth: 0.5)
- }
- } else {
- Circle().fill(Color.white.opacity(0.15))
- }
+ Circle()
+ .fill(Color.white)
+ .overlay { Circle().strokeBorder(OnboardingPalette.ink, lineWidth: 1.5) }
}
.contentShape(Circle())
}
@@ -518,6 +522,32 @@ struct OnboardingSlideshowView: View {
currentIndex = target
}
+ /// The artwork region's content: the live notch mock on demo slides,
+ /// otherwise the slide's static image.
+ @ViewBuilder
+ private func artworkLayer(for page: OnboardingPage) -> some View {
+ switch page.artwork {
+ case .image:
+ image(for: page)
+ .resizable()
+ .scaledToFit()
+ case .notchMock(let conversations):
+ OnboardingNotchMock(conversations: conversations, mode: .loop)
+ case .notchPanel(let conversations):
+ OnboardingNotchMock(conversations: conversations, mode: .expandedPanel)
+ case .notchComposer(let conversations):
+ OnboardingNotchMock(conversations: conversations, mode: .openComposer)
+ case .notchCompose(let conversations):
+ OnboardingNotchMock(conversations: conversations, mode: .composeAndRun)
+ case .inputMock(let commands):
+ OnboardingInputMock(commands: commands)
+ case .signInMock(let commands):
+ OnboardingSignInMock(commands: commands)
+ case .inputSummon(let commands):
+ OnboardingInputMock(commands: commands, mode: .commandSummon)
+ }
+ }
+
private func image(for page: OnboardingPage) -> Image {
if let bundle = page.imageBundle,
let image = platformImage(named: page.imageName, in: bundle) {
@@ -755,14 +785,15 @@ private struct OnboardingBottomPanelSizingView: View {
VStack(spacing: 0) {
Text(page.title, tableName: page.tableName, bundle: page.resolvedStringsBundle)
.font(.system(size: 28, weight: .semibold))
+ .tracking(-0.8)
.multilineTextAlignment(.center)
- .foregroundStyle(.white)
+ .foregroundStyle(OnboardingPalette.ink)
.fixedSize(horizontal: false, vertical: true)
Text(page.description, tableName: page.tableName, bundle: page.resolvedStringsBundle)
.font(.system(size: 18))
.multilineTextAlignment(.center)
- .foregroundStyle(Color.white.opacity(0.70))
+ .foregroundStyle(OnboardingPalette.bodyGray)
.fixedSize(horizontal: false, vertical: true)
.padding(.top, 6)
@@ -810,7 +841,7 @@ struct OnboardingPageIndicator: View {
onSelect(index)
} label: {
Capsule(style: .continuous)
- .fill(isCurrent ? Color.white.opacity(0.95) : Color.white.opacity(0.32))
+ .fill(isCurrent ? OnboardingPalette.ink.opacity(0.95) : OnboardingPalette.ink.opacity(0.28))
.frame(width: dotWidth, height: 8)
// Grow the hit target around the small dot — the gap to
// its neighbour plus a comfortable vertical band — without
@@ -828,13 +859,23 @@ struct OnboardingPageIndicator: View {
// MARK: - Default onboarding content
-/// The slides shown on first launch. Artwork is loaded from the app resource
-/// bundle by `imageName`; the named images don't ship yet, so each slide
-/// currently renders with an empty (dark) artwork area. To add screenshots,
-/// drop 16:10 images into `apps/Donkey/Sources/Donkey/Resources/`, register
-/// them as `.copy(...)` resources in `Package.swift`, and name them to match
-/// the `imageName` values below.
+/// The slides shown on first launch. Each slide's artwork is a live mock (see
+/// `OnboardingArtwork`): the sign-in and "ask" slides type out example commands
+/// in the Donkey field, the others drop the notch out of the screen edge and run
+/// a task. A slide left as `.image` instead loads `imageName` from the app
+/// resource bundle — drop a 16:10 image into
+/// `apps/Donkey/Sources/Donkey/Resources/` and register it in `Package.swift`.
enum OnboardingTour {
+ /// Example commands the input-field mock types out, drawn from the eval
+ /// fixtures — concrete, everyday tasks a user actually wants done.
+ static let exampleCommands: [String] = [
+ "give me a markdown of donkeyuse.com",
+ "create a playlist with the top 10 songs from 2021",
+ "turn on dark mode and enable Night Shift",
+ "extract the table from q3-figures.pdf into a CSV",
+ "split book.pdf into one file per chapter"
+ ]
+
/// The sign-in landing — the first slide when signed out. Its call-to-action
/// is the injected Google sign-in footer plus an Explore link into the
/// walkthrough, which ends on the closing slide's own Google button.
@@ -843,7 +884,8 @@ enum OnboardingTour {
imageBundle: DonkeyResourceBundle.app,
title: "Sign in to Donkey",
description: "Continue with Google to put Donkey to work on your Mac.",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.50, y: 0.16), bloomIntensity: 0.95)
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.50, y: 0.16), bloomIntensity: 0.95),
+ artwork: .signInMock(exampleCommands)
)
/// The walkthrough body — reached by Explore (signed out) or shown directly
@@ -854,28 +896,62 @@ enum OnboardingTour {
imageBundle: DonkeyResourceBundle.app,
title: "Meet Donkey",
description: "The workhorse for your Mac. Tell it what you want done — then go do something else.",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.26, y: 0.30), bloomIntensity: 0.30)
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.26, y: 0.30), bloomIntensity: 0.30),
+ artwork: .notchCompose([
+ OnboardingMockConversation(
+ id: "welcome-running",
+ accentIndex: 3,
+ prompt: "summarize report.pdf into a one-page brief and save it to my Desktop",
+ status: "Reading the PDF",
+ elapsedOffset: 0
+ ),
+ OnboardingMockConversation(
+ id: "welcome-idle",
+ accentIndex: 6,
+ prompt: "split book.pdf into one file per chapter",
+ status: "Done",
+ elapsedOffset: 0,
+ isRunning: false
+ )
+ ])
),
OnboardingPage(
imageName: "onboarding-ask",
imageBundle: DonkeyResourceBundle.app,
title: "Ask it for anything",
description: "Fill out PDFs, create a website, clip a YouTube video. Command it and Donkey works out the rest.",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.74, y: 0.18), bloomIntensity: 0.60)
- ),
- OnboardingPage(
- imageName: "onboarding-apps",
- imageBundle: DonkeyResourceBundle.app,
- title: "It works your apps for you",
- description: "Donkey clicks, types, and navigates across the apps you already use.",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.50, y: 0.40), bloomIntensity: 0.50)
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.74, y: 0.18), bloomIntensity: 0.60),
+ artwork: .inputSummon(Self.exampleCommands)
),
OnboardingPage(
imageName: "onboarding-parallel",
imageBundle: DonkeyResourceBundle.app,
title: "Hand it three jobs at once",
description: "Donkey runs several conversations in parallel, so nothing waits in line. Kick off a task, start another, come back when they're done.",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.80, y: 0.22), bloomIntensity: 0.80)
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.80, y: 0.22), bloomIntensity: 0.80),
+ artwork: .notchPanel([
+ OnboardingMockConversation(
+ id: "parallel-1",
+ accentIndex: 0,
+ prompt: "fill out f1120.pdf using 1120data.txt",
+ status: "Filling the form fields",
+ elapsedOffset: 47
+ ),
+ OnboardingMockConversation(
+ id: "parallel-2",
+ accentIndex: 3,
+ prompt: "compare the pricing of the top 3 note-taking apps and write me a summary doc on my Desktop",
+ status: "Comparing the options",
+ elapsedOffset: 19
+ ),
+ OnboardingMockConversation(
+ id: "parallel-3",
+ accentIndex: 4,
+ prompt: "download the audio from https://www.youtube.com/watch?v=v8u_7PPEzZE as an mp3",
+ status: "Downloading the audio",
+ elapsedOffset: 6
+ )
+ ])
)
]
@@ -887,7 +963,16 @@ enum OnboardingTour {
imageBundle: DonkeyResourceBundle.app,
title: "Donkey is ready to work",
description: "",
- background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.46, y: 0.16), bloomIntensity: 1.00)
+ background: OnboardingSlideBackground(bloomCenter: UnitPoint(x: 0.46, y: 0.16), bloomIntensity: 1.00),
+ artwork: .notchComposer([
+ OnboardingMockConversation(
+ id: "ready-1",
+ accentIndex: 6,
+ prompt: "extract the audio from meeting.mov as an mp3 and give me a transcript with the action items pulled out",
+ status: "Writing the transcript",
+ elapsedOffset: 12
+ )
+ ])
)
/// Signed out: the sign-in landing leads the walkthrough, which ends on the
diff --git a/apps/Donkey/Sources/Donkey/Onboarding/OnboardingArtwork.swift b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingArtwork.swift
new file mode 100644
index 00000000..6630b06b
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingArtwork.swift
@@ -0,0 +1,50 @@
+// What fills an onboarding slide's artwork region, and the data the notch mocks
+// read off. The live mocks themselves live in their own files
+// (`OnboardingNotchMock`, `OnboardingSignInMock`, `OnboardingInputMock`), built
+// on the shared `OnboardingMockKit`.
+
+import SwiftUI
+
+// MARK: - Mock data
+
+/// One mocked conversation shown in the notch. Mirrors the fields the real notch
+/// reads off `UserQueryConversation`: the prompt (echoed in the collapsed chin),
+/// a live status line (the expanded subtext), an accent, and how long it has
+/// "already" been running when the slide appears so the timer starts mid-task.
+struct OnboardingMockConversation: Identifiable, Sendable {
+ let id: String
+ /// Index into the shared accent palette; colours the pointer for this task.
+ var accentIndex: Int
+ /// The user's prompt — what the collapsed notch reads back while running.
+ var prompt: String
+ /// The live narration line shown as the expanded row's subtext.
+ var status: String
+ /// Seconds already elapsed when the slide is shown, so the clock starts part-way.
+ var elapsedOffset: TimeInterval
+ /// Running tasks get a lit pointer and a ticking clock; finished ones a silhouette.
+ var isRunning: Bool = true
+}
+
+/// Which live mock fills a slide's artwork region.
+enum OnboardingArtwork {
+ /// Static image loaded by `imageName` (the default; unchanged behaviour).
+ case image
+ /// Looping notch: collapse → pointer in → expand → dwell → collapse.
+ case notchMock([OnboardingMockConversation])
+ /// Static, wider expanded conversation panel; no collapsed pill or pointer.
+ case notchPanel([OnboardingMockConversation])
+ /// Pointer flies in, the notch expands and stays, then it clicks the composer
+ /// and leaves the caret blinking.
+ case notchComposer([OnboardingMockConversation])
+ /// Pointer expands the notch, clicks the composer, types a command, clicks
+ /// send, then vanishes while the task runs.
+ case notchCompose([OnboardingMockConversation])
+ /// The Donkey command field typing out each command in turn, with a colored
+ /// pointer that flies in to click send.
+ case inputMock([String])
+ /// Sign-in: the screen edge with a collapsed notch at top; the field types a
+ /// prompt, the pointer sends it, and it runs in the collapsed notch.
+ case signInMock([String])
+ /// "Ask anything": a ⌘+⌘ summon, then the field appears and types each prompt.
+ case inputSummon([String])
+}
diff --git a/apps/Donkey/Sources/Donkey/Onboarding/OnboardingInputMock.swift b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingInputMock.swift
new file mode 100644
index 00000000..6536b147
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingInputMock.swift
@@ -0,0 +1,399 @@
+// The command-field demo: a mock of the Donkey input field that types itself out,
+// then a colored donkey pointer flies in from offscreen, clicks send, and
+// vanishes — cycling through example commands and accent colors. One variant
+// types straight away; the other summons the field with a double-⌘ first. Built
+// on `OnboardingMockKit`.
+
+import SwiftUI
+
+// MARK: - Tuning
+
+/// Knobs for the typed-command demo: the field's size and position, the
+/// caret-blink and typewriter cadence, and the colored pointer's travel. The
+/// room left to tune the typing and pointer behaviour.
+struct OnboardingInputMockTuning {
+ // The real command composer's geometry (UserQueryLayout): a 576×66 black
+ // capsule with a 28pt mic and a 36.8pt send circle pinned trailing, here
+ // trimmed 10% narrower for the tour.
+ var fieldWidth: CGFloat = 518
+ var fieldHeight: CGFloat = 66
+ var leadingPadding: CGFloat = 20
+ var trailingPadding: CGFloat = 14.6
+ var textControlsSpacing: CGFloat = 12
+ var controlsSpacing: CGFloat = 16
+ var micSize: CGFloat = 28
+ var sendDiameter: CGFloat = 36.8
+ var fieldCenterYFraction: CGFloat = 0.46
+
+ var pointerSize: CGFloat = 30
+ /// Where the glyph's tip sits relative to its frame centre, so the pointer
+ /// lands its tip on the send button rather than its body.
+ var tipOffset = CGSize(width: 10, height: 13)
+ /// Accent index the first cycle uses; each cycle steps to the next colour.
+ var firstColorIndex: Int = 3
+ var pointerTravel: Double = 0.95
+
+ var blinkOn: Double = 0.5
+ var blinkOff: Double = 0.5
+ var perCharDelay: Double = 0.05
+ var postTypePause: Double = 0.55
+ var afterClickHold: Double = 0.25
+ var loopGap: Double = 0.7
+}
+
+// MARK: - Input mock
+
+/// The sign-in slide's artwork: a mock of the Donkey command field that types
+/// itself out, then a colored donkey pointer flies in from offscreen, clicks the
+/// send button, and vanishes — cycling through example commands and accent
+/// colors. Decorative only; never takes hit-testing.
+/// How the input mock opens: type straight away, or summon the field with a
+/// double-⌘ first.
+enum OnboardingInputMockMode {
+ case typeAndSend
+ case commandSummon
+}
+
+struct OnboardingInputMock: View {
+ /// Example commands typed in turn — drawn from the eval fixtures.
+ let commands: [String]
+ let mode: OnboardingInputMockMode
+ var tuning: OnboardingInputMockTuning
+
+ @State private var typed = ""
+ @State private var caretVisible = true
+ @State private var pointer: CGPoint = .zero
+ @State private var pointerVisible = false
+ @State private var pointerColor: Color = .blue
+ @State private var pressed = false
+ @State private var halo = false
+ @State private var showField: Bool
+ @State private var showKeyHint = false
+ @State private var keyPressed = false
+
+ init(
+ commands: [String],
+ mode: OnboardingInputMockMode = .typeAndSend,
+ tuning: OnboardingInputMockTuning = OnboardingInputMockTuning()
+ ) {
+ self.commands = commands
+ self.mode = mode
+ self.tuning = tuning
+ // The command-summon variant hides the field until the ⌘+⌘ plays.
+ _showField = State(initialValue: mode == .typeAndSend)
+ }
+
+ var body: some View {
+ GeometryReader { proxy in
+ let size = proxy.size
+ let send = sendCenter(in: size)
+ ZStack(alignment: .topLeading) {
+ inputBar(width: fieldWidth(in: size))
+ .scaleEffect(showField ? 1 : 0.96)
+ .opacity(showField ? 1 : 0)
+ .position(fieldCenter(in: size))
+
+ if showKeyHint {
+ commandKeyHint
+ .position(fieldCenter(in: size))
+ .transition(.scale(scale: 0.9).combined(with: .opacity))
+ }
+
+ if halo {
+ Circle()
+ .stroke(pointerColor.opacity(0.7), lineWidth: 2)
+ .frame(width: tuning.sendDiameter + 6, height: tuning.sendDiameter + 6)
+ .scaleEffect(pressed ? 1.3 : 1)
+ .position(send)
+ .transition(.opacity)
+ }
+
+ OnboardingCursorMark(color: pointerColor)
+ .frame(width: tuning.pointerSize, height: tuning.pointerSize)
+ .scaleEffect(pressed ? 0.86 : 1, anchor: .topTrailing)
+ .position(pointer)
+ .opacity(pointerVisible ? 1 : 0)
+ }
+ .frame(width: size.width, height: size.height)
+ .clipShape(Rectangle())
+ .task {
+ switch mode {
+ case .typeAndSend: await runInput(in: size)
+ case .commandSummon: await runSummon(in: size)
+ }
+ }
+ }
+ .allowsHitTesting(false)
+ }
+
+ // MARK: ⌘+⌘ summon hint
+
+ /// A realistic mechanical ⌘ keycap — a white sculpted top with a soft dark
+ /// drop shadow giving it real depth. On a press the cap slides down onto its
+ /// shadow, then springs back.
+ private var commandKeyHint: some View {
+ let face = CGSize(width: 108, height: 104)
+ let radius: CGFloat = 20
+ // The key's depth: how far the face sits above its shadow.
+ let depth = CGSize(width: 6, height: 8)
+ // Pressed, the cap travels most of the way down onto its shadow.
+ let press = keyPressed
+ ? CGSize(width: depth.width - 1, height: depth.height - 2)
+ : .zero
+
+ return ZStack(alignment: .topLeading) {
+ // Soft, light shadow giving the key just a little depth.
+ RoundedRectangle(cornerRadius: radius, style: .continuous)
+ .fill(OnboardingPalette.ink)
+ .frame(width: face.width, height: face.height)
+ .offset(x: depth.width, y: depth.height)
+ .blur(radius: 5)
+ .opacity(keyPressed ? 0.32 : 0.42)
+
+ // Keycap: a softly graded white top with a sculpted inner dish.
+ ZStack {
+ RoundedRectangle(cornerRadius: radius, style: .continuous)
+ .fill(
+ LinearGradient(
+ colors: [Color.white, Color(white: 0.91)],
+ startPoint: .top,
+ endPoint: .bottom
+ )
+ )
+ .overlay(
+ RoundedRectangle(cornerRadius: radius, style: .continuous)
+ .stroke(Color.black.opacity(0.12), lineWidth: 1)
+ )
+
+ RoundedRectangle(cornerRadius: radius - 7, style: .continuous)
+ .fill(Color.white)
+ .overlay(
+ RoundedRectangle(cornerRadius: radius - 7, style: .continuous)
+ .stroke(Color.black.opacity(0.05), lineWidth: 1)
+ )
+ .shadow(color: Color.black.opacity(0.05), radius: 1, x: 0, y: 1)
+ .padding(7)
+
+ VStack(spacing: 4) {
+ Image(systemName: "command")
+ .font(.system(size: 30, weight: .semibold))
+ Text("command")
+ .font(.system(size: 12, weight: .bold))
+ .tracking(0.2)
+ }
+ .foregroundStyle(OnboardingPalette.ink)
+ }
+ .frame(width: face.width, height: face.height)
+ .offset(x: press.width, y: press.height)
+ }
+ .frame(width: face.width + depth.width, height: face.height + depth.height, alignment: .topLeading)
+ }
+
+ // MARK: Field
+
+ private func inputBar(width: CGFloat) -> some View {
+ let hasText = !typed.isEmpty
+ return HStack(spacing: tuning.textControlsSpacing) {
+ ZStack(alignment: .leading) {
+ if !hasText {
+ Text("What can donkey do for you?")
+ .font(.system(size: 16, weight: .light))
+ .foregroundStyle(Color.white.opacity(0.58))
+ .lineLimit(1)
+ }
+ HStack(alignment: .center, spacing: 1) {
+ Text(typed)
+ .font(.system(size: 16, weight: .light))
+ .foregroundStyle(.white)
+ .lineLimit(1)
+ RoundedRectangle(cornerRadius: 1, style: .continuous)
+ .fill(Color.white)
+ .frame(width: 2, height: 20)
+ .opacity(caretVisible ? 1 : 0)
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+
+ // Trailing controls: the mic icon and the white send circle.
+ HStack(spacing: tuning.controlsSpacing) {
+ Image(systemName: "mic")
+ .font(.system(size: 24, weight: .ultraLight))
+ .foregroundStyle(Color.white.opacity(hasText ? 0.34 : 0.52))
+ .frame(width: tuning.micSize, height: tuning.micSize)
+
+ ZStack {
+ Circle().fill(Color.white.opacity(hasText ? 0.94 : 0.68))
+ Image(systemName: "arrow.up")
+ .font(.system(size: 17, weight: .semibold))
+ .foregroundStyle(Color.black.opacity(hasText ? 0.78 : 0.42))
+ }
+ .frame(width: tuning.sendDiameter, height: tuning.sendDiameter)
+ }
+ }
+ .padding(.leading, tuning.leadingPadding)
+ .padding(.trailing, tuning.trailingPadding)
+ .frame(width: width, height: tuning.fieldHeight)
+ .background(Capsule(style: .continuous).fill(Color.black))
+ .overlay(Capsule(style: .continuous).stroke(Color.white.opacity(0.34), lineWidth: 1))
+ .shadow(color: Color.black.opacity(0.2), radius: 12, x: 0, y: 5)
+ }
+
+ // MARK: Geometry
+
+ private func fieldWidth(in size: CGSize) -> CGFloat {
+ min(tuning.fieldWidth, size.width - 48)
+ }
+
+ private func fieldCenter(in size: CGSize) -> CGPoint {
+ CGPoint(x: size.width / 2, y: size.height * tuning.fieldCenterYFraction)
+ }
+
+ private func sendCenter(in size: CGSize) -> CGPoint {
+ let center = fieldCenter(in: size)
+ let right = center.x + fieldWidth(in: size) / 2
+ return CGPoint(x: right - tuning.trailingPadding - tuning.sendDiameter / 2, y: center.y)
+ }
+
+ /// The pointer's frame centre that lands its tip on the send button.
+ private func pointerTarget(in size: CGSize) -> CGPoint {
+ let send = sendCenter(in: size)
+ return CGPoint(x: send.x - tuning.tipOffset.width, y: send.y + tuning.tipOffset.height)
+ }
+
+ private func offscreenStart(in size: CGSize) -> CGPoint {
+ CGPoint(x: size.width + 70, y: size.height * 0.92)
+ }
+
+ // MARK: Simulation
+
+ /// One cycle: blink the caret twice, type the command, fly the colored
+ /// pointer in from offscreen to the send button and click, then vanish in
+ /// place — advancing the command and color, forever.
+ @MainActor
+ private func runInput(in size: CGSize) async {
+ let start = offscreenStart(in: size)
+ let send = sendCenter(in: size)
+ let target = pointerTarget(in: size)
+ var commandIndex = 0
+ var colorIndex = tuning.firstColorIndex
+
+ while !Task.isCancelled {
+ typed = ""
+ pressed = false
+ halo = false
+ pointerVisible = false
+ pointer = start
+ pointerColor = onboardingAccent(colorIndex)
+ _ = send // halo/click anchor, captured for clarity
+
+ // Blink the caret twice before typing begins.
+ for _ in 0..<2 {
+ caretVisible = true
+ if await onboardingSleep(tuning.blinkOn) == false { return }
+ caretVisible = false
+ if await onboardingSleep(tuning.blinkOff) == false { return }
+ }
+ caretVisible = true
+
+ // Type the command out, character by character.
+ for character in commands[commandIndex % commands.count] {
+ typed.append(character)
+ if await onboardingSleep(tuning.perCharDelay) == false { return }
+ }
+ if await onboardingSleep(tuning.postTypePause) == false { return }
+
+ // Fly the pointer in from offscreen to the send button.
+ pointerVisible = true
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = target }
+ if await onboardingSleep(tuning.pointerTravel) == false { return }
+
+ // Click: press in with a halo, then release.
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await onboardingSleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+ if await onboardingSleep(tuning.afterClickHold) == false { return }
+
+ // Vanish in place.
+ withAnimation(.easeOut(duration: 0.28)) {
+ pointerVisible = false
+ halo = false
+ }
+ caretVisible = false
+ if await onboardingSleep(tuning.loopGap) == false { return }
+
+ commandIndex += 1
+ colorIndex = (colorIndex + 1) % onboardingAccentPalette.count
+ }
+ }
+
+ /// One cycle for the summon variant: tap ⌘ twice, reveal the field, type the
+ /// command, fly the pointer in to send, vanish — advancing command and color.
+ @MainActor
+ private func runSummon(in size: CGSize) async {
+ let start = offscreenStart(in: size)
+ let target = pointerTarget(in: size)
+ var commandIndex = 0
+ var colorIndex = tuning.firstColorIndex
+
+ while !Task.isCancelled {
+ typed = ""
+ pressed = false
+ halo = false
+ pointerVisible = false
+ caretVisible = false
+ pointer = start
+ pointerColor = onboardingAccent(colorIndex)
+ withAnimation(.easeOut(duration: 0.2)) { showField = false }
+ showKeyHint = true
+ if await onboardingSleep(0.4) == false { return }
+
+ // Tap ⌘ twice to summon the field.
+ for _ in 0..<2 {
+ withAnimation(.easeIn(duration: 0.07)) { keyPressed = true }
+ if await onboardingSleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { keyPressed = false }
+ if await onboardingSleep(0.2) == false { return }
+ }
+ if await onboardingSleep(0.25) == false { return }
+
+ // Hide the hint and reveal the field.
+ withAnimation(.easeOut(duration: 0.2)) { showKeyHint = false }
+ withAnimation(.spring(response: 0.35, dampingFraction: 0.82)) { showField = true }
+ caretVisible = true
+ if await onboardingSleep(0.4) == false { return }
+
+ // Type the command out.
+ for character in commands[commandIndex % commands.count] {
+ typed.append(character)
+ if await onboardingSleep(tuning.perCharDelay) == false { return }
+ }
+ if await onboardingSleep(tuning.postTypePause) == false { return }
+
+ // Fly the pointer in and click send.
+ pointerVisible = true
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = target }
+ if await onboardingSleep(tuning.pointerTravel) == false { return }
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await onboardingSleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+ if await onboardingSleep(tuning.afterClickHold) == false { return }
+
+ // Vanish in place.
+ withAnimation(.easeOut(duration: 0.28)) {
+ pointerVisible = false
+ halo = false
+ }
+ caretVisible = false
+ if await onboardingSleep(tuning.loopGap) == false { return }
+
+ commandIndex += 1
+ colorIndex = (colorIndex + 1) % onboardingAccentPalette.count
+ }
+ }
+}
diff --git a/apps/Donkey/Sources/Donkey/Onboarding/OnboardingMockKit.swift b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingMockKit.swift
new file mode 100644
index 00000000..789fe4b1
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingMockKit.swift
@@ -0,0 +1,202 @@
+// Shared building blocks for the onboarding slide mocks — live SwiftUI re-creations
+// rendered inside slide artwork regions in place of static screenshots. The
+// "screen edge" is the dark top bezel of a Mac display; the collapsed notch drops
+// out of its centre and a simulated pointer drives it. The cursor glyph, the
+// grow-from-notch surface shape, the accent palette, and the elapsed-time format
+// are copied verbatim from the real notch UI (`UserQueryNotchStatusView`) so the
+// tour matches the running app.
+//
+// Every mock (`OnboardingNotchMock`, `OnboardingSignInMock`, `OnboardingInputMock`)
+// is built from the pieces here.
+
+import SwiftUI
+
+// MARK: - Screen top edge
+
+/// The top edge of a Mac screen — the line the notch component drops out of. A
+/// 1px full-width white hairline whose opacity tapers to nothing at both ends so
+/// the edge reads as solid across the centre and dissolves into the slide at the
+/// sides. The collapsed component anchors to this line's horizontal centre.
+struct OnboardingScreenEdge: View {
+ /// Colour of the edge at its solid mid-point. The ends always fade to fully
+ /// transparent regardless of this colour.
+ var color: Color = .white
+ /// Edge thickness in points.
+ var thickness: CGFloat = 1
+
+ var body: some View {
+ Rectangle()
+ .fill(
+ LinearGradient(
+ stops: [
+ .init(color: color.opacity(0), location: 0.0),
+ .init(color: color, location: 0.48),
+ .init(color: color.opacity(0), location: 0.98)
+ ],
+ startPoint: .leading,
+ endPoint: .trailing
+ )
+ )
+ .frame(height: thickness)
+ .frame(maxWidth: .infinity)
+ }
+}
+
+// MARK: - Live elapsed clock
+
+/// A ticking elapsed-time label, formatted exactly like the real notch
+/// ("45m 13s" / "1h 45m 13s"). Counts up from `appearedAt - offset`, so a task
+/// shown mid-run starts at its offset rather than zero.
+struct OnboardingElapsedClock: View {
+ let appearedAt: Date
+ let offset: TimeInterval
+ let font: Font
+ let color: Color
+
+ var body: some View {
+ TimelineView(.periodic(from: appearedAt, by: 1)) { context in
+ Text(Self.elapsedDescription(seconds: context.date.timeIntervalSince(appearedAt) + offset))
+ .font(font)
+ .foregroundStyle(color)
+ .lineLimit(1)
+ .fixedSize()
+ }
+ }
+
+ /// Formats elapsed seconds as "45m 13s" (or "1h 45m 13s"), dropping leading
+ /// zero units — copied from `UserQueryNotchStatusView.elapsedDescription`.
+ static func elapsedDescription(seconds totalSeconds: Double) -> String {
+ let clamped = max(0, Int(totalSeconds))
+ let hours = clamped / 3600
+ let minutes = (clamped % 3600) / 60
+ let seconds = clamped % 60
+
+ var parts: [String] = []
+ if hours > 0 { parts.append("\(hours)h") }
+ if minutes > 0 { parts.append("\(minutes)m") }
+ parts.append("\(seconds)s")
+ return parts.joined(separator: " ")
+ }
+}
+
+// MARK: - Accent palette (copied from UserQueryNotchStatusView)
+
+let onboardingAccentPalette: [Color] = [
+ Color(red: 0.114, green: 0.62, blue: 0.46),
+ Color(red: 0.94, green: 0.62, blue: 0.15),
+ Color(red: 0.83, green: 0.33, blue: 0.49),
+ Color(red: 0.22, green: 0.54, blue: 0.87),
+ Color(red: 0.5, green: 0.47, blue: 0.87),
+ Color(red: 0.88, green: 0.35, blue: 0.28),
+ Color(red: 0.24, green: 0.69, blue: 0.71),
+ Color(red: 0.66, green: 0.34, blue: 0.79)
+]
+
+func onboardingAccent(_ index: Int) -> Color {
+ let count = onboardingAccentPalette.count
+ return onboardingAccentPalette[((index % count) + count) % count]
+}
+
+// MARK: - Ported glyphs and shapes
+
+/// The donkey cursor glyph, geometry ported verbatim from `DonkeyCursorMark`
+/// (100×100 viewBox). Filled + outlined when active; a hollow gray silhouette
+/// when idle/finished. Tip points up-right at rotation 0.
+struct OnboardingCursorMark: View {
+ var color: Color
+ var silhouette: Bool = false
+
+ var body: some View {
+ GeometryReader { proxy in
+ let scale = min(proxy.size.width, proxy.size.height) / 100
+ let path = Self.cursorPath(scale: scale)
+ if silhouette {
+ path.stroke(
+ Color.white.opacity(0.5),
+ style: StrokeStyle(lineWidth: 6 * scale, lineJoin: .round)
+ )
+ } else {
+ path
+ .fill(color)
+ .overlay(
+ path.stroke(
+ Color.white.opacity(0.92),
+ style: StrokeStyle(lineWidth: 5.36 * scale, lineJoin: .round)
+ )
+ )
+ .shadow(color: Color.black.opacity(0.34), radius: 2 * scale, x: 0, y: 2 * scale)
+ }
+ }
+ .aspectRatio(1, contentMode: .fit)
+ .accessibilityHidden(true)
+ }
+
+ private static func cursorPath(scale: CGFloat) -> Path {
+ Path { path in
+ func point(_ x: CGFloat, _ y: CGFloat) -> CGPoint { CGPoint(x: x * scale, y: y * scale) }
+ path.move(to: point(83.086, 5.6406))
+ path.addLine(to: point(10.453, 34.6836))
+ path.addCurve(to: point(11.1327, 51.0276), control1: point(2.8514, 37.7227), control2: point(3.3085, 48.6326))
+ path.addLine(to: point(35.6947, 58.5471))
+ path.addCurve(to: point(41.4486, 64.301), control1: point(38.4486, 59.3909), control2: point(40.6049, 61.5471))
+ path.addLine(to: point(48.9681, 88.863))
+ path.addCurve(to: point(65.3121, 89.5427), control1: point(51.3665, 96.6911), control2: point(62.2731, 97.1442))
+ path.addLine(to: point(94.3551, 16.9097))
+ path.addCurve(to: point(83.0821, 5.6367), control1: point(97.1871, 9.8316), control2: point(90.1598, 2.8077))
+ path.closeSubpath()
+ }
+ }
+}
+
+/// The notch silhouette as an animatable clip — square top, rounded bottom —
+/// pinned to the top centre of the rect it fills, so animating width/height/
+/// cornerRadius grows the opening from the closed notch outward. Ported from
+/// `GrowingNotchShape`.
+struct OnboardingNotchShape: Shape {
+ var width: CGFloat
+ var height: CGFloat
+ var cornerRadius: CGFloat
+
+ var animatableData: AnimatablePair<CGFloat, AnimatablePair<CGFloat, CGFloat>> {
+ get { AnimatablePair(width, AnimatablePair(height, cornerRadius)) }
+ set {
+ width = newValue.first
+ height = newValue.second.first
+ cornerRadius = newValue.second.second
+ }
+ }
+
+ func path(in rect: CGRect) -> Path {
+ let clampedWidth = min(max(0, width), rect.width)
+ let clampedHeight = min(max(0, height), rect.height)
+ let radius = min(cornerRadius, clampedWidth / 2, clampedHeight / 2)
+ let opening = CGRect(
+ x: (rect.width - clampedWidth) / 2,
+ y: 0,
+ width: clampedWidth,
+ height: clampedHeight
+ )
+ return UnevenRoundedRectangle(
+ cornerRadii: RectangleCornerRadii(
+ topLeading: 0,
+ bottomLeading: radius,
+ bottomTrailing: radius,
+ topTrailing: 0
+ ),
+ style: .continuous
+ )
+ .path(in: opening)
+ }
+}
+
+// MARK: - Shared timing helper
+
+/// Sleeps for `seconds`, returning false if the task was cancelled (slide left).
+func onboardingSleep(_ seconds: Double) async -> Bool {
+ do {
+ try await Task.sleep(for: .seconds(seconds))
+ return !Task.isCancelled
+ } catch {
+ return false
+ }
+}
diff --git a/apps/Donkey/Sources/Donkey/Onboarding/OnboardingNotchMock.swift b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingNotchMock.swift
new file mode 100644
index 00000000..4d6ef158
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingNotchMock.swift
@@ -0,0 +1,576 @@
+// The notch demo: the screen edge with a collapsed component that grows into the
+// full conversation panel, driven by a simulated pointer. One view drives four
+// slide behaviours (loop, static panel, open-composer, compose-and-run); the
+// pointer path and timings are gathered in `OnboardingNotchMockTuning` — the
+// single place to tune the staged behaviour. Built on `OnboardingMockKit`.
+
+import SwiftUI
+
+// MARK: - Tuning (the simulation script + layout)
+
+/// Every knob the notch mock exposes: where the edge and pointer sit, the
+/// collapsed/expanded surface sizes, and the timing of each staged step. This is
+/// the room left to simulate the pointer and timer behaviour — adjust here.
+struct OnboardingNotchMockTuning {
+ // Layout, as fractions of the artwork region unless noted.
+ var edgeYFraction: CGFloat = 0.17
+ var edgeWidthFraction: CGFloat = 1.0
+ var collapsedWidth: CGFloat = 286
+ var collapsedHeight: CGFloat = 38
+ var expandedWidth: CGFloat = 392
+ /// Expanded height grows with the row count, capped to the region.
+ var expandedBaseHeight: CGFloat = 78
+ var rowHeight: CGFloat = 80
+ var collapsedCorner: CGFloat = 18
+ var expandedCorner: CGFloat = 26
+
+ // The animated pointer: a filled, accent-colored donkey cursor.
+ var pointerSize: CGFloat = 28
+ var pointerAccentIndex: Int = 3
+ /// The glyph tip's offset from its frame centre, so a click lands the tip.
+ var tipOffset = CGSize(width: 9, height: 12)
+
+ // Pointer rest position (fraction of region) and the hover target offset
+ // from the notch centre (points).
+ var pointerRestX: CGFloat = 0.77
+ var pointerRestY: CGFloat = 0.82
+ var pointerHoverDX: CGFloat = 16
+ var pointerHoverDY: CGFloat = 30
+
+ // Timings, seconds — the staged loop.
+ var runningHold: Double = 1.9 // collapsed + running before the pointer moves in
+ var pointerTravel: Double = 0.9 // pointer drift from rest to the notch
+ var expandedHold: Double = 2.9 // dwell expanded under the pointer
+ var pointerRetreat: Double = 0.6 // pointer drift back to rest on collapse
+ var loopGap: Double = 1.1 // settle before the loop repeats
+}
+
+// MARK: - Notch mock
+
+/// The staged mock: the screen edge, the collapsed/expanded notch surface that
+/// grows from the edge, and a simulated pointer that drifts in to trigger the
+/// expansion. Purely decorative — it never takes hit-testing, so the slideshow's
+/// own controls stay clickable through it.
+/// How the notch mock behaves on a slide.
+enum OnboardingNotchMockMode {
+ /// Collapse → pointer drifts in → expand → dwell → collapse, on a loop.
+ case loop
+ /// Static: just the expanded conversation panel, centered, no pointer.
+ case expandedPanel
+ /// One-shot: pointer flies in, the notch expands and stays open, then the
+ /// pointer clicks the composer and the text caret is left blinking.
+ case openComposer
+ /// One-shot: pointer expands the notch, clicks the composer, types a command,
+ /// clicks send, then vanishes while the task runs in the notch.
+ case composeAndRun
+}
+
+struct OnboardingNotchMock: View {
+ let conversations: [OnboardingMockConversation]
+ let mode: OnboardingNotchMockMode
+ var tuning: OnboardingNotchMockTuning
+
+ private enum Phase { case collapsed, expanded }
+
+ @State private var phase: Phase
+ @State private var pointer: CGPoint = .zero
+ @State private var pointerVisible = false
+ @State private var pressed = false
+ @State private var halo = false
+ @State private var haloPoint: CGPoint = .zero
+ @State private var composerFocused = false
+ @State private var composerCaretVisible = false
+ /// Text typed into the composer (`.composeAndRun`).
+ @State private var composerText = ""
+ /// Whether the typed prompt has been sent and is now running in the notch.
+ @State private var sentTask = false
+ /// When the sent task started, so its clock counts up from the send.
+ @State private var sentAt = Date()
+ /// Anchors every timer in the scene; reset each time the slide reappears.
+ @State private var appearedAt = Date()
+
+ init(
+ conversations: [OnboardingMockConversation],
+ mode: OnboardingNotchMockMode = .loop,
+ tuning: OnboardingNotchMockTuning = OnboardingNotchMockTuning()
+ ) {
+ self.conversations = conversations
+ self.mode = mode
+ self.tuning = tuning
+ _phase = State(initialValue: mode == .expandedPanel ? .expanded : .collapsed)
+ }
+
+ // Surface grow/shrink curves, copied from the real notch (prototype's
+ // cubic-bezier(0.2,0.9,0.24,1) open; faster ease-out close).
+ private static let surfaceOpen = Animation.timingCurve(0.2, 0.9, 0.24, 1, duration: 0.55)
+ private static let surfaceClose = Animation.easeOut(duration: 0.22)
+ private static let contentReveal = Animation.easeOut(duration: 0.3).delay(0.12)
+ private static let contentHide = Animation.easeOut(duration: 0.1)
+
+ var body: some View {
+ GeometryReader { proxy in
+ let size = proxy.size
+ ZStack(alignment: .topLeading) {
+ OnboardingScreenEdge(color: OnboardingPalette.ink.opacity(0.35))
+ .frame(width: size.width * tuning.edgeWidthFraction)
+ .position(x: size.width / 2, y: edgeY(size))
+
+ notchSurface(size: size)
+
+ if mode != .expandedPanel {
+ if halo {
+ Circle()
+ .stroke(onboardingAccent(tuning.pointerAccentIndex).opacity(0.7), lineWidth: 2)
+ .frame(width: 40, height: 40)
+ .position(haloPoint)
+ .transition(.opacity)
+ }
+
+ OnboardingCursorMark(color: onboardingAccent(tuning.pointerAccentIndex))
+ .frame(width: tuning.pointerSize, height: tuning.pointerSize)
+ .scaleEffect(pressed ? 0.86 : 1, anchor: .topTrailing)
+ .shadow(color: Color.black.opacity(0.28), radius: 3, x: 0, y: 1)
+ .position(pointer)
+ .opacity(pointerVisible ? 1 : 0)
+ }
+ }
+ .frame(width: size.width, height: size.height)
+ .task {
+ switch mode {
+ case .loop: await runLoop(in: size)
+ case .expandedPanel: break
+ case .openComposer: await runOpenComposer(in: size)
+ case .composeAndRun: await runComposeAndRun(in: size)
+ }
+ }
+ }
+ .allowsHitTesting(false)
+ }
+
+ // MARK: Surface
+
+ @ViewBuilder
+ private func notchSurface(size: CGSize) -> some View {
+ let canvasH = expandedHeight(in: size)
+ let openW = phase == .expanded ? tuning.expandedWidth : tuning.collapsedWidth
+ let openH = phase == .expanded ? canvasH : tuning.collapsedHeight
+ let corner = phase == .expanded ? tuning.expandedCorner : tuning.collapsedCorner
+ let shape = OnboardingNotchShape(width: openW, height: openH, cornerRadius: corner)
+
+ ZStack(alignment: .top) {
+ Color.black
+
+ collapsedContent
+ .frame(width: tuning.collapsedWidth, height: tuning.collapsedHeight)
+ .frame(maxWidth: .infinity, alignment: .top)
+ .opacity(phase == .expanded ? 0 : 1)
+ .animation(Self.contentHide, value: phase)
+
+ expandedContent
+ .opacity(phase == .expanded ? 1 : 0)
+ .animation(phase == .expanded ? Self.contentReveal : Self.contentHide, value: phase)
+ }
+ .frame(width: tuning.expandedWidth, height: canvasH, alignment: .top)
+ .clipShape(shape)
+ .overlay(shape.stroke(Color.white.opacity(0.08), lineWidth: 1))
+ .animation(phase == .expanded ? Self.surfaceOpen : Self.surfaceClose, value: phase)
+ .position(x: size.width / 2, y: edgeY(size) + canvasH / 2)
+ }
+
+ // MARK: Collapsed content (cursor cluster + rotating prompt + clock)
+
+ private var collapsedContent: some View {
+ // The chin advances to the next running task every 2.6s, the real notch's
+ // rotation; the lit pointer takes the speaking task's accent.
+ TimelineView(.periodic(from: appearedAt, by: 2.6)) { context in
+ let speaker = rotatingSpeaker(at: context.date)
+ HStack(spacing: 7) {
+ collapsedPointerCluster(speaker: speaker)
+ .frame(width: clusterWidth, height: 16)
+
+ Text(speaker?.prompt ?? "")
+ .font(.system(size: 12, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.92))
+ .lineLimit(1)
+ .truncationMode(.tail)
+
+ Spacer(minLength: 0)
+
+ if let speaker, speaker.isRunning {
+ OnboardingElapsedClock(
+ appearedAt: appearedAt,
+ offset: speaker.elapsedOffset,
+ font: .system(size: 11, weight: .regular).monospacedDigit(),
+ color: Color.white.opacity(0.5)
+ )
+ }
+ }
+ .padding(.horizontal, 13)
+ }
+ }
+
+ /// The tasks the notch should show right now. In `.composeAndRun` the notch
+ /// shows only the settled idle tasks until the typed prompt is sent — so it
+ /// never looks empty — then the new running task joins them on top.
+ private var effectiveConversations: [OnboardingMockConversation] {
+ if mode == .composeAndRun && !sentTask {
+ return conversations.filter { !$0.isRunning }
+ }
+ return conversations
+ }
+
+ private var runningConversations: [OnboardingMockConversation] {
+ effectiveConversations.filter(\.isRunning)
+ }
+
+ private func rotatingSpeaker(at date: Date) -> OnboardingMockConversation? {
+ let running = runningConversations
+ guard !running.isEmpty else { return effectiveConversations.first }
+ let step = Int(date.timeIntervalSince(appearedAt) / 2.6)
+ return running[((step % running.count) + running.count) % running.count]
+ }
+
+ private var clusterWidth: CGFloat {
+ let count = min(runningConversations.count, 3)
+ return 14 + 7 * CGFloat(max(0, count - 1))
+ }
+
+ @ViewBuilder
+ private func collapsedPointerCluster(speaker: OnboardingMockConversation?) -> some View {
+ let cluster = Array(runningConversations.prefix(3))
+ if cluster.isEmpty {
+ OnboardingCursorMark(color: onboardingAccent(0), silhouette: true)
+ .frame(width: 14, height: 14)
+ } else {
+ ZStack(alignment: .topLeading) {
+ // Oldest first so the newest pointer lands on top of the cascade.
+ ForEach(Array(cluster.reversed().enumerated()), id: \.element.id) { index, convo in
+ OnboardingCursorMark(
+ color: onboardingAccent(convo.accentIndex),
+ silhouette: convo.id != speaker?.id
+ )
+ .frame(width: 14, height: 14)
+ .offset(x: 7 * CGFloat(index), y: 3 * CGFloat(index))
+ .zIndex(convo.id == speaker?.id ? 10 : Double(index))
+ }
+ }
+ }
+ }
+
+ // MARK: Expanded content (rows + composer)
+
+ private var expandedContent: some View {
+ VStack(spacing: 8) {
+ ScrollView(.vertical, showsIndicators: false) {
+ VStack(spacing: 8) {
+ ForEach(effectiveConversations) { expandedRow($0) }
+ }
+ }
+
+ composer
+ }
+ .padding(14)
+ }
+
+ private func expandedRow(_ convo: OnboardingMockConversation) -> some View {
+ HStack(alignment: .top, spacing: 12) {
+ OnboardingCursorMark(
+ color: onboardingAccent(convo.accentIndex),
+ silhouette: !convo.isRunning
+ )
+ .frame(width: 14, height: 14)
+ .padding(.top, 1)
+
+ VStack(alignment: .leading, spacing: 4) {
+ Text(convo.prompt)
+ .font(.system(size: 13, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.9))
+ .lineLimit(1)
+ .truncationMode(.tail)
+ .frame(maxWidth: .infinity, alignment: .leading)
+
+ Text(convo.status)
+ .font(.system(size: 12, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .lineLimit(2)
+ .truncationMode(.tail)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ }
+ .padding(.horizontal, 12)
+ .padding(.vertical, 10)
+ .frame(maxWidth: .infinity, minHeight: 64, alignment: .topLeading)
+ .background(Color.white.opacity(0.07))
+ .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
+ .overlay(alignment: .bottomTrailing) {
+ if convo.isRunning {
+ OnboardingElapsedClock(
+ appearedAt: mode == .composeAndRun ? sentAt : appearedAt,
+ offset: mode == .composeAndRun ? 0 : convo.elapsedOffset,
+ font: .system(size: 11, weight: .regular).monospacedDigit(),
+ color: Color.white.opacity(0.5)
+ )
+ .padding(.horizontal, 12)
+ .padding(.bottom, 9)
+ }
+ }
+ }
+
+ private var composer: some View {
+ let hasText = !composerText.isEmpty
+ let caretShown = composerFocused && composerCaretVisible
+ return HStack(alignment: .bottom, spacing: 8) {
+ Group {
+ if hasText {
+ // The caret rides at the end of the text and wraps with it, so
+ // the line grows as the command is typed.
+ Text("\(composerText)\(caretShown ? "▏" : "")")
+ .font(.system(size: 13, weight: .regular))
+ .foregroundStyle(.white)
+ .lineLimit(3)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ } else {
+ HStack(spacing: 3) {
+ if composerFocused {
+ RoundedRectangle(cornerRadius: 1, style: .continuous)
+ .fill(Color.white)
+ .frame(width: 2, height: 15)
+ .opacity(composerCaretVisible ? 1 : 0)
+ }
+ Text("What can donkey do for you?")
+ .font(.system(size: 13, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.4))
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ }
+ Image(systemName: "arrow.up")
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(Color.black.opacity(hasText ? 0.8 : 0.55))
+ .frame(width: 22, height: 22)
+ .background(Color.white.opacity(hasText ? 0.95 : 0.7))
+ .clipShape(Circle())
+ }
+ .padding(.horizontal, 12)
+ .padding(.vertical, 11)
+ .frame(minHeight: 40, alignment: .bottom)
+ .background(Color.white.opacity(0.06))
+ .clipShape(RoundedRectangle(cornerRadius: 11, style: .continuous))
+ .overlay(
+ RoundedRectangle(cornerRadius: 11, style: .continuous)
+ .stroke(Color.white.opacity(composerFocused ? 0.28 : 0.1), lineWidth: 1)
+ )
+ }
+
+ // MARK: Geometry
+
+ private func edgeY(_ size: CGSize) -> CGFloat { size.height * tuning.edgeYFraction }
+
+ private func restPoint(_ size: CGSize) -> CGPoint {
+ CGPoint(x: size.width * tuning.pointerRestX, y: size.height * tuning.pointerRestY)
+ }
+
+ private func hoverPoint(_ size: CGSize) -> CGPoint {
+ CGPoint(x: size.width / 2 + tuning.pointerHoverDX, y: edgeY(size) + tuning.pointerHoverDY)
+ }
+
+ private func offscreenStart(_ size: CGSize) -> CGPoint {
+ CGPoint(x: size.width + 70, y: size.height * 0.9)
+ }
+
+ private func expandedHeight(in size: CGSize) -> CGFloat {
+ let needed = tuning.expandedBaseHeight
+ + CGFloat(effectiveConversations.count) * tuning.rowHeight
+ + composerExtraHeight
+ // Leave room for the slide's bottom fade and page dots; when the rows
+ // don't fit, the panel caps here and the row ScrollView scrolls.
+ let maxH = size.height - edgeY(size) - 84
+ return min(needed, max(tuning.collapsedHeight, maxH))
+ }
+
+ /// Extra panel height for a composer that has wrapped past one line as the
+ /// command is typed (≈ one 13pt line per extra row).
+ private var composerExtraHeight: CGFloat {
+ CGFloat(composerLineCount - 1) * 17
+ }
+
+ private var composerLineCount: Int {
+ guard !composerText.isEmpty else { return 1 }
+ // Text area = panel inset (28) + composer padding (24) + send (22) + gap (8).
+ let contentWidth = tuning.expandedWidth - 82
+ let perLine = max(8, Int(contentWidth / 7.2))
+ let lines = Int(ceil(Double(composerText.count) / Double(perLine)))
+ return min(3, max(1, lines))
+ }
+
+ /// The composer's centre within the artwork region, used as the click target
+ /// in `.openComposer`. The composer sits at the panel's bottom (14pt inset,
+ /// 40pt tall → centre 34pt up from the panel's bottom edge).
+ private func composerPoint(in size: CGSize) -> CGPoint {
+ let canvasH = expandedHeight(in: size)
+ let panelCenterY = edgeY(size) + canvasH / 2
+ return CGPoint(x: size.width / 2 - tuning.expandedWidth * 0.28, y: panelCenterY + canvasH / 2 - 34)
+ }
+
+ /// The composer's send button centre — trailing inside the composer row.
+ private func composerSendPoint(in size: CGSize) -> CGPoint {
+ CGPoint(x: size.width / 2 + tuning.expandedWidth / 2 - 37, y: composerPoint(in: size).y)
+ }
+
+ // MARK: Simulation
+
+ /// The staged loop: hold collapsed + running, drift the pointer in, expand on
+ /// "hover", dwell, then collapse and retreat — repeating for the slide's life.
+ @MainActor
+ private func runLoop(in size: CGSize) async {
+ pointer = restPoint(size)
+ pointerVisible = true
+ haloPoint = hoverPoint(size)
+
+ while !Task.isCancelled {
+ withAnimation(Self.surfaceClose) {
+ phase = .collapsed
+ halo = false
+ }
+ if await sleep(tuning.runningHold) == false { return }
+
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) {
+ pointer = hoverPoint(size)
+ }
+ if await sleep(tuning.pointerTravel) == false { return }
+
+ withAnimation(Self.surfaceOpen) { phase = .expanded }
+ withAnimation(.easeOut(duration: 0.25)) { halo = true }
+ if await sleep(tuning.expandedHold) == false { return }
+
+ withAnimation(Self.surfaceClose) {
+ phase = .collapsed
+ halo = false
+ }
+ withAnimation(.easeInOut(duration: tuning.pointerRetreat)) {
+ pointer = restPoint(size)
+ }
+ if await sleep(tuning.loopGap) == false { return }
+ }
+ }
+
+ /// One-shot: the pointer flies in from offscreen, the notch expands and stays
+ /// open, then the pointer crosses to the composer, clicks it, and the text
+ /// caret is left blinking in the focused field.
+ @MainActor
+ private func runOpenComposer(in size: CGSize) async {
+ pointer = offscreenStart(size)
+ pointerVisible = true
+ haloPoint = hoverPoint(size)
+
+ // Fly in to the notch and expand.
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = hoverPoint(size) }
+ if await sleep(tuning.pointerTravel) == false { return }
+ withAnimation(Self.surfaceOpen) { phase = .expanded }
+ withAnimation(.easeOut(duration: 0.25)) { halo = true }
+ if await sleep(0.5) == false { return }
+ withAnimation(.easeOut(duration: 0.3)) { halo = false }
+ if await sleep(0.5) == false { return }
+
+ // Cross to the composer and click it.
+ let composer = composerPoint(in: size)
+ let target = CGPoint(x: composer.x - tuning.tipOffset.width, y: composer.y + tuning.tipOffset.height)
+ haloPoint = composer
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = target }
+ if await sleep(tuning.pointerTravel) == false { return }
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await sleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+ withAnimation(.easeOut(duration: 0.3)) { halo = false }
+
+ // Leave the composer focused with a blinking caret.
+ composerFocused = true
+ while !Task.isCancelled {
+ composerCaretVisible = true
+ if await sleep(0.5) == false { return }
+ composerCaretVisible = false
+ if await sleep(0.5) == false { return }
+ }
+ }
+
+ /// One-shot: the pointer expands the notch, clicks the composer, types the
+ /// command, clicks send, then vanishes while the prompt runs in the notch.
+ @MainActor
+ private func runComposeAndRun(in size: CGSize) async {
+ pointer = offscreenStart(size)
+ pointerVisible = true
+ haloPoint = hoverPoint(size)
+
+ // Fly in and expand.
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = hoverPoint(size) }
+ if await sleep(tuning.pointerTravel) == false { return }
+ withAnimation(Self.surfaceOpen) { phase = .expanded }
+ withAnimation(.easeOut(duration: 0.25)) { halo = true }
+ if await sleep(0.45) == false { return }
+ withAnimation(.easeOut(duration: 0.3)) { halo = false }
+ if await sleep(0.35) == false { return }
+
+ // Click the composer to focus it.
+ let composer = composerPoint(in: size)
+ let composerTarget = CGPoint(x: composer.x - tuning.tipOffset.width, y: composer.y + tuning.tipOffset.height)
+ haloPoint = composer
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = composerTarget }
+ if await sleep(tuning.pointerTravel) == false { return }
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await sleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+ withAnimation(.easeOut(duration: 0.3)) { halo = false }
+ composerFocused = true
+ composerCaretVisible = true
+ if await sleep(0.3) == false { return }
+
+ // Type the command into the composer (the running task is the one being composed).
+ let command = (conversations.first(where: { $0.isRunning }) ?? conversations.first)?.prompt ?? ""
+ for character in command {
+ composerText.append(character)
+ if await sleep(0.045) == false { return }
+ }
+ if await sleep(0.45) == false { return }
+
+ // Cross to the send button and click it.
+ let sendPoint = composerSendPoint(in: size)
+ let sendTarget = CGPoint(x: sendPoint.x - tuning.tipOffset.width, y: sendPoint.y + tuning.tipOffset.height)
+ haloPoint = sendPoint
+ withAnimation(.easeInOut(duration: tuning.pointerTravel)) { pointer = sendTarget }
+ if await sleep(tuning.pointerTravel) == false { return }
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await sleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+ withAnimation(.easeOut(duration: 0.3)) { halo = false }
+
+ // Send: clear the composer and reveal the running task.
+ composerText = ""
+ composerFocused = false
+ sentAt = Date()
+ withAnimation(.easeOut(duration: 0.25)) { sentTask = true }
+
+ // The pointer vanishes; the task keeps running in the notch.
+ withAnimation(.easeOut(duration: 0.3)) { pointerVisible = false }
+ }
+
+ /// Sleeps for `seconds`, returning false if the task was cancelled (slide left).
+ private func sleep(_ seconds: Double) async -> Bool {
+ do {
+ try await Task.sleep(for: .seconds(seconds))
+ return !Task.isCancelled
+ } catch {
+ return false
+ }
+ }
+}
diff --git a/apps/Donkey/Sources/Donkey/Onboarding/OnboardingSignInMock.swift b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingSignInMock.swift
new file mode 100644
index 00000000..f303169f
--- /dev/null
+++ b/apps/Donkey/Sources/Donkey/Onboarding/OnboardingSignInMock.swift
@@ -0,0 +1,238 @@
+// The sign-in slide's artwork: the screen edge with a collapsed notch at the top
+// and the command field below. The field types a prompt and the pointer clicks
+// send; the sent prompt runs in the collapsed notch (it never expands), cycling
+// through the example commands. Built on `OnboardingMockKit`.
+
+import SwiftUI
+
+/// The sign-in slide: the screen edge with a collapsed notch at the top, and the
+/// command field below. The field types a prompt and the pointer clicks send;
+/// the sent prompt then runs in the collapsed notch (timer ticking) — it never
+/// expands. Cycles through the example commands. Decorative only.
+struct OnboardingSignInMock: View {
+ let commands: [String]
+
+ private let pillWidth: CGFloat = 320
+ private let pillHeight: CGFloat = 38
+ private let edgeYFraction: CGFloat = 0.13
+ private let fieldYFraction: CGFloat = 0.66
+ private let fieldHeight: CGFloat = 66
+ private let leadingPadding: CGFloat = 20
+ private let trailingPadding: CGFloat = 14.6
+ private let sendDiameter: CGFloat = 36.8
+ private let micSize: CGFloat = 28
+
+ @State private var typed = ""
+ @State private var caretVisible = true
+ @State private var pointer: CGPoint = .zero
+ @State private var pointerVisible = false
+ @State private var pointerColor: Color = .blue
+ @State private var pressed = false
+ @State private var halo = false
+
+ @State private var runningPrompt = ""
+ @State private var runningColor: Color = .blue
+ @State private var runningSince = Date()
+ @State private var hasRunning = false
+
+ var body: some View {
+ GeometryReader { proxy in
+ let size = proxy.size
+ let send = sendCenter(in: size)
+ ZStack(alignment: .topLeading) {
+ OnboardingScreenEdge(color: OnboardingPalette.ink.opacity(0.35))
+ .frame(width: size.width)
+ .position(x: size.width / 2, y: edgeY(size))
+
+ collapsedNotch
+ .position(x: size.width / 2, y: edgeY(size) + pillHeight / 2)
+
+ field(width: fieldWidth(in: size))
+ .position(fieldCenter(in: size))
+
+ if halo {
+ Circle()
+ .stroke(pointerColor.opacity(0.7), lineWidth: 2)
+ .frame(width: sendDiameter + 6, height: sendDiameter + 6)
+ .scaleEffect(pressed ? 1.3 : 1)
+ .position(send)
+ .transition(.opacity)
+ }
+
+ OnboardingCursorMark(color: pointerColor)
+ .frame(width: 30, height: 30)
+ .scaleEffect(pressed ? 0.86 : 1, anchor: .topTrailing)
+ .position(pointer)
+ .opacity(pointerVisible ? 1 : 0)
+ }
+ .frame(width: size.width, height: size.height)
+ .clipShape(Rectangle())
+ .task { await run(in: size) }
+ }
+ .allowsHitTesting(false)
+ }
+
+ // MARK: Collapsed notch
+
+ private var collapsedNotch: some View {
+ let shape = OnboardingNotchShape(width: pillWidth, height: pillHeight, cornerRadius: 18)
+ return ZStack {
+ Color.black
+ if hasRunning {
+ HStack(spacing: 7) {
+ OnboardingCursorMark(color: runningColor)
+ .frame(width: 14, height: 14)
+ Text(runningPrompt)
+ .font(.system(size: 12, weight: .regular))
+ .foregroundStyle(Color.white.opacity(0.92))
+ .lineLimit(1)
+ .truncationMode(.tail)
+ Spacer(minLength: 0)
+ OnboardingElapsedClock(
+ appearedAt: runningSince,
+ offset: 0,
+ font: .system(size: 11, weight: .regular).monospacedDigit(),
+ color: Color.white.opacity(0.5)
+ )
+ }
+ .padding(.horizontal, 13)
+ } else {
+ HStack {
+ OnboardingCursorMark(color: onboardingAccent(0), silhouette: true)
+ .frame(width: 14, height: 14)
+ Spacer(minLength: 0)
+ }
+ .padding(.leading, 13)
+ }
+ }
+ .frame(width: pillWidth, height: pillHeight)
+ .clipShape(shape)
+ .overlay(shape.stroke(Color.white.opacity(0.08), lineWidth: 1))
+ }
+
+ // MARK: Field
+
+ private func field(width: CGFloat) -> some View {
+ let hasText = !typed.isEmpty
+ return HStack(spacing: 12) {
+ ZStack(alignment: .leading) {
+ if !hasText {
+ Text("What can donkey do for you?")
+ .font(.system(size: 16, weight: .light))
+ .foregroundStyle(Color.white.opacity(0.58))
+ .lineLimit(1)
+ }
+ HStack(alignment: .center, spacing: 1) {
+ Text(typed)
+ .font(.system(size: 16, weight: .light))
+ .foregroundStyle(.white)
+ .lineLimit(1)
+ RoundedRectangle(cornerRadius: 1, style: .continuous)
+ .fill(Color.white)
+ .frame(width: 2, height: 20)
+ .opacity(caretVisible ? 1 : 0)
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+
+ HStack(spacing: 16) {
+ Image(systemName: "mic")
+ .font(.system(size: 24, weight: .ultraLight))
+ .foregroundStyle(Color.white.opacity(hasText ? 0.34 : 0.52))
+ .frame(width: micSize, height: micSize)
+ ZStack {
+ Circle().fill(Color.white.opacity(hasText ? 0.94 : 0.68))
+ Image(systemName: "arrow.up")
+ .font(.system(size: 17, weight: .semibold))
+ .foregroundStyle(Color.black.opacity(hasText ? 0.78 : 0.42))
+ }
+ .frame(width: sendDiameter, height: sendDiameter)
+ }
+ }
+ .padding(.leading, leadingPadding)
+ .padding(.trailing, trailingPadding)
+ .frame(width: width, height: fieldHeight)
+ .background(Capsule(style: .continuous).fill(Color.black))
+ .overlay(Capsule(style: .continuous).stroke(Color.white.opacity(0.34), lineWidth: 1))
+ .shadow(color: Color.black.opacity(0.2), radius: 12, x: 0, y: 5)
+ }
+
+ // MARK: Geometry
+
+ private func edgeY(_ size: CGSize) -> CGFloat { size.height * edgeYFraction }
+
+ private func fieldWidth(in size: CGSize) -> CGFloat { min(518, size.width - 48) }
+
+ private func fieldCenter(in size: CGSize) -> CGPoint {
+ CGPoint(x: size.width / 2, y: size.height * fieldYFraction)
+ }
+
+ private func sendCenter(in size: CGSize) -> CGPoint {
+ let center = fieldCenter(in: size)
+ let right = center.x + fieldWidth(in: size) / 2
+ return CGPoint(x: right - trailingPadding - sendDiameter / 2, y: center.y)
+ }
+
+ // MARK: Simulation
+
+ @MainActor
+ private func run(in size: CGSize) async {
+ let start = CGPoint(x: size.width + 70, y: size.height * 0.92)
+ let send = sendCenter(in: size)
+ let target = CGPoint(x: send.x - 10, y: send.y + 13)
+ var commandIndex = 0
+ var colorIndex = 3
+
+ while !Task.isCancelled {
+ typed = ""
+ pressed = false
+ halo = false
+ pointerVisible = false
+ pointer = start
+ pointerColor = onboardingAccent(colorIndex)
+
+ // Blink the caret once, then start typing the command.
+ caretVisible = true
+ if await onboardingSleep(0.5) == false { return }
+ caretVisible = false
+ if await onboardingSleep(0.5) == false { return }
+ caretVisible = true
+
+ let command = commands[commandIndex % commands.count]
+ for character in command {
+ typed.append(character)
+ if await onboardingSleep(0.05) == false { return }
+ }
+ if await onboardingSleep(0.5) == false { return }
+
+ // Fly the pointer in and click send.
+ pointerVisible = true
+ withAnimation(.easeInOut(duration: 0.95)) { pointer = target }
+ if await onboardingSleep(0.95) == false { return }
+ withAnimation(.easeOut(duration: 0.10)) {
+ pressed = true
+ halo = true
+ }
+ if await onboardingSleep(0.12) == false { return }
+ withAnimation(.easeOut(duration: 0.12)) { pressed = false }
+
+ // Send: the prompt moves into the collapsed notch and starts running.
+ runningPrompt = command
+ runningColor = pointerColor
+ runningSince = Date()
+ hasRunning = true
+ withAnimation(.easeOut(duration: 0.2)) { typed = "" }
+ caretVisible = false
+ withAnimation(.easeOut(duration: 0.28)) {
+ pointerVisible = false
+ halo = false
+ }
+
+ // Let it run in the notch before the next prompt.
+ if await onboardingSleep(2.6) == false { return }
+
+ commandIndex += 1
+ colorIndex = (colorIndex + 1) % onboardingAccentPalette.count
+ }
+ }
+}