Open source CapCut alternative.
TypeScript
Wire generic harness gates into notch UI
David Le9081a2ca336d
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swiftindex 4b69325a..a074e594 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift@@ -56,6 +56,7 @@ protocol PointerPromptCommandHandling: Sendable {) async -> PointerPromptCommandHandlingResultfunc pauseCommand(taskID: String) async -> Boolfunc resumeCommand(taskID: String) async -> Bool+ func approvePermissionGate(taskID: String) async -> Bool}extension PointerPromptCommandHandling {@@ -406,15 +407,11 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {registry: registry)let runStep = await genericRuntime.executeNextPlannedStep(taskID: taskID)- let result = await localRunResults.firstResult() ?? LocalAppTaskLiveRunResult(+ let result = await localRunResults.firstResult() ?? Self.syntheticLocalRunResult(command: commandRedaction.redactedText,traceID: traceID,- status: .failedSafe,resolution: resolution,- metadata: [- "reason": "genericHarnessMissingLocalRunResult",- "genericHarness.stoppedForGate": String(runStep?.stoppedForGate ?? false)- ]+ runStep: runStep)let finalized = await finalizeGenericHarnessTask(taskID: taskID,@@ -430,12 +427,12 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {).map(groundAgentVisualizationPlan)let handlingResult = PointerPromptCommandHandlingResult(status: result.status,- threadStatus: threadStatus(for: result),+ threadStatus: threadStatus(for: result, runStep: runStep),decision: routing.outcome.decision,summary: summary(for: result, runStep: runStep),taskLabel: taskLabel(for: result),traceID: traceID,- metadata: result.metadata.merging(+ metadata: Self.genericHarnessTaskMetadata(runStep?.task).merging(result.metadata) { current, _ in current }.merging(Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome)) { current, _ in current }.merging(Self.genericHarnessMetadata(@@ -484,6 +481,13 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {return genericResumed || oldRunnerResumed}+ func approvePermissionGate(taskID: String) async -> Bool {+ await genericHarnessLifecycle.approvePermissionGate(+ taskID: taskID,+ reason: "Pointer prompt approved pending permissions"+ ) != nil+ }+private func finalizeGenericHarnessTask(taskID: String,result: LocalAppTaskLiveRunResult,@@ -882,6 +886,16 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {for result: LocalAppTaskLiveRunResult,runStep: HarnessStepExecutionResult?) -> String {+ if let task = runStep?.task,+ task.status == .waitingForPermission {+ return Self.permissionGateSummary(for: task)+ }++ if let task = runStep?.task,+ task.status == .interrupted {+ return Self.interruptionSummary(for: task)+ }+if let question = runStep?.task.pendingContinuation?.question,!question.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {return question@@ -890,7 +904,14 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {return summary(for: result)}- private func threadStatus(for result: LocalAppTaskLiveRunResult) -> PointerPromptTaskStatus {+ private func threadStatus(+ for result: LocalAppTaskLiveRunResult,+ runStep: HarnessStepExecutionResult? = nil+ ) -> PointerPromptTaskStatus {+ if let status = Self.pointerPromptStatus(for: runStep?.task) {+ return status+ }+switch result.status {case .completed:return .completed@@ -1065,6 +1086,101 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {)}+ private static func syntheticLocalRunResult(+ command: String,+ traceID: String,+ resolution: LocalAppTaskCatalogResolution,+ runStep: HarnessStepExecutionResult?+ ) -> LocalAppTaskLiveRunResult {+ if let task = runStep?.task,+ task.status == .waitingForPermission {+ return LocalAppTaskLiveRunResult(+ command: command,+ traceID: traceID,+ status: .needsConfirmation,+ resolution: resolution,+ metadata: [+ "reason": "genericHarnessPermissionGate",+ "genericHarness.stoppedForGate": String(runStep?.stoppedForGate ?? false)+ ].merging(genericHarnessTaskMetadata(task)) { current, _ in current }+ )+ }++ return LocalAppTaskLiveRunResult(+ command: command,+ traceID: traceID,+ status: .failedSafe,+ resolution: resolution,+ metadata: [+ "reason": "genericHarnessMissingLocalRunResult",+ "genericHarness.stoppedForGate": String(runStep?.stoppedForGate ?? false)+ ]+ )+ }++ private static func pointerPromptStatus(for task: HarnessTaskState?) -> PointerPromptTaskStatus? {+ guard let task else { return nil }++ switch task.status {+ case .running, .resuming:+ return nil+ case .paused:+ return .paused+ case .waitingForUser:+ return .waitingForClarification+ case .waitingForPermission:+ return .waitingForPermission+ case .interrupted:+ return .interrupted+ case .completed:+ return .completed+ case .failedSafe, .cancelled:+ return .failed+ }+ }++ private static func genericHarnessTaskMetadata(_ task: HarnessTaskState?) -> [String: String] {+ guard let task else { return [:] }++ var metadata: [String: String] = [+ "genericHarness.taskStatus": task.status.rawValue+ ]+ if let continuation = task.pendingContinuation {+ metadata["genericHarness.pendingReason"] = continuation.reason+ metadata["genericHarness.pendingStage"] = continuation.stage.rawValue+ metadata["genericHarness.pendingToolName"] = continuation.pendingToolCall?.name ?? ""+ metadata["genericHarness.pendingToolCallID"] = continuation.pendingToolCall?.id ?? ""+ metadata["genericHarness.pendingQuestion"] = continuation.question ?? ""+ metadata["genericHarness.missingPermissions"] = continuation.missingPermissions+ .map(\.rawValue)+ .joined(separator: ",")+ metadata["genericHarness.newGoal"] = continuation.metadata["newGoal"] ?? ""+ }+ return metadata+ }++ private static func permissionGateSummary(for task: HarnessTaskState) -> String {+ let permissions = task.pendingContinuation?.missingPermissions ?? []+ let permissionText = permissions.isEmpty+ ? "permission"+ : permissions.map(\.rawValue).joined(separator: ", ")+ let pendingTool = task.pendingContinuation?.pendingToolCall?.name+ if let pendingTool, !pendingTool.isEmpty {+ return "Approve \(permissionText) for \(pendingTool)"+ }++ return "Approve \(permissionText)"+ }++ private static func interruptionSummary(for task: HarnessTaskState) -> String {+ if let newGoal = task.pendingContinuation?.metadata["newGoal"],+ !newGoal.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {+ return "Changed course: \(newGoal)"+ }++ return "Changed course"+ }+private static func harnessRequest(command: String,context: PointerPromptCommandContext?diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swiftindex ae54d72c..5182a92f 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayController.swift@@ -609,6 +609,9 @@ final class PointerPromptOverlayController {resumeRequested: { [weak self] taskID inself?.model.resumeTask(id: taskID)},+ approvePermissionRequested: { [weak self] taskID in+ self?.model.approvePermissionGate(id: taskID)+ },updateRequested: { [weak self] inself?.openAvailableUpdate()}diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swiftindex 3f740191..3145f0f8 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift@@ -342,7 +342,8 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkid: task.id,title: isFollowUp ? nil : result.taskLabel,detail: result.summary,- status: Self.taskStatus(for: result)+ status: Self.taskStatus(for: result),+ metadata: result.metadata)self.appendTaskEvent(taskID: task.id, role: .assistant, text: result.summary)self.activeTaskIDs.remove(task.id)@@ -380,14 +381,17 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink}func resumeTask(id taskID: String) {- guard task(withID: taskID)?.status == .paused else { return }+ guard let task = task(withID: taskID),+ task.status == .paused || task.status == .interrupted else {+ return+ }activeTaskIDs.insert(taskID)lastActiveTaskID = taskIDupdateTask(id: taskID, detail: "Running", status: .running)appendTaskEvent(taskID: taskID, role: .system, text: "Resumed")promptState.leadingSignalLevel = .thinking- promptState.promptText = task(withID: taskID)?.title ?? "Working"+ promptState.promptText = task.titlesyncPrimaryTaskPausedFlag()Task { [weak self, commandHandler] inlet resumedInMemory = await commandHandler.resumeCommand(taskID: taskID)@@ -399,6 +403,35 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink}}+ func approvePermissionGate(id taskID: String) {+ guard let task = task(withID: taskID),+ task.status == .waitingForPermission else {+ return+ }++ activeTaskIDs.insert(taskID)+ lastActiveTaskID = taskID+ let detail = Self.permissionApprovalDetail(for: task)+ updateTask(id: taskID, detail: detail, status: .running)+ appendTaskEvent(taskID: taskID, role: .system, text: detail)+ promptState.leadingSignalLevel = .thinking+ promptState.promptText = task.title+ syncPrimaryTaskPausedFlag()+ Task { [weak self, commandHandler] in+ let approved = await commandHandler.approvePermissionGate(taskID: taskID)+ await MainActor.run {+ guard let self else { return }+ if approved {+ self.updateTask(id: taskID, detail: "Permission approved", status: .running)+ } else {+ self.updateTask(id: taskID, detail: "Approval unavailable", status: .needsAttention)+ self.activeTaskIDs.remove(taskID)+ }+ self.syncPrimaryTaskPausedFlag()+ }+ }+ }+func updateNotchCommandInputTextHeight(_ height: CGFloat) {let clampedHeight = PointerPromptLayout.clampedComposerInputTextHeight(height)guard abs(notchCommandInputTextHeight - clampedHeight) > 0.5 else { return }@@ -616,8 +649,15 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkif let reservedAccentIndex {task.accentIndex = PointerPromptAccentPalette.normalizedIndex(reservedAccentIndex)}- task.detail = "Running"- task.status = .running+ if Self.shouldShowChangedCourseState(for: task) {+ task.detail = "Changed course: \(Self.collapsedDisplayText(for: text))"+ task.status = .interrupted+ task.metadata["genericHarness.taskStatus"] = "interrupted"+ task.metadata["genericHarness.newGoal"] = text+ } else {+ task.detail = "Running"+ task.status = .running+ }task.updatedAt = Date()notchAccentIndex = PointerPromptAccentPalette.normalizedIndex(task.accentIndex)prependTask(task)@@ -772,7 +812,8 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkid: String,title: String? = nil,detail: String? = nil,- status: PointerPromptTaskStatus? = nil+ status: PointerPromptTaskStatus? = nil,+ metadata: [String: String]? = nil) {guard let index = notchTasks.firstIndex(where: { $0.id == id }) else { return }@@ -786,6 +827,9 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkif let status {task.status = status}+ if let metadata {+ task.metadata = metadata+ }task.updatedAt = Date()notchTasks[index] = tasktaskStore.upsertTask(task)@@ -847,8 +891,12 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkswitch result.threadStatus {case .waitingForClarification:return "Waiting for detail"+ case .waitingForPermission:+ return "Waiting for approval"case .waitingForReview:return "Waiting for your review"+ case .interrupted:+ return "Changed course"case .needsAttention:return "Needs your attention"case .running:@@ -899,6 +947,34 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSinkreturn "Uploaded assets: \(displayNames)"}+ private static func permissionApprovalDetail(for task: PointerPromptNotchTask) -> String {+ let permissions = task.metadata["genericHarness.missingPermissions"]?+ .split(separator: ",")+ .map(String.init)+ .filter { !$0.isEmpty } ?? []+ guard !permissions.isEmpty else {+ return "Approving permission"+ }++ return "Approving \(permissions.joined(separator: ", "))"+ }++ private static func shouldShowChangedCourseState(for task: PointerPromptNotchTask) -> Bool {+ switch task.status {+ case .running, .interrupted:+ return true+ case .chatting,+ .paused,+ .completed,+ .waitingForClarification,+ .waitingForPermission,+ .waitingForReview,+ .needsAttention,+ .failed:+ return false+ }+ }+private static func persistedAsset(from draft: PointerPromptTaskAssetDraft,assetID: String,diff --git a/apps/Donkey/Sources/Donkey/PointerPromptTaskStore.swift b/apps/Donkey/Sources/Donkey/PointerPromptTaskStore.swiftindex ac842cd9..4ebb3e3a 100644--- a/apps/Donkey/Sources/Donkey/PointerPromptTaskStore.swift+++ b/apps/Donkey/Sources/Donkey/PointerPromptTaskStore.swift@@ -92,6 +92,7 @@ final class CoreDataPointerPromptTaskStore: PointerPromptTaskStoring {managedTask.setValue(Int64(task.accentIndex), forKey: Self.accentIndexKey)managedTask.setValue(task.createdAt, forKey: Self.createdAtKey)managedTask.setValue(task.updatedAt, forKey: Self.updatedAtKey)+ managedTask.setValue(Self.metadataJSONString(task.metadata), forKey: Self.metadataJSONKey)try? context.save()}@@ -211,7 +212,8 @@ final class CoreDataPointerPromptTaskStore: PointerPromptTaskStoring {attribute(statusKey, type: .stringAttributeType, isOptional: false),attribute(accentIndexKey, type: .integer64AttributeType, isOptional: false),attribute(createdAtKey, type: .dateAttributeType, isOptional: false),- attribute(updatedAtKey, type: .dateAttributeType, isOptional: false)+ attribute(updatedAtKey, type: .dateAttributeType, isOptional: false),+ attribute(metadataJSONKey, type: .stringAttributeType, isOptional: true)]taskEntity.uniquenessConstraints = [[idKey]]@@ -329,10 +331,30 @@ final class CoreDataPointerPromptTaskStore: PointerPromptTaskStoring {status: status,accentIndex: accentIndex,createdAt: createdAt,- updatedAt: updatedAt+ updatedAt: updatedAt,+ metadata: metadata(fromJSONString: managedTask.value(forKey: metadataJSONKey) as? String))}+ private static func metadataJSONString(_ metadata: [String: String]) -> String? {+ guard !metadata.isEmpty,+ let data = try? JSONEncoder().encode(metadata) else {+ return nil+ }++ return String(data: data, encoding: .utf8)+ }++ private static func metadata(fromJSONString string: String?) -> [String: String] {+ guard let string,+ let data = string.data(using: .utf8),+ let metadata = try? JSONDecoder().decode([String: String].self, from: data) else {+ return [:]+ }++ return metadata+ }+private static func event(from managedEvent: NSManagedObject) -> PointerPromptTaskEvent? {guard let id = managedEvent.value(forKey: eventIDKey) as? String,let taskID = managedEvent.value(forKey: eventTaskIDKey) as? String,@@ -390,6 +412,7 @@ final class CoreDataPointerPromptTaskStore: PointerPromptTaskStoring {private static let accentIndexKey = "accentIndex"private static let createdAtKey = "createdAt"private static let updatedAtKey = "updatedAt"+ private static let metadataJSONKey = "metadataJSON"private static let eventIDKey = "id"private static let eventTaskIDKey = "taskID"private static let eventRoleKey = "role"diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptSpawnContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptSpawnContracts.swiftindex 35a0a108..f8b2c983 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptSpawnContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptSpawnContracts.swift@@ -89,7 +89,9 @@ public enum PointerPromptSpawnLifecycle {.running,.paused,.waitingForClarification,+ .waitingForPermission,.waitingForReview,+ .interrupted,.needsAttention,.failed:truediff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptTaskContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptTaskContracts.swiftindex c6bc9454..568d3454 100644--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptTaskContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptTaskContracts.swift@@ -6,7 +6,9 @@ public enum PointerPromptTaskStatus: String, Codable, Equatable, Sendable {case pausedcase completedcase waitingForClarification+ case waitingForPermissioncase waitingForReview+ case interruptedcase needsAttentioncase failed}@@ -20,6 +22,7 @@ public struct PointerPromptNotchTask: Codable, Equatable, Identifiable, Sendablepublic var accentIndex: Intpublic var createdAt: Datepublic var updatedAt: Date+ public var metadata: [String: String]public init(id: String,@@ -29,7 +32,8 @@ public struct PointerPromptNotchTask: Codable, Equatable, Identifiable, Sendablestatus: PointerPromptTaskStatus,accentIndex: Int,createdAt: Date = Date(),- updatedAt: Date = Date()+ updatedAt: Date = Date(),+ metadata: [String: String] = [:]) {self.id = idself.title = title@@ -39,6 +43,7 @@ public struct PointerPromptNotchTask: Codable, Equatable, Identifiable, Sendableself.accentIndex = accentIndexself.createdAt = createdAtself.updatedAt = updatedAt+ self.metadata = metadata}}diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swiftindex fc206ff4..525dcb44 100644--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift@@ -304,9 +304,10 @@ public actor HarnessTaskCoordinator {public func grantPermissions(taskID: String,- permissions: Set<HarnessPermission>+ permissions: Set<HarnessPermission>,+ reason: String = "Permission granted") async -> HarnessTaskState? {- await mutate(taskID: taskID, status: .resuming, summary: "Permission granted") { task in+ await mutate(taskID: taskID, status: .resuming, summary: reason) { task intask.grantedPermissions.formUnion(permissions)task.pendingContinuation = nil}diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swiftindex 2b37886d..4e1f2043 100644--- a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift@@ -266,6 +266,22 @@ public struct AppHarnessGenericLifecycle: Sendable {await coordinator.resume(taskID: taskID, reason: reason)}+ @discardableResult+ public func approvePermissionGate(taskID: String, reason: String) async -> HarnessTaskState? {+ guard let task = await coordinator.task(id: taskID),+ task.status == .waitingForPermission,+ let continuation = task.pendingContinuation,+ !continuation.missingPermissions.isEmpty else {+ return nil+ }++ return await coordinator.grantPermissions(+ taskID: taskID,+ permissions: Set(continuation.missingPermissions),+ reason: reason+ )+ }+public static func localTaskRunDescriptor() -> HarnessToolDescriptor {HarnessToolDescriptor(name: AppHarnessGenericLifecycleToolNames.localAppRun,diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swiftindex 603235e0..a52639b9 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift@@ -26,6 +26,7 @@ public struct PointerPromptNotchStatusView: View {private let assetsDropped: @MainActor ([PointerPromptTaskAssetDraft]) -> Voidprivate let pauseRequested: @MainActor (String) -> Voidprivate let resumeRequested: @MainActor (String) -> Void+ private let approvePermissionRequested: @MainActor (String) -> Voidprivate let updateRequested: @MainActor () -> Voidpublic init(@@ -48,6 +49,7 @@ public struct PointerPromptNotchStatusView: View {assetsDropped: @escaping @MainActor ([PointerPromptTaskAssetDraft]) -> Void,pauseRequested: @escaping @MainActor (String) -> Void,resumeRequested: @escaping @MainActor (String) -> Void,+ approvePermissionRequested: @escaping @MainActor (String) -> Void,updateRequested: @escaping @MainActor () -> Void) {self.state = state@@ -69,6 +71,7 @@ public struct PointerPromptNotchStatusView: View {self.assetsDropped = assetsDroppedself.pauseRequested = pauseRequestedself.resumeRequested = resumeRequested+ self.approvePermissionRequested = approvePermissionRequestedself.updateRequested = updateRequested}@@ -483,7 +486,7 @@ public struct PointerPromptNotchStatusView: View {Spacer()- if task.status == .running || task.status == .paused {+ if task.status == .running || task.status == .paused || task.status == .waitingForPermission || task.status == .interrupted {activeTaskControls(for: task)} else {taskStatusAccessory(task)@@ -562,25 +565,47 @@ public struct PointerPromptNotchStatusView: View {)}+ @ViewBuilderprivate func activeTaskControls(for task: PointerPromptNotchTask) -> some View {- HStack(spacing: 6) {+ switch task.status {+ case .waitingForPermission:statusControlButton(- systemName: "play.fill",- label: "Resume",- isEnabled: task.status == .paused,+ systemName: "checkmark.shield",+ label: "Approve Permission",+ isEnabled: true,action: {- resumeRequested(task.id)+ approvePermissionRequested(task.id)})-+ case .interrupted:statusControlButton(- systemName: "pause.fill",- label: "Pause",- isEnabled: task.status == .running,+ systemName: "arrow.triangle.2.circlepath",+ label: "Resume Changed Task",+ isEnabled: true,action: {- pauseRequested(task.id)+ resumeRequested(task.id)})+ default:+ HStack(spacing: 6) {+ statusControlButton(+ systemName: "play.fill",+ label: "Resume",+ isEnabled: task.status == .paused,+ action: {+ resumeRequested(task.id)+ }+ )++ statusControlButton(+ systemName: "pause.fill",+ label: "Pause",+ isEnabled: task.status == .running,+ action: {+ pauseRequested(task.id)+ }+ )+ }}}@@ -639,11 +664,21 @@ public struct PointerPromptNotchStatusView: View {.font(.system(size: 12, weight: .regular)).foregroundStyle(Color.white.opacity(0.62)).frame(width: 18, height: 18)+ case .waitingForPermission:+ Image(systemName: "lock.shield")+ .font(.system(size: 11, weight: .regular))+ .foregroundStyle(Color.white.opacity(0.62))+ .frame(width: 18, height: 18)case .waitingForReview:Image(systemName: "doc.text.magnifyingglass").font(.system(size: 11, weight: .regular)).foregroundStyle(Color.white.opacity(0.62)).frame(width: 18, height: 18)+ case .interrupted:+ Image(systemName: "arrow.triangle.branch")+ .font(.system(size: 11, weight: .regular))+ .foregroundStyle(Color.white.opacity(0.62))+ .frame(width: 18, height: 18)case .needsAttention:Image(systemName: "exclamationmark").font(.system(size: 12, weight: .regular))@@ -708,8 +743,12 @@ public struct PointerPromptNotchStatusView: View {return "Done"case .waitingForClarification:return "Ask"+ case .waitingForPermission:+ return "Perm"case .waitingForReview:return "Rev"+ case .interrupted:+ return "Chg"case .needsAttention:return "Ask"case .failed:@@ -780,8 +819,12 @@ public struct PointerPromptNotchStatusView: View {return task.detail.isEmpty ? "Done" : task.detailcase .waitingForClarification:return task.detail.isEmpty ? "Waiting for detail" : task.detail+ case .waitingForPermission:+ return task.detail.isEmpty ? "Waiting for approval" : task.detailcase .waitingForReview:return task.detail.isEmpty ? "Waiting for review" : task.detail+ case .interrupted:+ return task.detail.isEmpty ? "Changed course" : task.detailcase .needsAttention:return task.detail.isEmpty ? "Needs attention" : task.detailcase .failed:diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swiftindex 7e4ef1c3..5541bafc 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift@@ -1111,6 +1111,38 @@ struct GenericHarnessTests {#expect(resumed?.pendingContinuation == nil)}+ @Test+ func pointerPromptLifecycleApprovesExactGenericPermissionGate() async {+ let store = InMemoryHarnessThreadStore()+ let coordinator = HarnessTaskCoordinator()+ let lifecycle = AppHarnessGenericLifecycle(threadStore: store, coordinator: coordinator)+ let task = await coordinator.createTask(+ id: "pointer-task-permission",+ threadID: "thread-permission",+ goal: "click a button"+ )+ _ = await coordinator.waitForPermission(+ taskID: task.id,+ missingPermissions: [.accessibility, .input],+ pendingToolCall: HarnessToolCall(+ id: "pending-click",+ name: "element.perform"+ ),+ reason: "Input needs approval"+ )++ let approved = await lifecycle.approvePermissionGate(+ taskID: task.id,+ reason: "Approved from notch"+ )+ let reloaded = await coordinator.task(id: task.id)++ #expect(approved?.status == .resuming)+ #expect(approved?.grantedPermissions == [.accessibility, .input])+ #expect(approved?.pendingContinuation == nil)+ #expect(reloaded?.grantedPermissions == [.accessibility, .input])+ }+@Testfunc pointerPromptLifecyclePlansRecoveryAsGenericToolStep() async {let store = InMemoryHarnessThreadStore()diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnLifecycleTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnLifecycleTests.swiftindex 9b92fcdd..c668ff56 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnLifecycleTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnLifecycleTests.swift@@ -8,7 +8,9 @@ struct PointerPromptSpawnLifecycleTests {#expect(!PointerPromptSpawnLifecycle.keepsVisibleResult(for: .completed))#expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .chatting))#expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .waitingForClarification))+ #expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .waitingForPermission))#expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .waitingForReview))+ #expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .interrupted))#expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .needsAttention))#expect(PointerPromptSpawnLifecycle.keepsVisibleResult(for: .failed))}diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.mdindex 41b6f47a..c23f8351 100644--- a/docs/guides/agent-harness.md+++ b/docs/guides/agent-harness.md@@ -100,6 +100,12 @@ rather than ad hoc thread snippets. Slow planner calls consume a compacted runcontext, including bounded world-state, failure, hint, memory, and semanticmemory summaries.+The pointer-prompt notch mirrors generic task stop states. Permission gates+show the pending tool and missing permissions, and the approval control grants+those exact permissions through the generic lifecycle. Follow-up course changes+surface as typed interrupted/changed-course task state instead of generic+attention text.+## Turn FlowThe desired loop is:diff --git a/plans/master-plan.md b/plans/master-plan.mdindex 2e553143..310ff074 100644--- a/plans/master-plan.md+++ b/plans/master-plan.md@@ -21,10 +21,7 @@ even when there are no active tasks.## Current Sequence-1. Wire interruption and permission gates into the UI. The notch/task UI should- control generic harness tasks and show the exact pending approval or- changed-course state.-2. Delete old app-specific paths once the generic path covers them. Remove+1. Delete old app-specific paths once the generic path covers them. Removehardcoded Music/Notes/Numbers/media/weather-style prompt rules, catalogspecial cases, repair logic, and demo-only workflow branches.