Open source CapCut alternative.
TypeScript
fix(app): surface conversational replies in the chin
David Lefd991440f5ea
diff --git a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swiftindex 42be3c48..389b83db 100644--- a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift@@ -964,11 +964,12 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {?? (completed ? "Done." : "I tried operating \(appName) but couldn't confirm the goal was finished.")// Stream the assistant's final reply token-by-token into the notch (the chin and the open task- // row) when the turn produced a real text answer. It is re-composed from the harness's drafted+ // row) whenever the turn produced a real text answer. It is re-composed from the harness's drafted// answer so it stays grounded; the streamed text becomes the authoritative reply, and a failed// or empty stream falls back to the draft already computed above. Only conversational answers- // stream — an action that merely finished ("Done.") has no message worth typing out.- if completed, let conversationMessage, let answerStream {+ // stream — an action that merely finished ("Done.") has no message worth typing out. A respond-only+ // turn (e.g. a plain "hi") never reaches `completed`, so gate on the answer itself, not completion.+ if let conversationMessage, let answerStream {let prompt = Self.finalAnswerPrompt(goal: command, draftAnswer: conversationMessage)if let streamed = await textGenerator.generateStreaming(prompt, onDelta: answerStream),!streamed.isEmpty {@@ -989,7 +990,16 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {agentID: agentID,reason: "User query harness run returned without a terminal status")- let threadStatus = Self.userQueryStatus(forHarness: finalStatus)+ // A turn whose terminal step was talking to the user (conversation.respond) is a conversational+ // back-and-forth, not an app action — surface it as `.chatting` so the reply lands in the chin and+ // reads as a message. We key off the typed tool name, never the user's words. This matters because+ // a respond-only turn (a plain "hi") leaves the agent runnable; the defensive `timeOutIfRunnable`+ // above flips it to `.timedOut`, which the chin doesn't surface — so the reply would otherwise be+ // dropped. When the run actually finished an action, keep the runtime's terminal status.+ let answeredConversationally = conversationMessage != nil+ let threadStatus: UserQueryConversationStatus = (answeredConversationally && !completed)+ ? .chatting+ : Self.userQueryStatus(forHarness: finalStatus)// A run that failed safe for lack of credits carries a typed flag the notch reads to show the// reload CTA banner (instead of inferring the credit state from the narration text).var responseMetadata = [@@ -999,7 +1009,7 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {responseMetadata[UserQueryConversationMetadataKey.creditReloadRequired] = "true"}let result = UserQueryCommandHandlingResult(- status: completed ? .completed : .failedSafe,+ status: (completed || answeredConversationally) ? .completed : .failedSafe,threadStatus: threadStatus,decision: decision,summary: response,diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swiftindex 29042c77..dfec36ad 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift@@ -861,8 +861,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {}/// The tasks the collapsed notch keeps surfaced as floating pointers: anything running, anything- /// blocked on the user (a clarification, a review, or a permission), plus terminal tasks (completed- /// or failed) the user hasn't dismissed yet by expanding the notch. A failure — like an auth error —+ /// blocked on the user (a clarification, a review, or a permission), plus terminal tasks (a finished+ /// action, a conversational reply, or a failure) the user hasn't dismissed yet by expanding the notch.+ /// A failure — like an auth error —/// holds the chin until acknowledged just as a completion does; a waiting task keeps its pointer lit/// and pulsing (and its question in the chin) until the user answers.var notchSurfacedTasks: [UserQueryConversation] {@@ -879,7 +880,8 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {status.isAwaitingUserResponse || status == .waitingForPermission}- /// Marks every currently-terminal task (completed or failed) as seen so it stops surfacing in the+ /// Marks every currently-terminal task (a finished action, a conversational reply, or a failure) as+ /// seen so it stops surfacing in the/// collapsed notch. Called when the notch expands — the user is now looking at the full list. The/// flag is written to the task store, so the dismissal sticks across relaunches.func acknowledgeSurfacedTasks() {@@ -892,7 +894,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {}private static func isSurfacedTerminalStatus(_ status: UserQueryConversationStatus) -> Bool {- status == .completed || status == .failed+ // A conversational reply (`.chatting`) surfaces like a completion: the back-and-forth has to land+ // in the chin until the user acknowledges it by expanding, the same as a finished action.+ status == .completed || status == .chatting || status == .failed}private static func isSeen(_ task: UserQueryConversation) -> Bool {diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swiftindex 76fcb6bd..73deb384 100644--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift@@ -461,7 +461,8 @@ public struct UserQueryNotchStatusView: View {/// the chin until the user expands. Otherwise 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.+ /// recent undismissed result — a finished action or a conversational reply — keeps narrating instead+ /// of leaving the chin empty.private func rotatingChinTask(at date: Date) -> UserQueryConversation? {if let errored = surfacedTasks.first(where: { $0.status == .failed }) {return errored@@ -473,7 +474,9 @@ public struct UserQueryNotchStatusView: View {}let running = surfacedTasks.filter { $0.status == .running }guard !running.isEmpty else {- return surfacedTasks.first { $0.status == .completed }+ // With nothing running, hold the chin on the most recent result so it keeps narrating —+ // a finished action's outcome or a conversational reply (`.chatting`), whichever is newest.+ return surfacedTasks.first { $0.status == .completed || $0.status == .chatting }}let anchor = running.map(\.createdAt).max() ?? datelet slot = Int(max(0, date.timeIntervalSince(anchor)) / Self.chinRotationInterval)