import React, { useState, useEffect } from 'react'; import { Header } from './components/Header'; import { LeftSidebar } from './components/LeftSidebar'; import { ChatArea } from './components/ChatArea'; import { RightPanel } from './components/RightPanel'; import { FloatingActionButtons } from './components/FloatingActionButtons'; import { Menu, X, User } from 'lucide-react'; import { Button } from './components/ui/button'; import { Toaster } from './components/ui/sonner'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { toast } from 'sonner'; export interface Message { id: string; role: 'user' | 'assistant'; content: string; timestamp: Date; references?: string[]; sender?: GroupMember; // For group chat } export interface User { name: string; email: string; } export interface GroupMember { id: string; name: string; email: string; avatar?: string; isAI?: boolean; } export type SpaceType = 'individual' | 'group'; export type FileType = 'syllabus' | 'lecture-slides' | 'literature-review' | 'other'; export interface UploadedFile { file: File; type: FileType; } export type LearningMode = 'concept' | 'socratic' | 'exam' | 'assignment' | 'summary'; export type Language = 'auto' | 'en' | 'zh'; function App() { const [isDarkMode, setIsDarkMode] = useState(() => { const saved = localStorage.getItem('theme'); return saved === 'dark' || (!saved && window.matchMedia('(prefers-color-scheme: dark)').matches); }); const [user, setUser] = useState(null); const [messages, setMessages] = useState([ { id: '1', role: 'assistant', content: "👋 Hi! I'm Clare, your AI teaching assistant for Module 10 – Responsible AI. I'm here to help you learn through personalized tutoring. Feel free to ask me anything about the course materials, or upload your documents to get started!", timestamp: new Date(), } ]); const [learningMode, setLearningMode] = useState('concept'); const [language, setLanguage] = useState('auto'); const [uploadedFiles, setUploadedFiles] = useState([]); const [memoryProgress, setMemoryProgress] = useState(36); const [leftSidebarOpen, setLeftSidebarOpen] = useState(false); const [rightPanelOpen, setRightPanelOpen] = useState(false); const [rightPanelVisible, setRightPanelVisible] = useState(true); const [spaceType, setSpaceType] = useState('individual'); const [exportResult, setExportResult] = useState(''); const [resultType, setResultType] = useState<'export' | 'quiz' | 'summary' | null>(null); // Mock group members const [groupMembers] = useState([ { id: 'clare', name: 'Clare AI', email: 'clare@ai.assistant', isAI: true }, { id: '1', name: 'Sarah Johnson', email: 'sarah.j@university.edu' }, { id: '2', name: 'Michael Chen', email: 'michael.c@university.edu' }, { id: '3', name: 'Emma Williams', email: 'emma.w@university.edu' }, ]); useEffect(() => { document.documentElement.classList.toggle('dark', isDarkMode); localStorage.setItem('theme', isDarkMode ? 'dark' : 'light'); }, [isDarkMode]); const handleSendMessage = (content: string) => { if (!content.trim() || !user) return; // In group mode, add sender info const sender: GroupMember | undefined = spaceType === 'group' ? { id: user.email, name: user.name, email: user.email } : undefined; const userMessage: Message = { id: Date.now().toString(), role: 'user', content, timestamp: new Date(), sender, }; setMessages(prev => [...prev, userMessage]); // In group mode, only respond if @Clare or @clare is mentioned const shouldAIRespond = spaceType === 'individual' || content.toLowerCase().includes('@clare'); if (shouldAIRespond) { // Simulate AI response setTimeout(() => { const responses: Record = { concept: "Great question! Let me break this concept down for you. In Responsible AI, this relates to ensuring our AI systems are fair, transparent, and accountable. Would you like me to explain any specific aspect in more detail?", socratic: "That's an interesting point! Let me ask you this: What do you think are the key ethical considerations when deploying AI systems? Take a moment to think about it.", exam: "Let me test your understanding with a quick question: Which of the following is NOT a principle of Responsible AI? A) Fairness B) Transparency C) Profit Maximization D) Accountability", assignment: "I can help you with that assignment! Let's break it down into manageable steps. First, what specific aspect are you working on?", summary: "Here's a quick summary: Responsible AI focuses on developing and deploying AI systems that are ethical, fair, transparent, and accountable to society.", }; const assistantMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: responses[learningMode], timestamp: new Date(), references: ['Module 10, Section 2.3', 'Lecture Notes - Week 5'], sender: spaceType === 'group' ? groupMembers.find(m => m.isAI) : undefined, }; setMessages(prev => [...prev, assistantMessage]); }, 1000); } }; const handleFileUpload = (files: File[]) => { const newFiles: UploadedFile[] = files.map(file => ({ file, type: 'other' as FileType, // Default type })); setUploadedFiles(prev => [...prev, ...newFiles]); }; const handleRemoveFile = (index: number) => { setUploadedFiles(prev => prev.filter((_, i) => i !== index)); }; const handleFileTypeChange = (index: number, type: FileType) => { setUploadedFiles(prev => prev.map((file, i) => i === index ? { ...file, type } : file )); }; const handleClearConversation = () => { setMessages([{ id: '1', role: 'assistant', content: "👋 Hi! I'm Clare, your AI teaching assistant for Module 10 – Responsible AI. I'm here to help you learn through personalized tutoring. Feel free to ask me anything about the course materials, or upload your documents to get started!", timestamp: new Date(), }]); }; const handleExport = () => { const result = `# Conversation Export Date: ${new Date().toLocaleDateString()} Student: ${user?.name} ## Summary This conversation covered key concepts in Module 10 – Responsible AI, including ethical considerations, fairness, transparency, and accountability in AI systems. ## Key Takeaways 1. Understanding the principles of Responsible AI 2. Real-world applications and implications 3. Best practices for ethical AI development Exported successfully! ✓`; setExportResult(result); setResultType('export'); toast.success('Conversation exported!'); }; const handleQuiz = () => { const quiz = `# Micro-Quiz: Responsible AI **Question 1:** Which of the following is a key principle of Responsible AI? a) Profit maximization b) Transparency c) Rapid deployment d) Cost reduction **Question 2:** What is algorithmic fairness? (Short answer expected) **Question 3:** True or False: AI systems should always prioritize accuracy over fairness. Generate quiz based on your conversation!`; setExportResult(quiz); setResultType('quiz'); toast.success('Quiz generated!'); }; const handleSummary = () => { const summary = `# Learning Summary ## Today's Session **Duration:** 25 minutes **Topics Covered:** 3 **Messages Exchanged:** 12 ## Key Concepts Discussed • Principles of Responsible AI • Ethical considerations in AI development • Fairness and transparency in algorithms ## Recommended Next Steps 1. Review Module 10, Section 2.3 2. Complete practice quiz on algorithmic fairness 3. Read additional resources on AI ethics ## Progress Update You've covered 65% of Module 10 content. Keep up the great work! 🎉`; setExportResult(summary); setResultType('summary'); toast.success('Summary generated!'); }; return (
setLeftSidebarOpen(!leftSidebarOpen)} onUserClick={() => setRightPanelOpen(!rightPanelOpen)} isDarkMode={isDarkMode} onToggleDarkMode={() => setIsDarkMode(!isDarkMode)} />
{/* Mobile Sidebar Toggle - Left */} {leftSidebarOpen && (
setLeftSidebarOpen(false)} /> )} {/* Left Sidebar */} {/* Main Chat Area */}
{/* Mobile Sidebar Toggle - Right */} {rightPanelOpen && (
setRightPanelOpen(false)} /> )} {/* Right Panel */} {rightPanelVisible && ( )} {/* Toggle Right Panel Button - Desktop only */} {/* Floating Action Buttons - Desktop only, when panel is closed */} {!rightPanelVisible && ( setRightPanelVisible(true)} onExport={handleExport} onQuiz={handleQuiz} onSummary={handleSummary} /> )}
); } export default App;