fix(chat): remove remaining router Back interception
This commit is contained in:
@@ -78,7 +78,8 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
/// Called when a system Back belongs to the Runs detail, not the app stack.
|
||||
final VoidCallback onPopToRuns;
|
||||
|
||||
/// Called when a system Back belongs to one chat session.
|
||||
/// Legacy callback retained for callers; chat Back is owned by its Navigator
|
||||
/// route and never invokes this override.
|
||||
final VoidCallback onPopToChat;
|
||||
|
||||
final bool cupertino;
|
||||
@@ -262,6 +263,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
|
||||
bool get _isExitRoot =>
|
||||
_rootExit.enabled &&
|
||||
_route.chatSessionId == null &&
|
||||
!_canStepUp &&
|
||||
switch (_route.kind) {
|
||||
AppRouteKind.pipelines ||
|
||||
@@ -272,11 +274,10 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
_ => false,
|
||||
};
|
||||
|
||||
/// Whether the open route has a level above it in its own tab (a stage,
|
||||
/// a run, a pipeline, a chat).
|
||||
/// Whether an inline run/pipeline detail needs the shell to step up. Chats
|
||||
/// always own a pushed route and use normal Navigator Back instead.
|
||||
bool get _canStepUp =>
|
||||
_route.runId != null ||
|
||||
_route.chatSessionId != null ||
|
||||
(_route.kind == AppRouteKind.pipelines && _route.pipelineId != null);
|
||||
|
||||
/// Goes up one level: a stage to its run or pipeline, an item to its list.
|
||||
@@ -299,10 +300,6 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
);
|
||||
return true;
|
||||
}
|
||||
if (_route.chatSessionId != null) {
|
||||
onPopToChat();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,3 +45,17 @@ sequence and did not establish the device-specific cause.
|
||||
`build/candidates/stock-chat-back-29880696/`. Combined release **29880730**, also
|
||||
including the requested rotating Stop icon, is now published/download-verified;
|
||||
see `slow-stop-rotation.md`. Web is published too. Device timing still unverified.
|
||||
|
||||
## Follow-up: remove remaining router interception
|
||||
|
||||
- User reports the device problem persists and requests only removal of the Back
|
||||
override. The router still treated a chat selection as an inline detail and
|
||||
could dispatch `onPopToChat` from its root PopScope/fallback.
|
||||
- Removed chat from that inline step-up path and disabled root double-back while
|
||||
a chat session is selected. The pushed chat route retains stock Navigator Back;
|
||||
no timing, scrolling, or animation workaround was added.
|
||||
- Regression tests reject a blocking PopScope while chat is open, fail if the
|
||||
legacy callback runs, and cover the exact scroll roundtrip at both widths.
|
||||
- Checks: all 108 application tests pass; full gate clean analysis and 1,860 tests
|
||||
pass. No physical-device testing; this does not prove the reported delay fixed.
|
||||
- Updated APK build/publication is in progress at the user's request.
|
||||
|
||||
@@ -15,14 +15,21 @@ AppRouterDelegate delegate(AppRoute initial, {void Function()? onChat}) =>
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
test('system Back leaves one chat session for the chat list', () async {
|
||||
var left = 0;
|
||||
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
||||
addTearDown(router.dispose);
|
||||
test(
|
||||
'router does not intercept chat Back or invoke the legacy override',
|
||||
() async {
|
||||
var left = 0;
|
||||
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
||||
addTearDown(router.dispose);
|
||||
|
||||
expect(await router.popRoute(), isTrue);
|
||||
expect(left, 1);
|
||||
});
|
||||
// With no Navigator mounted there is nothing to pop. The router must not
|
||||
// substitute a chat-specific callback or arm main-screen double-back.
|
||||
expect(await router.popRoute(), isFalse);
|
||||
expect(await router.popRoute(), isFalse);
|
||||
expect(left, 0);
|
||||
expect(router.route, AppRoute.chatSession('s1'));
|
||||
},
|
||||
);
|
||||
|
||||
test('system Back steps up one level at a time', () async {
|
||||
var runs = 0;
|
||||
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
router = AppRouterDelegate(
|
||||
initial: AppRoute.chat,
|
||||
cupertino: false,
|
||||
onPopToChat: () => router.goTo(AppRoute.chat),
|
||||
onPopToChat: () => fail('Chat Back must not use the router override'),
|
||||
onPopToRuns: () {},
|
||||
builder: (_, route) => AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
@@ -115,6 +115,14 @@ void main() {
|
||||
isTrue,
|
||||
reason: 'Chat must be pushed, not swapped into the main page',
|
||||
);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is PopScope && !widget.canPop,
|
||||
),
|
||||
findsNothing,
|
||||
reason:
|
||||
'The main-screen Back interceptor must not block an open chat',
|
||||
);
|
||||
expect(
|
||||
tester.widget<BackButton>(findNativeBack()).onPressed,
|
||||
isNull,
|
||||
|
||||
Reference in New Issue
Block a user