From 12914dd447e215524c3976d3d5bc39dd74563342 Mon Sep 17 00:00:00 2001 From: Ayush8923 <80516839+Ayush8923@users.noreply.github.com> Date: Fri, 9 Oct 2026 23:14:09 +0530 Subject: [PATCH 1/2] feat(*): init the chatbot flow --- app/(main)/chatbot/page.tsx | 74 ++++++++ app/api/chatbot/message/route.ts | 23 +++ app/components/Sidebar.tsx | 8 +- app/components/chatbot/ChatbotFlowCanvas.tsx | 69 +++++++ app/components/chatbot/ChatbotFlowContext.tsx | 23 +++ app/components/chatbot/ChatbotTestPanel.tsx | 119 ++++++++++++ app/components/chatbot/LlmNode.tsx | 88 +++++++++ app/components/chatbot/LlmNodeAdvanced.tsx | 63 +++++++ app/components/chatbot/LlmNodePromptField.tsx | 73 +++++++ app/components/chatbot/NodeFieldLabel.tsx | 22 +++ app/components/chatbot/TerminalNode.tsx | 26 +++ app/components/chatbot/flowHandleStyle.ts | 9 + app/components/chatbot/index.ts | 5 + app/components/icons/index.tsx | 1 + app/components/icons/sidebar/FlowIcon.tsx | 23 +++ app/hooks/useChatbotFlow.ts | 130 +++++++++++++ app/hooks/useChatbotTest.ts | 94 +++++++++ app/lib/chatbotClient.ts | 26 +++ app/lib/constants.ts | 4 + app/lib/modelSchema.ts | 2 + app/lib/navConfig.ts | 6 + app/lib/types/chatbot.ts | 45 +++++ package-lock.json | 178 ++++++++++++++++++ package.json | 1 + 24 files changed, 1107 insertions(+), 5 deletions(-) create mode 100644 app/(main)/chatbot/page.tsx create mode 100644 app/api/chatbot/message/route.ts create mode 100644 app/components/chatbot/ChatbotFlowCanvas.tsx create mode 100644 app/components/chatbot/ChatbotFlowContext.tsx create mode 100644 app/components/chatbot/ChatbotTestPanel.tsx create mode 100644 app/components/chatbot/LlmNode.tsx create mode 100644 app/components/chatbot/LlmNodeAdvanced.tsx create mode 100644 app/components/chatbot/LlmNodePromptField.tsx create mode 100644 app/components/chatbot/NodeFieldLabel.tsx create mode 100644 app/components/chatbot/TerminalNode.tsx create mode 100644 app/components/chatbot/flowHandleStyle.ts create mode 100644 app/components/chatbot/index.ts create mode 100644 app/components/icons/sidebar/FlowIcon.tsx create mode 100644 app/hooks/useChatbotFlow.ts create mode 100644 app/hooks/useChatbotTest.ts create mode 100644 app/lib/chatbotClient.ts create mode 100644 app/lib/types/chatbot.ts diff --git a/app/(main)/chatbot/page.tsx b/app/(main)/chatbot/page.tsx new file mode 100644 index 00000000..720f05b4 --- /dev/null +++ b/app/(main)/chatbot/page.tsx @@ -0,0 +1,74 @@ +/** + * Chatbot - Build a chatbot flow on a canvas and test each step live. + */ + +"use client"; + +import Sidebar from "@/app/components/Sidebar"; +import PageHeader from "@/app/components/PageHeader"; +import { Button } from "@/app/components/ui"; +import { PlusIcon } from "@/app/components/icons"; +import { ChatbotFlowCanvas, ChatbotTestPanel } from "@/app/components/chatbot"; +import { useApp } from "@/app/lib/context/AppContext"; +import { useChatbotFlow } from "@/app/hooks/useChatbotFlow"; + +export default function ChatbotPage() { + const { sidebarCollapsed } = useApp(); + const flow = useChatbotFlow(); + const node = flow.selectedNode; + + return ( +
+ {canSend + ? "Start a test - the bot will send the first message." + : "Pick a configuration and write a system prompt to start testing."} +
+ ++ Bot is typing… +
+ )} + +{id}
++ {sessionName ? `Test: ${sessionName}` : "Test chat"} +
++ You have unsaved changes. The chat uses the last saved flow. Save to + test your edits. +
+ )} +- {canSend - ? "Start a test - the bot will send the first message." - : "Pick a configuration and write a system prompt to start testing."} -
- -+ Pick a configuration, write a prompt and click Save to start a + chatbot session. +
+ ) : ( + messages.length === 0 && + !isPending && ( ++ The bot will send the first message. +
+ +Bot is typing…
)} + {isEnded && ( ++ This session was replaced by a newer one. Restart to continue + testing. +
+ )}{id}
+ {chatbotRef && ( ++ {chatbotRef} +
+ )}