mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 10:49:49 +08:00
feat: create a dedicated provider for dashbot navigation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:apidash/dashbot/features/chat/view/widgets/dashbot_task_buttons.dart';
|
||||
import 'package:apidash/providers/providers.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
|
||||
import '../../../../core/constants/constants.dart';
|
||||
@@ -66,6 +67,7 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
|
||||
_scrollToBottom();
|
||||
}
|
||||
});
|
||||
ref.watch(selectedRequestModelProvider.select((value) => value?.id));
|
||||
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
|
||||
@@ -17,6 +17,7 @@ import '../models/chat_action.dart';
|
||||
import '../models/chat_state.dart';
|
||||
import '../repository/chat_remote_repository.dart';
|
||||
import '../providers/service_providers.dart';
|
||||
import '../../../core/providers/dashbot_active_route_provider.dart';
|
||||
|
||||
class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
ChatViewmodel(this._ref) : super(const ChatState());
|
||||
@@ -270,6 +271,8 @@ class ChatViewmodel extends StateNotifier<ChatState> {
|
||||
isGenerating: false,
|
||||
currentStreamingResponse: '',
|
||||
);
|
||||
// Reset to base route (unpins chat) after clearing messages.
|
||||
_ref.read(dashbotActiveRouteProvider.notifier).resetToBaseRoute();
|
||||
}
|
||||
|
||||
Future<void> sendTaskMessage(ChatMessageType type) async {
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../../../../core/utils/dashbot_icons.dart';
|
||||
import '../../../../core/providers/dashbot_window_notifier.dart';
|
||||
|
||||
import '../../../../core/routes/dashbot_routes.dart';
|
||||
import '../../../../core/providers/dashbot_active_route_provider.dart';
|
||||
import 'package:apidash_design_system/tokens/measurements.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@@ -46,15 +47,15 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "🤖 Chat with Dashbot",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
);
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(DashbotRoutes.dashbotChat);
|
||||
},
|
||||
),
|
||||
],
|
||||
HomeScreenTaskButton(
|
||||
label: "🔎 Explain me this response",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.explainResponse,
|
||||
@@ -64,6 +65,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "🐞 Help me debug this error",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.debugError,
|
||||
@@ -73,6 +75,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "📄 Generate documentation",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.generateDoc,
|
||||
@@ -82,6 +85,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "📝 Generate Tests",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.generateTest,
|
||||
@@ -91,6 +95,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "🧩 Generate Code",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.generateCode,
|
||||
@@ -100,6 +105,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "📥 Import cURL",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.importCurl,
|
||||
@@ -109,6 +115,7 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
||||
HomeScreenTaskButton(
|
||||
label: "📄 Import OpenAPI",
|
||||
onPressed: () {
|
||||
ref.read(dashbotActiveRouteProvider.notifier).goToChat();
|
||||
Navigator.of(context).pushNamed(
|
||||
DashbotRoutes.dashbotChat,
|
||||
arguments: ChatMessageType.importOpenApi,
|
||||
|
||||
Reference in New Issue
Block a user