From 50c89976faa45254219438a1feb4452fc510bb5d Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 24 Nov 2026 00:06:06 +0000 Subject: [PATCH] Let the composer being typed in take pasted files; free Cmd+V on macOS A composer outside the active pane (a floating chat window, a side pane) refused file pastes even while focused, so the field's own text paste ran instead: a Finder copy pasted its file name and an image nothing. The focused composer now always takes the paste. On macOS the Edit > Paste menu item owned Cmd+V and sent paste: to the native text view, which pastes plain text only and never lets the key reach Flutter. The item keeps working from the menu but no longer claims the shortcut, so Cmd+V reaches the composer's file paste. Co-Authored-By: Claude Opus 5.5 --- .../chat/conversation/chat_composer_bar.dart | 5 +++- app/macos/Runner/Base.lproj/MainMenu.xib | 2 +- .../chat_clipboard_paste_native_test.dart | 30 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index 9747608d..85143b61 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -318,7 +318,10 @@ class _ChatComposerBarState extends State { /// default behaviour, so an inactive pane is never allowed to swallow it. bool _canAcceptPaste() => mounted && - (widget.ownsPasteWhenFocused && _focus.hasFocus || + // The composer the operator is typing in always takes the paste (a + // floating window's or a side pane's too); otherwise the active pane + // does, unless another composer has the keyboard. + (_focus.hasFocus || widget.pasteTarget && !ChatComposerPasteFocus.otherOwnerHasFocus(_focus)) && _composerIsCurrent() && diff --git a/app/macos/Runner/Base.lproj/MainMenu.xib b/app/macos/Runner/Base.lproj/MainMenu.xib index 80e867a4..5553afe0 100644 --- a/app/macos/Runner/Base.lproj/MainMenu.xib +++ b/app/macos/Runner/Base.lproj/MainMenu.xib @@ -91,7 +91,7 @@ - + diff --git a/app/test/features/chat/domain/chat_clipboard_paste_native_test.dart b/app/test/features/chat/domain/chat_clipboard_paste_native_test.dart index 8dcce08b..497813eb 100644 --- a/app/test/features/chat/domain/chat_clipboard_paste_native_test.dart +++ b/app/test/features/chat/domain/chat_clipboard_paste_native_test.dart @@ -130,6 +130,36 @@ void main() { }, variant: _macOS); } + testWidgets('a focused composer outside the active pane takes the paste', ( + tester, + ) async { + // A floating chat window's or a side pane's composer is not the paste + // target, but the operator typing in it means the paste is for it. + pasteboard = { + 'files': [ + { + 'name': 'notes.txt', + 'mime': 'text/plain', + 'bytes': Uint8List.fromList([104, 105]), + }, + ], + 'errors': const [], + }; + await tester.pumpWidget( + materialHost( + ChatComposerBar(composer: composer, running: false, pasteTarget: false), + ), + ); + await tester.pumpAndSettle(); + await tester.showKeyboard(_field); + await tester.pump(); + await paste(tester); + expect(fileReads, 1); + expect(find.text('notes.txt'), findsOneWidget); + expect(composer.draft, isEmpty); + await done(tester); + }, variant: _macOS); + testWidgets('a paste with nothing usable says what the clipboard held', ( tester, ) async {