Fix AI chat conversation errors and history loading issues
- Fix CircularProgress import from correct MUI package - Fix conversationId validation by omitting null values instead of sending them - Fix conversations API Zod schema default values (string vs number mismatch) - Remove debug logging from chat error handling - AI chat conversations now work properly with authentication - Chat history loading no longer fails with validation errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,8 +14,8 @@ const createConversationSchema = z.object({
|
|||||||
|
|
||||||
const getConversationsSchema = z.object({
|
const getConversationsSchema = z.object({
|
||||||
language: z.enum(['ro', 'en']).optional(),
|
language: z.enum(['ro', 'en']).optional(),
|
||||||
limit: z.string().transform(Number).pipe(z.number().min(1).max(50)).optional().default(20),
|
limit: z.string().transform(Number).pipe(z.number().min(1).max(50)).optional().default('20'),
|
||||||
offset: z.string().transform(Number).pipe(z.number().min(0)).optional().default(0),
|
offset: z.string().transform(Number).pipe(z.number().min(0)).optional().default('0'),
|
||||||
})
|
})
|
||||||
|
|
||||||
// GET /api/chat/conversations - List user's conversations
|
// GET /api/chat/conversations - List user's conversations
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
|
CircularProgress,
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
import {
|
import {
|
||||||
Chat,
|
Chat,
|
||||||
@@ -39,7 +40,6 @@ import {
|
|||||||
History,
|
History,
|
||||||
Add,
|
Add,
|
||||||
Delete,
|
Delete,
|
||||||
CircularProgress,
|
|
||||||
MoreVert,
|
MoreVert,
|
||||||
Edit,
|
Edit,
|
||||||
} from '@mui/icons-material'
|
} from '@mui/icons-material'
|
||||||
@@ -351,7 +351,7 @@ export default function FloatingChat() {
|
|||||||
headers,
|
headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
message: inputMessage,
|
message: inputMessage,
|
||||||
conversationId: activeConversationId,
|
...(activeConversationId && { conversationId: activeConversationId }),
|
||||||
history: messages.slice(-5), // Fallback for anonymous users
|
history: messages.slice(-5), // Fallback for anonymous users
|
||||||
locale: locale,
|
locale: locale,
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user