Focus floating chat from terminal shortcut

Raise the most recently used chat when Ctrl+Y is invoked from another window, then rely on the existing host lifecycle to focus its composer. Preserve toggle behavior while chat is active and retain the Apple shortcut aliases.
This commit is contained in:
2026-11-11 19:40:30 +00:00
parent 3da71c3053
commit 4668deeaf7
8 changed files with 142 additions and 17 deletions
@@ -221,7 +221,7 @@ class ChatWindows {
if (event is KeyDownEvent) tiling.floatActive();
return KeyEventResult.handled;
}
if (event is KeyDownEvent) manager.toggleGroup(chatWindowKind);
if (event is KeyDownEvent) manager.toggleOrRaiseGroup(chatWindowKind);
return KeyEventResult.handled;
}
}
@@ -1,16 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import '../../../ui/input/keyboard_owner.dart';
/// Whether [event] shows or hides the floating chats: Alt+Y (Option+Y),
/// Ctrl+Y, and Cmd+Y on Apple platforms, matching the terminal's Alt+T. It is
/// a global key handler like the terminal's toggle, so it works while a
/// composer or the terminal has the keyboard; a plain Y (or Shift+Y) always
/// types. Alt+Y is always the chord, as Alt+T is for the terminal. On Apple
/// platforms Ctrl+Y inside a terminal is left to the shell (yank), since Cmd+Y
/// is there; elsewhere Ctrl+Y is the chord, so it takes priority over the
/// shell's yank.
/// platforms Ctrl+Y is also the chord, so it takes priority over the shell's
/// yank.
///
/// A held chord's repeats match too (and are swallowed); only its first
/// press toggles.
@@ -31,7 +28,7 @@ bool chatFloatShortcut(
if (alt) return !control && !meta;
if (control == meta) return false;
if (!_apple(platform ?? defaultTargetPlatform)) return control;
return meta || !primaryFocusIsTypingSurface();
return control || meta;
}
bool _apple(TargetPlatform platform) =>
+14
View File
@@ -289,6 +289,20 @@ class WindowManager extends ChangeNotifier {
return true;
}
/// Hides the group when it is active; otherwise shows and raises its most
/// recently used window. A global shortcut should bring a group forward when
/// pressed from another window, rather than hide it behind that window.
bool toggleOrRaiseGroup(String groupId) {
final group = inGroup(groupId).toList();
if (group.isEmpty) return false;
if (group.any(isVisible) && active?.groupId == groupId) {
setGroupShown(groupId, false);
} else {
show(group.last.id);
}
return true;
}
/// Brings the next ([step] 1) or previous (-1) visible window to the top.
void cycle([int step = 1]) {
final visible = windows.where(isVisible).toList();