Paste and drop images into every box that talks to an agent

This commit is contained in:
Ian Gulliver
2026-10-20 17:32:32 -07:00
parent 49f57b73fc
commit 15482473f7
9 changed files with 133 additions and 83 deletions
+3 -13
View File
@@ -112,7 +112,7 @@ private final class CardModel {
}
var hasImages: Bool {
!store.images.images(key).isEmpty
store.images.has(key)
}
var typed: String {
@@ -494,7 +494,6 @@ private struct TextEntry: View {
@Environment(\.paneAccent) private var accent
@FocusState private var editing: Bool
@ViewState private var hover = false
@ViewState private var targeted = false
var body: some View {
let id = model.item.id
@@ -514,7 +513,6 @@ private struct TextEntry: View {
.writingToolsBehavior(.disabled)
.focused($editing)
.disabled(model.busy)
.focusedValue(\.composer, ComposerTarget(paste: { pb in store.images.add(key, pasteboard: pb, overlays) }))
.onKeyPress(.return, phases: .down) { press in
let marked = (NSApp.keyWindow?.firstResponder as? NSTextView)?.hasMarkedText() ?? false
if press.modifiers.contains(.shift) || marked {
@@ -536,16 +534,8 @@ private struct TextEntry: View {
.allowsHitTesting(false)
}
}
.overlay(RoundedRectangle(cornerRadius: 6).stroke(targeted || editing ? Palette.accent : Palette.border))
.overlay {
Color.clear
.contentShape(Rectangle())
.allowsHitTesting(false)
.onDrop(of: [.image, .fileURL], isTargeted: $targeted) { providers in
store.images.add(key, providers: providers, overlays)
return true
}
}
.overlay(RoundedRectangle(cornerRadius: 6).stroke(editing ? Palette.accent : Palette.border))
.imageInput(key)
}
.onChange(of: editing) {
if !editing {