Files
buzz/mobile/test/features/agents/agents_sheet_test.dart
klopez4212 0cde1fe2f4 Make mobile Agents a full-page owned-agent directory (#8693)
Replace the mobile Agents sheet with a full-page directory of verified
owned agents. Add dedicated creation and avatar pages with
catalog-backed model selection, reuse the profile emoji/photo/camera
controls, and expose Builderbot model settings while labeling desktop
agents “Manage on desktop.” Share one account-scoped model catalog
across editable cards and retries. Choose Bestie from the agent profile
using the shared encrypted main-agent record (text-only action, filled
star once selected), and move confirmed deletion to a top-left trash
control with native iOS glass. Include uploaded avatars in owner
registrations so desktop can display them.

Validation: mobile analysis and all 3,958 hosted-enabled app tests
passed; default-build tests run by the push hook. Earlier iPhone build
installed and iterated with the user; the current iOS build succeeds,
but final changes still need a device pass. Independent review found no
new blockers. Actual camera capture and live Bestie sync remain
unconfirmed; the existing shared `main-agent` wire format and Bestie
terminology are retained.

### Snapshots

Widget-harness captures with test data (not native iOS chrome).

| Agents directory | Image avatar editor |
| --- | --- |
| ![Agents
directory](https://github.com/user-attachments/assets/c68a0505-90a5-41db-980f-e3197cac63ac)
| ![Image avatar
editor](https://github.com/user-attachments/assets/9b126186-1e7c-4169-9a74-8f7f252cfa93)
|

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-10-29 18:30:17 +00:00

150 lines
6.0 KiB
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: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/profile/user_profile_sheet.dart';
import 'package:flutter/material.dart';
import 'package:buzz/features/home/home_page.dart';
import 'package:flutter_test/flutter_test.dart';
import 'agents_harness.dart';
import '../../helpers/remote_agents_fixture.dart';
void main() {
final existing = existingDesktopKeys.public;
testWidgets('agent profile sheet closes back to the full-page directory', (
tester,
) async {
final h = await AgentsHarness.create();
await h.open(
tester,
directory: [existing, otherAgentKeys.public],
botDirectory: ['b' * 64],
);
expect(find.byKey(ValueKey(otherAgentKeys.public)), findsNothing);
expect(find.byKey(ValueKey('b' * 64)), 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.byTooltip('Delete agent'), findsNothing);
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));
if (supportsRemoteAgents(h.community)) {
h.registry.listed = [
{
'agent_pubkey': fakeAgent,
'agent_id': 'remote-id',
'agent_name': 'Scout',
},
];
await h.controller.run(h.controller.refresh);
await tester.pumpAndSettle();
await tester.tap(find.byKey(ValueKey(fakeAgent)));
await tester.pumpAndSettle();
expect(find.byTooltip('Delete agent'), findsOneWidget);
expect(
tester.getCenter(find.byTooltip('Delete agent')).dx,
lessThan(tester.getCenter(find.byTooltip('Close sheet')).dx),
);
await tester.tap(find.byTooltip('Delete agent'));
await tester.pumpAndSettle();
await tester.tap(find.text('Cancel'));
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();
}
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],
home: HomePage(
onAgents: showAgents,
defaultAgentBuilder: (context) =>
DefaultAgentLauncher(onChooseAgent: () => showAgents(context)),
hasUnreadInbox: false,
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);
});
}