Chat: Ctrl+1-9 puts the keyboard in the opened chat's composer

A chat opened from the keyboard asks its composer for focus; the composer
takes it after the frame it is built in (new detail pane or phone page), or
at once when that chat is already open. Taps and other opens cancel the
request, so they keep focus where it was. The capture kit's press step
accepts modifier chords such as Control+2.
This commit is contained in:
2026-11-03 12:42:28 +00:00
parent d34185b56c
commit d6f636a325
7 changed files with 209 additions and 8 deletions
@@ -27,6 +27,7 @@ class ChatSessionsScreen extends StatefulWidget {
super.key,
required this.gateway,
required this.onOpen,
this.onShortcutOpen,
this.embedded = false,
this.syncToken = 0,
this.onSessions,
@@ -38,6 +39,10 @@ class ChatSessionsScreen extends StatefulWidget {
final ApiGateway gateway;
final void Function(JsonMap session) onOpen;
/// Opens a row the shell's Ctrl+1…Ctrl+9 named, so the destination can put
/// the keyboard in its composer; null opens it like a tap ([onOpen]).
final void Function(JsonMap session)? onShortcutOpen;
/// True under the application shell, which owns the single navigation bar.
final bool embedded;
@@ -174,10 +179,11 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
if (session != null && mounted) widget.onOpen(session);
}
void _open(JsonMap session) {
void _open(JsonMap session, {bool byShortcut = false}) {
_markedActiveSessionId = _sessionId(session);
unawaited(_controller.markOpened(session));
widget.onOpen(session);
final open = byShortcut ? widget.onShortcutOpen : null;
(open ?? widget.onOpen)(session);
}
// Methods rather than closures, so the list's memoized rows see the same
@@ -203,7 +209,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
isOpen: _folds.isOpen,
);
if (index < 0 || index >= rows.length) return false;
_open(rows[index]);
_open(rows[index], byShortcut: true);
return true;
}