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:
2026-12-03 00:49:36 +00:00
parent accb9970b6
commit 12c7642e35
25 changed files with 1223 additions and 46 deletions
@@ -1,16 +1,21 @@
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, 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.
/// 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);
void _bindQuickSwitch() {
_runtime.quickSwitch.attach(_toggleQuickSwitch);
unawaited(_runtime.recency.load());
}
void _unbindQuickSwitch() {
_runtime.quickSwitch.detach(_toggleQuickSwitch);
@@ -24,6 +29,12 @@ mixin _ChatScreenQuickSwitch on State<ChatScreen>, _ChatScreenWorkspace {
}
}
@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) {
@@ -36,9 +47,11 @@ mixin _ChatScreenQuickSwitch on State<ChatScreen>, _ChatScreenWorkspace {
final route = showChatQuickSwitch(
context,
sessions: _runtime.sessions,
recent: () => _runtime.recency.ids,
currentId: _workspaceVisible ? _workspace.activePane?.sessionId : null,
serverName: _quickSwitchServerName,
onSelected: (row) {
if (mounted) _openByShortcut(row);
if (mounted) unawaited(_openSwitched(row));
},
);
_quickSwitchRoute = route;
@@ -47,6 +60,20 @@ mixin _ChatScreenQuickSwitch on State<ChatScreen>, _ChatScreenWorkspace {
});
}
/// 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'] ?? ''}';