Rebind chat file and center-stage shortcuts
Give Cmd/Ctrl+E to the active chat Files panel while preserving terminal behavior, and move Center Stage to the shifted chord. Update shortcut documentation and regression coverage for the new bindings.
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:pipelines_app/features/chat/workspace/chat_center_stage_strip.da
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_motion_viewport.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_geometry.dart';
|
||||
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
|
||||
|
||||
class _MemoryStore implements ChatCenterStageStore {
|
||||
_MemoryStore();
|
||||
@@ -83,6 +84,8 @@ Widget host(
|
||||
List<KeyEvent>? fieldKeys,
|
||||
bool actionBars = false,
|
||||
bool filesProbe = false,
|
||||
VoidCallback? onToggleFiles,
|
||||
bool terminalSurface = false,
|
||||
ThemeMode themeMode = ThemeMode.light,
|
||||
}) => MaterialApp(
|
||||
themeMode: themeMode,
|
||||
@@ -98,31 +101,45 @@ Widget host(
|
||||
child: ChatCenterStageKeys(
|
||||
controller: stage,
|
||||
enabled: () => !singlePane,
|
||||
child: ChatWorkspace(
|
||||
controller: workspace,
|
||||
centerStage: stage,
|
||||
singlePane: singlePane,
|
||||
paneTitle: (pane) => pane.sessionId,
|
||||
paneBuilder: (_, pane, active) => Focus(
|
||||
onKeyEvent: (_, event) {
|
||||
fieldKeys?.add(event);
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
_Draft(key: ValueKey(pane.sessionId), name: pane.sessionId),
|
||||
if (filesProbe) _FilesWidthProbe(name: pane.sessionId),
|
||||
if (actionBars)
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: TextButton(
|
||||
key: ValueKey('action-${pane.sessionId}'),
|
||||
onPressed: () {},
|
||||
child: const Text('Action'),
|
||||
onToggleFiles: onToggleFiles ?? () {},
|
||||
child: Stack(
|
||||
children: [
|
||||
ChatWorkspace(
|
||||
controller: workspace,
|
||||
centerStage: stage,
|
||||
singlePane: singlePane,
|
||||
paneTitle: (pane) => pane.sessionId,
|
||||
paneBuilder: (_, pane, active) => Focus(
|
||||
onKeyEvent: (_, event) {
|
||||
fieldKeys?.add(event);
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
_Draft(
|
||||
key: ValueKey(pane.sessionId),
|
||||
name: pane.sessionId,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (filesProbe) _FilesWidthProbe(name: pane.sessionId),
|
||||
if (actionBars)
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: TextButton(
|
||||
key: ValueKey('action-${pane.sessionId}'),
|
||||
onPressed: () {},
|
||||
child: const Text('Action'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (terminalSurface)
|
||||
Positioned.fill(
|
||||
child: TypingSurface(
|
||||
child: Focus(autofocus: true, child: const SizedBox()),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -510,19 +527,28 @@ void main() {
|
||||
|
||||
for (final mac in [false, true]) {
|
||||
testWidgets(
|
||||
'${mac ? 'Cmd' : 'Ctrl'}+E toggles; a plain e reaches the field',
|
||||
'${mac ? 'Cmd' : 'Ctrl'}+Shift+E toggles; plain E reaches the field and the app chord toggles Files',
|
||||
(tester) async {
|
||||
wide(tester);
|
||||
debugDefaultTargetPlatformOverride = mac
|
||||
? TargetPlatform.macOS
|
||||
: TargetPlatform.linux;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
final workspace = threePanes();
|
||||
final store = _MemoryStore();
|
||||
final stage = ChatCenterStageController(store: store);
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
final keys = <KeyEvent>[];
|
||||
await tester.pumpWidget(host(workspace, stage, fieldKeys: keys));
|
||||
var filesToggles = 0;
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
workspace,
|
||||
stage,
|
||||
fieldKeys: keys,
|
||||
onToggleFiles: () => filesToggles++,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('input-three')));
|
||||
await tester.pump();
|
||||
|
||||
@@ -538,7 +564,9 @@ void main() {
|
||||
: LogicalKeyboardKey.metaLeft;
|
||||
keys.clear();
|
||||
await tester.sendKeyDownEvent(modifier);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyUpEvent(modifier);
|
||||
expect(stage.value, isTrue);
|
||||
expect(store.saved, isTrue);
|
||||
@@ -549,8 +577,21 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
|
||||
// The other platform's chord stays with the field (Ctrl+E on a Mac is
|
||||
// its end of line).
|
||||
// The app platform's unshifted chord toggles Files.
|
||||
keys.clear();
|
||||
await tester.sendKeyDownEvent(modifier);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
|
||||
await tester.sendKeyUpEvent(modifier);
|
||||
expect(stage.value, isTrue);
|
||||
expect(filesToggles, 1);
|
||||
expect(
|
||||
keys.whereType<KeyDownEvent>().map((event) => event.logicalKey),
|
||||
isNot(contains(LogicalKeyboardKey.keyE)),
|
||||
);
|
||||
|
||||
// The other platform's unshifted chord stays with the field (Ctrl+E
|
||||
// on a Mac is its terminal end of line).
|
||||
keys.clear();
|
||||
await tester.sendKeyDownEvent(other);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
|
||||
await tester.sendKeyUpEvent(other);
|
||||
@@ -584,6 +625,26 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test('Center Stage and Files use the physical E key', () {
|
||||
const event = KeyDownEvent(
|
||||
physicalKey: PhysicalKeyboardKey.keyE,
|
||||
logicalKey: LogicalKeyboardKey.keyQ,
|
||||
timeStamp: Duration.zero,
|
||||
);
|
||||
expect(
|
||||
chatCenterStageShortcut(
|
||||
event,
|
||||
_CtrlShiftHeld(),
|
||||
platform: TargetPlatform.linux,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
chatFilesShortcut(event, _CtrlHeld(), platform: TargetPlatform.linux),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Alt+E toggles from a focused composer without typing', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -601,6 +662,39 @@ void main() {
|
||||
expect(find.text('e'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('terminal keeps Ctrl+E but Center Stage chords still work', (
|
||||
tester,
|
||||
) async {
|
||||
wide(tester);
|
||||
final workspace = threePanes();
|
||||
final stage = ChatCenterStageController(store: _MemoryStore());
|
||||
var filesToggles = 0;
|
||||
addTearDown(workspace.dispose);
|
||||
addTearDown(stage.dispose);
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
workspace,
|
||||
stage,
|
||||
terminalSurface: true,
|
||||
onToggleFiles: () => filesToggles++,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
expect(filesToggles, 0);
|
||||
expect(stage.value, isFalse);
|
||||
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
expect(stage.value, isTrue);
|
||||
});
|
||||
|
||||
test('the choice is remembered', () async {
|
||||
final store = _MemoryStore();
|
||||
final first = ChatCenterStageController(store: store)..toggle();
|
||||
@@ -629,3 +723,19 @@ class _AltHeld extends HardwareKeyboard {
|
||||
@override
|
||||
bool get isShiftPressed => false;
|
||||
}
|
||||
|
||||
class _CtrlHeld extends HardwareKeyboard {
|
||||
@override
|
||||
bool get isAltPressed => false;
|
||||
@override
|
||||
bool get isControlPressed => true;
|
||||
@override
|
||||
bool get isMetaPressed => false;
|
||||
@override
|
||||
bool get isShiftPressed => false;
|
||||
}
|
||||
|
||||
class _CtrlShiftHeld extends _CtrlHeld {
|
||||
@override
|
||||
bool get isShiftPressed => true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user