Files
buzz/mobile/lib/shared/me/me_groups.dart
klopez4212 634f48a8bd Mobile: open Solo chats with Bestie and workspace controls (#8884)
Mobile New chat now opens directly with the synced Bestie selected. The
first send creates and names the chat; leaving an empty draft creates
nothing. New and existing Solo chats can select or clear a workspace
from the header popover, with a checkmark for the active choice and a No
Workspace option. Workspace and agent controls have separate iOS glass
surfaces, Bestie stays at the far right, and Back uses a chevron. The
agent sheet fits its list, with scrolling for long lists. Workspace
creation stays in the Home New menu.

The New menu groups Solo above Team. Android expands across the full
control row; iOS keeps its native menu while Search and Bestie merge
into New through Liquid Glass, with synchronized icon motion and the
residual glass fading away. Empty workspaces use a compact, muted
message.

Validation: 4,055 mobile tests passed (34 skipped), static analysis
passed, and native menu checks passed. Earlier physical-device previews
and the iPhone New-menu animation were visually approved before this
consolidation.

This PR consolidates the controls previously developed in #8891 into the
existing draft/first-send implementation. The New menu animations,
attachment handling, and durable retries remain in this PR. The combined
controls have widget interaction coverage; the combined build has not
yet had a new physical-device walkthrough.

Current combined controls below are Android Flutter widget renders with
fixture data, not device screenshots. Images are GitHub attachments
only.

| New conversation | Workspace popover | Compact agent sheet |
| --- | --- | --- |
| ![New chat
composer](https://github.com/user-attachments/assets/f9ea2a16-342e-4cea-a436-0777ff5e37aa)
| ![Checked workspace
popover](https://github.com/user-attachments/assets/80eb7a71-e424-4188-86d7-eb6292b148bf)
| ![Content-sized agent
sheet](https://github.com/user-attachments/assets/be608383-0188-4339-b56b-924085137452)
|

Empty workspace widget preview (unchanged):

![Compact empty workspace
message](https://github.com/user-attachments/assets/387c0729-dea3-4250-bb54-afc4e61b54a7)

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-01 21:40:30 +00:00

106 lines
3.5 KiB
Dart

import 'dart:convert';
import 'package:characters/characters.dart';
/// Desktop-compatible personal project and chat placement record.
class MeGroups {
static const tag = 'buzz-me-kit-v1';
final List<Map<String, dynamic>> groups;
final Map<String, String> assignments;
final List<String> channels;
const MeGroups({
this.groups = const [],
this.assignments = const {},
this.channels = const [],
});
static String coordinate(String community) =>
'$tag:${Uri.encodeComponent(community)}:groups:me';
factory MeGroups.decode(String plaintext, String community) {
if (utf8.encode(plaintext).length > 16384) {
throw const FormatException('Solo storage is full');
}
final raw = jsonDecode(plaintext) as Map<String, dynamic>;
final value = raw['value'] as Map<String, dynamic>;
if (raw['version'] != 1 ||
raw['community'] != community ||
raw['deleted'] is! bool ||
value['type'] != 'groups' ||
value['id'] != 'me') {
throw const FormatException('Unsupported Solo record');
}
final groups = (value['groups'] as List)
.map((g) => Map<String, dynamic>.from(g as Map))
.toList();
final assignments = Map<String, String>.from(value['assignments'] as Map);
final channels = List<String>.from(value['channels'] as List? ?? []);
final identifier = RegExp(r'^[a-zA-Z0-9_-]{1,128}$');
final channelId = RegExp(
r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$',
);
final ids = groups.map((g) => g['id']).toSet();
if (groups.length > 100 ||
ids.length != groups.length ||
groups.any(
(g) =>
g['id'] is! String ||
!identifier.hasMatch(g['id'] as String) ||
g['name'] is! String ||
(g['name'] as String).trim().isEmpty ||
(g['name'] as String).characters.length > 120 ||
g['defaultTemplateId'] is! String ||
(g['defaultTemplateId'] != '' &&
!identifier.hasMatch(g['defaultTemplateId'] as String)),
) ||
assignments.length > 1000 ||
assignments.entries.any(
(e) => !channelId.hasMatch(e.key) || !ids.contains(e.value),
) ||
channels.length > 1000 ||
channels.toSet().length != channels.length ||
channels.any((id) => !channelId.hasMatch(id))) {
throw const FormatException('Invalid Solo projects');
}
if (raw['deleted'] == true) return const MeGroups();
return MeGroups(
groups: groups,
assignments: assignments,
channels: channels,
);
}
String encode(String community) {
final result = jsonEncode({
'version': 1,
'community': community,
'deleted': false,
'value': {
'type': 'groups',
'id': 'me',
'groups': groups,
'assignments': assignments,
'channels': channels,
},
});
MeGroups.decode(result, community);
return result;
}
MeGroups place(String channel, {String? group, bool clearGroup = false}) {
if (group != null && !groups.any((g) => g['id'] == group)) {
throw StateError('This project changed. Refresh and try again.');
}
return MeGroups(
groups: groups,
assignments: {
for (final entry in assignments.entries)
if (!clearGroup || entry.key != channel) entry.key: entry.value,
channel: ?group,
},
channels: [...channels, if (!channels.contains(channel)) channel],
);
}
}