feat: Add isWaitingForAgentResponse property to TaskViewModel

- Added a boolean property `isWaitingForAgentResponse` to the `TaskViewModel` class to track whether a task is being created and waiting for a response from the agent.
- When a task is being created, we set `isWaitingForAgentResponse` to `true` and notify the listeners.
- When the task creation process is completed (successfully or not), `isWaitingForAgentResponse` is set to `false` and listeners are notified.
- Updated the `ChatView` class to listen to changes in `TaskViewModel.isWaitingForAgentResponse` to show the loading indicator conditionally.
This commit is contained in:
hunteraraujo
2023-10-31 16:59:36 -07:00
parent 2f187a853e
commit 688ba62db7
2 changed files with 12 additions and 2 deletions

View File

@@ -64,7 +64,7 @@ class _ChatViewState extends State<ChatView> {
@override
Widget build(BuildContext context) {
// TODO: Do we want to have a reference to task view model in this class?
final taskViewModel = Provider.of<TaskViewModel>(context, listen: false);
final taskViewModel = Provider.of<TaskViewModel>(context, listen: true);
return Scaffold(
body: Column(
children: [
@@ -105,7 +105,8 @@ class _ChatViewState extends State<ChatView> {
LoadingIndicator(
isLoading: Provider.of<TaskQueueViewModel>(context, listen: true)
.isBenchmarkRunning ||
widget.viewModel.isWaitingForAgentResponse),
widget.viewModel.isWaitingForAgentResponse ||
taskViewModel.isWaitingForAgentResponse),
const SizedBox(height: 10),
// Input area
Padding(