Merge looping mobile tape and remembered peek resizing

This commit is contained in:
2026-11-07 13:21:05 +00:00
15 changed files with 590 additions and 210 deletions
@@ -78,7 +78,7 @@ void _expectComposerBottom(WidgetTester tester, double expected) {
expect(tester.takeException(), isNull);
}
Color _border(WidgetTester tester, String id) {
Border _paneBorder(WidgetTester tester, String id) {
final box = tester.widget<DecoratedBox>(
find
.ancestor(
@@ -93,9 +93,12 @@ Color _border(WidgetTester tester, String id) {
)
.first,
);
return ((box.decoration as BoxDecoration).border! as Border).top.color;
return (box.decoration as BoxDecoration).border! as Border;
}
Color _border(WidgetTester tester, String id) =>
_paneBorder(tester, id).top.color;
void main() {
testWidgets(
'Android pushed chat clears gesture bar once and keyboard correctly',
@@ -152,4 +155,33 @@ void main() {
);
expect(tester.takeException(), isNull);
});
testWidgets('mobile pair keeps only its coloured draggable bottom boundary', (
tester,
) async {
await _mount(tester, const Size(1800, 1000));
final controller = tester
.widget<ChatWorkspace>(find.byType(ChatWorkspace))
.controller;
controller.splitActive('b', ChatSplitAxis.horizontal);
await tester.pumpAndSettle();
tester.view.physicalSize = const Size(390, 844);
await tester.pumpAndSettle();
final border = _paneBorder(tester, 'b');
expect(border.left.style, BorderStyle.none);
expect(border.right.style, BorderStyle.none);
expect(border.top.style, BorderStyle.none);
expect(
border.bottom.color,
chatColorShade(tester.element(_thread('b')), 'teal'),
);
expect(
find.byWidgetPredicate(
(widget) =>
widget is Semantics &&
widget.properties.label == 'Resize inactive chat',
),
findsOneWidget,
);
expect(tester.takeException(), isNull);
});
}
@@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_pane_presentation.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_backdrop.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_switch_motion.dart';
import 'package:pipelines_app/features/chat/workspace/chat_pane_swap_card.dart';
import 'package:pipelines_app/features/chat/workspace/chat_mobile_peek_divider.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
@@ -12,6 +13,7 @@ Widget _host(
bool mobile = true,
bool reduced = false,
ChatWorkspacePaneBuilder? paneBuilder,
ValueChanged<Set<String>>? onVisible,
}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
@@ -22,6 +24,7 @@ Widget _host(
controller: controller,
singlePane: mobile,
mobilePeeks: mobile,
onVisibleSessionIdsChanged: onVisible,
paneBuilder:
paneBuilder ??
(_, pane, active) => _Draft(key: ValueKey(pane.sessionId)),
@@ -134,7 +137,7 @@ void main() {
}
testWidgets(
'crossing cards overlap with incoming on top; interruption retains state',
'tape exits above incoming, wraps below, queues reversal and retains drafts',
(tester) async {
phone(tester);
final controller = ChatWorkspaceController()..open('a');
@@ -148,67 +151,120 @@ void main() {
bState.controller.text = 'Retained draft';
controller.activate(a);
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
await tester.pump(const Duration(milliseconds: 140));
final t = ChatPaneSwitchMotion.curve.transform(.25);
expect(tester.getRect(rect(a)).top, closeTo(_peekTop * (1 - t), .5));
expect(tester.getRect(rect(b)).top, closeTo(_peekTop * t, .5));
expect(
tester.getSize(find.byKey(const ValueKey('a'))).height,
closeTo(tester.getRect(rect(a)).height, .5),
);
final incoming = tester.getRect(rect(a));
final outgoing = tester.getRect(rect(b));
expect(incoming.overlaps(outgoing), isTrue);
expect(incoming.height + outgoing.height, greaterThan(800));
final cards = tester
.widgetList<ChatPaneSwapCard>(find.byType(ChatPaneSwapCard))
.toList();
expect(cards.last.lift, greaterThan(.5));
expect(cards.first.lift, 0);
final stack = tester.widget<Stack>(
find
.descendant(
of: find.byType(ChatWorkspace),
matching: find.byType(Stack),
)
.first,
final wrapped = tester.getRect(rect(b));
final exiting = tester.getRect(
find.byKey(const ValueKey('chat-tape-exit')),
);
expect(stack.children.last.key, ValueKey('chat-workspace-$a'));
final beforeA = tester.getRect(rect(a));
final beforeB = tester.getRect(rect(b));
double reveal(String session) => tester
.widget<ChatPanePresentation>(
find
.ancestor(
of: find.byKey(ValueKey(session)),
matching: find.byType(ChatPanePresentation),
)
.first,
)
.barReveal
.value;
final bar = reveal('a');
controller.activate(b);
await tester.pump();
expect(tester.getRect(rect(a)), beforeA);
expect(tester.getRect(rect(b)), beforeB);
expect(reveal('a'), closeTo(bar, .001));
await tester.pump(const Duration(milliseconds: 90));
expect(tester.getRect(rect(a)).top, greaterThan(beforeA.top));
expect(reveal('a'), lessThan(bar));
await tester.pumpAndSettle();
expect(tester.getRect(rect(a)).top, _peekTop);
expect(incoming.top, closeTo(_peekTop * (1 - t), .5));
expect(exiting.top, lessThan(0));
expect(exiting.bottom + 6, closeTo(incoming.top, .5));
expect(incoming.bottom + 6, closeTo(wrapped.top, .5));
expect(wrapped.top, greaterThan(_peekTop));
expect(
tester.getSize(find.byKey(const ValueKey('a'))).height,
tester.getSize(find.byKey(const ValueKey('b'))).height,
closeTo((800 - 6) * .2, .5),
);
expect(
tester.getSize(find.byKey(const ValueKey('a'))).height,
closeTo(incoming.height, .5),
);
controller.activate(b);
await tester.pump();
expect(tester.getRect(rect(a)), incoming);
expect(tester.getRect(rect(b)), wrapped);
await tester.pumpAndSettle();
expect(tester.getRect(rect(a)).top, _peekTop);
expect(tester.getRect(rect(b)).top, 0);
expect(tester.state(find.byKey(const ValueKey('a'))), same(aState));
expect(tester.state(find.byKey(const ValueKey('b'))), same(bState));
expect(bState.controller.text, 'Retained draft');
expect(find.byKey(const ValueKey('chat-tape-exit')), findsNothing);
await tester.pumpWidget(const SizedBox());
controller.dispose();
},
);
testWidgets(
'bottom separator shrinks peek, clamps both ends and retains size',
(tester) async {
phone(tester);
final controller = ChatWorkspaceController()..open('a');
final a = controller.activePaneId!;
controller.splitActive('b', ChatSplitAxis.horizontal);
await tester.pumpWidget(_host(controller));
await tester.pumpAndSettle();
await tester.drag(
find.byType(ChatMobilePeekDivider),
const Offset(0, 220),
);
await tester.pumpAndSettle();
expect(tester.getRect(rect(a)).height, closeTo(48, .5));
final saved = controller.snapshot()!;
await tester.pumpWidget(const SizedBox());
final restored = ChatWorkspaceController()..restoreLayout(saved);
await tester.pumpWidget(_host(restored));
await tester.pumpAndSettle();
expect(tester.getRect(rect(a)).height, closeTo(48, .5));
await tester.drag(
find.byType(ChatMobilePeekDivider),
const Offset(0, -500),
);
await tester.pumpAndSettle();
expect(tester.getRect(rect(a)).height, closeTo((800 - 6) * .2, .5));
await tester.pumpWidget(const SizedBox());
controller.dispose();
restored.dispose();
},
);
testWidgets('unpainted snapshot cannot start a tape exit', (tester) async {
final motion = AnimationController(vsync: tester);
final picture = ChatPaneBackdrop(motion);
late BuildContext context;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (value) {
context = value;
return const SizedBox();
},
),
),
);
expect(picture.capture(context), isFalse);
expect(picture.image, isNull);
picture.dispose();
motion.dispose();
});
testWidgets(
'visibility reports only the mobile pair, not retained third pane',
(tester) async {
phone(tester);
final controller = ChatWorkspaceController()..open('a');
controller.splitActive('b', ChatSplitAxis.horizontal);
controller.splitActive('c', ChatSplitAxis.horizontal);
final seen = <Set<String>>[];
await tester.pumpWidget(_host(controller, onVisible: seen.add));
await tester.pumpAndSettle();
expect(seen.last, {'a', 'c'});
controller.activate(
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
);
await tester.pumpAndSettle();
expect(seen.last, {'b', 'c'});
for (final pane in controller.panes.toList()) {
controller.close(pane.id);
}
await tester.pumpAndSettle();
expect(seen.last, isEmpty);
await tester.pumpWidget(const SizedBox());
controller.dispose();
},
);
testWidgets('reduced motion settles immediately', (tester) async {
phone(tester);
final controller = ChatWorkspaceController()..open('a');
@@ -16,6 +16,7 @@ ChatWorkspaceController _layout() {
(controller.root as ChatWorkspaceSplit).second as ChatWorkspaceSplit;
controller.resize(vertical.id, .64);
controller.activate(controller.panes.first.id);
controller.resizeMobilePeek(.085);
return controller;
}
@@ -77,6 +78,8 @@ void main() {
expect((root.second as ChatWorkspaceSplit).axis, ChatSplitAxis.vertical);
expect((root.second as ChatWorkspaceSplit).ratio, .64);
expect(restored.sidebarMode, 'hidden');
expect(restored.mobilePeekFraction, .085);
expect(fresh.mobilePeekFraction, .085);
fresh.splitActive('session-d', ChatSplitAxis.vertical);
final ids = <String>[];
void collect(ChatWorkspaceNode node) {
@@ -210,6 +213,22 @@ void main() {
},
);
test(
'legacy snapshots retain the original peek and invalid peek fractions reject',
() {
final legacy = _json(_pane('a', 'session-a'));
expect(ChatWorkspaceSnapshot.decode(legacy)!.mobilePeekFraction, .2);
for (final value in [0, -.1, .21, 'large', null]) {
final data = jsonDecode(legacy) as Map<String, dynamic>;
data['mobile_peek_fraction'] = value;
// Explicit null keeps backwards-compatible default semantics.
if (value != null) {
expect(ChatWorkspaceSnapshot.decode(jsonEncode(data)), isNull);
}
}
},
);
test(
'unknown ordinary fields are forward compatible but nesting and size are bounded',
() {