Chat quick switcher MRU, Closed section and markers; Alt+N, Alt+J and run tab keys
Ctrl+K lists open chats most recently used first (tracked on open and pane focus, persisted per server) and preselects the previous chat, so Ctrl+K, Enter returns to it. Rows mark needs you / working / unread; a query also lists matching closed chats under Closed, and choosing one reopens it. Alt+N (Option+N) starts a new chat and Alt+J (Option+J) opens the next chat waiting for you, unread or failed, cycling; the terminal keeps both. In run detail, bare 1-4 switch tabs when not typing. Cheatsheet entries added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import 'shell_navigation_bar.dart';
|
||||
import 'shell_rail_scope.dart';
|
||||
import 'list_pane_widths.dart';
|
||||
import 'shell_bar.dart';
|
||||
import 'shell_chat_actions_shortcut.dart';
|
||||
import 'shell_chat_shortcut.dart';
|
||||
import 'shell_cheatsheet.dart';
|
||||
import 'shell_cheatsheet_shortcut.dart';
|
||||
@@ -33,6 +34,7 @@ class AdaptiveShell extends StatefulWidget {
|
||||
this.onSearch,
|
||||
this.onOpenChat,
|
||||
this.onChatQuickSwitch,
|
||||
this.onChatAction,
|
||||
this.attentionCount = 0,
|
||||
this.runningRunCount,
|
||||
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
||||
@@ -77,6 +79,11 @@ class AdaptiveShell extends StatefulWidget {
|
||||
/// the composer focus of [onOpenChat] there too.
|
||||
final VoidCallback? onChatQuickSwitch;
|
||||
|
||||
/// Runs after Alt+N or Alt+J (see [shellChatActionShortcut]) has shown the
|
||||
/// Chat destination: the host starts a new chat or opens the next chat
|
||||
/// needing the operator. Null leaves both chords unhandled.
|
||||
final ValueChanged<ShellChatAction>? onChatAction;
|
||||
|
||||
/// Runs needing the operator today, retained in the tab's accessible label.
|
||||
final int attentionCount;
|
||||
|
||||
@@ -410,8 +417,20 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits).
|
||||
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits, Alt+N, Alt+J).
|
||||
if (primaryFocusIsTypingSurface()) return false;
|
||||
final chatAction = widget.onChatAction == null
|
||||
? null
|
||||
: shellChatActionShortcut(event, keyboard);
|
||||
if (chatAction != null) {
|
||||
// A dialog or popup over the shell keeps its keys.
|
||||
if (!_shellRouteHasKeyboard()) return false;
|
||||
if (event is KeyDownEvent) {
|
||||
if (_selected != AppDestination.chat) _select(AppDestination.chat);
|
||||
widget.onChatAction!(chatAction);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_selected == AppDestination.search &&
|
||||
event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.escape &&
|
||||
@@ -450,6 +469,16 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
widget.onOpenChat?.call();
|
||||
}
|
||||
|
||||
/// Whether the keyboard is outside any dialog, sheet or menu (a page, such
|
||||
/// as a phone's open chat, is fine).
|
||||
bool _shellRouteHasKeyboard() {
|
||||
final focusedContext = FocusManager.instance.primaryFocus?.context;
|
||||
final focusedRoute = focusedContext == null
|
||||
? null
|
||||
: ModalRoute.of(focusedContext);
|
||||
return focusedRoute is! PopupRoute;
|
||||
}
|
||||
|
||||
/// A popup or nested viewer owns Escape before the underlying Search tab.
|
||||
bool _searchEscape() {
|
||||
final route = ModalRoute.of(context);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// The app-wide chat actions bound to a bare Alt chord (Option on a Mac).
|
||||
enum ShellChatAction {
|
||||
/// Alt+N: a new chat, with the Chat list's create dialog.
|
||||
newChat,
|
||||
|
||||
/// Alt+J: the next chat waiting for the operator, unread or failed.
|
||||
nextAttention,
|
||||
}
|
||||
|
||||
/// The chat action [event] asks for, or null: Alt+N or Alt+J with no other
|
||||
/// modifier. Option+N and Option+J yield a dead key or a symbol on a Mac, so
|
||||
/// the key is matched by position as well. Repeats of a held chord match too,
|
||||
/// so the caller can swallow them; only the first press acts.
|
||||
///
|
||||
/// Neither chord is taken by Chromium, Firefox or Safari on Linux, Windows or
|
||||
/// macOS, nor by the app's other shortcuts (Alt+K, Alt+T, Alt+Y, Alt+E,
|
||||
/// Alt+`, Alt+/). The terminal keeps both for readline (Alt+N searches
|
||||
/// history), so the caller leaves them to it while it has the keyboard.
|
||||
ShellChatAction? shellChatActionShortcut(
|
||||
KeyEvent event,
|
||||
HardwareKeyboard keyboard,
|
||||
) {
|
||||
if (event is KeyUpEvent ||
|
||||
!keyboard.isAltPressed ||
|
||||
keyboard.isControlPressed ||
|
||||
keyboard.isMetaPressed ||
|
||||
keyboard.isShiftPressed) {
|
||||
return null;
|
||||
}
|
||||
bool key(LogicalKeyboardKey logical, PhysicalKeyboardKey physical) =>
|
||||
event.logicalKey == logical || event.physicalKey == physical;
|
||||
if (key(LogicalKeyboardKey.keyN, PhysicalKeyboardKey.keyN)) {
|
||||
return ShellChatAction.newChat;
|
||||
}
|
||||
if (key(LogicalKeyboardKey.keyJ, PhysicalKeyboardKey.keyJ)) {
|
||||
return ShellChatAction.nextAttention;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// [action]'s chord as it reads on [platform], for the help page.
|
||||
String shellChatActionLabel(
|
||||
ShellChatAction action, [
|
||||
TargetPlatform? platform,
|
||||
]) {
|
||||
final target = platform ?? defaultTargetPlatform;
|
||||
final apple = target == TargetPlatform.macOS || target == TargetPlatform.iOS;
|
||||
final letter = switch (action) {
|
||||
ShellChatAction.newChat => 'N',
|
||||
ShellChatAction.nextAttention => 'J',
|
||||
};
|
||||
return '${apple ? 'Option' : 'Alt'}+$letter';
|
||||
}
|
||||
Reference in New Issue
Block a user