Animate retained mobile chat reopening without remounting panes
This commit is contained in:
@@ -12,6 +12,7 @@ import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_mobile_peek_divider.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
|
||||
|
||||
@@ -321,7 +322,21 @@ void main() {
|
||||
testWidgets(
|
||||
'mobile Chats retap reopens the retained multi-pane workspace after tabs',
|
||||
(tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
// A restored empty layout chooses the retained inline mobile path from
|
||||
// the first selection, rather than the initial pushed detail route.
|
||||
SharedPreferences.setMockInitialValues({
|
||||
chatWorkspacePreferenceKey: jsonEncode({
|
||||
'version': 1,
|
||||
'root': null,
|
||||
'active_pane': null,
|
||||
'sidebar_mode': 'expanded',
|
||||
}),
|
||||
});
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
tester.view.physicalSize = const Size(560, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
@@ -348,6 +363,9 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('Chat a').first);
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/chat/a');
|
||||
expect(find.byType(ChatThreadView), findsOneWidget);
|
||||
await replyChatSessions(tester, channel, ['a', 'b'], index: 1);
|
||||
await replyChatHistory(
|
||||
tester,
|
||||
channel,
|
||||
@@ -409,6 +427,11 @@ void main() {
|
||||
expect(workspace.controller.paneCount, 2);
|
||||
expect(workspace.controller.activePane?.sessionId, 'b');
|
||||
expect(provider.value.uri.path, '/chat/b');
|
||||
final workspaceState = tester.state(find.byType(ChatWorkspace));
|
||||
final activeThreadState = tester.state(
|
||||
find.byKey(const ValueKey('chat-session-b')),
|
||||
);
|
||||
final restingTop = tester.getTopLeft(find.byType(ChatWorkspace)).dy;
|
||||
final paneOrder = workspace.controller.panes
|
||||
.map((p) => p.sessionId)
|
||||
.toList();
|
||||
@@ -455,7 +478,20 @@ void main() {
|
||||
// The selected Chats destination is already showing its list: the
|
||||
// second tap reuses the mounted workspace instead of opening a new one.
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pump();
|
||||
final enteringTop = tester.getTopLeft(find.byType(ChatWorkspace)).dy;
|
||||
expect(enteringTop, greaterThan(restingTop + 1));
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final midwayTop = tester.getTopLeft(find.byType(ChatWorkspace)).dy;
|
||||
expect(midwayTop, greaterThan(restingTop + 1));
|
||||
expect(midwayTop, lessThan(enteringTop));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getTopLeft(find.byType(ChatWorkspace)).dy, restingTop);
|
||||
expect(tester.state(find.byType(ChatWorkspace)), same(workspaceState));
|
||||
expect(
|
||||
tester.state(find.byKey(const ValueKey('chat-session-b'))),
|
||||
same(activeThreadState),
|
||||
);
|
||||
expect(provider.value.uri.path, '/chat/b');
|
||||
final restored = tester.widget<ChatWorkspace>(find.byType(ChatWorkspace));
|
||||
expect(restored.controller, same(workspace.controller));
|
||||
|
||||
Reference in New Issue
Block a user