Files
pipelines/app/lib/features/chat/chat_screen_float.dart
T
alan cdd54c113c Float several chats and keep them working on every tab
Floating chats were stuck on other destinations: the hidden Chat tab
muted the window's hide animation, so the window stayed painted but took
no input. The reveal now uses its own ticker, each floating pane's focus
scope hangs from a FloatingFocusRoot above the destination stack, and the
windows show over every destination like the terminal.

Any number of chats can float; the shortcut, a window's X and the menu
show or hide them together. Each pane keeps its own frame (also while
docked), saved in record version 2; version 1 records still load. Drags
read the live frame so fast pointer events no longer lose movement.
2026-11-10 15:26:38 +00:00

85 lines
2.6 KiB
Dart

part of 'screen.dart';
/// The floating chats for one Chat destination visit: their menu choices,
/// window frames and persistence (see `notes/chat-floating-pane.md`).
mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
@override
final ChatFloatFrames _floatFrames = ChatFloatFrames();
ChatFloatBinding? _floatBinding;
/// Restores and saves the floating chat in [store] once [restored] (the
/// workspace layout's own restore) completes.
@override
void _bindFloat(ChatFloatStore store, Future<void> restored) {
_floatBinding?.dispose();
final binding = _floatBinding = ChatFloatBinding(
controller: _workspace,
frames: _floatFrames,
store: store,
);
unawaited(
restored.then((_) {
if (mounted && identical(_floatBinding, binding)) {
return binding.start();
}
}),
);
}
@override
void _unbindFloat() {
_floatBinding?.dispose();
_floatBinding = null;
}
void _disposeFloat() {
_unbindFloat();
_floatFrames.dispose();
}
/// Panes float only on a wide layout, beside the chat list.
bool get _floatsHere => !_pageOpen && showsListBesideDetail(context);
void _dockFloat(ChatWorkspacePane pane) {
_workspace.dock(pane.id);
_composerFocus.request(pane.sessionId);
}
/// The pane menu's floating choices: Float on a tiled pane that can, and
/// Dock, Hide and Close on a floating chat.
List<Widget> _floatControls(ChatWorkspacePane pane) {
final shortcut = chatFloatShortcutLabel();
if (_workspace.isFloating(pane.id)) {
return [
ChatBarAction(
label: 'Dock',
onPressed: () => _dockFloat(pane),
materialIcon: Icons.vertical_split_outlined,
cupertinoIcon: CupertinoIcons.rectangle_split_3x1,
),
ChatBarAction(
label: 'Hide floating chats ($shortcut)',
onPressed: () => _workspace.setFloatShown(false),
materialIcon: Icons.visibility_off_outlined,
cupertinoIcon: CupertinoIcons.eye_slash,
),
ChatBarAction(
label: 'Close pane',
onPressed: () => _closePane(pane.id),
materialIcon: Icons.close,
cupertinoIcon: CupertinoIcons.xmark,
),
];
}
if (!_floatsHere || !_workspace.canFloat(pane.id)) return const [];
return [
ChatBarAction(
label: 'Float ($shortcut)',
onPressed: () => _workspace.float(pane.id),
materialIcon: Icons.picture_in_picture_alt_outlined,
cupertinoIcon: CupertinoIcons.rectangle_on_rectangle,
),
];
}
}