feat: Photo & Video attachment via web app
Summary
Added support for attaching images and videos via the web app. Linear and slack support coming soon.
https://github.com/user-attachments/assets/cd06c73f-10cc-48be-9485-0e9681de175a
Added uploads table to store the R2 uploads against the sessions.
Video support is done by breaking the video down into individual frames, that way agents can "view" the video. Linear support (coming soon) is super nice because the linear default prompt actually describes what's happening throughout the video as well.
Testing
Been using in production for my own company last couple of days. Video proof / pictures above.
Follow Ups
Linear and slack support
Note
This was vibe-coded with Fable 5, but tested in production and working well :)
Summary by CodeRabbit
-
New Features
- Added support for attaching images and videos to prompts through file selection, drag-and-drop, and paste.
- Added upload validation, size limits, session quotas, cleanup, and secure media streaming.
- Displayed attachment previews in the composer and rendered uploaded media in session timelines.
- Added video processing and frame extraction for prompt attachments.
-
Bug Fixes
- Prevented duplicate submissions and preserved drafts when uploads fail.
- Improved attachment validation, retry behavior, and warning messages.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds end-to-end prompt attachment support: validated uploads are stored and tracked per session, propagated through prompt handling, processed by the sandbox, and exposed in the web composer and session timeline.
Changes
Prompt attachment pipeline
| Layer / File(s) | Summary |
|---|---|
Media contracts and detection packages/control-plane/src/media.ts, packages/control-plane/src/media.test.ts |
Adds prompt-upload limits, MIME allowlists, magic-byte detection, storage keys, and coverage for supported image/video formats. |
Upload storage and streaming routes packages/control-plane/src/routes/session-uploads.ts, packages/control-plane/src/routes/stream-stored-media.ts, packages/web/src/app/api/sessions/[id]/uploads/..., packages/control-plane/src/router.ts |
Adds authenticated multipart upload/download routes, range streaming, object cleanup coordination, and sandbox download authorization. |
Session upload persistence and cleanup packages/control-plane/src/session/schema.ts, packages/control-plane/src/session/repository.ts, packages/control-plane/src/session/http/handlers/uploads.handler.ts, packages/control-plane/src/session/durable-object.ts |
Adds the uploads table, repository lifecycle methods, quota enforcement, stale-upload cleanup claims, and internal Durable Object routing. |
Attachment validation and prompt propagation packages/shared/src/types/*, packages/control-plane/src/routes/session-prompt.ts, packages/control-plane/src/session/message-queue.ts |
Enforces one attachment source, validates payloads, normalizes upload references, marks uploads referenced, and emits metadata-only user events. |
Sandbox attachment processing packages/sandbox-runtime/src/sandbox_runtime/attachment_processor.py, packages/sandbox-runtime/src/sandbox_runtime/bridge.py |
Downloads upload-backed media, expands videos into frames, builds OpenCode file parts, and emits media warnings. |
Composer upload and timeline rendering packages/web/src/hooks/*attachment*, packages/web/src/components/*, packages/web/src/app/(app)/* |
Adds attachment selection, previews, sequential uploads with retry reuse, prompt transport, attachment-only submissions, and timeline rendering. |
| Estimated code review effort: 5 (Critical) | ~120 minutes |
Sequence Diagram(s)
sequenceDiagram
participant User
participant WebApp
participant ControlPlane
participant SessionDO
participant Sandbox
participant OpenCode
User->>WebApp: add image or video attachment
WebApp->>ControlPlane: upload multipart file
ControlPlane->>SessionDO: register upload
WebApp->>ControlPlane: send prompt with upload reference
ControlPlane->>SessionDO: normalize and persist attachment
Sandbox->>ControlPlane: download referenced media
Sandbox->>OpenCode: send image parts or extracted video frames
Possibly related PRs
- ColeMurray/background-agents#579: Both changes modify
SessionMessageQueue.enqueuePromptFromApi(...). - ColeMurray/background-agents#730: Both changes modify the session prompt composer and its session-page wiring.
- ColeMurray/background-agents#732: Both changes modify session timeline event rendering.
Suggested reviewers: ColeMurray, open-inspect
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 21.18% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately summarizes the main change: adding photo and video attachment support in the web app. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
@ColeMurray resolved merge conflicts
Thanks @Blue101black for building and testing the attachment foundation here. We are going to take over the next iteration on a maintainer-owned branch based on the current PR head, so your existing commits and attribution will be preserved without substantially rewriting the branch in your fork.
For the replacement PR, we plan to narrow the initial scope to image attachments, apply a portable 4 MiB web upload limit for the default Vercel deployment, and remove the automatic eight-frame video pipeline and arbitrary remote-video download path. Direct browser-to-R2 uploads, explicit upload lifecycle cleanup, and a more deliberate video-understanding design will follow separately.
We will keep this PR open while preparing the replacement, link it here once it is ready for review, and then close this PR without merging so the original discussion and contribution history remain available. Thank you again for the substantial work that established this path.