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:
@@ -1,5 +1,6 @@
|
||||
import 'chat_pane_content.dart';
|
||||
import 'chat_runtime.dart';
|
||||
import 'windows/chat_windows.dart';
|
||||
import 'workspace/federated_workspace_store.dart';
|
||||
import '../../core/servers/chat/federated_chat_gateway.dart';
|
||||
import '../../shell/destination.dart';
|
||||
@@ -20,9 +21,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../core/servers/server_scope.dart';
|
||||
import 'workspace/chat_float_binding.dart';
|
||||
import 'workspace/chat_float_shortcut.dart';
|
||||
import 'workspace/chat_float_store.dart';
|
||||
import 'workspace/chat_workspace_binding.dart';
|
||||
import 'workspace/chat_workspace_snapshot.dart';
|
||||
import 'workspace/chat_workspace_store.dart';
|
||||
@@ -74,6 +73,7 @@ class ChatScreen extends StatefulWidget {
|
||||
this.onAvailableSessionsChanged,
|
||||
this.persistWorkspace = false,
|
||||
this.runtime,
|
||||
this.windows,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
@@ -83,6 +83,10 @@ class ChatScreen extends StatefulWidget {
|
||||
/// keeps its own for the visit when null.
|
||||
final ChatRuntime? runtime;
|
||||
|
||||
/// The app's floating chat windows; null offers none (a pane cannot
|
||||
/// float).
|
||||
final ChatWindows? windows;
|
||||
|
||||
/// The chat session the current route names, or null for the list.
|
||||
final String? initialSessionId;
|
||||
|
||||
@@ -137,6 +141,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
..gateway = widget.gateway
|
||||
..addListener(_runtimeChanged);
|
||||
_runtime.addSessionReplacedListener(_replacedElsewhere);
|
||||
_bindWindows();
|
||||
final initial = widget.initialSessionId;
|
||||
if (initial != null && initial.isNotEmpty) {
|
||||
_workspace.open(initial);
|
||||
@@ -282,12 +287,6 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
.toList()) {
|
||||
_closePane(pane.id);
|
||||
}
|
||||
for (final pane
|
||||
in _workspace.floatingPanes
|
||||
.where((pane) => pane.sessionId == sessionId)
|
||||
.toList()) {
|
||||
_closePane(pane.id);
|
||||
}
|
||||
unawaited(_sessions.refresh());
|
||||
}
|
||||
|
||||
@@ -374,7 +373,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
HardwareKeyboard.instance.removeHandler(_slashFocusKey);
|
||||
_page.dispose();
|
||||
_workspaceBinding?.dispose();
|
||||
_disposeFloat();
|
||||
_unbindWindows();
|
||||
_workspace.removeListener(_workspaceChanged);
|
||||
_workspace.dispose();
|
||||
_sessions.removeListener(_nextChanged);
|
||||
@@ -402,41 +401,36 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
: null,
|
||||
useNativeBack: _page.open,
|
||||
pasteTarget: _workspaceVisible && pane.id == _workspace.activePaneId,
|
||||
// A floating chat is never the active pane, so its composer takes a
|
||||
// paste while it has the keyboard.
|
||||
ownsPasteWhenFocused: _workspace.isFloating(pane.id),
|
||||
showBackButton: _page.open || !showsListBesideDetail(context),
|
||||
paneControls: (paneContext) => _workspace.isFloating(pane.id)
|
||||
? _floatControls(pane)
|
||||
: [
|
||||
ChatBarAction(
|
||||
label: 'Add chat pane',
|
||||
onPressed: () => _addPane(paneContext),
|
||||
materialIcon: Icons.add_box_outlined,
|
||||
cupertinoIcon: CupertinoIcons.plus_square,
|
||||
),
|
||||
if (_workspace.paneCount > 1)
|
||||
ChatBarAction(
|
||||
label: 'Open chats (${_workspace.paneCount})',
|
||||
onPressed: () => _pickPane(paneContext),
|
||||
materialIcon: Icons.view_quilt_outlined,
|
||||
cupertinoIcon: CupertinoIcons.square_split_2x2,
|
||||
),
|
||||
if (_workspace.paneCount > 1 && showsListBesideDetail(context))
|
||||
chatCenterStageAction(ChatCenterStageController.instance),
|
||||
...chatPaneMoveActions(
|
||||
ChatWorkspacePaneScope.maybeOf(paneContext),
|
||||
onMove: (target) => _movePane(pane.id, target),
|
||||
),
|
||||
..._floatControls(pane),
|
||||
if (_workspace.paneCount > 1)
|
||||
ChatBarAction(
|
||||
label: 'Close pane',
|
||||
onPressed: () => _closePane(pane.id),
|
||||
materialIcon: Icons.close,
|
||||
cupertinoIcon: CupertinoIcons.xmark,
|
||||
),
|
||||
],
|
||||
paneControls: (paneContext) => [
|
||||
ChatBarAction(
|
||||
label: 'Add chat pane',
|
||||
onPressed: () => _addPane(paneContext),
|
||||
materialIcon: Icons.add_box_outlined,
|
||||
cupertinoIcon: CupertinoIcons.plus_square,
|
||||
),
|
||||
if (_workspace.paneCount > 1)
|
||||
ChatBarAction(
|
||||
label: 'Open chats (${_workspace.paneCount})',
|
||||
onPressed: () => _pickPane(paneContext),
|
||||
materialIcon: Icons.view_quilt_outlined,
|
||||
cupertinoIcon: CupertinoIcons.square_split_2x2,
|
||||
),
|
||||
if (_workspace.paneCount > 1 && showsListBesideDetail(context))
|
||||
chatCenterStageAction(ChatCenterStageController.instance),
|
||||
...chatPaneMoveActions(
|
||||
ChatWorkspacePaneScope.maybeOf(paneContext),
|
||||
onMove: (target) => _movePane(pane.id, target),
|
||||
),
|
||||
..._floatControls(pane),
|
||||
if (_workspace.paneCount > 1)
|
||||
ChatBarAction(
|
||||
label: 'Close pane',
|
||||
onPressed: () => _closePane(pane.id),
|
||||
materialIcon: Icons.close,
|
||||
cupertinoIcon: CupertinoIcons.xmark,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user