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.
|
/// Called when a system Back belongs to the Runs detail, not the app stack.
|
||||||
final VoidCallback onPopToRuns;
|
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 VoidCallback onPopToChat;
|
||||||
|
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
@@ -262,6 +263,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
|||||||
|
|
||||||
bool get _isExitRoot =>
|
bool get _isExitRoot =>
|
||||||
_rootExit.enabled &&
|
_rootExit.enabled &&
|
||||||
|
_route.chatSessionId == null &&
|
||||||
!_canStepUp &&
|
!_canStepUp &&
|
||||||
switch (_route.kind) {
|
switch (_route.kind) {
|
||||||
AppRouteKind.pipelines ||
|
AppRouteKind.pipelines ||
|
||||||
@@ -272,11 +274,10 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Whether the open route has a level above it in its own tab (a stage,
|
/// Whether an inline run/pipeline detail needs the shell to step up. Chats
|
||||||
/// a run, a pipeline, a chat).
|
/// always own a pushed route and use normal Navigator Back instead.
|
||||||
bool get _canStepUp =>
|
bool get _canStepUp =>
|
||||||
_route.runId != null ||
|
_route.runId != null ||
|
||||||
_route.chatSessionId != null ||
|
|
||||||
(_route.kind == AppRouteKind.pipelines && _route.pipelineId != null);
|
(_route.kind == AppRouteKind.pipelines && _route.pipelineId != null);
|
||||||
|
|
||||||
/// Goes up one level: a stage to its run or pipeline, an item to its list.
|
/// 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;
|
return true;
|
||||||
}
|
}
|
||||||
if (_route.chatSessionId != null) {
|
|
||||||
onPopToChat();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
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
|
`build/candidates/stock-chat-back-29880696/`. Combined release **29880730**, also
|
||||||
including the requested rotating Stop icon, is now published/download-verified;
|
including the requested rotating Stop icon, is now published/download-verified;
|
||||||
see `slow-stop-rotation.md`. Web is published too. Device timing still unverified.
|
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() {
|
void main() {
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
test('system Back leaves one chat session for the chat list', () async {
|
test(
|
||||||
var left = 0;
|
'router does not intercept chat Back or invoke the legacy override',
|
||||||
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
() async {
|
||||||
addTearDown(router.dispose);
|
var left = 0;
|
||||||
|
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
|
||||||
|
addTearDown(router.dispose);
|
||||||
|
|
||||||
expect(await router.popRoute(), isTrue);
|
// With no Navigator mounted there is nothing to pop. The router must not
|
||||||
expect(left, 1);
|
// 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 {
|
test('system Back steps up one level at a time', () async {
|
||||||
var runs = 0;
|
var runs = 0;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void main() {
|
|||||||
router = AppRouterDelegate(
|
router = AppRouterDelegate(
|
||||||
initial: AppRoute.chat,
|
initial: AppRoute.chat,
|
||||||
cupertino: false,
|
cupertino: false,
|
||||||
onPopToChat: () => router.goTo(AppRoute.chat),
|
onPopToChat: () => fail('Chat Back must not use the router override'),
|
||||||
onPopToRuns: () {},
|
onPopToRuns: () {},
|
||||||
builder: (_, route) => AdaptiveShell(
|
builder: (_, route) => AdaptiveShell(
|
||||||
destination: AppDestination.chat,
|
destination: AppDestination.chat,
|
||||||
@@ -115,6 +115,14 @@ void main() {
|
|||||||
isTrue,
|
isTrue,
|
||||||
reason: 'Chat must be pushed, not swapped into the main page',
|
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(
|
expect(
|
||||||
tester.widget<BackButton>(findNativeBack()).onPressed,
|
tester.widget<BackButton>(findNativeBack()).onPressed,
|
||||||
isNull,
|
isNull,
|
||||||
|
|||||||
Reference in New Issue
Block a user