Copy and paste: the desktop's universal copy key works; Ctrl+C at the terminal login keeps the terminal

Omarchy's Super+C sends Ctrl+C by setting the modifier state with no Ctrl key
event while Super is held. Flutter's web engine only presses a modifier on its
own key event, so the app saw a plain "c": the chat selection was not copied
and the terminal typed the letter. A key modifier sync in front of the
framework's key handler now presses the modifiers the browser event's flags
hold (and outside Apple platforms lets go of a held Meta for Ctrl+C/V/X/A/
Insert), installed by the app's binding.

The terminal copies a selection on Ctrl+C without sending ^C, treats the
injected copy key as copy only, and pastes on Shift+Insert. A refused
clipboard write or read now shows a message instead of failing silently.

Server: before the login completes, Ctrl+C and Ctrl+\ erase the typed
password (Ctrl+U) and Ctrl+Z is dropped, so su is not killed and the terminal
no longer ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-29 17:57:28 +00:00
parent 58041e06b7
commit 3d739c3bfc
31 changed files with 2090 additions and 17 deletions
@@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_controller.dart';
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
import '../../../core/keyboard/browser_keys.dart';
import 'chat_composer_bar_fixtures.dart';
/// The desktop's universal paste key (Omarchy's Super+V sends Ctrl+V while
/// Super is held) pastes into the composer like Ctrl+V.
void main() {
late ComposerBarGateway gateway;
late ChatComposerController composer;
late int reads;
setUp(() {
gateway = ComposerBarGateway();
composer = ChatComposerController(
gateway,
's',
drafts: MemoryChatDraftStore(),
);
reads = 0;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.platform, (call) async {
if (call.method == 'Clipboard.getData') {
reads++;
return {'text': 'copied text'};
}
if (call.method == 'Clipboard.hasStrings') return {'value': true};
return null;
});
});
tearDown(() {
composer.dispose();
gateway.close();
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.platform, null);
});
for (final merged in [false, true]) {
testWidgets(
'Super+V (Ctrl${merged ? ' and Meta' : ''} in the flags) pastes into '
'the composer',
(tester) async {
final keys = BrowserKeys(tester);
await tester.pumpWidget(
materialHost(ChatComposerBar(composer: composer, running: false)),
);
await tester.pumpAndSettle();
await tester.showKeyboard(find.byKey(const Key('chat-composer-field')));
await keys.superChord(LogicalKeyboardKey.keyV, mergedMeta: merged);
await tester.pumpAndSettle();
expect(reads, 1);
expect(composer.draft, 'copied text');
await tester.pumpWidget(const SizedBox());
},
variant: TargetPlatformVariant({
TargetPlatform.linux,
TargetPlatform.windows,
}),
);
}
testWidgets(
'Super+V, Super+A and Super+X work in any text field (question answers, '
'find bars)',
(tester) async {
final keys = BrowserKeys(tester);
final controller = TextEditingController(text: 'answer: ');
addTearDown(controller.dispose);
await tester.pumpWidget(
materialHost(TextField(controller: controller, autofocus: true)),
);
await tester.pumpAndSettle();
controller.selection = const TextSelection.collapsed(offset: 8);
await keys.superChord(LogicalKeyboardKey.keyV, mergedMeta: true);
await tester.pumpAndSettle();
expect(controller.text, 'answer: copied text');
await keys.superChord(LogicalKeyboardKey.keyA);
expect(controller.selection.textInside(controller.text), controller.text);
await keys.superChord(LogicalKeyboardKey.keyX);
await tester.pumpAndSettle();
expect(controller.text, isEmpty);
},
variant: TargetPlatformVariant({
TargetPlatform.linux,
TargetPlatform.windows,
}),
);
}