Paste files and images into the chat composer on macOS

Native hosts reported clipboard-file paste as unsupported, and Flutter's
Clipboard carries text only, so Cmd+V of a Finder file or a screenshot in the
macOS app pasted nothing (or the file name). The macOS Runner now answers a
pipelines/clipboard_files channel with the pasteboard's file URLs, else its
image as PNG; the composer's Cmd+V reads it and attaches the files, falling
back to the pasteboard text when there are none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 20:42:05 +00:00
parent dd742ec8e4
commit f8ea50fd70
5 changed files with 373 additions and 8 deletions
@@ -328,8 +328,12 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
bool _canAcceptTextPaste() => _canAcceptPaste() && !_focus.hasFocus;
KeyEventResult _nativePasteKey(KeyEvent event) {
// Web uses the browser's clipboard event, never a second Clipboard read.
if (kIsWeb || event is! KeyDownEvent || !_canAcceptTextPaste()) {
// Web uses the browser's clipboard event, never a second Clipboard read; a
// native host that reads clipboard files (macOS) owns its paste key too.
if (kIsWeb ||
_paste.isSupported ||
event is! KeyDownEvent ||
!_canAcceptTextPaste()) {
return KeyEventResult.ignored;
}
final keys = HardwareKeyboard.instance;