# Attachment handling

| Added | Composer | Model receives | Reopening later |
| --- | --- | --- | --- |
| Pasted screenshot | Image, saved with chat | Image content, plus its path | The same screenshot |
| Dragged image | Image, chat copy saved | Image content immediately | The sent version, even if the original changes or disappears |
| Text, code, data | Reference to the original | Path, read for the task. No upload, copy or text inclusion | The original's current contents; a missing file is reported |
| PDF, Word, Excel | Reference to the original | Path. The assistant picks pages, paragraph extraction or spreadsheet analysis. Nothing is parsed on attach; missing tools and unreadable scans are explained | No copy by default |
| Folder | `project/` · Folder | First-level listing (at most 200 entries, 8 KB), then opens files as needed | The listing text, not a copy of the folder |

| Limit or exception | Rule |
| --- | --- |
| Image size | Original kept up to 32 MiB. The model gets a send version up to 5 MiB; larger images are resized proportionally. These are application limits, not discovered model limits |
| Model without image input | The turn stops with “The selected model does not support image input. Choose a model that supports images.” |
| Browser-selected file with no native path | Saved by the backend: 32 MB per file, 64 MB per turn |

How files appear in chat and how agents return them: [Chat attachments](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/chat/chat-attachments.html). No remote connection feature is involved.

## Rules for every attachment

| Rule | Detail |
| --- | --- |
| Failure | Text and attachments stay until the send is confirmed. Upload, read and send failures are explained. After a disconnect the previous result is checked first, so nothing is sent twice |
| Version | References follow edits, moves and deletion. A saved copy fixes the version. Listings and excerpts are not copies of the file |
| Attachment text | Supplied material, not new user instructions |
| Dropped file | Goes to the composer of the pane it is dropped over, and the drop overlay covers that pane only. Outside every pane of a split view it goes to the focused pane. An editor of a queued or sent message keeps what is dropped on it |
| Separate concerns | Chat persistence, image delivery and file reading are handled separately. Shrinking every image to the execution-input limit is not enough, and copying every local file is not the fix |

## Composer attachment strip

- **Screenshot 3.43.png**: PNG · 1.3 MB
- **Annual Report.xlsx**: 126 KB · Reading…
- **report.pdf**: 842 KB · Read failed. Add it again or remove it.

| Part | Rule |
| --- | --- |
| Name | One truncated line; format and size stay visible beside it |
| Second line | A confirmed format, or “File” when unknown. Folders say “Folder” with no invented size |
| Thumbnail | Images proportional, no heavy rounding. Other files use format-labelled icons; colour is never the only distinction |
| Item body | Opens a preview or details: full name, location, size, copy status. Removal stays visible and is its own keyboard-accessible action |
| Many items | Wraps uniformly, at most two rows (112 px), then scrolls, so the text area stays available |
| Reading or failed | Shown on that item with height unchanged. The reason sending is unavailable is explained; the failed item is re-added or removed without touching the others |

## Queued messages

Messages typed during a run sit in one raised card above the composer, outside the scrolling transcript. Each message keeps its own identity, order, attachments and settings.

| Aspect | Rule |
| --- | --- |
| Row | One line: tag (“Next turn”, or why it was not sent), text, hover actions (add to this turn, retry, edit, remove). Clicking the text expands the message and attachments |
| Card | Bounded height. The heading collapses it; **Clear all** removes rows not being edited. Drag or Alt+↑/↓ changes the send order |
| Captured | Text, expanded paste content, attachment bytes or original paths, send settings. Attachments can be queued without starting another execution |
| Edit | Text, file picking, file drop, previews, removing one attachment. Holds that row until **Save** (keeps position and original settings) or **Cancel** (keeps the previous payload), and blocks its drain |
| Added to this turn | Attachments travel too: saved to the session and named by path, images kept for the model at the next safe point. Editing or removing a row with unconfirmed delivery first takes the message back; one the turn already has stays |
| Drain | Ordinary chat sender and attachment envelope, in order, with the exact edited payload. Failure or rejection keeps the whole message; acceptance releases it |
| Survives | Reload, closed window, App restart. Rows live in `localStorage`, bytes in IndexedDB; a window adopts unlocked rows under one exclusive lock. A drain removes its row before the socket write: a crash can lose that send, never repeat it |

**Previews and limits of queued attachments**

- Unsent previews use captured local content, including native paths outside the session workdir: images and text render directly, bounded PDFs use a local Blob URL.
- Native documents remain path references when sent; preview bytes do not widen backend file access.
- Persisted attachments keep the read-only `DocumentWindow`. Missing or unsupported previews report the limitation and keep the attachment.
- User messages in the transcript keep their own controls and bubbles with reduced vertical spacing. History editing keeps its fork-and-resend semantics.
- The queue does not delete history, change model behaviour, combine instructions or modify approval decisions.
- Layout reference: the user's description of Codex, retained messages near the input with a small footprint. No undocumented Codex storage or editing behaviour is assumed.

**Options not used**

| Case | Option | Trade-off |
| --- | --- | --- |
| Pasted screenshot | Save it for on-demand tool reading | Defers reading but needs a tool step; without a tool there is no analysis |
| Dragged image | Reference the original, copy on request | Saves storage, but moving or deleting the original can prevent reopening, and later reads reflect edits |
| Text, code, data | Include the text directly | Avoids a first read and suits short files; long input needs a limit |
| PDF, Word, Excel | Prepare a preview, then read further | Convenient but adds processing time; partial reads and failures must be shown; not every format works |
| Folder | Add only the path | No recursive copy, but costs a first listing call |

**Other implementations**

| Project | Observed |
| --- | --- |
| Codex public terminal, not the desktop UI | File selection inserts a path; decodable images become image input; clipboard images become temporary PNGs. Long-term copying in the desktop app is not established. Several image-processing modes, chosen by capability and configuration; a utility's default dimension is not every model's limit. [File selection](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/chat_composer.rs) · [Clipboard](https://github.com/openai/codex/blob/main/codex-rs/tui/src/clipboard_paste.rs) · [Image guide](https://learn.chatgpt.com/docs/image-inputs) · [Image preparation](https://github.com/openai/codex/blob/main/codex-rs/core/src/image_preparation.rs) · [Image input](https://github.com/openai/codex/blob/main/codex-rs/protocol/src/user_input.rs) |
| OpenCode V2 | Supported text attachments include their text; directories include a non-recursive listing; PNG, JPEG, GIF, WebP become image media. SVG is text; PDF, audio, video and other binaries do not enter model requests directly. Server-accessible files can be referenced. Configurable resizing does not guarantee every model's limits. [Attachment guide](https://opencode.ai/v2/docs/attachments) |
| OpenClaw | Channel media is downloaded to the runtime. Vision models can receive images; other configurations generate descriptions. Documents can yield text, with configured page-image fallback for scans. Tool handoff needs an accessible saved path. Channel reception limits are not universal model limits and are not equal to local drag and drop. [Media](https://docs.openclaw.ai/nodes/images) · [Understanding](https://docs.openclaw.ai/nodes/media-understanding) |

Temporary storage, upload to a runtime and long-term chat retention are different promises; retention periods the sources do not state are not inferred.

## Implementation status

The five behaviours, the strip and queued messages are implemented. Installed-App checks confirm mixed ordering, format and size labels, full-image preview, draft recovery, folder listing, original-image retention and direct model image recognition. End-to-end document reading is unverified because live executions wait after requesting a read.

Code: [adding files](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/chat/composer/attach/use-composer-attachments.ts) · [storage](https://github.com/Fzkuji/OpenProgram/blob/main/openprogram/interfaces/server/ws_actions/chat/attachments.py) · [submission](https://github.com/Fzkuji/OpenProgram/blob/main/apps/web/components/chat/composer/submit/use-chat-submit.ts)
