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
@@ -4,6 +4,10 @@ part of 'screen.dart';
mixin _ChatScreenWorkspace on State<ChatScreen> {
Map<String, JsonMap> get _openedSessions;
ChatComposerFocusRequests get _composerFocus;
bool _chatOwnsKeyboard();
bool _toggleRecentChat();
void _noteRecentSession();
void _forgetRecentSessions();
JsonMap? _rowFor(String id);
void _back();
bool get _pageOpen;
@@ -89,6 +93,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
_workspaceBinding = null;
if (_workspaceScope != null && scope != _workspaceScope) {
_workspace.restoreLayout(ChatWorkspaceSnapshot.fromLayout(null, null)!);
_forgetRecentSessions();
_workspaceVisible = false;
_usedWorkspace = true;
_sidebarMode = ChatSidebarMode.expanded;
@@ -111,7 +116,9 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
String _workspaceSignature = '';
/// Ctrl+Tab cycles retained panes even when the sidebar or toolbar owns
/// focus. Command+Tab stays with the operating system's application switcher.
/// focus. Over a single pane it swaps in the chat shown before this one
/// instead, and back again (see [_toggleRecentChat]). Command+Tab stays
/// with the operating system's application switcher.
bool _cycleChatKey(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
if (event is! KeyDownEvent ||
@@ -120,19 +127,12 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
keyboard.isMetaPressed ||
keyboard.isAltPressed ||
!_workspaceVisible ||
_workspace.paneCount == 0) {
return false;
}
final destination = ShellBarScope.maybeOf(context)?.registry.focus;
if (destination != null && destination != AppDestination.chat) return false;
final focusContext = FocusManager.instance.primaryFocus?.context;
final route = focusContext == null
? ModalRoute.of(context)
: ModalRoute.of(focusContext);
if (route is PopupRoute || (route != null && !route.isCurrent)) {
_workspace.paneCount == 0 ||
!_chatOwnsKeyboard()) {
return false;
}
final panes = _workspace.panes;
if (panes.length == 1 && _toggleRecentChat()) return true;
final active = panes.indexWhere(
(pane) => pane.id == _workspace.activePaneId,
);
@@ -156,7 +156,9 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
}
void _workspaceChanged() {
if (!mounted || _workspaceBinding?.isRestoring == true) return;
if (!mounted) return;
_noteRecentSession();
if (_workspaceBinding?.isRestoring == true) return;
final signature =
'${_workspace.activePaneId}:${_workspace.panes.map((p) => '${p.id}=${p.sessionId}').join(',')}';
if (_workspaceSignature == signature) return;