mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 06:24:20 +01:00
This commit refines the `populateSelectedNodeHierarchy` method in the `SkillTreeViewModel` to accurately represent nodes that possess multiple parent nodes, ensuring a comprehensive and non-redundant representation of the entire hierarchy leading back to the root nodes. Modifications and Features: - The method now employs recursion to traverse all possible paths back to the root nodes from a selected node, capturing every unique node in the hierarchies. - A `Set` is utilized to monitor and ensure that each node is only added once to the `_selectedNodeHierarchy` list, eliminating the possibility of duplicates. - The finalized `_selectedNodeHierarchy` list is constructed such that the root of the tree is the last item in the list, providing a more logical representation of the hierarchy. These enhancements ensure a more accurate and efficient representation of the skill tree structure, particularly in scenarios where nodes have multiple parents, facilitating better navigation and interaction within the skill tree.
150 lines
5.7 KiB
Dart
150 lines
5.7 KiB
Dart
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
// TODO: Add view model for task queue instead of skill tree view model
|
|
class TaskQueueView extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final viewModel = Provider.of<SkillTreeViewModel>(context);
|
|
|
|
// Node hierarchy
|
|
final nodeHierarchy = viewModel.selectedNodeHierarchy ?? [];
|
|
|
|
return Material(
|
|
color: Colors.white,
|
|
child: Stack(
|
|
children: [
|
|
// The list of tasks (tiles)
|
|
ListView.builder(
|
|
itemCount: nodeHierarchy.length,
|
|
itemBuilder: (context, index) {
|
|
final node = nodeHierarchy[index];
|
|
|
|
// Choose the appropriate leading widget based on the task status
|
|
Widget leadingWidget;
|
|
switch (viewModel.benchmarkStatusMap[node]) {
|
|
case null:
|
|
case BenchmarkTaskStatus.notStarted:
|
|
leadingWidget = CircleAvatar(
|
|
radius: 12,
|
|
backgroundColor: Colors.grey,
|
|
child: CircleAvatar(
|
|
radius: 6,
|
|
backgroundColor: Colors.white,
|
|
),
|
|
);
|
|
break;
|
|
case BenchmarkTaskStatus.inProgress:
|
|
leadingWidget = SizedBox(
|
|
width: 24,
|
|
height: 24,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
),
|
|
);
|
|
break;
|
|
case BenchmarkTaskStatus.success:
|
|
leadingWidget = CircleAvatar(
|
|
radius: 12,
|
|
backgroundColor: Colors.green,
|
|
child: CircleAvatar(
|
|
radius: 6,
|
|
backgroundColor: Colors.white,
|
|
),
|
|
);
|
|
break;
|
|
case BenchmarkTaskStatus.failure:
|
|
leadingWidget = CircleAvatar(
|
|
radius: 12,
|
|
backgroundColor: Colors.red,
|
|
child: CircleAvatar(
|
|
radius: 6,
|
|
backgroundColor: Colors.white,
|
|
),
|
|
);
|
|
break;
|
|
}
|
|
|
|
return Container(
|
|
margin: EdgeInsets.fromLTRB(20, 5, 20, 5),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border.all(color: Colors.black, width: 1),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: ListTile(
|
|
leading: leadingWidget,
|
|
title: Center(child: Text('${node.label}')),
|
|
subtitle:
|
|
Center(child: Text('${node.data.info.description}')),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
|
|
Positioned(
|
|
bottom: 20,
|
|
left: 20,
|
|
right: 20,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
border: Border.all(color: Colors.green, width: 3),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: viewModel.isBenchmarkRunning
|
|
? null
|
|
: () {
|
|
// TODO: We should not be passing this dependency in like this
|
|
final chatViewModel =
|
|
Provider.of<ChatViewModel>(context, listen: false);
|
|
final taskViewModel =
|
|
Provider.of<TaskViewModel>(context, listen: false);
|
|
chatViewModel.clearCurrentTaskAndChats();
|
|
// Call runBenchmark method from SkillTreeViewModel
|
|
viewModel.runBenchmark(chatViewModel, taskViewModel);
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.center, // Center the children
|
|
children: [
|
|
Text(
|
|
'Initiate test suite',
|
|
style: TextStyle(
|
|
color: Colors.green, // Text color is set to green
|
|
fontWeight: FontWeight.bold, // Make text bold
|
|
fontSize: 16, // Increase font size
|
|
),
|
|
),
|
|
SizedBox(width: 10), // Gap of 10 between text and icon
|
|
Icon(
|
|
Icons.play_arrow,
|
|
color: Colors.green, // Icon color is set to green
|
|
size: 24, // Increase icon size
|
|
),
|
|
],
|
|
),
|
|
style: ButtonStyle(
|
|
backgroundColor: MaterialStateProperty.all(Colors.white),
|
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
),
|
|
),
|
|
minimumSize: MaterialStateProperty.all(
|
|
Size(double.infinity, 50)), // Full width
|
|
padding: MaterialStateProperty.all(EdgeInsets.all(0)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|