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 {