fix(udeci): fix frontend DTO field mapping (response/quick_options) and enable dual DTO compatibility (v3.8.38)

This commit is contained in:
2026-10-27 22:58:56 -03:00
parent bd88dfdd19
commit e45eb972dd
9 changed files with 54 additions and 31 deletions
+26 -18
View File
@@ -265,6 +265,25 @@
}
}
function closeChat() {
const panel = document.getElementById('aiChatPanel');
const backdrop = document.getElementById('aiChatBackdrop');
const launcher = document.getElementById('aiChatLauncher');
if (panel) {
panel.classList.add('d-none');
panel.style.transform = '';
panel.style.height = '';
panel.style.bottom = '';
}
if (backdrop) backdrop.classList.add('d-none');
if (launcher) launcher.classList.remove('chat-open');
document.body.classList.remove('ai-chat-mobile-open');
if ('speechSynthesis' in window && window.speechSynthesis.speaking) {
window.speechSynthesis.cancel();
}
}
async function sendQuery(queryText) {
if (!queryText || isProcessing) return;
@@ -310,9 +329,14 @@
}
const data = await res.json();
const reply = data.reply || "Disculpa, no pude procesar tu solicitud en este momento.";
const options = Array.isArray(data.options) ? data.options : [];
const reply = data.response || data.reply || "Disculpa, no pude procesar tu solicitud en este momento.";
const options = Array.isArray(data.quick_options) ? data.quick_options : (Array.isArray(data.options) ? data.options : []);
appendMessage('assistant', reply, options, true);
if (data.guide_step && window.WalkthroughEngine) {
closeChat();
window.WalkthroughEngine.startStep(data.guide_step);
}
} catch (err) {
console.error("[UdeCi Widget] Error al consultar API:", err);
appendMessage('assistant', "Hubo una interrupción en la conexión con el tutor inteligente. Por favor, verifica tu conexión o intenta nuevamente en unos instantes.", [], true);
@@ -356,22 +380,6 @@
}, 100);
}
function closeChat() {
panel.classList.add('d-none');
if (backdrop) backdrop.classList.add('d-none');
launcher.classList.remove('chat-open');
document.body.classList.remove('ai-chat-mobile-open');
if ('speechSynthesis' in window && window.speechSynthesis.speaking) {
window.speechSynthesis.cancel();
}
// Restaurar transform o estilos modificados por gestos
panel.style.transform = '';
panel.style.height = '';
panel.style.bottom = '';
}
// Toggle panel
launcher.addEventListener('click', () => {
const isHidden = panel.classList.contains('d-none');