This commit is contained in:
2025-12-08 12:19:53 +00:00
parent 9eeb88e9ea
commit 81674f8094
5 changed files with 324 additions and 86 deletions
+6
View File
@@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { ScrollArea } from '@/components/ui/scroll-area';
import { useSettings } from '@/contexts/SettingsContext';
import { useAchievements, incrementAiMessageCount } from '@/contexts/AchievementsContext';
import { useToast } from '@/hooks/use-toast';
import GlitchText from '@/components/GlitchText';
import MessageContent from '@/components/MessageContent';
@@ -79,6 +80,7 @@ const AIChat = () => {
const [tempCustomConfig, setTempCustomConfig] = useState<CustomApiConfig>({ endpoint: '', apiKey: '', model: '' });
const scrollRef = useRef<HTMLDivElement>(null);
const { playSound } = useSettings();
const { checkAiAchievements } = useAchievements();
const { toast } = useToast();
// Persist messages to localStorage
@@ -134,6 +136,10 @@ const AIChat = () => {
setInput('');
setIsLoading(true);
playSound('click');
// Track AI message count for achievements
incrementAiMessageCount();
checkAiAchievements();
try {
// Build chat history, filtering out empty messages, system notices, and ensuring proper alternation