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>
86 lines
2.9 KiB
Dart
86 lines
2.9 KiB
Dart
part of 'screen.dart';
|
|
|
|
/// The quick switcher Ctrl+K / Alt+K (Cmd+K on a Mac) shows when pressed on
|
|
/// the Chat destination: the open chats to jump to, most recently used first
|
|
/// with the one used before the current chat selected, filtered as the
|
|
/// operator types (see [showChatQuickSwitch]). Pressing the shortcut again
|
|
/// closes it. A chosen chat opens as a keyboard choice from the list does:
|
|
/// its pane is reused when it is already open, and its composer takes the
|
|
/// keyboard. A closed chat a query found is reopened first.
|
|
mixin _ChatScreenQuickSwitch on State<ChatScreen>, _ChatScreenWorkspace {
|
|
ChatRuntime get _runtime;
|
|
|
|
ModalRoute<JsonMap>? _quickSwitchRoute;
|
|
|
|
void _bindQuickSwitch() {
|
|
_runtime.quickSwitch.attach(_toggleQuickSwitch);
|
|
unawaited(_runtime.recency.load());
|
|
}
|
|
|
|
void _unbindQuickSwitch() {
|
|
_runtime.quickSwitch.detach(_toggleQuickSwitch);
|
|
final open = _quickSwitchRoute;
|
|
_quickSwitchRoute = null;
|
|
// The navigator is locked while this screen is torn down; close after.
|
|
if (open != null) {
|
|
WidgetsBinding.instance.addPostFrameCallback(
|
|
(_) => closeChatQuickSwitch(open),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void _touchActiveChat() {
|
|
final id = _workspaceVisible ? _workspace.activePane?.sessionId : null;
|
|
if (id != null) _runtime.recency.touch(id);
|
|
}
|
|
|
|
void _toggleQuickSwitch() {
|
|
final open = _quickSwitchRoute;
|
|
if (open != null && open.isActive) {
|
|
_quickSwitchRoute = null;
|
|
closeChatQuickSwitch(open);
|
|
return;
|
|
}
|
|
// Another popup or dialog over the chat keeps the keyboard.
|
|
if (!mounted || !_chatOwnsKeyboard()) return;
|
|
final route = showChatQuickSwitch(
|
|
context,
|
|
sessions: _runtime.sessions,
|
|
recent: () => _runtime.recency.ids,
|
|
currentId: _workspaceVisible ? _workspace.activePane?.sessionId : null,
|
|
serverName: _quickSwitchServerName,
|
|
onSelected: (row) {
|
|
if (mounted) unawaited(_openSwitched(row));
|
|
},
|
|
);
|
|
_quickSwitchRoute = route;
|
|
route.popped.whenComplete(() {
|
|
if (identical(_quickSwitchRoute, route)) _quickSwitchRoute = null;
|
|
});
|
|
}
|
|
|
|
/// Opens a chosen chat, reopening it first when it was closed. A refused
|
|
/// reopen leaves it closed, with the list row showing the server's words.
|
|
Future<void> _openSwitched(JsonMap row) async {
|
|
if (chatQuickSwitchIsClosed(row)) {
|
|
final id = '${row['id'] ?? ''}';
|
|
await _runtime.sessions.reopen(id);
|
|
if (!mounted || _runtime.sessions.errorFor(id) != null) return;
|
|
row = {...row}
|
|
..remove('closed_at')
|
|
..remove('closed');
|
|
}
|
|
if (mounted) _openByShortcut(row);
|
|
}
|
|
|
|
/// The machine a federated row is on, as the list names it.
|
|
String? _quickSwitchServerName(JsonMap row) {
|
|
final id = '${row['_server_id'] ?? ''}';
|
|
final named = mounted && id.isNotEmpty
|
|
? ServerContext.nameFor(context, id)
|
|
: null;
|
|
return named ?? row['_server_name'] as String?;
|
|
}
|
|
}
|