Skip to content

#870 Paste and drop attachments in Session Chat - #875

Merged
ivanfenenko merged 2 commits into
mainfrom
feature/870-paste-and-drop-attachments
Oct 27, 2026
Merged

ivanfenenko merged 2 commits into
mainfrom
feature/870-paste-and-drop-attachments

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Paste an image or file into the Session Chat composer, or drop images and files anywhere on Session Chat, to attach them to the next prompt (iOS and Android). Plain text still pastes and drops as text.
  • Drag-over state is variant A from the prototype: the chat dims and a new Drop Overlay design-system component (accept and reject variants, gallery entry on both platforms) says what will be attached, how many will be skipped and why, or "Can't attach this/these".
  • Shared rules in AttachmentDropRouting on both platforms, tested against the same vectors in shared/attachment-drop/attachment-drop-cases.json: per-item routing through the Streamed attachment uploads in Session Chat #644 policy (folder, duplicate, model support, 20 MB, uploads), the card text, and Pasted image N.png naming.
  • Drops are off when the composer is not a prompt (question, permission, child lockout), when attaching is disabled, and during dictation; they then fall through to the system default.
  • Analytics: attach_paste and attach_drop, logged once per paste or drop that adds at least one attachment.
  • Android: keeps the TextFieldValue prompt field (only the TextFieldState field reads contentReceiver, and that one can't colour mentions). Paste goes through the text menu (appendTextContextMenuComponents / filterTextContextMenuComponents), Ctrl+V / Shift+Insert, and an InterceptPlatformTextInput wrapper that accepts keyboard image insertion (commitContent). Drops use dragAndDropTarget + requestDragAndDropPermissions.
  • iOS: OpenCodeMentionTextView overrides paste(_:) / canPerformAction for image, PDF and file-URL pasteboard items; Session Chat uses a SwiftUI DropDelegate, and the prompt field gives up its own text drop interaction while an attachment is dragged over the chat.

Checks

  • Android: :app:testDebugUnitTest 2873 tests, 0 failures; :app:assembleDebug OK; ktlint clean on all changed lines.
  • iOS: build OK; AttachmentDropRoutingTests, AttachmentMimeSharedVectorTests and SessionChatViewModelTests 227 tests passed.
  • Device checks against a local opencode v2.2.0 server:
    • iPhone 16 Pro Max simulator: image copied in Photos → edit-menu Paste → image chip, no text inserted, no paste-permission prompt; pasting again → "This file has already been uploaded".
    • Pixel 9a emulator: Gboard copied-image suggestion (commitContent), text-menu Paste and Ctrl+V all attach; Ctrl+V of the same file → duplicate error.
    • Drop Overlay accept and reject states in the component gallery on both platforms.

Screenshots

iOS: paste from Photos iOS: same image again Android: Gboard image insert Android: text-menu Paste
iOS paste of a Photos image becomes a chip iOS second paste shows the duplicate error Android keyboard image insertion becomes a chip Android text-menu Paste becomes a chip
Android: Ctrl+V duplicate iOS: Drop Overlay accept iOS: Drop Overlay reject Android: Drop Overlay
Android Ctrl+V of the same file shows the duplicate error iOS Drop Overlay accept states in the gallery iOS Drop Overlay reject state in the gallery Android Drop Overlay in the gallery

Issue

Risks / Follow-ups

  • Dropping from another app was not exercised on a device (needs iPad split view or Android multi-window); drop routing is covered by unit tests only.
  • Android names only the types in a drag until the drop, so its card says "Drop to attach images" / "Some will be skipped · …" without counts (shared vectors cover this). A text file dragged alone shows no card on Android (same text/plain type as a text selection) but still attaches on drop.
  • iOS paste treats only image, PDF and file-URL pasteboard items as attachments; rich text with web archives still pastes as text.

🤖 Generated with Claude Code

Images and files can be pasted into the Session Chat composer and dropped
anywhere on Session Chat on iOS and Android. A drag-over scrim card (new
Drop Overlay component) says what a drop will attach, or why it can't.
Pasted and dropped items go through the existing #644 routing; shared
test vectors in shared/attachment-drop cover routing, the card text and
Pasted image N.png naming on both platforms.

Android keeps the TextFieldValue prompt field and hooks paste through the
text menu, Ctrl+V/Shift+Insert and an InputConnection wrapper for keyboard
image insertion. iOS overrides paste on the prompt text view and yields
the field's text drop while an attachment is dragged over the chat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review October 27, 2026 21:34

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 1 finding(s) that 2+ of 3 passes agreed on.

5 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/components/input/OpenCodeComposerPaste.kt:98 medium: Non-text clipboard without URI breaks Paste entirely (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Input/OpenCodeMentionTextView.swift:363 medium: Mixed text+image paste drops the text (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Domain/Message/Attachment/AttachmentItemProviders.swift:13 medium: A dragged or pasted link is classified as a text file when its suggestedName contains a dot (deepseek-v4.1-flash)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatScreen.kt:367 low: Pasted folder never reports the folder error (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/components/input/OpenCodeComposerPaste.kt:160 low: The text-menu Paste is hidden for any non-text clip, but the replacement Paste does nothing when the clip has no URI (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.119 · 1 pass(es) stopped early

- Android: a clip counts as an attachment only when it names an image or
  only non-text types, so the built-in Paste is never hidden for a text
  clip that also carries an app-specific type.
- Android: a pasted folder shows "Folders can't be attached." like a drop.
- iOS: a dragged or pasted web link is never a text file, even when its
  suggested name has a dot (example.com).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 9dd52e1 into main Oct 27, 2026
5 checks passed
@ivanfenenko
ivanfenenko deleted the feature/870-paste-and-drop-attachments branch October 27, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste and drop attachments in Session Chat

1 participant