Skip to content

Agent Mesh

Fix Dart isolate crash, avoid ANR, and add custom banana icon

Antonio Ojeab699a09291c5
diff --git a/mobile/sam-node-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/mobile/sam-node-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
index db77bb4b..a273a6e9 100644
Binary files a/mobile/sam-node-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/mobile/sam-node-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/mobile/sam-node-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/mobile/sam-node-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 17987b79..fb7f97f4 100644
Binary files a/mobile/sam-node-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/mobile/sam-node-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/mobile/sam-node-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/mobile/sam-node-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 09d43914..87d12e83 100644
Binary files a/mobile/sam-node-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/mobile/sam-node-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/mobile/sam-node-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/mobile/sam-node-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index d5f1c8d3..0c5144fd 100644
Binary files a/mobile/sam-node-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/mobile/sam-node-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/mobile/sam-node-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/mobile/sam-node-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index 4d6372ee..5d928c6b 100644
Binary files a/mobile/sam-node-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/mobile/sam-node-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/mobile/sam-node-app/lib/main.dart b/mobile/sam-node-app/lib/main.dart
index fde679a7..efda34a7 100644
--- a/mobile/sam-node-app/lib/main.dart
+++ b/mobile/sam-node-app/lib/main.dart
@@ -17,6 +17,22 @@ import 'package:url_launcher/url_launcher.dart';
import 'sam_ffi.dart';
import 'mcp_server.dart';
+String? _isolatedFetchHubInfo(String url) {
+ try {
+ return SamNodeLib().fetchHubInfoJSON(url);
+ } catch (e) {
+ return '{"error": "FFI_ERROR: ${e.toString()}"}';
+ }
+}
+
+String? _isolatedEnroll(Map<String, dynamic> args) {
+ try {
+ return SamNodeLib().enroll(args['dataDir'], args['hubText'], args['jwtText'], args['allowLoopback']);
+ } catch (e) {
+ return e.toString();
+ }
+}
+
void main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
@@ -144,7 +160,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
try {
final hubUrl = _hubController.text.trim();
debugPrint('DEBUG: Fetching hub info from $hubUrl');
- final infoJson = await Isolate.run(() => SamNodeLib().fetchHubInfoJSON(hubUrl));
+ final infoJson = await Isolate.run(() => _isolatedFetchHubInfo(hubUrl));
debugPrint('DEBUG: Hub info JSON: $infoJson');
if (infoJson == null) {
throw Exception('Failed to fetch hub info');
@@ -347,7 +363,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
try {
final hubUrl = _hubController.text.trim();
debugPrint('DEBUG: Device Login: Fetching hub info from $hubUrl');
- final infoJson = await Isolate.run(() => SamNodeLib().fetchHubInfoJSON(hubUrl));
+ final infoJson = await Isolate.run(() => _isolatedFetchHubInfo(hubUrl));
if (infoJson == null) throw Exception('Failed to fetch hub info');
final info = jsonDecode(infoJson);
@@ -559,12 +575,12 @@ class _NodeControlPageState extends State<NodeControlPage> {
final hubText = _hubController.text;
final jwtText = _jwtController.text;
final err = await Isolate.run(() {
- return SamNodeLib().enroll(
- dataDir,
- hubText,
- jwtText,
- true, // allowLoopback
- );
+ return _isolatedEnroll({
+ 'dataDir': dataDir,
+ 'hubText': hubText,
+ 'jwtText': jwtText,
+ 'allowLoopback': true,
+ });
});
setState(() {