Add global keyboard shortcuts cheatsheet

Expose the existing shortcut help as a global Ctrl+?/Cmd+? cheatsheet while preserving Ctrl+/ search behavior. Register the current shortcuts and cover composer, terminal, layout, and close interactions with focused tests.
This commit is contained in:
2026-11-12 14:41:20 +00:00
parent a3fb506a57
commit 3e0b1e55c7
9 changed files with 1002 additions and 50 deletions
+21
View File
@@ -13,6 +13,8 @@ import 'shell_rail_scope.dart';
import 'list_pane_widths.dart';
import 'shell_bar.dart';
import 'shell_chat_shortcut.dart';
import 'shell_cheatsheet.dart';
import 'shell_cheatsheet_shortcut.dart';
import 'shell_list_shortcuts.dart';
import 'shell_runs_pipelines_shortcut.dart';
import 'shell_search_shortcut_labels.dart';
@@ -92,6 +94,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// page of its own for the system Back to close first.
final Map<AppDestination, bool> _nestedCanPop = {};
final ShellBarRegistry _bar = ShellBarRegistry();
final ShellCheatsheet _cheatsheet = ShellCheatsheet();
late final ListPaneWidths _paneWidths = ListPaneWidths(
store: widget.listPaneWidthStore,
);
@@ -390,6 +393,24 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
/// terminal their own Ctrl+A (select all, line start).
bool _handleDestinationKeyEvent(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
// Ctrl+? opens the shortcuts cheatsheet from anywhere, including a focused
// composer and floating windows; the terminal keeps the chord while it has
// the keyboard. Escape closes the cheatsheet while it is open.
if (shellCheatsheetShortcut(event, keyboard) &&
!primaryFocusIsTypingSurface()) {
if (event is KeyDownEvent) _cheatsheet.toggle(context);
return true;
}
if (_cheatsheet.isOpen &&
event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape &&
!keyboard.isControlPressed &&
!keyboard.isMetaPressed &&
!keyboard.isShiftPressed &&
!keyboard.isAltPressed) {
_cheatsheet.close(context);
return true;
}
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
// Alt+K still opens Chat there.
if (shellChatShortcut(event, keyboard) &&