diff --git a/frontend/src/i18n/embed.ts b/frontend/src/i18n/embed.ts index d644d743..4ffc3943 100644 --- a/frontend/src/i18n/embed.ts +++ b/frontend/src/i18n/embed.ts @@ -106,6 +106,8 @@ const messages = { "unableToGetKnowledgeBaseId": "无法获取知识库ID", "summaryInProgress": "正在总结答案……", "thinkingAlt": "正在思考", + "preparingAnswer": "正在准备回答…", + "connectingModelAndGeneratingAnswer": "正在连接模型并生成回答…", "deepThoughtCompleted": "已深度思考", "deepThoughtAlt": "深度思考完成", "referencesTitle": "参考了{count}个相关内容", @@ -596,6 +598,8 @@ const messages = { "unableToGetKnowledgeBaseId": "Unable to get knowledge base ID", "summaryInProgress": "Summarizing answer…", "thinkingAlt": "Thinking in progress", + "preparingAnswer": "Preparing an answer…", + "connectingModelAndGeneratingAnswer": "Connecting to the model and generating an answer…", "deepThoughtCompleted": "Deep thinking completed", "deepThoughtAlt": "Deep thinking finished", "referencesTitle": "Referenced {count} related item(s)", @@ -1048,6 +1052,8 @@ const koEmbedPublish = { followUpQuestions: '이어서 질문', followUpQuestionsLoading: '추천 질문 로딩 중', thinkingAlt: '생각 중', + preparingAnswer: '답변을 준비하고 있습니다…', + connectingModelAndGeneratingAnswer: '모델에 연결하여 답변을 생성하고 있습니다…', refreshSuggestedQuestions: '다른 질문', imageTooMany: '이미지는 최대 5장까지 업로드할 수 있습니다', imageTypeSizeError: 'JPG/PNG/GIF/WEBP만 지원하며, 각 파일은 10MB 이하여야 합니다', @@ -1136,6 +1142,8 @@ const ruEmbedPublish = { followUpQuestions: 'Спрашивайте дальше', followUpQuestionsLoading: 'Загрузка рекомендуемых вопросов', thinkingAlt: 'Обдумывание...', + preparingAnswer: 'Подготовка ответа…', + connectingModelAndGeneratingAnswer: 'Подключение к модели и создание ответа…', refreshSuggestedQuestions: 'Ещё', imageTooMany: 'Можно загрузить не более 5 изображений', imageTypeSizeError: 'Поддерживаются только JPG/PNG/GIF/WEBP, каждый файл до 10 МБ', diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 2e26df75..00f1720b 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -2558,6 +2558,8 @@ export default { refreshSuggestedQuestions: 'More', thinking: 'Thinking...', thinkingAlt: 'Thinking in progress', + preparingAnswer: 'Preparing an answer…', + connectingModelAndGeneratingAnswer: 'Connecting to the model and generating an answer…', deepThoughtCompleted: 'Deep thinking completed', deepThoughtAlt: 'Deep thinking finished', referencesTitle: 'Referenced {count} related item(s)', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index bd77d2e2..37ed3ef6 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -3046,6 +3046,8 @@ export default { refreshSuggestedQuestions: '다른 질문', thinking: '생각 중...', thinkingAlt: '생각 중', + preparingAnswer: '답변을 준비하고 있습니다…', + connectingModelAndGeneratingAnswer: '모델에 연결하여 답변을 생성하고 있습니다…', deepThoughtCompleted: '심층 분석 완료', deepThoughtAlt: '심층 분석 완료', referencesTitle: '{count}개의 관련 내용 참조', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 7930731c..3d1f5f7a 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -3046,6 +3046,8 @@ export default { refreshSuggestedQuestions: 'Ещё', thinking: 'Думаю...', thinkingAlt: 'Обдумывание...', + preparingAnswer: 'Подготовка ответа…', + connectingModelAndGeneratingAnswer: 'Подключение к модели и создание ответа…', deepThoughtCompleted: 'Глубокий анализ завершён', deepThoughtAlt: 'Глубокий анализ', referencesTitle: 'Использовано {count} связанного материала', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index c80b842f..285aa678 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -3046,6 +3046,8 @@ export default { refreshSuggestedQuestions: '换一批', thinking: '思考中...', thinkingAlt: '正在思考', + preparingAnswer: '正在准备回答…', + connectingModelAndGeneratingAnswer: '正在连接模型并生成回答…', deepThoughtCompleted: '已深度思考', deepThoughtAlt: '深度思考完成', referencesTitle: '参考了{count}个相关内容', diff --git a/frontend/src/utils/rag-pipeline-state.test.ts b/frontend/src/utils/rag-pipeline-state.test.ts new file mode 100644 index 00000000..3f44055b --- /dev/null +++ b/frontend/src/utils/rag-pipeline-state.test.ts @@ -0,0 +1,52 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { shouldShowRagModelAnswerWait } from './rag-pipeline-state.ts' + +const completedRetrieval = { + isCompleted: false, + hasAnswer: false, + hasThinkingEvent: false, + stepCount: 2, + allStepsDone: true, + hasCompletedRetrievalStep: true, +} + +test('shows the model-answer wait state after the RAG pipeline finishes', () => { + assert.equal(shouldShowRagModelAnswerWait(completedRetrieval), true) +}) + +test('does not show the model-answer wait state while a pipeline step is pending', () => { + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + allStepsDone: false, + }), false) +}) + +test('does not show the model-answer wait state before pipeline events arrive', () => { + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + stepCount: 0, + }), false) +}) + +test('does not mistake a completed pre-retrieval step for the model-answer wait', () => { + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + hasCompletedRetrievalStep: false, + }), false) +}) + +test('hides the model-answer wait state when thinking, answer, or completion arrives', () => { + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + hasThinkingEvent: true, + }), false) + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + hasAnswer: true, + }), false) + assert.equal(shouldShowRagModelAnswerWait({ + ...completedRetrieval, + isCompleted: true, + }), false) +}) diff --git a/frontend/src/utils/rag-pipeline-state.ts b/frontend/src/utils/rag-pipeline-state.ts new file mode 100644 index 00000000..bd063f0b --- /dev/null +++ b/frontend/src/utils/rag-pipeline-state.ts @@ -0,0 +1,23 @@ +export interface RagModelAnswerWaitState { + isCompleted: boolean + hasAnswer: boolean + hasThinkingEvent: boolean + stepCount: number + allStepsDone: boolean + hasCompletedRetrievalStep: boolean +} + +/** + * Show a model-answer wait state only in the quiet gap after every visible RAG + * pipeline step has finished and before the model emits thinking or answer text. + */ +export function shouldShowRagModelAnswerWait(state: RagModelAnswerWaitState): boolean { + return ( + !state.isCompleted && + !state.hasAnswer && + !state.hasThinkingEvent && + state.stepCount > 0 && + state.allStepsDone && + state.hasCompletedRetrievalStep + ) +} diff --git a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs index 75594e2d..712a255d 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs +++ b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs @@ -50,7 +50,7 @@ test('rag pipeline opens references from search steps and the drawer composable' test('rag pipeline uses a native pending step and lets the thinking title shimmer while pending', () => { assert.match(source, /showPrePipelineWait/) assert.match(source, /class="action-card action-pending"/) - assert.match(source, /t\('chat\.thinkingAlt'\)/) + assert.match(source, /t\('chat\.preparingAnswer'\)/) assert.match(source, /showThinkingStep/) assert.match(source, /'action-pending': thinkingPending/) assert.match(source, /hasThinkingEvent/) @@ -58,6 +58,13 @@ test('rag pipeline uses a native pending step and lets the thinking title shimme assert.doesNotMatch(source, /showActivityIndicator/) }) +test('rag pipeline shows a pending model-answer step after retrieval completes', () => { + assert.match(source, /showModelAnswerWait/) + assert.match(source, /shouldShowRagModelAnswerWait/) + assert.match(source, /t\('chat\.connectingModelAndGeneratingAnswer'\)/) + assert.match(source, /rag-model-wait-step/) +}) + test('done row appears only after the full turn completes', () => { assert.match(source, /const showDoneRow = computed\(\(\) => \{[\s\S]*hasAnswer\.value/) }) diff --git a/frontend/src/views/chat/components/RagPipelineProgress.vue b/frontend/src/views/chat/components/RagPipelineProgress.vue index e642459a..babb464a 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.vue +++ b/frontend/src/views/chat/components/RagPipelineProgress.vue @@ -8,7 +8,7 @@