12c7642e35
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>
57 lines
2.0 KiB
Dart
57 lines
2.0 KiB
Dart
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';
|
|
}
|