Chat: slash focuses the composer; Ctrl+Tab over one pane toggles recent chats

A bare / typed outside any text field puts the keyboard in the active
chat's composer through the existing focus request, after the frame, so
the slash is not typed into it. Ctrl+Tab with a single pane now swaps in
the chat shown before the current one and back; two or more panes keep
cycling panes. The visit remembers its shown chats most-recent-first,
dropping closed, /new-moved and other-server ids.
This commit is contained in:
2026-11-07 00:46:02 +00:00
parent f4ba2ab25e
commit de0c06cec1
5 changed files with 335 additions and 13 deletions
+9 -1
View File
@@ -35,6 +35,7 @@ import 'ui/sessions/chat_sessions_body.dart';
import 'ui/sessions/chat_sessions_controller.dart';
import 'ui/sessions/chat_sessions_screen.dart';
part 'chat_screen_keys.dart';
part 'chat_screen_workspace.dart';
/// The Chat destination's list/detail switch.
@@ -73,7 +74,8 @@ class ChatScreen extends StatefulWidget {
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
class _ChatScreenState extends State<ChatScreen>
with _ChatScreenWorkspace, _ChatScreenKeys {
/// The list's controller, shared with the mounted list screen. The list
/// screen refreshes it on mount and swaps its repository when the socket is
/// replaced; this destination lists created rows and re-reads after a
@@ -141,10 +143,12 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
_workspace.open(initial);
_workspaceVisible = true;
_publishedWorkspaceSession = initial;
_noteRecentSession();
}
_workspace.addListener(_workspaceChanged);
_bindWorkspacePersistence();
HardwareKeyboard.instance.addHandler(_cycleChatKey);
HardwareKeyboard.instance.addHandler(_slashFocusKey);
// Seen from now on, so the press that chooses the first chat counts.
LastPointerKind.instance;
_sessions.addListener(_nextChanged);
@@ -201,6 +205,7 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
void _openBySelection(JsonMap session) =>
_open(session, focusComposer: chatSelectionFocusesComposer(session));
@override
void _open(JsonMap session, {bool focusComposer = false}) {
final id = '${session['id'] ?? ''}';
if (id.isEmpty) return;
@@ -254,6 +259,7 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
if (accepted != null) _acceptedModels[id] = accepted;
_startNotice = (id: id, notice: notice);
_openedSessions[id] = <String, dynamic>{...session}..remove('running');
_forgetRecentSession(previousId);
_workspace.replaceSession(previousId, id);
if (_workspace.paneCount == 0) _open(session);
}
@@ -271,6 +277,7 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
/// `/close` was accepted: the conversation leaves, back to the list, which
/// re-reads the closed row.
void _closed(String sessionId) {
_forgetRecentSession(sessionId);
for (final pane
in _workspace.panes
.where((pane) => pane.sessionId == sessionId)
@@ -391,6 +398,7 @@ class _ChatScreenState extends State<ChatScreen> with _ChatScreenWorkspace {
@override
void dispose() {
HardwareKeyboard.instance.removeHandler(_cycleChatKey);
HardwareKeyboard.instance.removeHandler(_slashFocusKey);
_page.dispose();
_workspaceBinding?.dispose();
_workspace.removeListener(_workspaceChanged);