import 'package:flutter/material.dart'; import '../../../shell/windows/window_entry.dart'; import '../../../ui/adaptive/window_margins.dart'; import '../chat_pane_content.dart'; import 'chat_windows.dart'; /// A floating window's chat: the same live view as a tiled pane (see /// [buildChatPaneContent]), with what a window decides. Before the server /// has been reached it says so instead of reading a chat. class ChatWindowContent extends StatelessWidget { const ChatWindowContent({ super.key, required this.windows, required this.entry, }); final ChatWindows windows; final WindowEntry entry; @override Widget build(BuildContext context) { final runtime = windows.runtime; final sessionId = entry.contentId; return ListenableBuilder( listenable: Listenable.merge([ runtime, runtime.syncToken, windows.readiness, ]), builder: (context, _) { // A chat is drawn once: the tiling wins, and this window closes. if (windows.tiling?.holds(sessionId) ?? false) { WidgetsBinding.instance.addPostFrameCallback( (_) => windows.manager.close(entry.id), ); return const SizedBox.shrink(); } if (!windows.ready) { return Center( child: Text( 'Connecting…', style: Theme.of(context).textTheme.bodyMedium, ), ); } // A small window keeps the compact bar insets. return WindowMargins.compact( child: buildChatPaneContent( runtime: runtime, sessionId: sessionId, placement: ChatPanePlacement( syncToken: runtime.syncToken.value, onBack: () {}, showBackButton: false, // Never the active pane: its composer takes a paste while it // has the keyboard. ownsPasteWhenFocused: true, onNewSession: (previousId, session, notice) => windows .startedNewSession(entry.id, previousId, session, notice), onSessionClosed: () => windows.sessionClosed(entry.id), ), ), ); }, ); } }