From a270d40cd52b65b8e84d43881d5ddff59a9140fb Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 16 Jul 2026 18:10:31 +0800 Subject: [PATCH] fix(chat): replace detached typing dots with native loading placeholders Remove redundant bounce-dot indicators from agent/RAG timelines and non-agent answers; use existing pending step cards before activity and a compact spinner for global wait states so streaming feedback stays aligned with the timeline. --- .../components/css/chat-timeline-loading.less | 74 -------- .../css/chat-timeline-loading.test.mjs | 9 +- .../AgentStreamDisplay.style.test.mjs | 12 +- .../chat/components/AgentStreamDisplay.vue | 179 ++---------------- .../RagPipelineProgress.style.test.mjs | 4 +- .../chat/components/RagPipelineProgress.vue | 11 +- frontend/src/views/chat/components/botmsg.vue | 55 ------ frontend/src/views/chat/index.vue | 58 +++--- frontend/src/views/dev/MarkdownTestPage.vue | 45 ----- 9 files changed, 53 insertions(+), 394 deletions(-) diff --git a/frontend/src/components/css/chat-timeline-loading.less b/frontend/src/components/css/chat-timeline-loading.less index 2a68dc44..53fb8047 100644 --- a/frontend/src/components/css/chat-timeline-loading.less +++ b/frontend/src/components/css/chat-timeline-loading.less @@ -1,28 +1,3 @@ -@keyframes chatTimelineTypingBounce { - - 0%, - 60%, - 100% { - transform: translate3d(0, 0, 0); - } - - 30% { - transform: translate3d(0, -5px, 0); - } -} - -@keyframes chatTimelineLoadingFadeIn { - from { - opacity: 0; - transform: translateY(6px); - } - - to { - opacity: 1; - transform: translateY(0); - } -} - // A light sweep across in-progress text (the "光影" / shimmer effect). The base // is the muted secondary color and a brighter band slides across, signalling // "this step is still running" without the layout cost of a spinner. @@ -77,52 +52,3 @@ color: var(--td-text-color-secondary); } } - -.streaming-loading-node { - .tree-child-content { - position: relative; - } - - .loading-indicator { - display: flex; - align-items: center; - min-height: 24px; - padding: 0; - margin: 0; - position: relative; - animation: chatTimelineLoadingFadeIn 0.3s ease-out; - } - - .loading-typing { - position: absolute; - left: -42px; - top: 9px; - display: flex; - align-items: center; - gap: 4px; - - span { - width: 4px; - height: 4px; - border-radius: 50%; - background: var(--td-text-color-placeholder); - animation: chatTimelineTypingBounce 1.4s ease-in-out infinite; - // Composite each dot on its own layer so the bounce runs off the main - // thread and does not smear/ghost while the answer relayouts every token. - will-change: transform; - backface-visibility: hidden; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.2s; - } - - &:nth-child(3) { - animation-delay: 0.4s; - } - } - } -} diff --git a/frontend/src/components/css/chat-timeline-loading.test.mjs b/frontend/src/components/css/chat-timeline-loading.test.mjs index 45620ae2..c9e9921e 100644 --- a/frontend/src/components/css/chat-timeline-loading.test.mjs +++ b/frontend/src/components/css/chat-timeline-loading.test.mjs @@ -7,12 +7,9 @@ import test from 'node:test' const here = dirname(fileURLToPath(import.meta.url)) const css = readFileSync(join(here, 'chat-timeline-loading.less'), 'utf8') -test('timeline loading uses shared gray bounce dots on the axis', () => { - assert.match(css, /\.streaming-loading-node\s*\{[\s\S]*left:\s*-42px/) - assert.match(css, /width:\s*4px/) - assert.match(css, /background:\s*var\(--td-text-color-placeholder\)/) - assert.match(css, /animation:\s*chatTimelineTypingBounce/) - assert.match(css, /animation-delay:\s*0\.2s/) +test('shared timeline styles do not add a detached loading row', () => { + assert.doesNotMatch(css, /\.streaming-loading-node/) + assert.doesNotMatch(css, /chatTimelineTypingBounce/) }) test('in-progress step titles get the streaming shimmer sweep', () => { diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs b/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs index f1c8f163..896acd0f 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs +++ b/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs @@ -58,9 +58,10 @@ test('tool rows use line icon names instead of legacy asset masks', () => { assert.doesNotMatch(source, /getToolIcon\(event\.tool_name\)/) }) -test('rag mode delegates pre-answer loading to pipeline and keeps dots while answer streams', () => { - assert.match(source, /if \(props\.ragMode\) return hasAnswerStarted\.value/) +test('rag mode delegates pre-answer loading to pipeline and adds no row after answer starts', () => { + assert.match(source, /if \(props\.ragMode \|\| hasAnswerStarted\.value\) return false/) assert.match(source, /v-if="!ragMode \|\| displayEvents\.length > 0 \|\| showAgentActivityIndicator"/) + assert.doesNotMatch(source, /ChatActivityIndicator/) }) test('rag mode keeps model thinking out of the answer stream component', () => { @@ -90,9 +91,10 @@ test('pending tool rows do not render an extra axis dot', () => { assert.doesNotMatch(source, /&\.action-pending\s*\{[\s\S]*&::after/) }) -test('agent mode keeps gray timeline dots for the full turn', () => { +test('agent mode only shows a native timeline placeholder before visible activity', () => { assert.match(source, /if \(isConversationDone\.value\) return false/) - assert.match(source, /if \(props\.ragMode\) return false/) - assert.match(source, /return true;\s*\}\);/) + assert.match(source, /return displayEvents\.value\.length === 0/) + assert.match(source, /class="action-card action-pending"/) + assert.match(source, /t\('chat\.thinkingAlt'\)/) assert.match(source, /chat-timeline-loading\.less/) }) diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index 5b082b26..aa4e3a56 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -419,11 +419,12 @@
-
-
- - - +
+
+
+ + {{ t('chat.thinkingAlt') }} +
@@ -1266,11 +1267,13 @@ watch(answerFullyRendered, (ready) => { }); }); -// Agent: dots until the turn completes. RAG: pipeline dots before answer; answer stream dots after. +// Only render a placeholder before the agent has produced any visible step or +// answer. Once real activity exists it carries its own pending state, and once +// answer text starts the stream itself is sufficient feedback. const showAgentActivityIndicator = computed(() => { if (isConversationDone.value) return false; - if (props.ragMode) return hasAnswerStarted.value; - return true; + if (props.ragMode || hasAnswerStarted.value) return false; + return displayEvents.value.length === 0; }); const isStreamingTimelineEvent = (event: any): boolean => { @@ -1649,7 +1652,7 @@ const displayEvents = computed(() => { // While the conversation is still running, keep the same lightweight tool-log // surface as the completed tree. Raw thinking narration is noisy during - // streaming; the active state is represented by the compact activity dots. + // streaming; real tool rows carry their own pending state. if (!isConversationDone.value) { return result.filter((e: any) => { if (e.type === 'thinking') return false; @@ -2577,13 +2580,6 @@ const handleAddToKnowledge = (answerEvent: any) => { &.is-embedded { margin-bottom: 0; - - .loading-indicator { - height: 41px; - padding: 0 0 0 4px; - margin-top: 0; - animation: none; - } } } @@ -2978,22 +2974,6 @@ const handleAddToKnowledge = (answerEvent: any) => { } } -// Loading 动画关键帧 -@keyframes dotBounce { - - 0%, - 80%, - 100% { - transform: scale(1); - opacity: 0.6; - } - - 40% { - transform: scale(1.3); - opacity: 1; - } -} - @keyframes spin { 0% { transform: rotate(0deg); @@ -3018,32 +2998,6 @@ const handleAddToKnowledge = (answerEvent: any) => { } } -@keyframes typingBounce { - - 0%, - 60%, - 100% { - transform: translate3d(0, 0, 0); - } - - 30% { - transform: translate3d(0, -5px, 0); - } -} - -@keyframes wave { - - 0%, - 40%, - 100% { - transform: scaleY(0.4); - } - - 20% { - transform: scaleY(1); - } -} - @keyframes pulseBorder { 0%, @@ -3320,115 +3274,6 @@ const handleAddToKnowledge = (answerEvent: any) => { } } -.loading-indicator { - display: flex; - align-items: center; - min-height: 24px; - padding: 0; - margin-top: 0; - position: relative; - animation: fadeInUp 0.3s ease-out; - - // 方案1: 三个跳动的圆点 - .loading-dots { - display: flex; - align-items: center; - gap: 6px; - - span { - width: 8px; - height: 8px; - border-radius: 50%; - background: var(--td-brand-color); - animation: dotBounce 1.4s ease-in-out infinite; - - &:nth-child(1) { - animation-delay: -0.32s; - } - - &:nth-child(2) { - animation-delay: -0.16s; - } - - &:nth-child(3) { - animation-delay: 0s; - } - } - } - - // 打字机效果 - .loading-typing { - display: flex; - align-items: center; - gap: 4px; - - span { - width: 4px; - height: 4px; - border-radius: 50%; - background: var(--td-text-color-placeholder); - animation: typingBounce 1.4s ease-in-out infinite; - // Composite each dot so the bounce stays smooth and ghost-free while the - // streaming answer relayouts every token. - will-change: transform; - backface-visibility: hidden; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.2s; - } - - &:nth-child(3) { - animation-delay: 0.4s; - } - } - } - - // 方案5: 波浪线 - .loading-wave { - display: flex; - align-items: center; - gap: 3px; - - span { - width: 3px; - height: 16px; - background: var(--td-brand-color); - border-radius: 2px; - animation: wave 1.2s ease-in-out infinite; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.1s; - } - - &:nth-child(3) { - animation-delay: 0.2s; - } - - &:nth-child(4) { - animation-delay: 0.3s; - } - - &:nth-child(5) { - animation-delay: 0.4s; - } - } - } - - .botanswer_loading_gif { - width: 24px; - height: 18px; - margin-left: 0; - } -} - @keyframes spin { to { transform: rotate(360deg); diff --git a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs index 3a0f5623..b5712af1 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs +++ b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs @@ -47,8 +47,10 @@ test('rag pipeline opens references from search steps and the drawer composable' assert.match(source, /handleStepClick/) }) -test('rag pipeline keeps loading inside the thinking step instead of orphan dots', () => { +test('rag pipeline uses a native pending step and keeps later loading inside the thinking step', () => { assert.match(source, /showPrePipelineWait/) + assert.match(source, /class="action-card action-pending"/) + assert.match(source, /t\('chat\.thinkingAlt'\)/) assert.match(source, /showThinkingStep/) assert.match(source, /thinking-loading/) assert.match(source, /hasThinkingEvent/) diff --git a/frontend/src/views/chat/components/RagPipelineProgress.vue b/frontend/src/views/chat/components/RagPipelineProgress.vue index ec44b073..b5fa99d7 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.vue +++ b/frontend/src/views/chat/components/RagPipelineProgress.vue @@ -4,11 +4,12 @@
-
-
- - - +
+
+
+ + {{ t('chat.thinkingAlt') }} +
diff --git a/frontend/src/views/chat/components/botmsg.vue b/frontend/src/views/chat/components/botmsg.vue index 7fb020a7..d6595168 100644 --- a/frontend/src/views/chat/components/botmsg.vue +++ b/frontend/src/views/chat/components/botmsg.vue @@ -34,14 +34,6 @@
- -
-
- - - -
-
{ padding: 8px 0; } -.loading-indicator { - padding: 8px 0; -} - -.loading-typing { - display: flex; - align-items: center; - gap: 4px; - - span { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--td-brand-color); - animation: typingBounce 1.4s ease-in-out infinite; - // Composite the dots so the bounce stays smooth and ghost-free while the - // answer relayouts each streamed token. - will-change: transform; - backface-visibility: hidden; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.2s; - } - - &:nth-child(3) { - animation-delay: 0.4s; - } - } -} - -@keyframes typingBounce { - - 0%, - 60%, - 100% { - transform: translate3d(0, 0, 0); - } - - 30% { - transform: translate3d(0, -6px, 0); - } -} - .img_loading { background: var(--td-bg-color-container-hover); height: 230px; diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 34ab0db7..65a78e3a 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -97,13 +97,9 @@ @dismiss="(set) => dismissSuggestions(session, set)" />
-
-
- - - -
+
+
@@ -1231,43 +1227,33 @@ onBeforeRouteUpdate((to, from, next) => { margin-left: 16px; } - .loading-typing { + .chat-global-wait { display: flex; align-items: center; - gap: 4px; + min-height: 28px; + padding-left: 4px; + } - span { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--td-text-color-placeholder); - animation: typingBounce 1.4s ease-in-out infinite; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.2s; - } - - &:nth-child(3) { - animation-delay: 0.4s; - } - } + .chat-global-wait__spinner { + width: 12px; + height: 12px; + box-sizing: border-box; + border: 1.5px solid var(--td-component-stroke); + border-top-color: var(--td-text-color-secondary); + border-radius: 50%; + animation: chatGlobalWaitSpin 0.8s linear infinite; } } -@keyframes typingBounce { - - 0%, - 60%, - 100% { - transform: translateY(0); +@keyframes chatGlobalWaitSpin { + to { + transform: rotate(360deg); } +} - 30% { - transform: translateY(-8px); +@media (prefers-reduced-motion: reduce) { + .chat-global-wait__spinner { + animation-duration: 1.8s; } } diff --git a/frontend/src/views/dev/MarkdownTestPage.vue b/frontend/src/views/dev/MarkdownTestPage.vue index f2d46678..93b40f9a 100644 --- a/frontend/src/views/dev/MarkdownTestPage.vue +++ b/frontend/src/views/dev/MarkdownTestPage.vue @@ -79,9 +79,6 @@
-
- -
@@ -581,48 +578,6 @@ watch(customInput, () => { margin-bottom: 12px; } -.loading-typing { - display: flex; - align-items: center; - gap: 4px; - padding: 8px 0; - - span { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--td-brand-color, #0052d9); - animation: typingBounce 1.4s ease-in-out infinite; - will-change: transform; - backface-visibility: hidden; - - &:nth-child(1) { - animation-delay: 0s; - } - - &:nth-child(2) { - animation-delay: 0.2s; - } - - &:nth-child(3) { - animation-delay: 0.4s; - } - } -} - -@keyframes typingBounce { - - 0%, - 60%, - 100% { - transform: translate3d(0, 0, 0); - } - - 30% { - transform: translate3d(0, -6px, 0); - } -} - .shimmer-demo { display: flex; flex-direction: column;