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:
hunteraraujo
2023-09-16 19:24:54 -07:00
parent 11101286a3
commit 60ae12dfd5
3 changed files with 34 additions and 13 deletions

View File

@@ -1,4 +1,6 @@
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class SideBarView extends StatelessWidget {
final ValueNotifier<String> selectedViewNotifier;
@@ -7,6 +9,9 @@ class SideBarView extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: should we pass this in as a dependency?
final skillTreeViewModel =
Provider.of<SkillTreeViewModel>(context, listen: false);
return Material(
child: ValueListenableBuilder(
valueListenable: selectedViewNotifier,
@@ -21,7 +26,9 @@ class SideBarView extends StatelessWidget {
color:
selectedView == 'TaskView' ? Colors.blue : Colors.black,
icon: const Icon(Icons.chat),
onPressed: () => selectedViewNotifier.value = 'TaskView',
onPressed: skillTreeViewModel.isBenchmarkRunning
? null
: () => selectedViewNotifier.value = 'TaskView',
),
IconButton(
splashRadius: 0.1,
@@ -29,8 +36,9 @@ class SideBarView extends StatelessWidget {
? Colors.blue
: Colors.black,
icon: const Icon(Icons.emoji_events), // trophy icon
onPressed: () =>
selectedViewNotifier.value = 'SkillTreeView',
onPressed: skillTreeViewModel.isBenchmarkRunning
? null
: () => selectedViewNotifier.value = 'SkillTreeView',
),
],
),

View File

@@ -53,17 +53,19 @@ class TaskQueueView extends StatelessWidget {
border: Border.all(color: Colors.green, width: 3),
),
child: ElevatedButton(
onPressed: () {
// Create a ReportRequestBody with hardcoded values
ReportRequestBody reportRequestBody = ReportRequestBody(
category: "",
tests: testNames,
mock: true,
);
onPressed: viewModel.isBenchmarkRunning
? null
: () {
// Create a ReportRequestBody with hardcoded values
ReportRequestBody reportRequestBody = ReportRequestBody(
category: "",
tests: testNames,
mock: true,
);
// Call runBenchmark method from SkillTreeViewModel
viewModel.runBenchmark(reportRequestBody);
},
// Call runBenchmark method from SkillTreeViewModel
viewModel.runBenchmark(reportRequestBody);
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.center, // Center the children