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
@@ -3,14 +3,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../ui/floating/floating_layer.dart';
import '../../../ui/motion/motion.dart';
import '../../../ui/motion/quick_switch_animation.dart';
import 'chat_center_stage_layout.dart';
import 'chat_center_stage_motion.dart';
import 'chat_center_stage_strip.dart';
import 'chat_float_binding.dart';
import 'chat_float_host.dart';
import 'chat_workspace_controller.dart';
import 'chat_workspace_geometry.dart';
import 'chat_mobile_panes.dart';
@@ -45,7 +42,6 @@ class ChatWorkspace extends StatefulWidget {
this.onVisibleSessionIdsChanged,
this.centerStage,
this.paneColor,
this.floatFrames,
});
final ChatWorkspaceController controller;
final ChatWorkspacePaneBuilder paneBuilder;
@@ -65,11 +61,6 @@ class ChatWorkspace extends StatefulWidget {
/// A pane's chat colour, for its strip beside the stage.
final Color? Function(ChatWorkspacePane)? paneColor;
/// Offers floating chats (see [ChatFloatHost]) in these frames; null for a
/// workspace without them. They show only while the panes are not
/// collapsed.
final ChatFloatFrames? floatFrames;
/// Keyboard navigation only: the owner can focus the target composer.
/// Pointer activation leaves text-selection and pointer focus alone.
final ValueChanged<ChatWorkspacePane>? onFocusPane;
@@ -83,8 +74,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
final _focus = FocusNode(debugLabel: 'Chat workspace');
final Map<String, FocusScopeNode> _panes = {};
/// Each pane's view keeps its State when it moves into or out of the
/// floating window.
/// Each pane's view keeps its State as the tiling rearranges.
final Map<String, GlobalKey> _views = {};
late final ChatPaneSwitchMotion _motion;
late final ChatCenterStageMotion _stage = ChatCenterStageMotion(vsync: this);
@@ -295,13 +285,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
: !collapsed || pane.id == activeId)
pane.sessionId,
});
final floating = widget.floatFrames == null
? const <ChatWorkspacePane>[]
: widget.controller.floatingPanes;
final existing = {
...panes.map((p) => p.id),
...floating.map((p) => p.id),
};
final existing = {...panes.map((p) => p.id)};
_views.removeWhere((id, _) => !existing.contains(id));
for (final id
in _panes.keys.where((id) => !existing.contains(id)).toList()) {
@@ -342,7 +326,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
edge,
},
};
final surface = chatWorkspaceSurface(
return chatWorkspaceSurface(
context: context,
backdrop: _backdrop,
motion: _motion,
@@ -364,21 +348,6 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
moveTargets[pane.id],
),
);
final frames = widget.floatFrames;
if (frames == null) return surface;
return ChatFloatHost(
controller: widget.controller,
frames: frames,
enabled: !widget.singlePane,
title: (pane) => widget.paneTitle?.call(pane) ?? pane.sessionId,
content: _floatView,
scope: (pane) => _panes[pane.id],
focusedPane: () => widget.controller.panes
.where((pane) => _panes[pane.id]?.hasFocus ?? false)
.firstOrNull,
onFocusPane: widget.onFocusPane,
child: surface,
);
},
),
),
@@ -441,19 +410,6 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
);
}
/// A floating chat's view: the same keyed content as in the tiling, so
/// floating and docking move it without rebuilding the chat. Its focus
/// hangs from the shell's [FloatingFocusRoot], so it keeps the keyboard
/// while another destination (which excludes this one) shows.
Widget _floatView(ChatWorkspacePane pane) => _paneContent(
pane,
active: true,
peek: false,
mobile: false,
edges: {},
focusParent: FloatingFocusRoot.maybeOf(context),
);
Widget _paneContent(
ChatWorkspacePane pane, {
required bool active,
@@ -461,7 +417,6 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
required bool mobile,
required Set<String> edges,
Map<ChatPaneDirection, String>? moveTargets,
FocusNode? focusParent,
}) {
var actionBarPointerDown = false;
bool preservesStageForActionBar() =>
@@ -469,7 +424,6 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
return KeyedSubtree(
key: _views.putIfAbsent(pane.id, () => GlobalKey(debugLabel: pane.id)),
child: FocusScope(
parentNode: focusParent,
node: _panes.putIfAbsent(
pane.id,
() => FocusScopeNode(debugLabel: pane.id),