Host floating chats on the shell window system

Phase 2.3 and 2.4 of docs/plans/floating-windows.md. A floating chat is a
window of the chat kind over the app's WindowManager, built from the
app-lifetime ChatRuntime, so it shows over every destination and at start
without the Chat destination being built. Float and Dock move the same
keyed view between the tiling and the window host. The pipelines app keeps
one runtime and one ChatWindows; saved chatFloat records (v1 and v2) are
brought over once.

ChatFloatHost, ChatFloatWindow, the float frames and binding, the
controller's float list and FloatingFocusRoot are gone; the workspace only
asks whether a chat is out in a window. Every MenuAnchor targets the root
overlay (guarded by a test), and menus and tooltips name the Alt chords.
This commit is contained in:
2026-11-10 21:17:40 +00:00
parent 9695100faa
commit fdc730422d
44 changed files with 1369 additions and 1792 deletions
+47 -61
View File
@@ -1,81 +1,67 @@
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`).
/// Floating a tiled pane into a window and docking it back (see
/// [ChatWindows] and `notes/chat-floating-pane.md`).
mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
@override
final ChatFloatFrames _floatFrames = ChatFloatFrames();
ChatFloatBinding? _floatBinding;
ChatTiling? _tiling;
/// 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();
}
}),
void _bindWindows() {
final windows = widget.windows;
if (windows == null) return;
_workspace.showOutside = windows.show;
windows.tiling = _tiling = ChatTiling(
holds: _workspace.holdsSession,
dock: _dockSession,
canFloatActive: () {
final pane = _workspace.activePane;
return mounted &&
pane != null &&
_floatsHere &&
_workspaceVisible &&
_workspace.canFloat(pane.id) &&
_chatOwnsKeyboard();
},
floatActive: () {
final pane = _workspace.activePane;
if (pane != null) _floatPane(pane.id);
},
);
}
@override
void _unbindFloat() {
_floatBinding?.dispose();
_floatBinding = null;
}
void _disposeFloat() {
_unbindFloat();
_floatFrames.dispose();
void _unbindWindows() {
final windows = widget.windows;
if (windows != null && identical(windows.tiling, _tiling)) {
windows.tiling = null;
}
_workspace.showOutside = null;
}
/// Panes float only on a wide layout, beside the chat list.
bool get _floatsHere => !_pageOpen && showsListBesideDetail(context);
bool get _floatsHere =>
widget.windows != null && !_pageOpen && showsListBesideDetail(context);
void _dockFloat(ChatWorkspacePane pane) {
_workspace.dock(pane.id);
_composerFocus.request(pane.sessionId);
/// The pane leaves the tiling and its live view moves into a window in
/// the same frame.
void _floatPane(String paneId) {
final pane = _workspace.detach(paneId);
if (pane != null) widget.windows?.float(pane.sessionId);
}
/// The pane menu's floating choices: Float on a tiled pane that can, and
/// Dock, Hide and Close on a floating chat.
void _dockSession(String sessionId) {
if (!mounted) return;
_workspaceVisible = true;
if (!_pageOpen && showsListBesideDetail(context)) _usedWorkspace = true;
_workspace.dock(sessionId);
_composerFocus.request(sessionId);
}
/// The pane menu's Float choice, on a tiled pane that can.
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),
label: 'Float (${chatFloatShortcutLabel()})',
onPressed: () => _floatPane(pane.id),
materialIcon: Icons.picture_in_picture_alt_outlined,
cupertinoIcon: CupertinoIcons.rectangle_on_rectangle,
),