Cycle mobile tape through added panes and retain horizontal unfold layout

This commit is contained in:
2026-11-07 16:10:05 +00:00
parent 329005abe3
commit 9c67415c22
6 changed files with 126 additions and 22 deletions
@@ -156,6 +156,10 @@ void main() {
);
final workspace = tester.widget<ChatWorkspace>(find.byType(ChatWorkspace));
expect(workspace.controller.paneCount, 2);
expect(
(workspace.controller.root as ChatWorkspaceSplit).axis,
ChatSplitAxis.horizontal,
);
expect(workspace.controller.activePane?.sessionId, 'b');
final first = workspace.controller.panes.first.id;
await tester.tap(find.byKey(ValueKey('chat-peek-$first')));
@@ -169,6 +173,25 @@ void main() {
isFalse,
);
expect(tester.state(_thread('a')), same(stateA));
tester.view.physicalSize = const Size(880, 1000);
await tester.pumpAndSettle();
final aRect = tester.getRect(
find.byKey(
ValueKey('chat-workspace-${workspace.controller.panes.first.id}'),
),
);
final bRect = tester.getRect(
find.byKey(
ValueKey('chat-workspace-${workspace.controller.panes.last.id}'),
),
);
expect(aRect.top, bRect.top);
expect(aRect.right, lessThan(bRect.left));
expect(tester.state(_thread('a')), same(stateA));
expect(
tester.widget<EditableText>(_input('a')).controller.text,
'Phone draft A',
);
expect(tester.takeException(), isNull);
});
@@ -187,6 +187,73 @@ void main() {
},
);
testWidgets('quick switch loops through four added panes and keeps drafts', (
tester,
) async {
phone(tester);
final controller = ChatWorkspaceController()..open('a');
for (final id in ['b', 'c', 'd']) {
controller.splitActive(id, ChatSplitAxis.horizontal);
}
await tester.pumpWidget(_host(controller));
await tester.pumpAndSettle();
final states = {
for (final id in ['a', 'b', 'c', 'd'])
id: tester.state<_DraftState>(
find.byKey(ValueKey(id), skipOffstage: false),
),
};
for (final entry in states.entries) {
entry.value.controller.text = 'Draft ${entry.key}';
}
for (final id in ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd']) {
final pane = controller.panes.firstWhere((pane) => pane.sessionId == id);
await tester.tap(find.byKey(ValueKey('chat-peek-${pane.id}')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 140));
final incoming = tester.getRect(rect(pane.id));
final next = controller
.panes[(controller.panes.indexWhere((p) => p.id == pane.id) + 1) % 4];
final entering = tester.getRect(rect(next.id));
final exiting = tester.getRect(
find.byKey(const ValueKey('chat-tape-exit')),
);
expect(exiting.bottom + 6, closeTo(incoming.top, .5));
expect(incoming.bottom + 6, closeTo(entering.top, .5));
await tester.pumpAndSettle();
expect(controller.activePane!.sessionId, id);
expect(tester.getRect(rect(pane.id)).top, 0);
expect(tester.getRect(rect(next.id)).top, _peekTop);
}
for (final entry in states.entries) {
expect(
tester.state(find.byKey(ValueKey(entry.key), skipOffstage: false)),
same(entry.value),
);
expect(entry.value.controller.text, 'Draft ${entry.key}');
}
// The chooser can jump to a retained pane that was not the preview.
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
);
await tester.pumpAndSettle();
expect(controller.activePane!.sessionId, 'b');
final c = controller.panes.firstWhere((p) => p.sessionId == 'c');
expect(tester.getRect(rect(c.id)).top, _peekTop);
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'd').id,
);
await tester.pumpAndSettle();
controller.close(controller.panes.firstWhere((p) => p.sessionId == 'a').id);
await tester.pumpAndSettle();
final b = controller.panes.firstWhere((p) => p.sessionId == 'b');
await tester.tap(find.byKey(ValueKey('chat-peek-${b.id}')));
await tester.pumpAndSettle();
expect(controller.activePane!.sessionId, 'b');
await tester.pumpWidget(const SizedBox());
controller.dispose();
});
testWidgets(
'bottom separator shrinks peek, clamps both ends and retains size',
(tester) async {