Let a queued message be taken back into the composer

This commit is contained in:
Ian Gulliver
2026-10-17 15:45:27 -07:00
parent e67576ac53
commit 658f78934c
12 changed files with 218 additions and 37 deletions
+12 -1
View File
@@ -135,6 +135,7 @@ struct PendingSend: Identifiable {
let local: Bool
let queued: Bool
let md: [MDBlock]
var inputId: Int? = nil
}
@MainActor
@@ -231,6 +232,10 @@ final class TranscriptBuilder {
}
}
func withdrawn(_ inputId: Int) {
pending.removeAll { $0.inputId == inputId }
}
private func confirmPending(_ text: String, queued: Bool, local: Bool) {
let i = queued ? pending.firstIndex { !$0.local && $0.text == text } : nil
if let i = i ?? (local ? pending.firstIndex { $0.local && $0.text == text } : nil) {
@@ -417,7 +422,13 @@ final class TranscriptBuilder {
confirmPending(text, queued: false, local: true)
pendingIds += 1
let images = (p["images"] as? [(any Sendable)?] ?? []).map { jsString($0) }
pending.append(PendingSend(id: pendingIds, text: text, images: [], imageIds: images, local: false, queued: true, md: trimmed(text).isEmpty ? [] : parseMarkdown(text)))
pending.append(PendingSend(id: pendingIds, text: text, images: [], imageIds: images, local: false, queued: true, md: trimmed(text).isEmpty ? [] : parseMarkdown(text), inputId: int(p, "id")))
}
continue
}
if ev.kind == "user.unqueued" {
if sink == nil, let id = int(p, "id") {
withdrawn(id)
}
continue
}