From 6127e873b2614a8c7e18ae58451d101e17cf5cac Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 20:29:21 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Fix:=20Chargement=20mod=C3=A8les=20IA=20dan?= =?UTF-8?q?s=20Assistant=20pour=20utilisateurs=20non-admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problème: Les modèles IA ne s'affichaient pas dans l'Assistant IA - Settings route nécessite requireAdmin (routes/settings.routes.js:10) - Frontend vérifiait settings.openrouter_api_key avant de charger les modèles - Utilisateurs non-admin ne peuvent jamais récupérer settings - Donc openRouterModels restait toujours vide [] Solution: - Suppression du check settings.openrouter_api_key (Index.tsx:557,263) - Le backend retourne déjà [] si clé API non configurée (fix précédent) - Tous les utilisateurs peuvent maintenant charger les modèles IA Note: L'admin doit configurer la clé API OpenRouter dans Admin → OpenRouter pour que les modèles s'affichent --- src/pages/Index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index e164d59..7d70cdc 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -260,10 +260,10 @@ const Index = () => { }, [showAdmin]); useEffect(() => { - if (showAdmin && adminTab === 'openrouter' && settings.openrouter_api_key && openRouterModels.length === 0) { + if (showAdmin && adminTab === 'openrouter' && openRouterModels.length === 0) { loadOpenRouterModels(); } - }, [showAdmin, adminTab, settings.openrouter_api_key]); + }, [showAdmin, adminTab]); useEffect(() => { if (showAdmin && adminTab === 'calendar') { @@ -552,12 +552,12 @@ const Index = () => { } }, []); - // Load models when chatbox opens (only if API key is configured) + // Load models when chatbox opens useEffect(() => { - if (chatOpen && settings.openrouter_api_key && openRouterModels.length === 0) { + if (chatOpen && openRouterModels.length === 0) { loadOpenRouterModels(); } - }, [chatOpen, settings.openrouter_api_key]); + }, [chatOpen]); // Set default model when models are loaded useEffect(() => { From 4ed230cfa1c9e4be91c0528ae8712e7ebbae3372 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 20:30:26 +0000 Subject: [PATCH 2/2] =?UTF-8?q?UX:=20Am=C3=A9lioration=20messages=20Assist?= =?UTF-8?q?ant=20IA=20quand=20pas=20de=20mod=C3=A8les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Améliorations UX: 1. Message bouton sélecteur adapté selon rôle utilisateur - Admin: "Configurer clé API OpenRouter" - Non-admin: "Aucun modèle IA configuré" 2. Popover avec lien direct vers config pour admins - CommandEmpty affiche message explicatif - Bouton "Configurer OpenRouter" ouvre Admin → OpenRouter - Ferme le popover et ouvre directement l'onglet config Résultat: L'admin peut maintenant configurer OpenRouter en 1 clic depuis le chat --- src/pages/Index.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 7d70cdc..dd7c7ba 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -2443,7 +2443,7 @@ const Index = () => { {loadingModels ? ( "Chargement des modèles..." ) : openRouterModels.length === 0 ? ( - "Aucun modèle disponible" + user?.is_admin ? "Configurer clé API OpenRouter" : "Aucun modèle IA configuré" ) : selectedModel ? ( <> {openRouterModels.find(m => m.id === selectedModel)?.name || "Sélectionner un modèle"} @@ -2462,7 +2462,26 @@ const Index = () => { - Aucun modèle trouvé. + + {openRouterModels.length === 0 && user?.is_admin ? ( +
+

Aucun modèle IA disponible

+ +
+ ) : ( + "Aucun modèle trouvé." + )} +
{openRouterModels.map((model) => (