Chat stack: the default, also on a wide phone or tablet; a close button where the pile was

Chat stack is now the default phone chat navigation (a stored choice is
kept), and on Android or iOS it stays on a wide layout (an unfolded
foldable) above the active pane, where floating is ignored too. When
expanded, the pile turns into a close button at its own spot and the
column rises above it; while a chat is dragged that button is the remove
target, replacing the separate x at the bottom. Chat widget tests start
on Quick switch (they run as Android); the stack's tests choose it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 21:47:57 +00:00
parent fba3b924f1
commit 130c1e6708
18 changed files with 344 additions and 184 deletions
@@ -11,7 +11,7 @@ import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_column.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_disc.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_drag.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_remove_target.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_close_target.dart';
import 'package:pipelines_app/features/chat/stack/mobile_chat_navigation.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
@@ -117,7 +117,7 @@ Finder _button(WidgetTester tester, String id) {
}
final _add = find.byKey(const ValueKey('chat-stack-button-add'));
final _target = find.byType(ChatStackRemoveTarget);
final _target = find.byType(ChatStackCloseTarget);
/// Holds [finder] until it lifts.
Future<TestGesture> _lift(WidgetTester tester, Finder finder) async {
@@ -127,7 +127,7 @@ Future<TestGesture> _lift(WidgetTester tester, Finder finder) async {
}
double _shown(WidgetTester tester) =>
tester.widget<ChatStackRemoveTarget>(_target).shown.value;
tester.widget<ChatStackCloseTarget>(_target).armed.value;
void main() {
final navigation = MobileChatNavigationController.instance;
@@ -182,7 +182,7 @@ void main() {
final from = tester.getCenter(_button(tester, 'b'));
await gesture.moveBy(tester.getCenter(_target) - from);
await tester.pumpAndSettle();
final drag = tester.widget<ChatStackRemoveTarget>(_target).hover;
final drag = tester.widget<ChatStackCloseTarget>(_target).hover;
expect(drag.value, 1);
await gesture.up();
await tester.pumpAndSettle();
@@ -308,9 +308,9 @@ void main() {
await gesture.moveBy(const Offset(0, -kChatStackPitch));
await tester.pump();
expect(tester.getCenter(_button(tester, 'b')).dy, b.dy + kChatStackPitch);
// No slide: the target sits in place.
// No turn or growth: the button only fades.
expect(
find.descendant(of: _target, matching: find.byType(SlideTransition)),
find.descendant(of: _target, matching: find.byType(RotationTransition)),
findsNothing,
);
await gesture.up();
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_close_target.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_column.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_disc.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_entry.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_fab.dart';
import 'package:pipelines_app/features/chat/stack/chat_stack_pose.dart';
@@ -103,7 +105,8 @@ void main() {
expect(find.text('Chat 0'), findsOneWidget);
expect(find.text('Chat 4'), findsOneWidget);
expect(find.text(ChatStackColumn.addLabel), findsOneWidget);
// Item 0 sits on the stack; each further item rises one pitch.
// The stack's slot holds the close button; item 0 sits a pitch above
// it and each further item rises one more.
final first = tester.getCenter(
find.byKey(const ValueKey('chat-stack-button-pane-0')),
);
@@ -114,7 +117,11 @@ void main() {
find.byKey(const ValueKey('chat-stack-button-add')),
);
expect(first.dx, closeTo(slot.center.dx, .5));
expect(first.dy, closeTo(slot.center.dy, .5));
expect(first.dy, closeTo(slot.center.dy - kChatStackPitch, .5));
expect(
tester.getCenter(find.bySemanticsLabel(ChatStackCloseTarget.label)),
slot.center,
);
expect(second.dy, lessThan(first.dy));
expect(add.dy, lessThan(second.dy));
// Outside the column.
@@ -126,6 +133,22 @@ void main() {
expect(harness.opened, isEmpty);
});
testWidgets('the close button where the pile was folds the column', (
tester,
) async {
final harness = await _pump(tester);
final slot = tester.getRect(find.byKey(const Key('chat-stack')));
await tester.tap(find.byKey(const Key('chat-stack')));
await _settle(tester);
await tester.tapAt(slot.center);
await tester.pump();
expect(_state(tester).expanded, isFalse);
await _settle(tester);
expect(find.byType(ChatStackColumn), findsNothing);
expect(harness.opened, isEmpty);
expect(harness.added, 0);
});
testWidgets('tapping a chat opens it and folds the column', (tester) async {
final harness = await _pump(tester);
await tester.tap(find.byKey(const Key('chat-stack')));
@@ -34,6 +34,15 @@ class _Gateway extends FakeChatGateway {
}
}
class _Store implements MobileChatNavigationStore {
_Store(this.value);
final String? value;
@override
Future<String?> load() async => value;
@override
Future<bool> save(String value) async => true;
}
Future<void> _pump(WidgetTester tester, Size size) async {
SharedPreferences.setMockInitialValues({});
unawaited(
@@ -114,14 +123,53 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('a wide window keeps its panes and shows no stack', (
tester,
) async {
await _pump(tester, const Size(1280, 800));
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
expect(_stack, findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
testWidgets(
'a wide desktop window keeps its panes and shows no stack',
variant: TargetPlatformVariant.desktop(),
(tester) async {
await _pump(tester, const Size(1280, 800));
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
expect(_stack, findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
},
);
testWidgets(
'a wide phone or tablet layout (an unfolded foldable) keeps the stack',
variant: TargetPlatformVariant({
TargetPlatform.android,
TargetPlatform.iOS,
}),
(tester) async {
await _pump(tester, const Size(1280, 800));
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
// The list stays beside the chat, the stack floats over the pane.
expect(find.byKey(const Key('chat-row-b')), findsOneWidget);
expect(_stack.hitTestable(), findsOneWidget);
await tester.tap(_stack);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('chat-stack-button-add')));
await tester.pumpAndSettle();
await tester.tap(find.text('Beta').last);
await tester.pumpAndSettle();
expect(find.bySemanticsLabel(chatStackLabel(2)), findsOneWidget);
await tester.pumpWidget(const SizedBox.shrink());
},
);
test('Chat stack is the default without a stored choice', () async {
final controller = MobileChatNavigationController(store: _Store(null));
expect(controller.value, MobileChatNavigation.chatStack);
await controller.restore();
expect(controller.value, MobileChatNavigation.chatStack);
final chosen = MobileChatNavigationController(store: _Store('quickSwitch'));
await chosen.restore();
expect(chosen.value, MobileChatNavigation.quickSwitch);
controller.dispose();
chosen.dispose();
});
}