mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
Duo keeps conversations and Settings details open across closed, book and flat postures. Book mode splits at the fold; flattening restores the sidebar. Native rail controls, full-width navigation backdrops and sheet-local safe areas keep content aligned. Ordinary iPhones remain single-pane in portrait and landscape; tablet and Duo split layouts remain enabled. Includes the recovered preview's matching pane widths, Buzz empty-pane mark, stable Settings chevrons, Bestie pane routing and Duo-only upward New menu attachment. Current main's Activity redesign, Search content fade and unread-navigation button are retained. Menu selection checks sit beside their labels. Shared mobile changes remain in scope: the native iOS status editor, Appearance preview layout, avatar crop preservation, onboarding footer layout, profile/invite sheet geometry and nested conversation navigation. This PR is not exclusively Duo-gated. Nested navigator observers preserve recording cancellation and navigation callbacks; crop resizing preserves the selected image region. iOS 27.1 APIs remain compile-time and runtime gated. Validation on the reconciled source: Flutter analysis, Activity/Home journeys, the full mobile test suite, file-size checks and Swift package tests. The iPhone single-pane fix was also exercised on an iPhone 18 Pro simulator before reconciliation. Fresh hosted CI and physical-device confirmation of the reconciled build are separate and remain pending. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: Tom Brow <tomb@squareup.com>
429 lines
17 KiB
Dart
429 lines
17 KiB
Dart
import 'package:flutter/services.dart';
|
||
import 'package:buzz/shared/widgets/duo_toolbar.dart';
|
||
import 'package:buzz/shared/widgets/app_list_card.dart';
|
||
import 'package:buzz/shared/widgets/agent_artwork_panel.dart';
|
||
import 'package:buzz/shared/agents/remote_agents.dart';
|
||
import 'package:buzz/shared/me/me_sync.dart';
|
||
import 'package:buzz/shared/me/default_agent.dart';
|
||
import 'package:buzz/shared/theme/theme_provider.dart';
|
||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||
import 'package:buzz/features/channels/default_agent_launcher.dart';
|
||
import 'package:buzz/features/agents/agents_page.dart';
|
||
import 'package:buzz/features/agents/agent_card.dart';
|
||
import 'package:buzz/features/profile/user_profile_sheet.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter/foundation.dart';
|
||
import 'package:buzz/features/home/home_page.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
||
import 'agents_harness.dart';
|
||
import '../../helpers/remote_agents_fixture.dart';
|
||
|
||
void main() {
|
||
final existing = existingDesktopKeys.public;
|
||
|
||
testWidgets(
|
||
'Duo keeps agent directory beside profile and Back clears detail',
|
||
(tester) async {
|
||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||
tester.view.devicePixelRatio = 1;
|
||
tester.view.physicalSize = const Size(951, 669);
|
||
tester.view.padding = const FakeViewPadding(right: 76, bottom: 21);
|
||
tester.view.viewPadding = const FakeViewPadding(right: 76, bottom: 21);
|
||
addTearDown(tester.view.reset);
|
||
try {
|
||
final h = await AgentsHarness.create();
|
||
await h.open(tester, directory: [existing]);
|
||
expect(find.text('Select an agent'), findsOneWidget);
|
||
await tester.tap(find.byKey(ValueKey(existing)));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(BottomSheet), findsNothing);
|
||
final profile = find.byType(UserProfileSheet);
|
||
expect(profile, findsOneWidget);
|
||
expect(find.byType(AgentCard).hitTestable(), findsOneWidget);
|
||
expect(tester.getRect(profile).left, closeTo(376, .01));
|
||
expect(tester.getRect(profile).right, 951);
|
||
final artwork = find.descendant(
|
||
of: profile,
|
||
matching: find.byType(AgentArtworkPanel),
|
||
);
|
||
expect(tester.getRect(artwork).right, 951);
|
||
for (final card
|
||
in find
|
||
.descendant(of: profile, matching: find.byType(AppListCard))
|
||
.evaluate()) {
|
||
expect(
|
||
tester.getRect(find.byWidget(card.widget)).right,
|
||
lessThanOrEqualTo(875),
|
||
);
|
||
}
|
||
expect(
|
||
tester
|
||
.getSize(
|
||
find
|
||
.descendant(
|
||
of: profile,
|
||
matching: find.byType(SingleChildScrollView),
|
||
)
|
||
.first,
|
||
)
|
||
.height,
|
||
greaterThan(500),
|
||
);
|
||
expect(find.byKey(const ValueKey('duo-toolbar-Back')), findsOneWidget);
|
||
final profileElement = tester.element(profile);
|
||
tester.view.physicalSize = const Size(669, 951);
|
||
tester.view.padding = const FakeViewPadding(top: 82, bottom: 34);
|
||
tester.view.viewPadding = const FakeViewPadding(top: 82, bottom: 34);
|
||
await tester.pumpAndSettle();
|
||
expect(profile, findsOneWidget);
|
||
expect(tester.element(profile), same(profileElement));
|
||
expect(find.byType(AgentCard).hitTestable(), findsNothing);
|
||
tester.view.physicalSize = const Size(951, 669);
|
||
tester.view.padding = const FakeViewPadding(right: 76, bottom: 21);
|
||
tester.view.viewPadding = const FakeViewPadding(right: 76, bottom: 21);
|
||
await tester.pumpAndSettle();
|
||
expect(tester.element(profile), same(profileElement));
|
||
expect(find.byType(AgentCard).hitTestable(), findsOneWidget);
|
||
|
||
tester.view.padding = const FakeViewPadding(left: 76, bottom: 21);
|
||
tester.view.viewPadding = const FakeViewPadding(left: 76, bottom: 21);
|
||
await tester.pumpAndSettle();
|
||
expect(tester.getRect(profile).left, closeTo(452, .01));
|
||
expect(tester.getRect(artwork).right, 951);
|
||
expect(tester.element(profile), same(profileElement));
|
||
|
||
Navigator.of(tester.element(profile)).pop();
|
||
await tester.pumpAndSettle();
|
||
expect(profile, findsNothing);
|
||
expect(find.text('Select an agent'), findsOneWidget);
|
||
expect(find.byType(AgentCard).hitTestable(), findsOneWidget);
|
||
tester.view.physicalSize = const Size(466, 678);
|
||
tester.view.padding = const FakeViewPadding(right: 76, bottom: 21);
|
||
tester.view.viewPadding = const FakeViewPadding(right: 76, bottom: 21);
|
||
await tester.pumpAndSettle();
|
||
await tester.tap(find.byKey(ValueKey(existing)));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(BottomSheet), findsOneWidget);
|
||
final sheetArtwork = find.descendant(
|
||
of: find.byType(UserProfileSheet),
|
||
matching: find.byType(AgentArtworkPanel),
|
||
);
|
||
expect(tester.getRect(sheetArtwork).left, 0);
|
||
expect(tester.getRect(sheetArtwork).right, 466);
|
||
expect(
|
||
find.byKey(const ValueKey('duo-toolbar-Close agents')),
|
||
findsNothing,
|
||
);
|
||
expect(
|
||
find.byKey(const ValueKey('duo-toolbar-Close sheet')),
|
||
findsOneWidget,
|
||
);
|
||
expect(
|
||
find.byKey(const ValueKey('buzz-sheet-ios-glass-close')),
|
||
findsNothing,
|
||
);
|
||
final sheetPortal = tester
|
||
.widgetList<DuoToolbarPortal>(find.byType(DuoToolbarPortal))
|
||
.singleWhere(
|
||
(portal) => portal.actions.any((a) => a.label == 'Close sheet'),
|
||
);
|
||
sheetPortal.actions.single.onPressed!();
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(UserProfileSheet), findsNothing);
|
||
expect(
|
||
find.byKey(const ValueKey('duo-toolbar-Close agents')),
|
||
findsOneWidget,
|
||
);
|
||
expect(tester.takeException(), isNull);
|
||
} finally {
|
||
debugDefaultTargetPlatformOverride = null;
|
||
}
|
||
},
|
||
);
|
||
|
||
testWidgets('agent profile sheet closes back to the full-page directory', (
|
||
tester,
|
||
) async {
|
||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||
const MethodChannel('dev.fluttercommunity.plus/connectivity_status'),
|
||
(_) async => null,
|
||
);
|
||
addTearDown(
|
||
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||
const MethodChannel('dev.fluttercommunity.plus/connectivity_status'),
|
||
null,
|
||
),
|
||
);
|
||
tester.view.physicalSize = const Size(390, 844);
|
||
tester.view.devicePixelRatio = 1;
|
||
addTearDown(tester.view.resetPhysicalSize);
|
||
addTearDown(tester.view.resetDevicePixelRatio);
|
||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||
final h = await AgentsHarness.create();
|
||
final prefs = await SharedPreferences.getInstance();
|
||
await h.open(
|
||
tester,
|
||
directory: [existing, otherAgentKeys.public],
|
||
overrides: [savedPrefsProvider.overrideWithValue(prefs)],
|
||
);
|
||
expect(find.byKey(ValueKey(otherAgentKeys.public)), findsNothing);
|
||
expect(find.byKey(ValueKey(oldAppAgentKeys.public)), findsNothing);
|
||
if (!supportsRemoteAgents(h.community)) {
|
||
expect(find.text('Sign in to create an agent'), findsNothing);
|
||
for (final button in tester.widgetList<IconButton>(
|
||
find.byWidgetPredicate(
|
||
(widget) => widget is IconButton && widget.tooltip == 'Add agent',
|
||
),
|
||
)) {
|
||
expect(button.onPressed, isNull);
|
||
}
|
||
}
|
||
await h.controller.run(() async {
|
||
throw StateError('Resume unfinished setup');
|
||
});
|
||
await tester.pumpAndSettle();
|
||
expect(find.textContaining('Resume unfinished setup'), findsNothing);
|
||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||
final list = tester.element(find.byType(AgentsPage));
|
||
final container = ProviderScope.containerOf(list);
|
||
expect(find.text('Set as default'), findsNothing);
|
||
expect(find.text('Model not shared'), findsNothing);
|
||
expect(find.byIcon(Icons.star), findsNothing);
|
||
expect(find.text('Manage on desktop'), findsOneWidget);
|
||
expect(find.byIcon(Icons.keyboard_arrow_down), findsNothing);
|
||
|
||
await tester.tap(find.byKey(ValueKey(existing)));
|
||
await tester.pump();
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(BottomSheet), findsOneWidget);
|
||
expect(find.byType(UserProfileSheet), findsOneWidget);
|
||
expect(find.text('Model not shared'), findsNothing);
|
||
expect(list.mounted, isTrue);
|
||
expect(find.text('Identity'), findsNothing);
|
||
expect(find.text('Settings'), findsNothing);
|
||
expect(
|
||
find.descendant(
|
||
of: find.byType(UserProfileSheet),
|
||
matching: find.text('Manage on desktop'),
|
||
),
|
||
findsNothing,
|
||
);
|
||
expect(
|
||
find.descendant(
|
||
of: find.byType(UserProfileSheet),
|
||
matching: find.text('Unknown'),
|
||
),
|
||
findsNothing,
|
||
);
|
||
expect(find.text('Instructions'), findsOneWidget);
|
||
expect(find.text('Management'), findsOneWidget);
|
||
expect(
|
||
find.textContaining('Keep Buzz open and your desktop online'),
|
||
findsOneWidget,
|
||
);
|
||
expect(
|
||
find.textContaining('Instructions aren’t available'),
|
||
findsOneWidget,
|
||
);
|
||
await tester.pumpAndSettle();
|
||
expect(find.byTooltip('Copy public key'), findsOneWidget);
|
||
final semantics = tester.ensureSemantics();
|
||
final platformCalls = <MethodCall>[];
|
||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||
SystemChannels.platform,
|
||
(call) async {
|
||
platformCalls.add(call);
|
||
return null;
|
||
},
|
||
);
|
||
addTearDown(
|
||
() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||
SystemChannels.platform,
|
||
null,
|
||
),
|
||
);
|
||
final keyRow = find.byTooltip('Copy public key');
|
||
await tester.ensureVisible(keyRow);
|
||
await tester.tapAt(tester.getTopLeft(keyRow) + const Offset(8, 8));
|
||
await tester.pumpAndSettle();
|
||
expect(
|
||
platformCalls.where((call) => call.method == 'Clipboard.setData'),
|
||
hasLength(1),
|
||
);
|
||
expect(
|
||
platformCalls.where((call) => call.method == 'HapticFeedback.vibrate'),
|
||
hasLength(1),
|
||
);
|
||
expect(find.bySemanticsLabel('Copied public key'), findsOneWidget);
|
||
semantics.dispose();
|
||
|
||
await tester.pumpAndSettle();
|
||
expect(find.byTooltip('Delete agent'), findsNothing);
|
||
// Reopen through the real reader, recover a failed network query, then
|
||
// verify the registered instruction text appears rather than profile bio.
|
||
await tester.tap(find.byTooltip('Close sheet'));
|
||
await tester.pumpAndSettle();
|
||
h.onQuery = (_) async => throw StateError('Offline');
|
||
await tester.tap(find.byKey(ValueKey(existing)));
|
||
await tester.pumpAndSettle();
|
||
expect(find.text('Could not load instructions.'), findsOneWidget);
|
||
h.onQuery = (_) async => [];
|
||
h.authorityDown = true;
|
||
await tester.ensureVisible(find.text('Retry'));
|
||
await tester.tap(find.text('Retry'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.text('Could not load instructions.'), findsOneWidget);
|
||
h.authorityDown = false;
|
||
await tester.ensureVisible(find.text('Retry'));
|
||
await tester.tap(find.text('Retry'));
|
||
await tester.pumpAndSettle();
|
||
expect(
|
||
find.textContaining('Instructions aren’t available'),
|
||
findsOneWidget,
|
||
);
|
||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||
await tester.pumpAndSettle();
|
||
await tester.pumpAndSettle();
|
||
await tester.ensureVisible(find.byTooltip('Copy public key'));
|
||
expect(tester.takeException(), isNull);
|
||
tester.platformDispatcher.clearTextScaleFactorTestValue();
|
||
await tester.pumpAndSettle();
|
||
await tester.pumpAndSettle();
|
||
h.relay.loseAcknowledgment = true;
|
||
await tester.ensureVisible(find.text('Make Bestie'));
|
||
await tester.tap(find.text('Make Bestie'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.textContaining('Could not save Bestie.'), findsOneWidget);
|
||
h.relay.loseAcknowledgment = false;
|
||
h.relay.events = []; // The unacknowledged write was not retained.
|
||
await tester.ensureVisible(find.text('Make Bestie'));
|
||
await tester.tap(find.text('Make Bestie'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.text('Your Bestie'), findsOneWidget);
|
||
final savedSync = container.read(meSyncProvider);
|
||
expect(decodeDefaultAgent(h.relay.events.single, savedSync), existing);
|
||
expect(
|
||
savedSync.prefs!.containsKey(
|
||
'main-agent:${savedSync.community}:${savedSync.pubkey}',
|
||
),
|
||
isTrue,
|
||
);
|
||
|
||
await tester.tap(find.byTooltip('Close sheet'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(UserProfileSheet), findsNothing);
|
||
expect(find.byKey(ValueKey(existing)), findsOneWidget);
|
||
expect(tester.element(find.byType(AgentsPage)), same(list));
|
||
expect(
|
||
tester.widget<AgentCard>(find.byKey(ValueKey(existing))).isBestie,
|
||
isTrue,
|
||
);
|
||
expect(
|
||
find.descendant(
|
||
of: find.byKey(ValueKey(existing)),
|
||
matching: find.byIcon(Icons.star),
|
||
),
|
||
findsOneWidget,
|
||
);
|
||
if (supportsRemoteAgents(h.community)) {
|
||
h.registry.listed = [
|
||
{
|
||
'agent_pubkey': fakeAgent,
|
||
'agent_id': 'remote-id',
|
||
'agent_name': 'Scout',
|
||
'agent_instructions': 'Review carefully.',
|
||
},
|
||
];
|
||
await h.controller.run(h.controller.refresh);
|
||
await tester.pumpAndSettle();
|
||
await tester.tap(find.byKey(ValueKey(fakeAgent)));
|
||
await tester.pumpAndSettle();
|
||
expect(
|
||
find.textContaining('This agent runs on Builderbot.'),
|
||
findsOneWidget,
|
||
);
|
||
// Remote instructions come from the registry row, not published config.
|
||
expect(h.registry.bodies['/v3/beekeeper/list-agents'], {
|
||
'include_instructions': true,
|
||
});
|
||
expect(find.text('Review carefully.'), findsOneWidget);
|
||
expect(
|
||
find.textContaining('Instructions aren’t available'),
|
||
findsNothing,
|
||
);
|
||
await tester.pumpAndSettle();
|
||
await tester.ensureVisible(find.text('Delete agent'));
|
||
expect(
|
||
tester.getTopLeft(find.text('Delete agent')).dy,
|
||
greaterThan(tester.getTopLeft(find.text('Public key')).dy),
|
||
);
|
||
final deleteCard = find.ancestor(
|
||
of: find.text('Delete agent'),
|
||
matching: find.byType(AppListCard),
|
||
);
|
||
expect(deleteCard, findsOneWidget);
|
||
expect(
|
||
find.descendant(of: deleteCard, matching: find.text('Public key')),
|
||
findsNothing,
|
||
);
|
||
await tester.tap(find.text('Delete agent'));
|
||
await tester.pumpAndSettle();
|
||
await tester.tap(find.text('Cancel'));
|
||
await tester.pumpAndSettle();
|
||
await tester.pumpAndSettle();
|
||
h.relay.events = [];
|
||
await tester.ensureVisible(find.text('Make Bestie'));
|
||
await tester.tap(find.text('Make Bestie'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.text('Your Bestie'), findsOneWidget);
|
||
expect(decodeDefaultAgent(h.relay.events.single, savedSync), fakeAgent);
|
||
await tester.tap(find.byTooltip('Close sheet'));
|
||
await tester.pumpAndSettle();
|
||
expect(
|
||
tester.widget<AgentCard>(find.byKey(ValueKey(existing))).isBestie,
|
||
isFalse,
|
||
);
|
||
expect(
|
||
tester.widget<AgentCard>(find.byKey(ValueKey(fakeAgent))).isBestie,
|
||
isTrue,
|
||
);
|
||
}
|
||
ScaffoldMessenger.of(list).clearSnackBars();
|
||
await tester.tap(find.byTooltip('Close agents'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(BottomSheet), findsNothing);
|
||
h.relay.events = [];
|
||
final sync = container.read(meSyncProvider);
|
||
await sync.prefs!.remove('main-agent:${sync.community}:${sync.pubkey}');
|
||
await h.open(
|
||
tester,
|
||
directory: [existing],
|
||
overrides: [savedPrefsProvider.overrideWithValue(prefs)],
|
||
home: HomePage(
|
||
onAgents: showAgents,
|
||
openBestieConversation: (_, _, _) async {},
|
||
defaultAgentBuilder: (context) => DefaultAgentLauncher(
|
||
onChooseAgent: () => showAgents(context, createOnOpen: true),
|
||
),
|
||
settingsPageBuilder: (_) => const SizedBox.shrink(),
|
||
mePageBuilder: (_, _, _) =>
|
||
const SliverToBoxAdapter(child: Text('Solo workspace')),
|
||
),
|
||
);
|
||
await tester.tap(find.byTooltip('Bestie'));
|
||
await tester.pumpAndSettle();
|
||
await tester.tap(find.byKey(ValueKey(existing)));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(UserProfileSheet), findsOneWidget);
|
||
expect(find.text('Model not shared'), findsNothing);
|
||
await tester.binding.handlePopRoute();
|
||
await tester.pumpAndSettle();
|
||
expect(find.byType(UserProfileSheet), findsNothing);
|
||
await tester.tap(find.byTooltip('Close agents'));
|
||
await tester.pumpAndSettle();
|
||
expect(find.byTooltip('Search'), findsOneWidget);
|
||
});
|
||
}
|