mirror of
https://github.com/block/buzz.git
synced 2026-11-03 16:01:35 +00:00
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 | | --- | --- | |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
131 lines
5.2 KiB
Dart
131 lines
5.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import '../../shared/agents/remote_agents.dart';
|
|
import '../../shared/community/community.dart';
|
|
import 'agent_model_menu.dart';
|
|
|
|
// Share one request/result while controls are mounted. Account transitions
|
|
// discard the old catalog; save-time validation still fetches a fresh catalog.
|
|
final _modelCatalogProvider = FutureProvider.autoDispose
|
|
.family<List<RemoteAgentModel>, RemoteAgentController>((ref, controller) {
|
|
final subject = controller.account.subjectChanges;
|
|
void changed() => ref.invalidateSelf();
|
|
subject.addListener(changed);
|
|
ref.onDispose(() => subject.removeListener(changed));
|
|
return controller.modelCatalog();
|
|
}, retry: (_, _) => null);
|
|
|
|
/// An authenticated model menu with explicit reasoning effort confirmation.
|
|
class RemoteAgentModelControl extends HookConsumerWidget {
|
|
const RemoteAgentModelControl({
|
|
required this.controller,
|
|
required this.agent,
|
|
required this.community,
|
|
required this.isCurrent,
|
|
super.key,
|
|
});
|
|
final RemoteAgentController controller;
|
|
final Map<String, dynamic> agent;
|
|
final Community community;
|
|
final bool Function() isCurrent;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
useListenable(controller);
|
|
final subject = controller.account.account?.subject;
|
|
final provider = _modelCatalogProvider(controller);
|
|
final catalog = ref.watch(provider);
|
|
if (catalog.isLoading) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
if (catalog.hasError) {
|
|
return TextButton(
|
|
onPressed: () => ref.invalidate(provider),
|
|
child: const Text('Retry models'),
|
|
);
|
|
}
|
|
final models = catalog.asData?.value;
|
|
if (models == null) return const Center(child: CircularProgressIndicator());
|
|
if (models.isEmpty) return const Center(child: Text('No models available'));
|
|
final selected = models
|
|
.where((model) => model.id == agent['model_id'])
|
|
.firstOrNull;
|
|
return AgentModelMenu(
|
|
label: selected?.name ?? (agent['model_id'] as String?) ?? 'Choose model',
|
|
actions: [
|
|
for (final model in models)
|
|
(
|
|
label: model.name,
|
|
symbol: model.id == selected?.id ? 'checkmark' : '',
|
|
onPressed: controller.busy
|
|
? null
|
|
: () async {
|
|
String? effort =
|
|
model.efforts.contains(agent['reasoning_effort'])
|
|
? agent['reasoning_effort'] as String
|
|
: null;
|
|
final choice = await showDialog<String>(
|
|
context: context,
|
|
builder: (context) => StatefulBuilder(
|
|
builder: (context, setState) => AlertDialog(
|
|
title: Text(model.name),
|
|
content: DropdownButtonFormField<String>(
|
|
initialValue: effort,
|
|
isExpanded: true,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Reasoning effort',
|
|
),
|
|
items: [
|
|
for (final value in model.efforts)
|
|
DropdownMenuItem(
|
|
value: value,
|
|
child: Text(value),
|
|
),
|
|
],
|
|
onChanged: (value) =>
|
|
setState(() => effort = value),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Cancel'),
|
|
),
|
|
TextButton(
|
|
onPressed: effort == null
|
|
? null
|
|
: () => Navigator.pop(context, effort),
|
|
child: const Text('Save'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
if (choice == null || !context.mounted) return;
|
|
final saved = await controller.updateModel(
|
|
community: community,
|
|
pubkey: agent['agent_pubkey'] as String,
|
|
model: model,
|
|
effort: choice,
|
|
isCurrent: () =>
|
|
context.mounted &&
|
|
controller.account.account?.subject == subject &&
|
|
isCurrent(),
|
|
);
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
saved ? 'Model updated' : controller.failure,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|