mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
Implement UI Disable Feature During Benchmark Run
Added a state variable isBenchmarkRunning in SkillTreeViewModel to track the status of benchmark execution. This state variable is used to conditionally disable specific UI components: - The "Initiate test suite" button in TaskQueueView is disabled during the benchmark. - All IconButtons in SideBarView are disabled during the benchmark. - Node selection in SkillTreeView is disabled during the benchmark. This ensures that the user cannot interact with these components while a benchmark test is running, thereby improving UX and preventing potential issues.
This commit is contained in:
@@ -9,11 +9,15 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
|
|
||||||
class SkillTreeViewModel extends ChangeNotifier {
|
class SkillTreeViewModel extends ChangeNotifier {
|
||||||
|
// TODO: Potentially move to task queue view model when we create one
|
||||||
final BenchmarkService benchmarkService;
|
final BenchmarkService benchmarkService;
|
||||||
|
// TODO: Potentially move to task queue view model when we create one
|
||||||
|
bool isBenchmarkRunning = false;
|
||||||
|
|
||||||
List<SkillTreeNode> _skillTreeNodes = [];
|
List<SkillTreeNode> _skillTreeNodes = [];
|
||||||
List<SkillTreeEdge> _skillTreeEdges = [];
|
List<SkillTreeEdge> _skillTreeEdges = [];
|
||||||
SkillTreeNode? _selectedNode;
|
SkillTreeNode? _selectedNode;
|
||||||
|
// TODO: Potentially move to task queue view model when we create one
|
||||||
List<SkillTreeNode>? _selectedNodeHierarchy;
|
List<SkillTreeNode>? _selectedNodeHierarchy;
|
||||||
|
|
||||||
SkillTreeNode? get selectedNode => _selectedNode;
|
SkillTreeNode? get selectedNode => _selectedNode;
|
||||||
@@ -69,6 +73,7 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void toggleNodeSelection(String nodeId) {
|
void toggleNodeSelection(String nodeId) {
|
||||||
|
if (isBenchmarkRunning) return;
|
||||||
if (_selectedNode?.id == nodeId) {
|
if (_selectedNode?.id == nodeId) {
|
||||||
// Unselect the node if it's already selected
|
// Unselect the node if it's already selected
|
||||||
_selectedNode = null;
|
_selectedNode = null;
|
||||||
@@ -127,6 +132,9 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
|
|
||||||
// TODO: Update to actual implementation
|
// TODO: Update to actual implementation
|
||||||
Future<void> runBenchmark(ReportRequestBody reportRequestBody) async {
|
Future<void> runBenchmark(ReportRequestBody reportRequestBody) async {
|
||||||
|
isBenchmarkRunning = true;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final result = await benchmarkService.generateReport(reportRequestBody);
|
final result = await benchmarkService.generateReport(reportRequestBody);
|
||||||
// Pretty-print the JSON result
|
// Pretty-print the JSON result
|
||||||
@@ -135,6 +143,9 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Failed to generate report: $e");
|
print("Failed to generate report: $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBenchmarkRunning = false;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Update to actual implementation
|
// TODO: Update to actual implementation
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class SideBarView extends StatelessWidget {
|
class SideBarView extends StatelessWidget {
|
||||||
final ValueNotifier<String> selectedViewNotifier;
|
final ValueNotifier<String> selectedViewNotifier;
|
||||||
@@ -7,6 +9,9 @@ class SideBarView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// TODO: should we pass this in as a dependency?
|
||||||
|
final skillTreeViewModel =
|
||||||
|
Provider.of<SkillTreeViewModel>(context, listen: false);
|
||||||
return Material(
|
return Material(
|
||||||
child: ValueListenableBuilder(
|
child: ValueListenableBuilder(
|
||||||
valueListenable: selectedViewNotifier,
|
valueListenable: selectedViewNotifier,
|
||||||
@@ -21,7 +26,9 @@ class SideBarView extends StatelessWidget {
|
|||||||
color:
|
color:
|
||||||
selectedView == 'TaskView' ? Colors.blue : Colors.black,
|
selectedView == 'TaskView' ? Colors.blue : Colors.black,
|
||||||
icon: const Icon(Icons.chat),
|
icon: const Icon(Icons.chat),
|
||||||
onPressed: () => selectedViewNotifier.value = 'TaskView',
|
onPressed: skillTreeViewModel.isBenchmarkRunning
|
||||||
|
? null
|
||||||
|
: () => selectedViewNotifier.value = 'TaskView',
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
splashRadius: 0.1,
|
splashRadius: 0.1,
|
||||||
@@ -29,8 +36,9 @@ class SideBarView extends StatelessWidget {
|
|||||||
? Colors.blue
|
? Colors.blue
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
icon: const Icon(Icons.emoji_events), // trophy icon
|
icon: const Icon(Icons.emoji_events), // trophy icon
|
||||||
onPressed: () =>
|
onPressed: skillTreeViewModel.isBenchmarkRunning
|
||||||
selectedViewNotifier.value = 'SkillTreeView',
|
? null
|
||||||
|
: () => selectedViewNotifier.value = 'SkillTreeView',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ class TaskQueueView extends StatelessWidget {
|
|||||||
border: Border.all(color: Colors.green, width: 3),
|
border: Border.all(color: Colors.green, width: 3),
|
||||||
),
|
),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: viewModel.isBenchmarkRunning
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
// Create a ReportRequestBody with hardcoded values
|
// Create a ReportRequestBody with hardcoded values
|
||||||
ReportRequestBody reportRequestBody = ReportRequestBody(
|
ReportRequestBody reportRequestBody = ReportRequestBody(
|
||||||
category: "",
|
category: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user