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
-14
View File
@@ -1,14 +0,0 @@
import '../shell/windows/window_kind.dart';
import '../shell/windows/window_manager.dart';
import '../shell/windows/window_store.dart';
/// The app's floating windows, for the app's lifetime: the kinds features
/// register at start and the one manager the shell's window host draws.
abstract final class AppWindows {
static final WindowKinds kinds = WindowKinds();
static final WindowManager manager = WindowManager(
kinds: kinds,
store: const SharedPreferencesWindowStore(),
);
}
+10
View File
@@ -1,7 +1,9 @@
import '../core/servers/chat/chat_server_pool.dart';
import 'package:flutter/material.dart';
import '../features/chat/chat_runtime.dart';
import '../features/chat/screen.dart';
import '../features/chat/windows/chat_windows.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
@@ -25,6 +27,8 @@ class ChatDestination extends StatelessWidget {
this.onBack,
this.onWorkspaceEmpty,
this.onAvailableSessionsChanged,
this.runtime,
this.windows,
});
final AppSession session;
@@ -36,6 +40,10 @@ class ChatDestination extends StatelessWidget {
final VoidCallback? onWorkspaceEmpty;
final ValueChanged<Set<String>>? onAvailableSessionsChanged;
/// The chats' app-lifetime state and floating windows (see [ChatScreen]).
final ChatRuntime? runtime;
final ChatWindows? windows;
@override
Widget build(BuildContext context) => AnimatedBuilder(
animation: Listenable.merge([session, ?pool]),
@@ -86,5 +94,7 @@ class ChatDestination extends StatelessWidget {
onBack: onBack,
onWorkspaceEmpty: onWorkspaceEmpty,
onAvailableSessionsChanged: onAvailableSessionsChanged,
runtime: runtime,
windows: windows,
);
}
+60 -5
View File
@@ -35,9 +35,13 @@ import '../features/updates/web_release.dart';
import '../features/settings/server_connections.dart';
import 'app.dart';
import '../shell/windows/window_host.dart';
import '../shell/windows/window_kind.dart';
import '../shell/windows/window_manager.dart';
import '../shell/windows/window_store.dart';
import 'app_terminals.dart';
import 'app_windows.dart';
import '../features/chat/chat_runtime.dart';
import '../features/chat/windows/chat_windows.dart';
import '../features/chat/workspace/chat_float_store.dart';
import '../features/terminal/terminal_layout.dart';
import 'app_route.dart';
import 'app_router.dart';
@@ -99,7 +103,8 @@ class PipelinesApp extends StatefulWidget {
/// The terminal surface's saved layout; null is the device's own.
final TerminalLayout? terminalLayout;
/// The floating windows; the app's own ([AppWindows.manager]) when null.
/// The floating windows; the app keeps its own (saved on this device)
/// when null.
final WindowManager? windows;
final ServerEndpoint server;
final PipelinesClient? client;
@@ -216,6 +221,8 @@ class _PipelinesAppState extends State<PipelinesApp>
NotificationServiceHandoff? _deliveryHandoff;
late final AppTerminals _terminals;
late final WindowManager _windows;
late final ChatRuntime _chatRuntime;
late final ChatWindows _chatWindows;
@override
void initState() {
@@ -236,9 +243,38 @@ class _PipelinesAppState extends State<PipelinesApp>
bindServerIdentity(_session.gateway, widget.serverId);
bindServerIdentity(_session.client, widget.serverId);
// One server for now: windows are kept per server, and this one's show.
_windows = (widget.windows ?? AppWindows.manager)
..server = widget.serverId ?? 'server';
unawaited(_windows.restore());
_windows =
(widget.windows ??
WindowManager(
kinds: WindowKinds(),
store: const SharedPreferencesWindowStore(),
))
..server = widget.serverId ?? 'server';
final chatGateway = widget.chatPool?.gateway ?? _session.gateway;
final chatScope = widget.chatPool != null
? 'all-saved-servers'
: serverStorageScope(serverIdentity(chatGateway));
_chatRuntime = ChatRuntime(gateway: chatGateway, serverKey: chatScope);
_chatWindows = ChatWindows(
manager: _windows,
runtime: _chatRuntime,
openInChat: (id) => _delegate.goTo(AppRoute.chatSession(id)),
ready: _chatReady,
readiness: Listenable.merge([_session, ?widget.chatPool]),
)..start();
_session.addListener(_chatSyncChanged);
widget.chatPool?.addListener(_chatSyncChanged);
_chatSyncChanged();
// Every kind is registered: saved windows can be restored, then the
// floating chats an older build saved are brought over once.
unawaited(
_windows.restore().then((_) {
if (!mounted) return null;
return _chatWindows.migrate(
SharedPreferencesChatFloatStore(serverScope: chatScope),
);
}),
);
_terminals = AppTerminals(
pool: widget.chatPool,
connection: _session,
@@ -464,6 +500,11 @@ class _PipelinesAppState extends State<PipelinesApp>
(_provider as PlatformRouteInformationProvider).dispose();
}
_terminals.dispose();
_session.removeListener(_chatSyncChanged);
widget.chatPool?.removeListener(_chatSyncChanged);
_chatWindows.dispose();
_chatRuntime.dispose();
if (widget.windows == null) _windows.dispose();
_session.dispose();
super.dispose();
}
@@ -732,6 +773,18 @@ class _PipelinesAppState extends State<PipelinesApp>
_delegate.goTo(AppRoute.run(id));
}
/// Whether a chat can be read: the server has been reached (or saved
/// machines connect on their own).
bool _chatReady() {
final pool = widget.chatPool;
if (pool != null && pool.servers.catalog.servers.isNotEmpty) return true;
return _session.everConnected || _session.connected;
}
/// A replaced socket makes open chats re-subscribe, also in windows.
void _chatSyncChanged() => _chatRuntime.syncToken.value =
widget.chatPool?.revision ?? _session.connectionEpoch;
/// The shell rebuilds its Runs tab badge from the attention count alone; the
/// destination bodies keep their state through it.
Widget _buildShell(BuildContext context, AppRoute route) =>
@@ -835,6 +888,8 @@ class _PipelinesAppState extends State<PipelinesApp>
initialSessionId: chatRoute.chatSessionId,
onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)),
onBack: () => _delegate.goTo(AppRoute.chat),
runtime: _chatRuntime,
windows: _chatWindows,
onWorkspaceEmpty: () => _chatWorkspaceRoute = null,
onAvailableSessionsChanged: (ids) {
_availableChatSessionIds = ids;