fdc730422d
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.
101 lines
3.3 KiB
Dart
101 lines
3.3 KiB
Dart
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';
|
|
import 'connection_status.dart';
|
|
import 'server_endpoint.dart';
|
|
|
|
/// The Chat destination: the shared session list and one read-only thread.
|
|
///
|
|
/// Before the shared socket accepts its first connection nothing is requested,
|
|
/// so an offline launch cannot look like an empty chat list. After that the
|
|
/// screen stays mounted through drops; a reconnect advances [syncToken] so the
|
|
/// open conversation re-subscribes and re-reads without losing its selection.
|
|
class ChatDestination extends StatelessWidget {
|
|
const ChatDestination({
|
|
super.key,
|
|
required this.session,
|
|
required this.server,
|
|
this.pool,
|
|
this.initialSessionId,
|
|
this.onSessionSelected,
|
|
this.onBack,
|
|
this.onWorkspaceEmpty,
|
|
this.onAvailableSessionsChanged,
|
|
this.runtime,
|
|
this.windows,
|
|
});
|
|
|
|
final AppSession session;
|
|
final ChatServerPool? pool;
|
|
final ServerEndpoint server;
|
|
final String? initialSessionId;
|
|
final ValueChanged<String>? onSessionSelected;
|
|
final VoidCallback? onBack;
|
|
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]),
|
|
builder: (context, _) {
|
|
final cupertino = usesCupertinoHost(context);
|
|
// Saved machines connect independently; their state and sign-in live
|
|
// in Settings, so the chat itself carries no connection chrome.
|
|
if (pool != null && pool!.servers.catalog.servers.isNotEmpty) {
|
|
return _chatScreen();
|
|
}
|
|
if ((server.requiresConfiguration || server.error != null) &&
|
|
session.endpoint == null) {
|
|
return ConnectionGate(
|
|
session: session,
|
|
server: server,
|
|
cupertino: cupertino,
|
|
);
|
|
}
|
|
if (!session.everConnected) {
|
|
if (session.connected) return _chatScreen();
|
|
return ConnectionGate(
|
|
session: session,
|
|
server: server,
|
|
cupertino: cupertino,
|
|
);
|
|
}
|
|
// The banner stays below the top bar; without it the chat screen
|
|
// reaches the top edge (an open chat beside the list draws its own bar
|
|
// there).
|
|
return TopBarNotices(
|
|
notices: [
|
|
if (!session.connected)
|
|
ConnectionBanner(session: session, cupertino: cupertino),
|
|
],
|
|
child: _chatScreen(),
|
|
);
|
|
},
|
|
);
|
|
|
|
Widget _chatScreen() => ChatScreen(
|
|
gateway: pool?.gateway ?? session.gateway,
|
|
persistWorkspace: true,
|
|
initialSessionId: initialSessionId == null
|
|
? null
|
|
: pool?.gateway.normalizeId(initialSessionId!) ?? initialSessionId,
|
|
syncToken: pool?.revision ?? session.connectionEpoch,
|
|
onSessionSelected: onSessionSelected,
|
|
onBack: onBack,
|
|
onWorkspaceEmpty: onWorkspaceEmpty,
|
|
onAvailableSessionsChanged: onAvailableSessionsChanged,
|
|
runtime: runtime,
|
|
windows: windows,
|
|
);
|
|
}
|