Skip to content

Open source CapCut alternative.

TypeScript

Fix pointer prompt placeholder fallback

David Le3044a3a9f043
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
index 7781d3ae..fa3743d8 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptOverlayModel.swift
@@ -76,6 +76,7 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
promptState.isActive = true
promptState.isPrimaryActionEnabled = true
promptState.leadingSignalLevel = .ready
+ promptState.promptText = PointerPromptCopy.defaultPromptPlaceholder
}
func updateVoiceWaveformLevels(_ levels: [Double]) {
@@ -502,6 +503,13 @@ final class PointerPromptOverlayModel: ObservableObject, PointerPromptIntentSink
result: PointerPromptCommandHandlingResult
) {
syncPrimaryTaskPausedFlag()
+ if promptState.isActive {
+ if lastActiveTaskID == taskID {
+ lastActiveTaskID = notchTasks.first?.id
+ }
+ return
+ }
+
if let runningTask = notchTasks.first(where: { activeTaskIDs.contains($0.id) && $0.status == .running }) {
promptState.leadingSignalLevel = .thinking
promptState.promptText = runningTask.title
diff --git a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift
index 072f5203..f977e7c2 100644
--- a/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/PointerPromptContracts.swift
@@ -3,6 +3,12 @@ import Foundation
public enum PointerPromptCopy {
public static let defaultPromptPlaceholder = "What can donkey do for you?"
+ private static let transientComposerPlaceholders: Set<String> = [
+ "Listening...",
+ "No voice captured",
+ "Transcribing...",
+ "Voice unavailable"
+ ]
public static func normalizedDisplayText(_ text: String) -> String {
text
@@ -11,6 +17,15 @@ public enum PointerPromptCopy {
.joined(separator: " ")
}
+ public static func composerPlaceholder(for text: String) -> String {
+ let normalizedText = normalizedDisplayText(text)
+ guard transientComposerPlaceholders.contains(normalizedText) else {
+ return defaultPromptPlaceholder
+ }
+
+ return normalizedText
+ }
+
public static func isTaskDisplayText(_ text: String) -> Bool {
let normalizedText = normalizedDisplayText(text)
return !normalizedText.isEmpty &&
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
index cca89626..0d1a0e5c 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptStageView.swift
@@ -273,7 +273,7 @@ struct PointerPromptComposer: View {
private var textInput: some View {
ComposerMultilineTextInput(
text: $messageText,
- placeholder: state.promptText,
+ placeholder: PointerPromptCopy.composerPlaceholder(for: state.promptText),
isActive: state.isActive,
textHeightChanged: inputTextHeightChanged,
expansionChanged: inputExpansionChanged,
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
index 3e90d35f..512384d9 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
@@ -16,4 +16,17 @@ struct PointerPromptCopyTests {
#expect(!PointerPromptCopy.isTaskDisplayText(" \(PointerPromptCopy.defaultPromptPlaceholder) "))
#expect(PointerPromptCopy.isTaskDisplayText("Open Safari"))
}
+
+ @Test
+ func composerPlaceholderDoesNotReuseTaskOrResultText() {
+ #expect(
+ PointerPromptCopy.composerPlaceholder(for: "I couldn't find a supported local action for that yet.") ==
+ PointerPromptCopy.defaultPromptPlaceholder
+ )
+ #expect(
+ PointerPromptCopy.composerPlaceholder(for: "play some justin bieber") ==
+ PointerPromptCopy.defaultPromptPlaceholder
+ )
+ #expect(PointerPromptCopy.composerPlaceholder(for: "Listening...") == "Listening...")
+ }
}