feat(web): drag-and-drop files onto chat panel to add as attachments
Summary
Add drag-and-drop support so users can drag files from the OS desktop or file manager onto the right-side chat panel to attach them to the current composer message — the same UX pattern used by ChatGPT, Slack, and Notion.
Desired behaviour
| Action | Result |
|---|---|
| User starts dragging a file (anywhere on page) | A drop-zone overlay appears on the right chat panel only |
| User hovers file over left sidebar | Overlay stays on right panel; sidebar shows no drop affordance |
| User drops file on right chat panel | File is added as a composer attachment (same path as paste / attach button) |
| User drops file on left sidebar | Nothing happens; browser default is suppressed |
| User cancels drag (Escape / drags off window) | Overlay disappears |
Scope constraint
- Overlay is shown as soon as a
dragenteris detected anywhere on the page (so the user can see where to drop even before reaching the target). - Actual drop is accepted only on the right panel — the
div.min-w-0.flex-1.flex-colwrapper inrouter.tsx(currently around line 540).
Implementation notes
The attachment plumbing already exists. HappyComposer calls api.composer().addAttachment(file) for pasted images (handlePaste, ~line 554). Drag-and-drop can reuse the same path:
// inside the right-panel drop handler
event.preventDefault()
const files = Array.from(event.dataTransfer.files)
for (const file of files) {
await api.composer().addAttachment(file)
}
Suggested approach:
- Add a
useDragOverhook (or inline logic on the right-panel wrapper) that listens todragenter/dragleave/dragover/dropondocument. - Show a full-height overlay inside the right panel while a drag is active — something like a semi-transparent backdrop with a dashed border and "Drop to attach" label.
- Only the
drophandler on the right panel callsaddAttachment; the sidebar has no drop listener. - Guard the same way as the existing paste path (e.g. skip if
disabled, respectattachmentsReady).
Acceptance criteria
- [ ] Dragging any file over the page shows the overlay on the right chat panel.
- [ ] Dropping on the left sidebar does not add an attachment and does not navigate away.
- [ ] Dropping on the right panel adds the file(s) as attachment chips in the composer.
- [ ] The overlay disappears on drop, on drag-cancel, and when the cursor leaves the window.
- [ ] Works for images and non-image files (PDF, text, etc.) consistent with what
addAttachmentalready accepts.
Confirmed: this is not currently implemented in web/src; I did not find existing drag/drop handlers there. The requested approach matches the current attachment plumbing, with two details to preserve:
api.composer().addAttachment(file)is already used by paste, but the current paste handler only accepts image clipboard files.- The attachment adapter itself accepts
*/*, so the attach-button path supports non-image files as well. - Scheduled sends and attachments are intentionally blocked together today, so drag/drop should reuse the same guard as the existing attachment paths.
Relevant code:
web/src/router.tsx:540- right-side panel wrapper:min-w-0 flex-1 flex-col bg-[var(--app-bg)]; this is the right place for a panel-scoped overlay/drop target.web/src/components/AssistantChat/HappyComposer.tsx:535- paste handler reads clipboard files.web/src/components/AssistantChat/HappyComposer.tsx:537- paste currently filters toimage/*only.web/src/components/AssistantChat/HappyComposer.tsx:546- paste path suppresses attachment add while a schedule is active.web/src/components/AssistantChat/HappyComposer.tsx:554- existing path callsapi.composer().addAttachment(file).web/src/components/AssistantChat/HappyComposer.tsx:195-attachmentsReadylogic used before send.web/src/lib/attachmentAdapter.ts:28- attachment adapter declaresaccept: '*/*'.web/src/lib/attachmentAdapter.ts:48- upload size limit is currently 50 MiB.web/src/lib/attachmentAdapter.ts:74- upload goes throughapi.uploadFile(...).web/src/lib/attachmentAdapter.ts:94- previews are generated only for image files under 5 MiB.web/src/components/AssistantChat/ComposerButtons.tsx:479- attach button usesComposerPrimitive.AddAttachment.web/src/components/AssistantChat/ComposerButtons.tsx:482- attach button is disabled when controls are disabled or a schedule is active.web/src/components/SessionChat.tsx:949- attachment adapter is only provided for active sessions.
No more info needed from the reporter; acceptance criteria are specific enough to implement.
HAPI Bot