diff --git a/attached_assets/{73BD5BFF-8FC0-4540-95E0-A6F045D802E9}_1763388140785.png b/attached_assets/{73BD5BFF-8FC0-4540-95E0-A6F045D802E9}_1763388140785.png new file mode 100644 index 0000000..8befa0b Binary files /dev/null and b/attached_assets/{73BD5BFF-8FC0-4540-95E0-A6F045D802E9}_1763388140785.png differ diff --git a/client/src/components/ai-chat.tsx b/client/src/components/ai-chat.tsx index 55320bd..d56d334 100644 --- a/client/src/components/ai-chat.tsx +++ b/client/src/components/ai-chat.tsx @@ -36,11 +36,11 @@ export default function AiChat() { const { toast } = useToast(); // Fetch available models from OpenRouter - const { data: modelsData, isLoading: modelsLoading } = useQuery<{ models: OpenRouterModel[] }>({ - queryKey: ['/api/ai/models'], + const { data: modelsData, isLoading: modelsLoading } = useQuery<{ data: OpenRouterModel[] }>({ + queryKey: ['/api/openrouter/models'], }); - const availableModels = modelsData?.models || []; + const availableModels = modelsData?.data || []; const generateMutation = useMutation({ mutationFn: async (productInfo: any) => { diff --git a/replit.md b/replit.md index 261645d..073508f 100644 --- a/replit.md +++ b/replit.md @@ -10,6 +10,9 @@ Preferred communication style: Simple, everyday language. ## Recent Changes +### November 17, 2025 +- **AI Assistant Model Loading Fix**: Fixed bug preventing non-admin users from accessing the AI assistant feature. Problem: The AI chat component (`ai-chat.tsx`) was querying `/api/ai/models` which requires admin privileges (`requireAdmin`), causing model list to fail loading for regular users. Solution: Changed the component to use `/api/openrouter/models` endpoint instead, which only requires authentication (`requireAuth`). Updated data structure access from `modelsData?.models` to `modelsData?.data` to match the OpenRouter API response format `{ data: OpenRouterModel[] }`. This fix enables all authenticated users to load the model list and use the AI assistant feature. The endpoint `/api/openrouter/models` was already being used in Settings page for the same purpose, ensuring consistency across the application. + ### November 5, 2025 - **New Post Media Grid Optimization**: Optimized the "Nouvelle publication" media grid for better performance and usability. Changes: (1) Limited display to 12 most recent media items sorted by createdAt descending, (2) Removed infinite scroll functionality, (3) Implemented useMemo with spread copy to prevent React Query cache mutation during sorting, (4) Added conditional rendering for videos using `