Files
pipelines/app/lib/features/chat/chat_screen_attention.dart
T
alan 12c7642e35 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>
2026-12-03 00:49:36 +00:00

55 lines
1.7 KiB
Dart

part of 'screen.dart';
/// The Chat destination's app-wide chat shortcuts, run through
/// [ChatRuntime.newChat] and [ChatRuntime.nextAttention] (the shell shows
/// Chat first): Alt+N starts a new chat with the list's own create dialog,
/// and Alt+J opens the next chat needing the operator (waiting for an answer,
/// unread, or a failed action), cycling in list order. Neither acts while a
/// popup or dialog over the chat keeps the keyboard.
mixin _ChatScreenAttention on State<ChatScreen>, _ChatScreenWorkspace {
ChatRuntime get _runtime;
void _bindAttention() {
_runtime.newChat.attach(_startNewChat);
_runtime.nextAttention.attach(_openNextAttention);
}
void _unbindAttention() {
_runtime.newChat.detach(_startNewChat);
_runtime.nextAttention.detach(_openNextAttention);
}
void _startNewChat() {
if (!mounted || !_chatOwnsKeyboard()) return;
final state = _sessionsKey.currentState;
if (state != null) unawaited(state.newChat());
}
void _openNextAttention() {
if (!mounted || !_chatOwnsKeyboard()) return;
final sessions = _runtime.sessions;
final current = _workspaceVisible ? _workspace.activePane?.sessionId : null;
final next = chatNextNeedingAttention(
sessions.sessions,
current,
(row) => chatNeedsAttention(
row,
unread: sessions.isUnseen(row),
failed: sessions.errorFor('${row['id'] ?? ''}') != null,
),
);
if (next != null) {
_openByShortcut(next);
return;
}
ScaffoldMessenger.maybeOf(context)
?..hideCurrentSnackBar()
..showSnackBar(
const SnackBar(
key: Key('chat-no-attention'),
content: Text('No other chat needs you.'),
),
);
}
}