Open source CapCut alternative.
TypeScript
feat(app): mirror notch completed-task surfacing and pointer cluster
David Lefd92ce23c949
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swiftindex 06ca6505..574079ab 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift@@ -588,6 +588,7 @@ final class UserQueryOverlayController {notchCommandInputTextHeight: model.notchCommandInputTextHeight,isNotchCommandInputExpanded: model.isNotchCommandInputExpanded,notchTasks: model.notchTasks,+ notchSurfacedTasks: model.notchSurfacedTasks,accentIndex: model.notchAccentIndex,spawnState: spawnCue,spawnStates: model.spawnStates,@@ -616,6 +617,7 @@ final class UserQueryOverlayController {commandInputTextHeight: model.notchCommandInputTextHeight,isCommandInputExpanded: model.isNotchCommandInputExpanded,tasks: model.notchTasks,+ surfacedTasks: model.notchSurfacedTasks,accentIndex: model.notchAccentIndex,spawnState: spawnCue,commandSubmitted: { [weak self] text in@@ -793,6 +795,8 @@ final class UserQueryOverlayController {self.isStatusExpanded = trueself.statusHoverPhase = .expandedself.statusExpansionWorkItem = nil+ // Opening the notch dismisses the completed pointers piled up in the collapsed surface.+ self.model.acknowledgeSurfacedCompletions()self.updateStatusPanelView()self.focusStatusComposerTextInputIfAvailable()}@@ -978,10 +982,10 @@ final class UserQueryOverlayController {)}- /// The collapsed chin hangs below the notch whenever any task is running; the notch view- /// rotates which running task's progress line it shows. It only grows the real-notch surface.+ /// The collapsed chin hangs below the notch whenever a task is surfaced — running, or a completion+ /// the user hasn't dismissed yet. The notch view rotates which one's line it shows. Real notch only.private var statusChinHeight: CGFloat {- model.notchTasks.contains { $0.status == .running } ? Self.statusChinBandHeight : 0+ model.notchSurfacedTasks.isEmpty ? 0 : Self.statusChinBandHeight}private static let statusChinBandHeight: CGFloat = 20@@ -1431,6 +1435,7 @@ private struct StatusPanelViewSnapshot: Equatable {var notchCommandInputTextHeight: CGFloatvar isNotchCommandInputExpanded: Boolvar notchTasks: [UserQueryNotchTask]+ var notchSurfacedTasks: [UserQueryNotchTask]var accentIndex: Intvar spawnState: UserQuerySpawnState?var spawnStates: [UserQuerySpawnState]diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swiftindex 08b383bd..4588cf45 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift@@ -33,6 +33,10 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {private var updateChecker: any DonkeyUpdateCheckingprivate let appCatalogRefreshLoop: LocalAppDynamicCatalogRefreshLoopprivate var activeTaskIDs: Set<String> = []+ /// Completed tasks the user has already seen surfaced in the collapsed notch. Expanding the notch+ /// acknowledges them so their colored pointers stop floating in the collapsed surface; the tasks+ /// themselves stay in the expanded list until closed.+ private var acknowledgedCompletionIDs: Set<String> = []private var lastActiveTaskID: String?/// The task/spawn the in-flight Gemini Live turn reports into, so the user/// sees the same cursor-and-task feedback as a local pipeline run.@@ -585,6 +589,23 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {}}+ /// The tasks the collapsed notch keeps surfaced as floating pointers: anything running, plus+ /// completed tasks the user hasn't dismissed yet by expanding the notch.+ var notchSurfacedTasks: [UserQueryNotchTask] {+ notchTasks.filter { task in+ task.status == .running ||+ (task.status == .completed && !acknowledgedCompletionIDs.contains(task.id))+ }+ }++ /// Marks every currently-completed task as seen so it stops surfacing in the collapsed notch.+ /// Called when the notch expands — the user is now looking at the full list.+ func acknowledgeSurfacedCompletions() {+ for task in notchTasks where task.status == .completed {+ acknowledgedCompletionIDs.insert(task.id)+ }+ }+/// Closes a task: removes it from the notch list and tears down its pointer./// Offered only for stopped (paused/interrupted/failed) and completed tasks —/// the same affordance the prototype calls "close".diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swiftindex f2e5031e..0eda0e0f 100644--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift@@ -18,6 +18,7 @@ public struct UserQueryNotchStatusView: View {private let commandInputTextHeight: CGFloatprivate let isCommandInputExpanded: Boolprivate let tasks: [UserQueryNotchTask]+ private let surfacedTasks: [UserQueryNotchTask]private let accentIndex: Intprivate let spawnState: UserQuerySpawnState?private let commandSubmitted: @MainActor (String) -> Void@@ -46,6 +47,7 @@ public struct UserQueryNotchStatusView: View {commandInputTextHeight: CGFloat,isCommandInputExpanded: Bool,tasks: [UserQueryNotchTask] = [],+ surfacedTasks: [UserQueryNotchTask] = [],accentIndex: Int,spawnState: UserQuerySpawnState? = nil,commandSubmitted: @escaping @MainActor (String) -> Void,@@ -71,6 +73,7 @@ public struct UserQueryNotchStatusView: View {self.commandInputTextHeight = commandInputTextHeightself.isCommandInputExpanded = isCommandInputExpandedself.tasks = tasks+ self.surfacedTasks = surfacedTasksself.accentIndex = accentIndexself.spawnState = spawnStateself.commandSubmitted = commandSubmitted@@ -168,11 +171,37 @@ public struct UserQueryNotchStatusView: View {private var restingCollapsedContent: some View {DonkeyCursorMark(color: accentColor, silhouette: true)- .frame(width: 13, height: 13)+ .frame(width: 14, height: 14).padding(.leading, 10).frame(width: animatingSurfaceWidth, height: animatingSurfaceHeight, alignment: .leading)}+ /// The leading-lane pointer(s). A single surfaced task shows one colored pointer; several surfaced+ /// tasks (running plus undismissed completions) overlap as a cascading stack, newest on top, capped+ /// so the lane never crowds. With nothing surfaced it falls back to the idle silhouette.+ @ViewBuilder+ private func pointerCluster(size: CGFloat) -> some View {+ let cluster = Array(surfacedTasks.prefix(Self.maxClusterPointers))+ if cluster.isEmpty {+ DonkeyCursorMark(color: accentColor, silhouette: true)+ .frame(width: size, height: size)+ } else {+ let count = cluster.count+ let width = size + Self.clusterStepX * CGFloat(count - 1)+ let height = size + Self.clusterStepY * CGFloat(count - 1)+ ZStack(alignment: .topLeading) {+ // Oldest first so the newest pointer lands on top, furthest along the cascade.+ ForEach(Array(cluster.reversed().enumerated()), id: \.element.id) { index, task in+ DonkeyCursorMark(color: accentColor(for: task.accentIndex))+ .frame(width: size, height: size)+ .offset(x: Self.clusterStepX * CGFloat(index), y: Self.clusterStepY * CGFloat(index))+ .zIndex(Double(index))+ }+ }+ .frame(width: width, height: height)+ }+ }+private func notchSurfaceShape(cornerRadius: CGFloat) -> UnevenRoundedRectangle {UnevenRoundedRectangle(cornerRadii: RectangleCornerRadii(@@ -213,8 +242,7 @@ public struct UserQueryNotchStatusView: View {private var fullWidthCollapsedContent: some View {HStack(spacing: 7) {- DonkeyCursorMark(color: accentColor, silhouette: !hasRunningTask)- .frame(width: 13, height: 13)+ pointerCluster(size: 14)Text(taskTitle).font(.system(size: 12, weight: .regular))@@ -242,12 +270,8 @@ public struct UserQueryNotchStatusView: View {TimelineView(.periodic(from: Self.chinRotationAnchor, by: Self.chinRotationInterval)) { context inlet speaker = rotatingChinTask(at: context.date)ZStack {- DonkeyCursorMark(- color: speaker.map { accentColor(for: $0.accentIndex) } ?? accentColor,- silhouette: speaker == nil- )- .frame(width: 13, height: 13)- .position(x: collapsedLeadingLaneCenterX, y: layout.collapsedVisibleHeight / 2)+ pointerCluster(size: 14)+ .position(x: collapsedLeadingLaneCenterX, y: layout.collapsedVisibleHeight / 2)collapsedRightSlot.frame(width: collapsedSideLaneWidth, height: layout.collapsedVisibleHeight)@@ -271,12 +295,15 @@ public struct UserQueryNotchStatusView: View {}}- /// The running task currently surfaced in the chin. Running tasks (newest first) rotate- /// round-robin; the clock is anchored to the newest task's start, so a freshly added task- /// shows first (the view re-renders on the task change) and then yields to the others.+ /// The task currently surfaced in the chin. Running tasks (newest first) rotate round-robin; the+ /// clock is anchored to the newest task's start, so a freshly added task shows first (the view+ /// re-renders on the task change) and then yields to the others. When nothing is running, the most+ /// recent undismissed completion keeps narrating its result instead of leaving the chin empty.private func rotatingChinTask(at date: Date) -> UserQueryNotchTask? {- let running = tasks.filter { $0.status == .running }- guard !running.isEmpty else { return nil }+ let running = surfacedTasks.filter { $0.status == .running }+ guard !running.isEmpty else {+ return surfacedTasks.first { $0.status == .completed }+ }let anchor = running.map(\.createdAt).max() ?? datelet slot = Int(max(0, date.timeIntervalSince(anchor)) / Self.chinRotationInterval)let index = ((slot % running.count) + running.count) % running.count@@ -844,12 +871,12 @@ public struct UserQueryNotchStatusView: View {}}- /// The collapsed right gutter follows the prototype exactly: it can only ever show one of the- /// three supported notifications — an attention glyph, a missing-permissions shield, or an- /// update cloud — the live run time while a task runs, "Done" once it finishes, otherwise- /// nothing. The time only ever rides alongside the chin (a running task always narrates), so the- /// gutter never shows a lonely clock without a chin; every state's full elapsed total lives in- /// the expanded row.+ /// The collapsed right gutter follows the prototype exactly: it only ever carries an icon or the+ /// live clock — one of the three supported notifications (an attention glyph, a missing-permissions+ /// shield, or an update cloud) or the run time while a task runs, otherwise nothing. A finished task+ /// is never labelled here; it keeps surfacing as a colored pointer + chin line instead. The time+ /// only rides alongside the chin (a running task always narrates), so the gutter never shows a+ /// lonely clock; every state's full elapsed total lives in the expanded row.@ViewBuilderprivate var collapsedRightSlot: some View {if let task = primaryTask {@@ -862,11 +889,9 @@ public struct UserQueryNotchStatusView: View {slotIcon("shield")case .running:compactLiveTime(since: task.createdAt)- case .completed:- // A finished task shows a status, not a clock.- slotText("Done", opacity: 0.92)- case .paused, .interrupted, .failed, .chatting:- // No chin in these states, so no time: they surface in the expanded list instead.+ case .completed, .paused, .interrupted, .failed, .chatting:+ // The gutter only ever carries icons or the live clock — a completed task keeps+ // surfacing as a colored pointer + chin line instead, and the rest surface in the list.EmptyView()}} else if updateState.isActionable {@@ -943,13 +968,6 @@ public struct UserQueryNotchStatusView: View {tasks.first}- private var hasRunningTask: Bool {- tasks.contains { $0.status == .running }- }-- private func isPrimaryTask(_ task: UserQueryNotchTask) -> Bool {- task.id == primaryTask?.id- }/// The task's status line, resolved through the centralized activity vocabulary so the notch and/// the future conversation view speak the same language.@@ -989,6 +1007,11 @@ public struct UserQueryNotchStatusView: View {private static let expandedContentDismissAnimation = Animation.easeOut(duration: 0.1)private static let contentInset: CGFloat = 14private static let taskListCommandSpacing: CGFloat = 8+ /// The collapsed leading lane shows at most this many overlapping pointers; extra surfaced tasks+ /// are still listed when the notch is expanded.+ private static let maxClusterPointers = 3+ private static let clusterStepX: CGFloat = 8+ private static let clusterStepY: CGFloat = 3/// The chin advances to the next running task every 2.6s, on a clock shared by all tasks.private static let chinRotationInterval: TimeInterval = 2.6private static let chinRotationAnchor = Date(timeIntervalSinceReferenceDate: 0)