Skip to content

Attach files to messages: paste, + button, or drag and drop - #3

Merged
calesthio merged 1 commit into
mainfrom
attachments
Nov 27, 2026
Merged

calesthio merged 1 commit into
mainfrom
attachments

Conversation

@calesthio

Copy link
Copy Markdown
Contributor

Summary

Lets people attach screenshots, images, PDFs and any other file to a message, the way OpenMontage Studio attaches references (a + button and drag-and-drop), plus pasting from the clipboard. Agents are told where each file is saved so they can open it.

Related issue

None.

Changes

  • Message box: a new + button opens the system file picker (multiple files, any type). Ctrl+V / ⌘V pastes screenshots or copied files, and pasted screenshots get a readable name ("Screenshot 2026-11-26 at 21.46.04.png"). Files can be dropped anywhere on the window. Files wait in a tray above the input with a thumbnail or file-type badge and a remove button. A message can contain only files.
  • Pasting from Word, Excel or a web page: these also copy a picture of the selection. If the clipboard has real text, the text is pasted as usual and no image is attached.
  • In the chat: images show inline and open full size when clicked. Other files show as chips that download.
  • Storage (core/room.py): uploads are saved to <room>/workspace/attachments/<id>/<cleaned name>, beside room-history.jsonl. Names are made safe on Windows and macOS, and an ID must be 32 hex characters before it is used in a path. Limits are 50 MB per file and 20 per message. A new messages.attachments column is added through an additive migration. Messages without files look exactly as before in state, the archive and prompts.
  • Prompt (core/prompt.py): each message's JSON line lists {name, type, path} for its files. When any file is present, one extra sentence tells the agent to open them with its own tools.
  • HTTP (server.py):
    • POST /api/attachments accepts raw bytes with an X-Filename header.
    • GET /api/attachments/<id> serves PNG, JPEG, GIF, WebP and BMP inline. Every other type is served as an application/octet-stream download with default-src 'none'.
    • /api/messages accepts attachments: [id].
    • Both routes use the existing trusted-origin check.
  • Docs: the API table in docs/ARCHITECTURE.md covers the new routes and fields.

Notes for reviewers

  • Files go through the Python service, not Electron IPC, so the same code path runs in the Windows app, the macOS app (its Edit menu already routes ⌘V) and a plain browser. There are no changes under desktop/.
  • How agents are started is unchanged: no new flags, permissions or sandbox modes. Agents already have full file access and already read the archive folder.
  • A file removed from the tray before sending stays on disk in the room folder. Cleaning those up could be a follow-up.

Testing

  • py -3 -m pytest tests -q (146 passed, 1 skipped). New tests cover the upload, send and serve round trip, files-only messages, prompt and archive paths, cleaned names, path-traversal IDs, empty files, and a room created before this change.
  • npm test (in desktop/) was not run because nothing in desktop/ changed.
  • Providers checked manually: none. I tested with a room that had no agents.
  • Operating systems checked manually: Windows 11, in the in-app browser against a service started with a temporary --data folder. I checked paste, the + button, drag-and-drop, sending, the full-size image view and dark mode, and confirmed the files and the archive entries on disk. macOS has not been checked by hand.

Checklist

  • The change is focused on a single logical concern.
  • I ran the tests above locally, and any manual checks used a temporary data folder (--data), not my real chats.
  • I updated docs/README if behavior or usage changed.
  • Anything that changes how agents are started (flags, permission or sandbox modes) is called out above. (Nothing changes.)
  • No unrelated files (build output, signing.local.ps1, local config, databases) are included in the diff.

🤖 Generated with Claude Code

People can now paste a screenshot or file, pick files with a new + button,
or drop files on the window. Files upload to the local service and are kept
in the room's workspace/attachments folder, beside the transcript archive
agents already read. Each agent's prompt and room-history.jsonl list every
attached file's absolute path, so any provider can open it with its own tools.

Images show inline in the chat and open full size; other files download and
never render in the app. Names are cleaned so they are valid on Windows and
macOS, IDs never become paths unchecked, and files are capped at 50 MB each
and 20 per message. Old rooms gain the new column through an additive
migration. Works the same in the Electron shell on both OSes and in a browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@calesthio
calesthio merged commit 31a0100 into main Nov 27, 2026
8 checks passed
@calesthio
calesthio deleted the attachments branch November 27, 2026 05:51
@calesthio calesthio mentioned this pull request Nov 27, 2026
3 tasks done
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.

1 participant