/* ======================================== ChatHistory Component — padhle (Refined Workspace) ======================================== */ import { useEffect, useRef } from "react"; import Message from "../message/Message"; import SelectorFlow from "../selector-flow/SelectorFlow"; import "./ChatHistory.css"; const ChatHistory = ({ messages, activeSubject, activeGrade, activeChapter, onPromptClick, isTyping, selectorStep, selectorData, }) => { const hasMessages = messages.length > 0; const isSelector = selectorStep !== "chat"; const suggestions = [ { id: 1, icon: "eco", iconFilled: true, color: "--color-accent-green", colorBg: "--color-accent-green-bg", keywords: ["photosynthesis"], text: "Explain how ", textEnd: " works in simple terms", }, { id: 2, icon: "calculate", iconFilled: false, color: "--color-accent-blue", colorBg: "--color-accent-blue-bg", keywords: ["derivatives"], text: "Help me understand ", textEnd: " in calculus", }, { id: 3, icon: "account_balance", iconFilled: false, color: "--color-accent-orange", colorBg: "--color-accent-orange-bg", keywords: ["Industrial"], text: "What caused the ", textEnd: " Revolution?", }, { id: 4, icon: "edit", iconFilled: true, color: "--color-accent-purple", colorBg: "--color-accent-purple-bg", keywords: ["Romeo and Juliet"], text: "Help me analyze themes in ", textEnd: "", }, ]; const fullPromptTexts = suggestions.map( (s) => s.text + s.keywords.join(" ") + s.textEnd, ); const streamingMsg = messages.find((m) => m.streaming); const historyRef = useRef(null); // Scroll only the chat pane, and only when a message is added. Streaming // token updates must not move the page or restart a smooth-scroll animation. useEffect(() => { const history = historyRef.current; if (history) history.scrollTop = history.scrollHeight; }, [messages.length]); /* ─── Messages mode ─── */ if (hasMessages) { return (
Your AI tutor for grades 6–12. Ask anything!
I'll answer questions
related to your selected
subject and chapter
using your textbook
content.