fix(chat): double-back to close with a chat open beside the list

This commit is contained in:
2026-10-24 16:20:56 +01:00
parent 2740bb0673
commit 7bb95d4610
3 changed files with 120 additions and 1 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../shell/list_detail.dart';
import 'android_root_exit.dart';
import 'app_route.dart';
@@ -134,8 +135,13 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
/// page key is stable, so changing the route updates it in place instead of
/// remounting it and losing the open run. Search is the only extra page, so
/// its native Close action pops just that page.
/// Whether the window shows an open chat beside its list rather than as a
/// pushed page. Read in [build], so a resize rebuilds the Back policy.
bool _chatBesideList = false;
@override
Widget build(BuildContext context) {
_chatBesideList = showsListBesideDetail(context);
final searching = searchOpen && searchBuilder != null;
final templates = templatesOpen && templatesBuilder != null;
final schedules = schedulesOpen && schedulesBuilder != null;
@@ -263,7 +269,9 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
bool get _isExitRoot =>
_rootExit.enabled &&
_route.chatSessionId == null &&
// A phone's open chat is a pushed page with stock Back. Beside the list
// it is no page at all, so the list root's double-back applies.
(_route.chatSessionId == null || _chatBesideList) &&
!_canStepUp &&
switch (_route.kind) {
AppRouteKind.pipelines ||