Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(ios): preview image attachments in the composer

leepokaifa84cb5f0c36
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
index 7bb04bf4..7f08bece 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
@@ -143,7 +143,7 @@ struct Composer: View {
private var trailing: Trailing {
if onInterrupt != nil, draft.isEmpty, files.isEmpty { return .interrupt }
- if working, draft.isEmpty { return .stop }
+ if working, draft.isEmpty, files.isEmpty { return .stop }
if onCall != nil, draft.isEmpty, files.isEmpty { return .call }
return .send
}
@@ -263,27 +263,11 @@ struct Composer: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 6) {
ForEach(files) { file in
- HStack(spacing: 6) {
- Image(systemName: AttachmentIcon.symbol(file.name))
- .foregroundStyle(Palette.secondary)
- Text(file.name)
- .font(.footnote)
- .foregroundStyle(Palette.text)
- .lineLimit(1)
- .truncationMode(.middle)
- .frame(maxWidth: 160, alignment: .leading)
- Button {
+ ComposerAttachment(file: file) {
+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {
files.removeAll { $0.id == file.id }
- } label: {
- Image(systemName: "xmark").font(.system(size: 10, weight: .bold)).foregroundStyle(Palette.secondary)
}
- .buttonStyle(.plain)
- .accessibilityLabel("Remove \(file.name)")
- .help("Remove")
}
- .padding(.horizontal, 10)
- .padding(.vertical, 6)
- .background(Palette.surface, in: Capsule())
}
}
.padding(.horizontal, 10)
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerAttachment.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerAttachment.swift
new file mode 100644
index 00000000..148afa4e
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerAttachment.swift
@@ -0,0 +1,81 @@
+import CodyncKit
+import SwiftUI
+import UniformTypeIdentifiers
+
+/// A local attachment, shown before it is uploaded or sent.
+struct ComposerAttachment: View {
+ let file: OutgoingFile
+ let remove: () -> Void
+ @State private var image: CGImage?
+ @State private var loaded = false
+ @Environment(\.displayScale) private var displayScale
+
+ private var size: CGFloat { 112 }
+ private var expectsImage: Bool {
+ UTType(filenameExtension: (file.name as NSString).pathExtension)?.conforms(to: .image) == true
+ }
+
+ var body: some View {
+ Group {
+ if image != nil || (expectsImage && !loaded) {
+ ZStack {
+ RoundedRectangle(cornerRadius: 16).fill(Palette.surface)
+ if let image {
+ Image(decorative: image, scale: displayScale)
+ .resizable()
+ .scaledToFit()
+ } else {
+ Image(systemName: "photo").foregroundStyle(Palette.secondary)
+ }
+ }
+ .frame(width: size, height: size)
+ .clipShape(RoundedRectangle(cornerRadius: 16))
+ .accessibilityLabel("Image attachment: \(file.name)")
+ .overlay(alignment: .topTrailing) {
+ removeButton
+ .foregroundStyle(.white)
+ .background(.black.opacity(0.75), in: Circle())
+ .padding(4)
+ }
+ } else {
+ HStack(spacing: 6) {
+ Image(systemName: AttachmentIcon.symbol(file.name))
+ .foregroundStyle(Palette.secondary)
+ Text(file.name)
+ .font(.footnote)
+ .foregroundStyle(Palette.text)
+ .lineLimit(1)
+ .truncationMode(.middle)
+ .frame(maxWidth: 160, alignment: .leading)
+ removeButton.foregroundStyle(Palette.secondary)
+ }
+ .padding(.leading, 10)
+ .padding(.trailing, 4)
+ .padding(.vertical, 4)
+ .background(Palette.surface, in: Capsule())
+ }
+ }
+ .task(id: file.id) {
+ let data = file.data
+ let pixels = Int(size * displayScale)
+ let thumbnail = await Task.detached(priority: .userInitiated) {
+ ImageData.thumbnail(data, maxPixels: pixels)
+ }.value
+ guard !Task.isCancelled else { return }
+ image = thumbnail
+ loaded = true
+ }
+ }
+
+ private var removeButton: some View {
+ Button(action: remove) {
+ Image(systemName: "xmark")
+ .font(.system(size: 11, weight: .bold))
+ .frame(width: 28, height: 28)
+ .contentShape(Circle())
+ }
+ .buttonStyle(PressScale())
+ .accessibilityLabel("Remove \(file.name)")
+ .help("Remove")
+ }
+}
diff --git a/docs/design/composer-attachments.md b/docs/design/composer-attachments.md
new file mode 100644
index 00000000..3c1e62c2
--- /dev/null
+++ b/docs/design/composer-attachments.md
@@ -0,0 +1,19 @@
+# Composer attachments
+
+iPhone and the desktop app show local image attachments as thumbnails above the text field,
+with a remove button in the upper-right corner. The entire image fits inside the
+preview; its original data remains the attachment sent to the host. On iPhone,
+ImageIO creates display-sized thumbnails off the main actor; the desktop app
+(`views/thread/ComposerAttachment.tsx`) lets the browser decode the image. Invalid image data falls
+back to the filename chip, as do non-image files. Multiple attachments scroll
+horizontally and remain removable individually.
+
+The iPhone clipboard suggestion is not an attachment: tapping **Paste image**
+loads it into the draft and replaces the suggestion with the thumbnail. Merely
+focusing the composer does not read and attach clipboard contents. Picking a
+photo or image file uses the same preview. A draft containing only attachments
+shows Send, including when another reply is running (the message is queued).
+
+The TUI retains its filename row and backspace removal: its text renderer does
+not implement terminal image protocols.
+No upload API, message format, or attachment limit changes.