Skip to content

Paste and drop attachments in Session Chat #870

Closed

Description

@ivanfenenko

People can paste an image or file into the Session Chat composer, and drag files from another app onto Session Chat, to attach them to the next prompt.

Background

Today the only way to attach something is the attachment sources sheet (Photos, Files, log file). Neither app handles a pasted image or a drop: on iOS the composer OpenCodeMentionTextView (UITextView) only takes text, and on Android the composer BasicTextField has no content receiver or drop target.

Paste and drop are only new ways to add attachments. Everything after that already exists from #403 and #644: mime detection, the inline-versus-upload routing, duplicate detection, the full-width attachment chip with upload progress and cancel, Send blocked while an upload is pending, and the existing error copy.

Related: #869 lists "drag-and-drop attachments onto the composer" under Tier 3. This issue covers that item, extended to the whole Session Chat and to paste.

Decision

Prototype: shared privately, not linked here.

Drag-over state is variant A, scrim card:

  • The whole Session Chat is the drop target, not just the composer. While accepted items are over it, the chat dims and a centred dashed card shows up to four item previews, Drop to attach N images (or N files when the kinds are mixed), and Adds them to the message you are writing.
  • If some items will be skipped, the subtitle says how many and the first reason, for example 1 will be skipped · Folders can't be attached.
  • If nothing in the drag can be attached, the card switches to the error style with Can't attach this / Can't attach these and the reason, and the platform drop indicator shows no-drop.
  • On drop, accepted items become chips in the composer exactly as if picked from Files or Photos; skipped items show the existing composer error line.

Rejected: B (the composer grows into a drop well) and C (an accent edge glow with a small pill).

Behaviour

  • Accepted content: images and any file, routed through the existing Streamed attachment uploads in Session Chat #644 policy (inline data: URL when the model reads the type natively and it is at most 20 MB, streamed upload when the server supports it, otherwise the existing error). Plain text still pastes and drops into the composer as text.
  • Text in drags: the Session Chat drop target only reacts to drags that carry at least one image or file. A text-only drag shows no scrim card and keeps the platform default: it drops into the composer text field as text, and dropping it elsewhere on Session Chat does nothing. When a drag carries both an image or file and text (for example an image dragged from a browser, which also carries its URL), the image or file is attached and the text is ignored.
  • Paste: the system edit menu's Paste and ⌘V / Ctrl+V with a hardware keyboard. When the clipboard holds an image or file, Paste adds an attachment and inserts no text. When it holds only text, Paste behaves as it does today. A pasted image without a file name is named Pasted image N.png, with N counting up within the draft.
  • Duplicates: the Streamed attachment uploads in Session Chat #644 rule (same name and byte size as a file already in the draft) applies to pasted and dropped files that have a name. Pasted images without a name are never duplicates: pasting the same image twice adds two attachments, Pasted image 1.png and Pasted image 2.png.
  • Errors: reuse the existing strings (This file is larger than 20 MB., This file has already been uploaded, This model does not support image attachments., Only images, PDFs, or text files can be attached here., The attachment could not be read.). The one new string is Folders can't be attached.
  • When drops are off: the drop target is inactive when the composer is not a prompt composer (a question or permission prompt is showing) and when attaching is disabled for the session. Drops then fall through to the system default.
  • Where it applies: Session Chat on phone and tablet, including the tablet split-view detail pane. Dropping on Home or the sidebar is out of scope.
  • Product analytics logs paste and drop as attachment sources alongside the existing picker sources (attach_pick_photos, attach_pick_files, attach_pick_log_file): new actions attach_paste and attach_drop, same names on both platforms, logged once per paste or drop that adds at least one attachment.

Platform notes

  • iOS: set pasteConfiguration (or override canPerformAction/paste) on OpenCodeMentionTextView so image and file pasteboard items become attachments, without triggering the paste-permission prompt on a user-initiated paste. Add a drop target over Session Chat (UIDropInteraction or SwiftUI onDrop) and make sure the text view's own drop interaction doesn't swallow file drops. Load item providers as files and pass them through the same ingestion path as the Files importer.
  • Android: use Modifier.contentReceiver on the composer for paste and keyboard image insertion. contentReceiver is expected to need the TextFieldState overload of BasicTextField, but the composer uses the TextFieldValue overload on purpose to keep mention ranges and the caret stable (OpenCodeSessionComposer.kt). Settle this first, before any other Android work: confirm whether the value-based field can receive pasted content; if not, either move the composer to TextFieldState with mention ranges and caret behaviour preserved, or find another paste hook that keeps the value-based field. Record the choice here, since a migration changes the size of this ticket.
    • Decided: keep the value-based field and use other paste hooks. In Compose foundation 1.12.1 only the TextFieldState field consults contentReceiver, but TextFieldBuffer has no public styling, so a migration would lose the mention highlight. Instead: the text context menu (appendTextContextMenuComponents / filterTextContextMenuComponents, on by default) offers Paste for an image or file clip, Ctrl+V / Shift+Insert are intercepted in onPreviewKeyEvent, and keyboard image insertion (commitContent) goes through InterceptPlatformTextInput, which wraps the composer's InputConnection and advertises image MIME types. Add Modifier.dragAndDropTarget on Session Chat, call requestDragAndDropPermissions for cross-app content URIs, and feed the URIs to AttachmentIngestionService.
  • Behaviour is a synchronized Feature Slice with unit tests for item routing (accepted, skipped and reason, folder, duplicate) and the drag-over summary text.

Remaining:

  • Android paste approach decided first: contentReceiver on the value-based composer, a TextFieldState migration, or another paste hook; choice recorded on this issue
  • Shared drop/paste item routing and drag-over summary (count, kind noun, skipped count and first reason), with the same test vectors on both platforms
  • Scrim card drag-over overlay (variant A) on the whole Session Chat, including the all-rejected error state
  • Paste of images and files into the composer via the edit menu and ⌘V / Ctrl+V; text paste unchanged
  • Drop disabled for non-prompt composers and when attaching is disabled
  • Analytics for the paste and drop sources
  • Android implementation and tests
  • iOS implementation and tests

Activity

  1. added
    enhancement
    shared
    todo
    priority: medium
    on Oct 27, 2026
  2. added 2 commits that reference this issue on Oct 27, 2026
  3. added 4 commits that reference this issue on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority: mediumsharedtodo

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions