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:
2026-11-12 19:52:39 +00:00
parent 19b1d1326a
commit 3029295b1f
15 changed files with 382 additions and 52 deletions
@@ -31,11 +31,22 @@ class _Gateway extends FakeChatGateway {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'},
for (final id in ['a', 'b', 'c'])
{'id': id, 'title': 'Chat $id', 'directory': '/home/$id'},
],
});
}
if (type == 'chat_shells') return Future.value({'chat_shells': []});
if (type == 'directory_listing') {
final path = '${fields['path'] ?? '/home/a'}';
return Future.value({
'directory_listing': {
'path': path,
'home': '/home/a',
'entries': <JsonMap>[],
},
});
}
return super.call(type, fields);
}
}
@@ -334,6 +345,27 @@ void main() {
await app.stop(tester);
});
testWidgets('Ctrl+E opens Files in the focused floating chat', (
tester,
) async {
await _saved('a', 'b');
final app = _App(_Store());
await app.start(tester);
await _menu(tester, 'b', 'Float (Alt+Y)');
await tester.tap(_input('b'));
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(find.byType(FilesPanel), findsOneWidget);
await tester.tap(_shown('Chat b'));
expect(tester.takeException(), isNull);
await tester.pump(const Duration(milliseconds: 100));
await app.stop(tester);
});
testWidgets('the last tiled chat floats and leaves the tiling empty', (
tester,
) async {
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/files/files_panel.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
@@ -18,10 +19,23 @@ class _Gateway extends FakeChatGateway {
if (type == 'chat_sessions') {
return Future.value({
'chat_sessions': [
for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'},
for (final id in ['a', 'b', 'c'])
{'id': id, 'title': 'Chat $id', 'directory': '/home/$id'},
],
});
}
if (type == 'directory_listing') {
final path = '${fields['path'] ?? '/home/a'}';
return Future.value({
'directory_listing': {
'path': path,
'home': '/home/a',
'entries': [
{'name': 'notes.md', 'path': '$path/notes.md'},
],
},
});
}
if (type == 'chat_shells') return Future.value({'chat_shells': []});
return super.call(type, fields);
}
@@ -248,6 +262,41 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('Ctrl+E opens and closes Files and restores composer focus', (
tester,
) async {
await _setup(tester);
final composer = _input('a');
await tester.tap(composer);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(find.byType(FilesPanel), findsOneWidget);
final filter = find.descendant(
of: find.byType(FilesPanel),
matching: find.byType(EditableText),
);
expect(filter, findsOneWidget);
expect(
tester.widget<EditableText>(filter).focusNode.hasPrimaryFocus,
isTrue,
);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyE);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(find.byType(FilesPanel), findsNothing);
await tester.pump(const Duration(milliseconds: 50));
expect(
tester.widget<EditableText>(composer).focusNode.hasPrimaryFocus,
isTrue,
);
expect(tester.takeException(), isNull);
});
testWidgets(
'drag compacts and expands sidebar without losing panes or drafts',
(tester) async {
@@ -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;
}
@@ -13,6 +13,7 @@ const _implemented = [
'Focus the active chat composer',
'Send a chat message',
'Choose a slash command',
'Toggle Files',
'Toggle Center Stage',
'Stop a running chat',
'Focus the neighbouring chat pane',
@@ -91,6 +92,16 @@ void main() {
'Ctrl+Alt+Shift+Arrows',
);
expect(at(TargetPlatform.macOS, 'Stop a running chat').keys, 'Esc, Esc');
expect(at(TargetPlatform.macOS, 'Toggle Files').keys, 'Cmd+E');
expect(
at(TargetPlatform.macOS, 'Toggle Center Stage').keys,
'Option+E, Cmd+Shift+E',
);
expect(at(TargetPlatform.windows, 'Toggle Files').keys, 'Ctrl+E');
expect(
at(TargetPlatform.windows, 'Toggle Center Stage').keys,
'Alt+E, Ctrl+Shift+E',
);
expect(
at(TargetPlatform.macOS, 'Copy selected terminal text').keys,
'Cmd+C',