Skip to content

Open source CapCut alternative.

TypeScript

feat(app): let the user retry a failed tool-setup row

David Le9daddd2864b6
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
index 312ea3c2..5063af2f 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
@@ -733,6 +733,9 @@ final class UserQueryOverlayController {
reloadCreditsRequested: { [weak self] conversationID in
self?.model.reloadCredits(id: conversationID)
},
+ retrySetupRequested: { [weak self] conversationID in
+ self?.model.retrySystemToolsSetup(id: conversationID)
+ },
submitChoiceForm: { [weak self] conversationID, selection in
self?.model.submitChoiceForm(conversationID: conversationID, selection: selection)
}
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
index 06243e94..9c611a2c 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
@@ -272,15 +272,42 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
)
scheduleSystemSetupAutoAcknowledge(id: id)
case .failed:
+ // The row carries a Retry action while failed (see `retrySystemToolsSetup`), so the message
+ // states the outcome plainly rather than promising an automatic retry the user can't see.
announceLifecycle(
conversationID: id,
- UserQueryActivity(kind: .failed, summary: "Couldn’t finish setting up tools — Donkey will try again later"),
+ UserQueryActivity(kind: .failed, summary: "Couldn’t finish setting up tools"),
status: .failed
)
scheduleSystemSetupAutoAcknowledge(id: id)
}
}
+ /// Re-run the bundled-tools install for a setup row the user tapped Retry on. The launch-time run gives
+ /// up after a few attempts and parks the row at `.failed`; this lets the user drive a fresh attempt then
+ /// and there — no relaunch. Re-open the row to running immediately so the tap registers and the
+ /// `status == .failed` guard makes a second tap a no-op (no double-launch). The installer's own events
+ /// then drive the row to completed/failed; if it returns having done nothing (tools already current, so
+ /// no events fired) the result settles the optimistic row so it never spins forever.
+ func retrySystemToolsSetup(id: String) {
+ guard let conversation = conversation(withID: id),
+ conversation.origin == .system,
+ conversation.status == .failed else {
+ return
+ }
+ updateConversation(id: id, detail: "Retrying…", status: .running)
+ Task { [weak self] in
+ let installed = await BundledToolsInstaller.shared.installIfNeeded(onEvent: { event in
+ Task { @MainActor in self?.applyToolsSetupEvent(event) }
+ })
+ await MainActor.run {
+ guard let self,
+ self.conversation(withID: id)?.status == .running else { return }
+ self.applyToolsSetupEvent(installed ? .completed : .failed)
+ }
+ }
+ }
+
/// Create the setup row on the first event of a fresh run, or re-open the persisted one to running for a
/// new version's download (which clears its "seen" flag so it resurfaces). Reuses the stable id.
private func ensureSystemSetupConversation() {
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
index f807e370..ae18ee4b 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
@@ -61,6 +61,9 @@ public struct UserQueryNotchStatusView: View {
/// A conversation that failed for lack of credits shows a "Reload credits" CTA in its banner; tapping it
/// fires this so the app can open the billing page (reuses the permission-banner button styling).
private let reloadCreditsRequested: @MainActor (String) -> Void
+ /// A failed system tool-setup row shows a "Retry" pill; tapping it fires this so the app re-runs the
+ /// bundled-tools install without waiting for the next launch.
+ private let retrySetupRequested: @MainActor (String) -> Void
/// A conversation waiting on a generative options form (user.choose) submits the user's picks through
/// this — (conversationID, selection of fieldID→value). The harness resumes the task with the choices.
private let submitChoiceForm: @MainActor (String, [String: String]) -> Void
@@ -99,6 +102,7 @@ public struct UserQueryNotchStatusView: View {
needsLogin: Bool = false,
loginRequested: @escaping @MainActor () -> Void = {},
reloadCreditsRequested: @escaping @MainActor (String) -> Void = { _ in },
+ retrySetupRequested: @escaping @MainActor (String) -> Void = { _ in },
submitChoiceForm: @escaping @MainActor (String, [String: String]) -> Void = { _, _ in }
) {
self.state = state
@@ -134,6 +138,7 @@ public struct UserQueryNotchStatusView: View {
self.needsLogin = needsLogin
self.loginRequested = loginRequested
self.reloadCreditsRequested = reloadCreditsRequested
+ self.retrySetupRequested = retrySetupRequested
self.submitChoiceForm = submitChoiceForm
}
@@ -890,8 +895,9 @@ public struct UserQueryNotchStatusView: View {
/// (or Stop) button, or a Resume + Close pair. Permission rows carry their own banner controls.
private func controlsReserve(for conversation: UserQueryConversation) -> CGFloat {
if !conversation.isUserControllable {
- // A finished system row carries a lone Close (see `topRightControls`); a still-running one carries
- // no controls, so its text spans the full row.
+ // A failed setup row carries Retry + Close (a pair); a finished one carries a lone Close; a
+ // still-running one carries no controls, so its text spans the full row (see `topRightControls`).
+ if isRetryableSystemSetup(conversation) { return 74 }
return conversation.isUserDismissible ? 44 : 0
}
if conversation.status == .waitingForPermission { return 0 }
@@ -1067,6 +1073,10 @@ public struct UserQueryNotchStatusView: View {
default:
stateControls(for: conversation)
}
+ } else if isRetryableSystemSetup(conversation) {
+ // A setup row whose install gave up is the user's to retry — offer Retry + Close, the same
+ // two-button shape a paused user row uses for Resume + Close.
+ retryAndCloseControls(for: conversation)
} else if conversation.isUserDismissible {
// A finished system row (tool setup, "Tools ready") is no longer the app's to run — it's just a
// notice the user can clear. Offer Close so it can be deleted like any other completed row.
@@ -1121,6 +1131,28 @@ public struct UserQueryNotchStatusView: View {
}
}
+ /// A failed tool-setup row gets Retry + Close — the same text-button + Close shape a row waiting on the
+ /// user uses for Reply. Retry re-runs the bundled-tools install now rather than waiting for the next
+ /// launch; Close clears it like any other finished system row.
+ @ViewBuilder
+ private func retryAndCloseControls(for conversation: UserQueryConversation) -> some View {
+ HStack(spacing: 6) {
+ NotchTextButton(label: "Retry", isEnabled: true) {
+ retrySetupRequested(conversation.id)
+ }
+ NotchControlButton(systemName: "xmark", label: "Close", isEnabled: true) {
+ dismissRequested(conversation.id)
+ }
+ }
+ }
+
+ /// Whether this is the system tool-setup row in its failed state — the one row that offers Retry. Typed
+ /// on origin + status, never inferred from the narration text; a failed system row is also dismissible,
+ /// so the Retry it adds sits beside Close.
+ private func isRetryableSystemSetup(_ conversation: UserQueryConversation) -> Bool {
+ conversation.origin == .system && conversation.status == .failed
+ }
+
/// A conversation waiting on the user gets Reply (answer the clarification / respond to the review) + Close.
/// Reply pins the composer to this conversation and focuses the input; the user's next message answers it.
@ViewBuilder