Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Refactor ChatInputField to Support Continuous Mode

hunteraraujod80053e8dc7a
diff --git a/frontend/lib/views/chat/chat_input_field.dart b/frontend/lib/views/chat/chat_input_field.dart
index 560e9069fe..e6fcca1c8a 100644
--- a/frontend/lib/views/chat/chat_input_field.dart
+++ b/frontend/lib/views/chat/chat_input_field.dart
@@ -3,10 +3,14 @@ import 'package:flutter/material.dart';
class ChatInputField extends StatefulWidget {
// Callback to be triggered when the send button is pressed
final Function(String) onSendPressed;
+ final Function() onContinuousModePressed;
+ final bool isContinuousMode;
const ChatInputField({
Key? key,
required this.onSendPressed,
+ required this.onContinuousModePressed,
+ this.isContinuousMode = false,
}) : super(key: key);
@override
@@ -49,6 +53,8 @@ class _ChatInputFieldState extends State<ChatInputField> {
// when the content exceeds its maximum height
child: SingleChildScrollView(
reverse: true,
+ // TODO: Deselect text field after user goes into continous mode
+ // TODO: Include tool tip to explain clicking text field will end continuous mode
child: TextField(
controller: _controller,
// Allowing the TextField to expand vertically and accommodate multiple lines
@@ -56,16 +62,35 @@ class _ChatInputFieldState extends State<ChatInputField> {
decoration: InputDecoration(
hintText: 'Type a message...',
border: InputBorder.none,
- suffixIcon: IconButton(
- splashRadius: 0.1,
- icon: const Icon(Icons.send),
- onPressed: () {
- // TODO: We allow empty messages?
- if (_controller.text.isNotEmpty) {
- widget.onSendPressed(_controller.text);
- _controller.clear();
- }
- },
+ suffixIcon: Row(
+ mainAxisSize: MainAxisSize.min, // Set to minimum space
+ children: [
+ if (!widget.isContinuousMode)
+ // TODO: Include tool tip to explain single message sending
+ IconButton(
+ splashRadius: 0.1,
+ icon: const Icon(Icons.send),
+ onPressed: () {
+ widget.onSendPressed(_controller.text);
+ _controller.clear();
+ },
+ ),
+ // TODO: Include tool tip to explain continuous mode
+ // TODO: Include pop up to explain continuous mode reprecussions
+ IconButton(
+ splashRadius: 0.1,
+ icon: Icon(widget.isContinuousMode
+ ? Icons.pause
+ : Icons.fast_forward),
+ onPressed: () {
+ if (!widget.isContinuousMode) {
+ widget.onSendPressed(_controller.text);
+ _controller.clear();
+ }
+ widget.onContinuousModePressed();
+ },
+ )
+ ],
),
),
),