Skip to content

Open source CapCut alternative.

TypeScript

feat(app): let users dismiss the finished tool-setup row

David Lecf09e9ca0341
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
index 846de8a6..c1fb5297 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
@@ -1097,9 +1097,10 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// the same affordance the prototype calls "close".
func dismissConversation(id conversationID: String) {
guard let conversation = conversation(withID: conversationID) else { return }
- // A system-driven conversation (tool setup) is the app's to close, not the user's — it clears
- // itself once finished (see `scheduleSystemSetupAutoAcknowledge`).
- guard conversation.isUserControllable else { return }
+ // A system-driven conversation (tool setup) is the app's to run while it works, but once it has
+ // finished it is just a notice the user can clear — so a completed/failed system row is dismissible
+ // too (see `isUserDismissible`). A still-running one stays the app's.
+ guard conversation.isUserDismissible else { return }
guard conversation.status != .running else { return }
notchConversations.removeAll { $0.id == conversationID }
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
index 9ed3fe70..491db20a 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
@@ -90,6 +90,20 @@ public extension UserQueryConversation {
/// Only conversations they started are theirs to control; a system-driven one (tool setup) is watched,
/// not operated. Every control surface and lifecycle hook gates on this, so the rule can't be missed.
var isUserControllable: Bool { origin == .user }
+
+ /// Whether the person may dismiss (close) this row. Their own conversations are always theirs to close;
+ /// a system-driven one (tool setup) is the app's to run while it works, but once it has settled it is
+ /// just a finished notice — so a completed or failed system row becomes dismissible too. A still-running
+ /// system row stays untouchable until the app settles it. Broader than `isUserControllable` precisely
+ /// because a finished system row is closeable without being otherwise operable.
+ var isUserDismissible: Bool {
+ switch origin {
+ case .user:
+ return true
+ case .system:
+ return status == .completed || status == .failed
+ }
+ }
}
public extension UserQueryConversation {
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
index 8d7638c7..2714fa5a 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
@@ -876,8 +876,11 @@ public struct UserQueryNotchStatusView: View {
/// Trailing room a row's text leaves for the pinned top-right controls, by control set: a lone Close
/// (or Stop) button, or a Resume + Close pair. Permission rows carry their own banner controls.
private func controlsReserve(for conversation: UserQueryConversation) -> CGFloat {
- // A system-driven row carries no controls (see `topRightControls`), so its text spans the full row.
- if !conversation.isUserControllable { return 0 }
+ 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.
+ return conversation.isUserDismissible ? 44 : 0
+ }
if conversation.status == .waitingForPermission { return 0 }
return rowShowsControlPair(conversation) ? 74 : 44
}
@@ -1043,11 +1046,7 @@ public struct UserQueryNotchStatusView: View {
/// running → stop; paused → resume + close; everything else → close, so any conversation can be deleted.
@ViewBuilder
private func topRightControls(_ conversation: UserQueryConversation) -> some View {
- if !conversation.isUserControllable {
- // A system-driven row (tool setup) is the app's to run: the user watches it, but it carries no
- // Stop / Resume / Close — it can't be stopped or dismissed by hand.
- EmptyView()
- } else {
+ if conversation.isUserControllable {
switch conversation.status {
case .waitingForPermission:
// The permission banner carries its own Approve / Deny; the row needs no extra control.
@@ -1055,6 +1054,14 @@ public struct UserQueryNotchStatusView: View {
default:
stateControls(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.
+ closeControl(for: conversation)
+ } else {
+ // A system row still running is the app's to run: the user watches it, but it carries no
+ // Stop / Resume / Close — it can't be stopped or dismissed by hand until it settles.
+ EmptyView()
}
}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/SystemToolsSetupConversationTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/SystemToolsSetupConversationTests.swift
index f255a4c8..ae1c9968 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/SystemToolsSetupConversationTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/SystemToolsSetupConversationTests.swift
@@ -5,9 +5,11 @@ import Testing
@testable import Donkey
/// The first-run tool-bundle download surfaces as a normal-looking conversation, but it is system-driven:
-/// the app runs it to completion and the user can't stop, resume, reply to, or dismiss it. That rule is
-/// carried by `origin == .system` (so `isUserControllable` is false), and the relaunch restore must never
-/// hand a system row to the harness auto-resume — it has no loop behind it. These lock both.
+/// the app runs it to completion and the user can't stop, resume, or reply to it. While it runs it can't be
+/// dismissed either; once it finishes it becomes a closeable notice the user can clear. That is carried by
+/// `origin == .system` (so `isUserControllable` is false) plus `isUserDismissible` (true only for a finished
+/// system row). The relaunch restore must also never hand a system row to the harness auto-resume — it has
+/// no loop behind it. These lock all three.
@Suite
@MainActor
struct SystemToolsSetupConversationTests {
@@ -36,6 +38,17 @@ struct SystemToolsSetupConversationTests {
#expect(!conversation(id: "s", status: .running, origin: .system).isUserControllable)
}
+ @Test
+ func systemConversationBecomesDismissibleOnlyOnceFinished() {
+ // The app owns a system row while it runs — not dismissible. Once it settles (Tools ready → completed,
+ // or a give-up → failed) it is just a notice the user can clear, so it becomes dismissible. A user row
+ // is always the user's to close.
+ #expect(!conversation(id: "s", status: .running, origin: .system).isUserDismissible)
+ #expect(conversation(id: "s", status: .completed, origin: .system).isUserDismissible)
+ #expect(conversation(id: "s", status: .failed, origin: .system).isUserDismissible)
+ #expect(conversation(id: "u", status: .running, origin: .user).isUserDismissible)
+ }
+
@Test
func restoredSystemConversationIsNeverAutoResumed() {
let now = Date()