diff --git a/memento-note/components/ai-chat.tsx b/memento-note/components/ai-chat.tsx index d2c9acd..ca520d1 100644 --- a/memento-note/components/ai-chat.tsx +++ b/memento-note/components/ai-chat.tsx @@ -83,19 +83,24 @@ export function AIChat({ showFloatingTrigger = true }: { showFloatingTrigger?: b } } - await sendMessage( - { text }, - { - body: { - tone: selectedTone, - chatScope, - notebookId: chatScope !== 'all' ? chatScope : undefined, - webSearch: webSearch && webSearchAvailable, - conversationId: convId, - language, + try { + await sendMessage( + { text }, + { + body: { + tone: selectedTone, + chatScope, + notebookId: chatScope !== 'all' ? chatScope : undefined, + webSearch: webSearch && webSearchAvailable, + conversationId: convId, + language, + } } - } - ) + ) + } catch (error) { + console.error('Chat send error:', error) + toast.error(t('chat.assistantError') || 'Failed to send message') + } } const fetchHistory = async () => { diff --git a/memento-note/components/chat/chat-container.tsx b/memento-note/components/chat/chat-container.tsx index fac1e45..e7e9b1c 100644 --- a/memento-note/components/chat/chat-container.tsx +++ b/memento-note/components/chat/chat-container.tsx @@ -137,17 +137,22 @@ export function ChatContainer({ initialConversations, notebooks, webSearchAvaila } } - await sendMessage( - { text: content }, - { - body: { - conversationId: convId, - notebookId: notebookId || selectedNotebook || undefined, - language, - webSearch: webSearchEnabled, - }, - } - ) + try { + await sendMessage( + { text: content }, + { + body: { + conversationId: convId, + notebookId: notebookId || selectedNotebook || undefined, + language, + webSearch: webSearchEnabled, + }, + } + ) + } catch (error) { + console.error('Chat send error:', error) + toast.error(t('chat.assistantError') || 'Failed to send message') + } } const handleNewChat = () => { diff --git a/memento-note/components/contextual-ai-chat.tsx b/memento-note/components/contextual-ai-chat.tsx index 932e839..ea2ec0c 100644 --- a/memento-note/components/contextual-ai-chat.tsx +++ b/memento-note/components/contextual-ai-chat.tsx @@ -220,7 +220,12 @@ export function ContextualAIChat({ const text = input.trim() if (!text || isLoading) return setInput('') - await sendMessage({ text }, { body: buildChatBody() }) + try { + await sendMessage({ text }, { body: buildChatBody() }) + } catch (error) { + console.error('Chat send error:', error) + toast.error(t('chat.assistantError') || 'Failed to send message') + } } // ── Action execution ──────────────────────────────────────────────────────── @@ -493,7 +498,7 @@ export function ContextualAIChat({

- + IA Assistant

@@ -510,9 +515,12 @@ export function ContextualAIChat({

@@ -534,7 +542,7 @@ export function ContextualAIChat({ > {tab.label} {activeTab === tab.id && ( - + )} ))} @@ -562,7 +570,7 @@ export function ContextualAIChat({ {resourcePreview && (
-

+

{resourcePreview.source === 'chat' ? 'Injecter depuis Discussion' : 'Aperçu IA'}

- +
)} @@ -594,7 +602,7 @@ export function ContextualAIChat({ {messages.length === 0 && (
- +

Posez une question à l'Assistant pour commencer.

@@ -623,7 +631,7 @@ export function ContextualAIChat({ {isLoading && (
-
+
)} @@ -664,11 +672,11 @@ export function ContextualAIChat({ className={cn( 'h-[52px] rounded-xl border transition-all flex flex-col items-center justify-center gap-1.5 shadow-sm', isActive - ? 'bg-[#75B2D6]/10 border-[#75B2D6] text-[#75B2D6]' + ? 'bg-memento-blue/10 border-memento-blue text-memento-blue' : 'bg-white/60 border-border text-[#1C1C1C]/40 hover:border-[#1C1C1C]/20' )} > - + {tone.label} ) @@ -680,7 +688,7 @@ export function ContextualAIChat({