Keep asynchronous clipboard files with their original composer

This commit is contained in:
2026-11-08 00:10:34 +00:00
parent d9a99457cf
commit b08d458c4b
3 changed files with 60 additions and 6 deletions
@@ -297,9 +297,7 @@ void main() {
expect(fake.canAcceptText!(), isFalse);
});
testWidgets('paste is only taken by the active composer', (
tester,
) async {
testWidgets('paste is only taken by the active composer', (tester) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
@@ -312,6 +310,48 @@ void main() {
expect(fake.canAccept!(), isTrue);
});
testWidgets('accepted file paste stays with its original inactive chat', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
expect(fake.canAccept!(), isTrue);
final decodingFinished = fake.onFiles!;
await pumpWith(tester, paste: fake.source, pasteTarget: false);
decodingFinished([
_file('original.txt', [1]),
]);
await tester.pump();
expect(find.text('original.txt'), findsOneWidget);
});
testWidgets('late file decoding never attaches to a replacement composer', (
tester,
) async {
final fake = _FakePaste();
await pumpBar(tester, paste: fake.source);
final decodingFinished = fake.onFiles!;
composer = ChatComposerController(
gateway,
'replacement',
drafts: MemoryChatDraftStore(),
newOperationId: () => 'op/replacement',
);
controllers.add(composer);
await pumpWith(tester, paste: fake.source);
decodingFinished([
_file('wrong-chat.txt', [1]),
]);
await tester.pump();
expect(find.text('wrong-chat.txt'), findsNothing);
expect(fake.canAccept!(), isTrue);
fake.paste([
_file('replacement.txt', [2]),
]);
await tester.pump();
expect(find.text('replacement.txt'), findsOneWidget);
});
testWidgets('a paste during an in-flight prompt adds nothing', (
tester,
) async {