Remove Cupertino chat conversation branches

Keep the Material-only conversation implementation while preserving public Cupertino parameters for callers. Narrow affected tests to Material hosts so the dead platform paths are no longer exercised.
This commit is contained in:
2026-11-11 13:11:05 +00:00
parent 8f52c7ec55
commit 96de9f5bea
32 changed files with 812 additions and 2005 deletions
@@ -19,15 +19,10 @@ const _session = <String, dynamic>{
'model_provider': 'p1',
};
Widget _host(Widget child, {required bool cupertino}) => cupertino
? CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoPageScaffold(child: child),
)
: MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Scaffold(body: child),
);
Widget _host(Widget child) => MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Scaffold(body: child),
);
void _useNarrowText(WidgetTester tester) {
tester.view.physicalSize = const Size(320, 640);
@@ -39,58 +34,49 @@ void _useNarrowText(WidgetTester tester) {
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} wide header uses one explicit control gap',
(tester) async {
tester.view.physicalSize = const Size(1440, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
testWidgets('wide header uses one explicit control gap', (tester) async {
tester.view.physicalSize = const Size(1440, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
Widget control(String key) =>
SizedBox(key: Key(key), width: 48, height: 48);
Widget control(String key) =>
SizedBox(key: Key(key), width: 48, height: 48);
await tester.pumpWidget(
_host(
ChatThreadHeader(
title: 'Chat',
folder: 'demo',
onInfo: () {},
controls: [
control('header-control-1'),
control('header-control-2'),
],
actions: [control('header-action-1'), control('header-action-2')],
moreActions: [
ChatBarAction(
label: 'More action',
onPressed: () {},
materialIcon: Icons.more_horiz,
cupertinoIcon: CupertinoIcons.ellipsis,
),
],
await tester.pumpWidget(
_host(
ChatThreadHeader(
title: 'Chat',
folder: 'demo',
onInfo: () {},
controls: [control('header-control-1'), control('header-control-2')],
actions: [control('header-action-1'), control('header-action-2')],
moreActions: [
ChatBarAction(
label: 'More action',
onPressed: () {},
materialIcon: Icons.more_horiz,
cupertinoIcon: CupertinoIcons.ellipsis,
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
double gap(String left, String right) =>
tester.getTopLeft(find.byKey(Key(right))).dx -
tester.getTopRight(find.byKey(Key(left))).dx;
expect(gap('header-control-1', 'header-control-2'), 8);
expect(gap('header-control-2', 'header-action-1'), 8);
expect(gap('header-action-1', 'header-action-2'), 8);
expect(
tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx -
tester.getTopRight(find.byKey(const Key('header-action-2'))).dx,
8,
);
},
],
),
),
);
}
await tester.pumpAndSettle();
double gap(String left, String right) =>
tester.getTopLeft(find.byKey(Key(right))).dx -
tester.getTopRight(find.byKey(Key(left))).dx;
expect(gap('header-control-1', 'header-control-2'), 8);
expect(gap('header-control-2', 'header-action-1'), 8);
expect(gap('header-action-1', 'header-action-2'), 8);
expect(
tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx -
tester.getTopRight(find.byKey(const Key('header-action-2'))).dx,
8,
);
});
testWidgets('short large-text header keeps controls in its single row', (
tester,
@@ -116,7 +102,6 @@ void main() {
),
),
),
cupertino: false,
),
);
await tester.pumpAndSettle();
@@ -148,7 +133,6 @@ void main() {
session: _session,
onBack: () => backed++,
),
cupertino: false,
),
);
await tester.pumpAndSettle();
@@ -194,157 +178,134 @@ void main() {
);
// The mode control is Material only.
for (final cupertino in [false]) {
for (final width in [320.0, 390.0, 1280.0]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} grouped actions at $width and text scale 2',
(tester) async {
_useNarrowText(tester);
tester.view.physicalSize = Size(width, 800);
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(const []);
gateway.subscribe = () async => const {};
var sidebar = 0;
var pane = 0;
var next = 0;
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: _title,
session: {
..._session,
'mode': 'safe',
'mode_name': 'Ask before making changes',
},
onBack: () {},
onNextChat: () => next++,
sidebarControl: ChatBarAction(
label: 'Sidebar action',
onPressed: () => sidebar++,
materialIcon: Icons.menu,
cupertinoIcon: CupertinoIcons.sidebar_left,
),
paneControls: [
ChatBarAction(
label: 'Pane action',
onPressed: () => pane++,
materialIcon: Icons.add_box,
cupertinoIcon: CupertinoIcons.plus_square,
),
],
),
cupertino: cupertino,
for (final width in [320.0, 390.0, 1280.0]) {
testWidgets('grouped actions at $width and text scale 2', (tester) async {
_useNarrowText(tester);
tester.view.physicalSize = Size(width, 800);
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(const []);
gateway.subscribe = () async => const {};
var sidebar = 0;
var pane = 0;
var next = 0;
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: _title,
session: {
..._session,
'mode': 'safe',
'mode_name': 'Ask before making changes',
},
onBack: () {},
onNextChat: () => next++,
sidebarControl: ChatBarAction(
label: 'Sidebar action',
onPressed: () => sidebar++,
materialIcon: Icons.menu,
cupertinoIcon: CupertinoIcons.sidebar_left,
),
);
await tester.pumpAndSettle();
final selectors = find.byKey(
const Key('chat-model-permission-island'),
);
final actions = find.byKey(const Key('chat-actions-island'));
expect(selectors, findsOneWidget);
expect(actions, findsOneWidget);
expect(
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
.abs(),
lessThan(16),
);
expect(find.byKey(const Key('chat-next')), findsNothing);
expect(find.text('Next chat'), findsNothing);
expect(find.byKey(const Key('chat-model')), findsOneWidget);
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
if (width < 600) {
expect(find.text('model-a'), findsNothing);
expect(find.text('Ask before making changes'), findsNothing);
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
expect(
find.byIcon(
cupertino
? CupertinoIcons.shield_lefthalf_fill
: Icons.shield_outlined,
paneControls: [
ChatBarAction(
label: 'Pane action',
onPressed: () => pane++,
materialIcon: Icons.add_box,
cupertinoIcon: CupertinoIcons.plus_square,
),
findsOneWidget,
);
if (!cupertino) {
expect(
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
contains('Change model, currently'),
);
expect(
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
contains('Change mode, currently'),
);
}
expect(
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
.abs(),
lessThan(16),
);
}
for (final key in ['chat-model', 'chat-mode']) {
expect(
tester.getSize(find.byKey(Key(key))).width,
greaterThanOrEqualTo(cupertino ? 44 : 48),
);
}
expect(find.text('Sidebar action'), findsNothing);
expect(find.text('Pane action'), findsNothing);
expect(tester.takeException(), isNull);
// Both More entries retain their original callbacks in native menus.
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Sidebar action'));
await tester.pumpAndSettle();
expect(sidebar, 1);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Pane action'));
await tester.pumpAndSettle();
expect(pane, 1);
expect(next, 0);
expect(tester.takeException(), isNull);
},
],
),
),
);
}
await tester.pumpAndSettle();
final selectors = find.byKey(const Key('chat-model-permission-island'));
final actions = find.byKey(const Key('chat-actions-island'));
expect(selectors, findsOneWidget);
expect(actions, findsOneWidget);
expect(
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
lessThan(16),
);
expect(find.byKey(const Key('chat-next')), findsNothing);
expect(find.text('Next chat'), findsNothing);
expect(find.byKey(const Key('chat-model')), findsOneWidget);
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
if (width < 600) {
expect(find.text('model-a'), findsNothing);
expect(find.text('Ask before making changes'), findsNothing);
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
expect(find.byIcon(Icons.shield_outlined), findsOneWidget);
expect(
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
contains('Change model, currently'),
);
expect(
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
contains('Change mode, currently'),
);
expect(
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy).abs(),
lessThan(16),
);
}
for (final key in ['chat-model', 'chat-mode']) {
expect(
tester.getSize(find.byKey(Key(key))).width,
greaterThanOrEqualTo(48),
);
}
expect(find.text('Sidebar action'), findsNothing);
expect(find.text('Pane action'), findsNothing);
expect(tester.takeException(), isNull);
// Both More entries retain their original callbacks in native menus.
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Sidebar action'));
await tester.pumpAndSettle();
expect(sidebar, 1);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Pane action'));
await tester.pumpAndSettle();
expect(pane, 1);
expect(next, 0);
expect(tester.takeException(), isNull);
});
}
for (final cupertino in [false, true]) {
testWidgets(
'sidebar layout submenu retains callback on ${cupertino ? 'Cupertino' : 'Material'}',
(tester) async {
ChatSidebarMode? picked;
await tester.pumpWidget(
_host(
ChatThreadHeader(
title: 'Chat',
folder: 'demo',
onInfo: () {},
actions: const [Icon(Icons.folder_outlined)],
moreActions: [
ChatSidebarButton(
mode: ChatSidebarMode.expanded,
onChanged: (value) => picked = value,
),
],
testWidgets('sidebar layout submenu retains callback on Material', (
tester,
) async {
ChatSidebarMode? picked;
await tester.pumpWidget(
_host(
ChatThreadHeader(
title: 'Chat',
folder: 'demo',
onInfo: () {},
actions: const [Icon(Icons.folder_outlined)],
moreActions: [
ChatSidebarButton(
mode: ChatSidebarMode.expanded,
onChanged: (value) => picked = value,
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
expect(find.byType(ChatSidebarButton), findsNothing);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Chat list layout'));
await tester.pumpAndSettle();
await tester.tap(find.text('Hide chat list'));
await tester.pumpAndSettle();
expect(picked, ChatSidebarMode.hidden);
expect(tester.takeException(), isNull);
},
],
),
),
);
}
await tester.pumpAndSettle();
expect(find.byType(ChatSidebarButton), findsNothing);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Chat list layout'));
await tester.pumpAndSettle();
await tester.tap(find.text('Hide chat list'));
await tester.pumpAndSettle();
expect(picked, ChatSidebarMode.hidden);
expect(tester.takeException(), isNull);
});
testWidgets('a conversation without a model keeps the same compact row', (
tester,
@@ -364,7 +325,6 @@ void main() {
session: {..._session, 'backend': 'other'},
onBack: () {},
),
cupertino: false,
),
);
await tester.pumpAndSettle();