diff --git a/static/js/document.js b/static/js/document.js index c2745c6b6..06e8720aa 100644 --- a/static/js/document.js +++ b/static/js/document.js @@ -3753,7 +3753,11 @@ import { bindMenuDismiss, dismissOrRemove } from './escMenuStack.js'; await _streamEmailBodyText(textarea, newBody); if (uiModule) uiModule.showToast(`AI draft inserted (${data.model_used || 'AI'})`); } else { - if (uiModule) uiModule.showError(data.error || 'Failed to generate reply'); + const rawMsg = data.error || 'Failed to generate reply'; + const msg = /empty response/i.test(rawMsg) + ? 'AI reply failed: AI returned empty response.' + : rawMsg; + if (uiModule) uiModule.showError(msg); } } catch (e) { if (uiModule) uiModule.showError('Failed to generate AI reply'); diff --git a/static/js/emailInbox.js b/static/js/emailInbox.js index 7f0e24773..17b1d1dc2 100644 --- a/static/js/emailInbox.js +++ b/static/js/emailInbox.js @@ -804,7 +804,10 @@ async function _openEmail(em, itemEl, preloadedData = null, mode = 'reply', note if (result.success && result.reply) { aiSuggestedBody = _cleanAiReplyText(result.reply); } else { - const _msg = result.error || 'AI reply could not be generated'; + const _rawMsg = result.error || 'AI reply could not be generated'; + const _msg = /empty response/i.test(_rawMsg) + ? 'AI returned empty response.' + : _rawMsg; console.error('AI reply generation failed:', _msg); import('./ui.js').then(m => m.showError && m.showError('AI reply failed: ' + _msg)).catch(() => {}); return;