fix(chat): use stock Navigator Back at every screen width

This commit is contained in:
2026-10-24 12:36:17 +01:00
parent 0ecd4a8487
commit f22afabd94
16 changed files with 262 additions and 53 deletions
@@ -846,7 +846,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
final title = widget.title.trim();
return ShellBar(
title: title.isEmpty ? null : title,
onBack: widget.onBack,
actions: [
if (hasModel)
ConstrainedBox(
+6 -13
View File
@@ -165,7 +165,7 @@ class _ChatScreenState extends State<ChatScreen> {
}
}
/// The open chat is its own page over the tabs on a phone.
/// The open chat is a real page above the main screen at every window width.
final DetailPageHost _page = DetailPageHost();
@override
@@ -200,12 +200,11 @@ class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
final selected = _selected;
// On a phone an open chat is its own page over the tabs; a wide window
// keeps it in the tab, beside the destination rail.
final narrow = MediaQuery.sizeOf(context).width < kDetailPageMaxWidth;
// Chats are real Navigator pages at every width. Do not swap a conversation
// into the home page and manually emulate Back on tablets/foldables.
_page.sync(
context,
selected: selected != null && narrow,
selected: selected != null,
destination: AppDestination.chat,
onClosed: _back,
builder: (context) => selected == null
@@ -220,14 +219,8 @@ class _ChatScreenState extends State<ChatScreen> {
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: narrow || selected == null,
);
if (narrow) return list;
return Stack(
children: [
Offstage(offstage: selected != null, child: list),
if (selected != null) _thread(selected, _back),
],
publishShellBar: true,
);
return list;
}
}