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, _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.'), ), ); } }