diff --git a/js/components/input-area.js b/js/components/input-area.js index 18f016b..be530e3 100644 --- a/js/components/input-area.js +++ b/js/components/input-area.js @@ -370,6 +370,9 @@ export async function sendMessage() { filePreviewEl.innerHTML = ''; autoResizeTextarea(); + // 助手占位 + appendAssistantPlaceholder(); + // 流式回复 state.set(KEYS.IS_STREAMING, true); updateSendButton(true); @@ -465,8 +468,8 @@ ${ragContext} console.log('[RAG] numCtx:', numCtx, 'system长度:', chatParams.system?.length || 0); console.log('[RAG] 开始调用 chatStream...'); - // 助手占位(放在RAG检索之后,确保消息顺序:用户 → 检索状态 → AI) - appendAssistantPlaceholder(); + // 开始回复时清除 RAG 临时状态消息 + document.querySelectorAll('.rag-status').forEach(el => el.remove()); await api.chatStream(chatParams, (chunk) => { if (chunk.message) { @@ -510,6 +513,9 @@ ${ragContext} } catch (err) { console.error('[InputArea] 流式聊天错误:', err); + // 清除 RAG 临时状态消息 + document.querySelectorAll('.rag-status').forEach(el => el.remove()); + if (err.name === 'AbortError') { const placeholder = document.querySelector('#messagesContainer .message.assistant.loading'); const loadingDots = placeholder?.querySelector('.loading-dots');