Skip to content

feat: add image drag-drop and paste support to codegen chat#12351

Open
rlueder wants to merge 1 commit intogitbutlerapp:masterfrom
rlueder:feat/image-drop-paste-codegen
Open

feat: add image drag-drop and paste support to codegen chat#12351
rlueder wants to merge 1 commit intogitbutlerapp:masterfrom
rlueder:feat/image-drop-paste-codegen

Conversation

@rlueder
Copy link

@rlueder rlueder commented Feb 13, 2026

Summary

  • Users can now drag-drop or paste images (PNG, JPG, GIF, WebP, SVG, BMP) into the Claude Code chat input
  • Images appear as thumbnails in the attachment list, matching how other attachments (files, commits) work
  • On submit, images are decoded from base64, written to temp files, and Claude is instructed to use its Read tool to view them (since the SDK is text-only)
  • Includes a 5MB size limit per image with a toast notification for oversized files

How it works

Since claude_agent_sdk_rs only exposes client.query(&str) (text-only), images can't be sent as native multimodal content blocks. Instead:

  1. Frontend: Images are converted to base64 and stored in the attachment service
  2. Backend: On submit, base64 is decoded, written to a temp file at {tmp}/gitbutler-images/{uuid}.{ext}, and the message tells Claude the file path so it can use its Read tool to view it

Screenshot

Example: user pastes a screenshot and asks Claude to fix a UI issue based on the image

Gitbutler_image_upload

Changes

File Change
apps/desktop/src/lib/codegen/types.ts Add image variant to PromptAttachment
packages/ui/src/lib/index.ts Export FileUploadPlugin
apps/desktop/src/components/codegen/CodegenInput.svelte Wire FileUpload plugin, implement handleFileDrop
apps/desktop/src/components/codegen/AttachmentList.svelte Render image thumbnails
crates/but-claude/src/lib.rs Add Image(ImageAttachment) to enum
crates/but-claude/src/legacy.rs Add Image variant + From impl
crates/but-claude/src/session.rs Handle image in validate_attachment and format_message_with_attachments
Cargo.toml / crates/but-claude/Cargo.toml Add base64 dependency

Test plan

  • Drag a PNG/JPG from Finder into the chat input — appears as thumbnail in attachment list
  • Copy an image (e.g., Cmd+Shift+4 screenshot), paste into chat — appears as attachment
  • Send a message with an image attached — Claude can view the image via Read tool
  • Click X on image attachment to remove it
  • Try a >5MB image — shows error toast
  • Verify existing attachment types (file, commit, lines, directory) still work

🤖 Generated with Claude Code

Users can now drag-drop or paste images (PNG, JPG, GIF, WebP, SVG, BMP)
into the Claude Code chat input. Images are stored as base64 in the
attachment service, displayed as thumbnails in the attachment list, and
written to temp files on submit so Claude can view them via its Read tool.

Key changes:
- Add 'image' variant to PromptAttachment (TS + Rust + legacy)
- Wire FileUploadPlugin into CodegenInput with 5MB size limit
- Render image thumbnails in AttachmentList
- Decode base64 and write to temp files in format_message_with_attachments
- Add base64 crate dependency to but-claude

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 13, 2026

@rlueder is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop @gitbutler/ui labels Feb 13, 2026
@krlvi
Copy link
Member

krlvi commented Feb 16, 2026

hey! thanks for the PR - do we know if this works on various platforms? I remember there being a drag and drop of external files on mac


// Write to a temp file in the system temp directory
let filename = format!("{}.{}", uuid::Uuid::new_v4(), ext);
let temp_dir = std::env::temp_dir().join("gitbutler-images");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might wanna use the "tempfile" crate for this

@rlueder
Copy link
Author

rlueder commented Feb 16, 2026

hey! thanks for the PR - do we know if this works on various platforms? I remember there being a drag and drop of external files on mac

Works well on mac and Linux, I have a Windows machine I can give it a go and will report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@gitbutler/desktop @gitbutler/ui rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants