From b888bb22cde431cd528663390e53327444a2f3c2 Mon Sep 17 00:00:00 2001 From: "Roberto.silva" Date: Wed, 25 Feb 2026 16:04:30 -0600 Subject: [PATCH] Agregar estilo cuando la respuesta del asistente sea refusal fix #139 --- src/routes/planes/$planId/_detalle/iaplan.tsx | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/routes/planes/$planId/_detalle/iaplan.tsx b/src/routes/planes/$planId/_detalle/iaplan.tsx index b745990..cc4b307 100644 --- a/src/routes/planes/$planId/_detalle/iaplan.tsx +++ b/src/routes/planes/$planId/_detalle/iaplan.tsx @@ -126,16 +126,16 @@ function RouteComponent() { const conversacionJson = activeChatData?.conversacion_json || [] const chatMessages = useMemo(() => { - const json = activeChatData?.conversacion_json - if (!Array.isArray(json)) return [] - + const json = activeChatData?.conversacion_json || [] return json.map((msg: any, index: number) => { const isAssistant = msg.user === 'assistant' return { - id: `${activeChatId}-${index}-${msg.timestamp}`, // ID estable + id: `${activeChatId}-${index}`, role: isAssistant ? 'assistant' : 'user', content: isAssistant ? msg.message : msg.prompt, + // EXTRAEMOS EL CAMPO REFUSAL + isRefusal: isAssistant && msg.refusal === true, suggestions: isAssistant && msg.recommendations ? msg.recommendations.map((rec: any) => ({ @@ -275,7 +275,7 @@ function RouteComponent() { // Si no hay campos, enviamos el texto tal cual if (fields.length === 0) return userInput - return `Instrucción del usuario: ${userInput}` + return ` ${userInput}` } const handleSend = async (promptOverride?: string) => { @@ -504,31 +504,44 @@ function RouteComponent() { {chatMessages.map((msg) => (
- {/* Contenido de texto normal */} - {msg.content} - - {/* Si el mensaje tiene sugerencias (ImprovementCard) */} - {msg.suggestions && msg.suggestions.length > 0 && ( -
- s.applied)} - /> + {/* Icono opcional de advertencia si es refusal */} + {msg.isRefusal && ( +
+ Aviso del Asistente
)} + + {msg.content} + + {/* Renderizado de sugerencias (ImprovementCard) */} + {!msg.isRefusal && + msg.suggestions && + msg.suggestions.length > 0 && ( +
+ +
+ )}
))}