- Extended TaskService to manage a list of deleted tasks using shared_preferences.
- Modified TaskViewModel to filter out tasks that have been marked as deleted locally.
- Loaded the list of deleted tasks during app initialization in main.dart.
- Replaced direct service initialization with Provider and ProxyProvider in main.dart.
- Introduced a ChangeNotifierProxyProvider for ApiSettingsViewModel to include a reference to RestApiUtility.
- Refactored MyApp class to fetch services from providers instead of direct instantiation.
This commit enhances the dependency injection pattern to support dynamic updates to the API base URL. The use of ProxyProvider allows for more flexible and efficient management of dependencies, particularly between RestApiUtility and other services.
- Added ApiBaseUrlField widget to the TaskView.
- Included a TextEditingController to manage the API base URL value.
- Initialized the text field with the current base URL value from ApiSettingsViewModel.
- Modified the layout to place the API base URL field and associated buttons below the task list.
The commit introduces a user interface enhancement that allows the user to update the API base URL directly from the TaskView. This ensures better configurability and user experience.
- Added a reference to RestApiUtility within ApiSettingsViewModel.
- Modified _loadBaseURL and updateBaseURL methods to update the base URL in RestApiUtility whenever a change is made.
- This ensures that changes to the base URL in the settings are propagated to the utility responsible for making API calls.
This integration allows the application to dynamically update the base URL for API calls through the user interface, enhancing flexibility and configurability.
- Extracted the API Base URL field and associated buttons into a new ApiBaseUrlField widget.
- Utilized Consumer to listen for changes in ApiSettingsViewModel.
- Maintained the look and feel consistent with the application's existing UI elements.
This refactor enhances code modularity and readability by isolating the API settings UI in its own widget.
Updated main.dart to provide ApiSettingsViewModel at the top-level using MultiProvider. This ensures that the ViewModel is accessible throughout the app, allowing for dynamic updates to the API's base URL.
Modified RestApiUtility to include a method for updating the base URL dynamically. This allows the application to adapt to changes in the API's base URL without requiring a restart.
Created a new ViewModel called ApiSettingsViewModel that is responsible for getting and setting the API's base URL. Utilized the shared_preferences package for persistent storage of the base URL.
This commit updates the ViewModel classes for both Chat and Task to accommodate the new structured responses received from the API. These changes are essential for the correct functioning of the application as they deal with the new TaskResponse and Step objects.
Updates in ChatViewModel:
- Modified `fetchChatsForTask` to handle structured step data
- Updated how steps are retrieved and processed
Updates in TaskViewModel:
- Updated `fetchTasks` to use the new TaskResponse object
- Refactored task fetching and selection logic
These updates ensure that the ViewModel classes are aligned with the new structured API responses, improving data handling and UI updates.
This commit updates the ChatService and TaskService classes to use the api.get method instead of the previous api.getList. This change allows us to handle structured API responses more effectively, particularly those containing pagination information and detailed task and step data.
- Update ChatService methods to use api.get
- Update TaskService methods to use api.get
- Handle structured TaskResponse in TaskService.listAllTasks
This commit introduces a new class called TaskResponse, which holds both the tasks and pagination information returned from the API. The class includes a factory constructor to create an instance from JSON data, ensuring that the API response is neatly packaged into an easily manageable object. This enhances code readability and maintainability.
- Create a TaskResponse class with tasks and pagination fields
- Add a factory constructor for JSON to TaskResponse conversion
This commit updates the Task model to include optional fields for
'additionalInput' and 'artifacts'. The 'fromMap' factory method is also
adapted to populate these fields if they exist in the JSON response.
This change aligns the Task model with the expected server responses,
making it more flexible and robust.
Added a new Pagination class to model the pagination data that comes with API responses. This will help in handling paginated data more effectively and transparently.
The Pagination class includes fields for total items, total pages, current page, and page size. It also includes a factory constructor for creating an instance from a JSON object.
This commit refactors the main.dart file to include service initialization and dependency injection:
- RestApiUtility Initialization: Initialize the RestApiUtility with a mock API endpoint.
- Service Initialization: Initialize ChatService and TaskService with the created RestApiUtility.
- Dependency Injection: Pass the initialized services to MyApp constructor.
- Provider Update: Replace the ChangeNotifierProvider creation in MultiProvider to use the new ChatViewModel and TaskViewModel initialized with the respective services.
This setup allows for better separation of concerns and easier testing, as the services are now decoupled from the view models.
This commit adds functionality to handle user interactions in the TaskView class by implementing the onPressed, onTap, and onDelete methods:
- onPressed: Triggered when the "New Task" button is pressed. It clears the current task ID and chat history in the ChatViewModel.
- onTap: Triggered when a task list tile is tapped. It selects the task in TaskViewModel and updates the current task ID in ChatViewModel.
- onDelete: Triggered when the delete button on a task list tile is pressed. It deletes the task from TaskViewModel and clears the current task ID and chat history in ChatViewModel if the deleted task was the current task.
These implementations provide a seamless user experience for managing tasks and associated chats.
This commit enhances the ChatView class by implementing the onSendPressed functionality, which is triggered when the user sends a message through the ChatInputField:
- When onSendPressed is triggered, it checks if a task ID is currently selected (currentTaskId in ChatViewModel).
- If a task ID is selected, the message is sent as a chat message for that task using sendChatMessage from ChatViewModel.
- If no task ID is selected, a new task is created using createTask from TaskViewModel, and then the message is sent for that new task.
This change provides a complete workflow for sending chat messages, either within an existing task or by creating a new task.
This commit brings a key update to the ChatInputField widget, making it more flexible and decoupled:
- The onSendPressed callback now takes a string parameter. This string represents the message that the user wishes to send.
- The onPressed of the send button (IconButton) is now implemented within the ChatInputField widget. It checks if the TextField has any text before calling onSendPressed.
- Added a TextEditingController to manage the TextField's content.
This commit includes a significant overhaul of the TaskViewModel to use the newly created TaskService and integrate it with the task API. Specifically:
- Removed dependency on mock data for tasks.
- Added real API calls through the TaskService for task operations like creating and fetching tasks.
- Updated createTask to return the ID of the newly created task.
- Updated fetchTasks method to fetch tasks from the API and update the local list.
- Updated selectTask to handle selection based on string IDs.
These changes make the TaskViewModel ready for real-world usage and remove dependencies on mock data.
This commit refactors the ChatViewModel to use the newly created ChatService and Step model for chat-related functionalities. The changes include:
- Replaced mock data source with real API calls via ChatService.
- Introduced _currentTaskId to keep track of the current task ID.
- Added fetchChatsForTask method to fetch steps related to the current task and populate the chat list.
- Implemented sendChatMessage to execute a step and add both user and agent messages to the chat list.
By making these changes, the ChatViewModel is now fully integrated with the backend services and models, thus enabling a more realistic and dynamic chat experience.
This commit adds a new TaskService class to handle all task-related operations, including task creation, listing, and artifacts management.
- Implemented methods for creating a new task (createTask).
- Added functionality to retrieve details for a specific task (getTaskDetails).
- Enabled listing all tasks with optional pagination (listAllTasks).
- Enabled listing all artifacts for a specific task with optional pagination (listTaskArtifacts).
By encapsulating these operations within the TaskService class, this commit provides a clean and centralized way to interact with the backend for task functionalities, making the application more maintainable and easier to extend.
This commit adds a new ChatService class to handle all chat-related operations, including steps and artifacts.
- Implemented methods for executing a step within a task (executeStep).
- Added functionality to retrieve details for a specific step (getStepDetails).
- Enabled listing all steps for a specific task with optional pagination (listTaskSteps).
- Laid groundwork for artifact uploading (uploadArtifact) and downloading (downloadArtifact), though these are not implemented yet.
By encapsulating these operations within the ChatService class, this commit provides a clean and centralized way to interact with the backend for chat functionalities, making the application more maintainable and easier to extend.
This commit introduces the Step class to the codebase, designed to model the steps related to tasks.
- Implemented Step class with both required and optional fields.
- Provided a fromMap factory method for easy deserialization from API responses.
- Ensured that optional fields are handled gracefully, providing default values where necessary.
The addition of the Step class lays the foundation for more complex interactions with tasks, including the ability to handle steps with varying levels of information. This makes the application more flexible and robust when interfacing with the backend.
This commit introduces a new utility class, RestApiUtility, designed to encapsulate all the HTTP request operations.
- Created RestApiUtility class with a constructor that accepts a base URL.
- Added get method to perform GET requests and return data as a Map.
- Added getList method to perform GET requests and return data as a List.
- Added post method to perform POST requests with payload and return data as a Map.
The class uses the http package for making network calls and dart:convert for JSON serialization and deserialization. This centralized approach makes it easier to manage API calls and handle errors across the application.
This commit updates the Task model to use string-based identifiers (id) instead of integers. The change aligns the model with the backend service, which uses string-based UUIDs for task identification.
This commit updates the Chat model to use string-based identifiers (id and taskId) instead of integers. This change aligns the model with the backend service, which uses string-based UUIDs for task and chat identification.
This commit adds the TaskRequestBody class, which is designed to encapsulate the request body when creating a new task. The class includes a toJson method for easy serialization to JSON format.
Additionally, unit tests have been written to ensure that the TaskRequestBody object is created with the correct values and that it serializes to the expected JSON structure.
- Added TaskRequestBody class with input and optional additionalInput fields.
- Implemented toJson method for converting an instance of the class to JSON.
- Added unit tests to verify both object creation and JSON serialization.
These changes provide a standardized way to manage the request body when creating new tasks, improving the overall code quality and maintainability.
This commit introduces the StepRequestBody class, designed to encapsulate the request body for sending a chat message in the form of a step. The class includes a toJson method for easy serialization to JSON format.
Additionally, unit tests have been added to ensure that the StepRequestBody object is created with the correct values and that it serializes to the expected JSON format.
- Added StepRequestBody class with input and optional additionalInput fields.
- Implemented toJson method for converting an instance of the class to JSON.
- Added unit tests to verify both object creation and JSON serialization.
These changes provide a robust way to manage the request body for step-based chat messages.