"use client"; import { useState } from "react"; import { AssistantMessage } from "@/app/chat/components/assistant-message"; import { UserMessage } from "@/app/chat/components/user-message"; import Nudges from "@/app/chat/nudges"; import type { Message } from "@/app/chat/types"; import OnboardingCard from "@/app/onboarding/components/onboarding-card"; import { useChatStreaming } from "@/hooks/useChatStreaming"; import { OnboardingStep } from "./onboarding-step"; export function OnboardingContent({ handleStepComplete, currentStep, }: { handleStepComplete: () => void; currentStep: number; }) { const [responseId, setResponseId] = useState(null); const [selectedNudge, setSelectedNudge] = useState(""); const [assistantMessage, setAssistantMessage] = useState( null, ); const { streamingMessage, isLoading, sendMessage } = useChatStreaming({ onComplete: (message, newResponseId) => { setAssistantMessage(message); if (newResponseId) { setResponseId(newResponseId); } }, onError: (error) => { console.error("Chat error:", error); setAssistantMessage({ role: "assistant", content: "Sorry, I couldn't connect to the chat service. Please try again.", timestamp: new Date(), }); }, }); const NUDGES = ["What is OpenRAG?"]; const handleNudgeClick = async (nudge: string) => { setSelectedNudge(nudge); setAssistantMessage(null); await sendMessage({ prompt: nudge, previousResponseId: responseId || undefined, }); }; // Determine which message to show (streaming takes precedence) const displayMessage = streamingMessage || assistantMessage; return (
= 0} isCompleted={currentStep > 0} text="Let's get started by setting up your model provider." > = 1} isCompleted={currentStep > 1 || !!selectedNudge} text="Excellent, let's move on to learning the basics." >
{/* User message - show when nudge is selected */} {currentStep >= 1 && !!selectedNudge && (
1 ? "opacity-50" : ""}>
)} {/* Assistant message - show streaming or final message */} {currentStep >= 1 && !!selectedNudge && (displayMessage || isLoading) && (
1 ? "opacity-50" : ""}> {}} isStreaming={!!streamingMessage} /> {!isLoading && displayMessage && currentStep === 1 && (
)}
)} = 2} isCompleted={currentStep > 2} text="Step 2: Connect your model" >

Choose and connect your preferred AI model provider.

= 3} isCompleted={currentStep > 3} text="Step 3: You're all set!" >

Your account is ready to use. Let's start chatting!

); }