From a1d8f55cbd47e11e68c6a116ad8a596e75f60841 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 16 Jul 2026 19:13:07 +0800 Subject: [PATCH] fix(chat): improve streaming wait indicators across chat and embed Keep the agent timeline placeholder visible between tool rounds when nothing is pending, remove redundant thinking dot loaders, and replace embed bouncing dots with a lightweight native spinner. --- .../AgentStreamDisplay.style.test.mjs | 6 +- .../chat/components/AgentStreamDisplay.vue | 45 +++++++------ .../RagPipelineProgress.style.test.mjs | 5 +- .../chat/components/RagPipelineProgress.vue | 22 +------ frontend/src/views/chat/components/botmsg.vue | 4 -- frontend/src/views/chat/index.vue | 2 +- frontend/src/views/embed/EmbedBotMessage.vue | 50 --------------- frontend/src/views/embed/EmbedChatCore.vue | 64 +++++++++---------- frontend/src/views/embed/EmbedPage.vue | 4 -- 9 files changed, 66 insertions(+), 136 deletions(-) diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs b/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs index 896acd0f..ac86030b 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs +++ b/frontend/src/views/chat/components/AgentStreamDisplay.style.test.mjs @@ -91,9 +91,11 @@ test('pending tool rows do not render an extra axis dot', () => { assert.doesNotMatch(source, /&\.action-pending\s*\{[\s\S]*&::after/) }) -test('agent mode only shows a native timeline placeholder before visible activity', () => { +test('agent mode shows a native placeholder before answer whenever nothing is pending', () => { assert.match(source, /if \(isConversationDone\.value\) return false/) - assert.match(source, /return displayEvents\.value\.length === 0/) + assert.match(source, /return !hasPendingStreamingActivity\.value/) + assert.match(source, /const hasPendingStreamingActivity = computed/) + assert.match(source, /event\.type === 'tool_approval_required' \|\| event\.type === 'mcp_oauth_required'/) 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 aa4e3a56..5178eadd 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -1267,13 +1267,27 @@ watch(answerFullyRendered, (ready) => { }); }); -// 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. +// Whether any currently visible step is actively pending (a running tool, or a +// blocking approval/OAuth prompt). A pending step shimmers on its own, so we +// don't stack a placeholder on top of it. +const hasPendingStreamingActivity = computed(() => { + return displayEvents.value.some((event: any) => { + if (!event) return false; + if (event.pending === true) return true; + return event.type === 'tool_approval_required' || event.type === 'mcp_oauth_required'; + }); +}); + +// Before any answer text appears, keep a native timeline placeholder whenever +// nothing is currently pending. This covers both the initial wait (no events +// yet) and the gap between rounds — the previous tool finished but the model +// has not emitted the next step/answer — which would otherwise show a static, +// feedback-less timeline. Once a real pending step exists it carries its own +// shimmer, and once answer text starts the stream itself is enough feedback. const showAgentActivityIndicator = computed(() => { if (isConversationDone.value) return false; if (props.ragMode || hasAnswerStarted.value) return false; - return displayEvents.value.length === 0; + return !hasPendingStreamingActivity.value; }); const isStreamingTimelineEvent = (event: any): boolean => { @@ -2624,6 +2638,13 @@ const handleAddToKnowledge = (answerEvent: any) => { } } +// While streaming, the last timeline step is `tree-child-last` (margin-bottom: 0) +// and the answer streams in directly beneath it. Give the answer breathing room +// so it does not collide with the final tool row. +.event-item.tree-child + .event-item.event-answer { + margin-top: 16px; +} + // ============ Tree View ============ .tree-container { margin: 0 0 16px; @@ -2974,16 +2995,6 @@ const handleAddToKnowledge = (answerEvent: any) => { } } -@keyframes spin { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } -} - @keyframes pulse { 0%, @@ -3274,12 +3285,6 @@ const handleAddToKnowledge = (answerEvent: any) => { } } -@keyframes spin { - to { - transform: rotate(360deg); - } -} - // Final step layout override: keep agent reasoning/tool output visually close to // Claude's compact timeline instead of boxed cards. .agent-stream-display { diff --git a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs index b5712af1..75594e2d 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs +++ b/frontend/src/views/chat/components/RagPipelineProgress.style.test.mjs @@ -47,13 +47,14 @@ test('rag pipeline opens references from search steps and the drawer composable' assert.match(source, /handleStepClick/) }) -test('rag pipeline uses a native pending step and keeps later loading inside the thinking step', () => { +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, /showThinkingStep/) - assert.match(source, /thinking-loading/) + assert.match(source, /'action-pending': thinkingPending/) assert.match(source, /hasThinkingEvent/) + assert.doesNotMatch(source, /thinking-loading/) assert.doesNotMatch(source, /showActivityIndicator/) }) diff --git a/frontend/src/views/chat/components/RagPipelineProgress.vue b/frontend/src/views/chat/components/RagPipelineProgress.vue index b5fa99d7..1f704344 100644 --- a/frontend/src/views/chat/components/RagPipelineProgress.vue +++ b/frontend/src/views/chat/components/RagPipelineProgress.vue @@ -64,14 +64,7 @@ {{ t('agent.think') }} -
-
- - - -
-
-
+
{{ thinkingContent }}
@@ -166,14 +159,7 @@ {{ t('agent.think') }} -
-
- - - -
-
-
+
{{ thinkingContent }}
@@ -658,10 +644,6 @@ watch(thinkingExpanded, (expanded) => { } .rag-thinking-step { - .thinking-loading { - padding: 4px 0 0; - } - .thinking-detail-content { margin-top: 4px; padding: 0; diff --git a/frontend/src/views/chat/components/botmsg.vue b/frontend/src/views/chat/components/botmsg.vue index d6595168..58f13d9b 100644 --- a/frontend/src/views/chat/components/botmsg.vue +++ b/frontend/src/views/chat/components/botmsg.vue @@ -414,10 +414,6 @@ onBeforeUnmount(() => { margin-left: 16px; } -.thinking-loading { - padding: 8px 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 65a78e3a..d0fedf9c 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -1253,7 +1253,7 @@ onBeforeRouteUpdate((to, from, next) => { @media (prefers-reduced-motion: reduce) { .chat-global-wait__spinner { - animation-duration: 1.8s; + animation: none; } } diff --git a/frontend/src/views/embed/EmbedBotMessage.vue b/frontend/src/views/embed/EmbedBotMessage.vue index 07aa17a6..0c33ff03 100644 --- a/frontend/src/views/embed/EmbedBotMessage.vue +++ b/frontend/src/views/embed/EmbedBotMessage.vue @@ -17,13 +17,6 @@
-
-
- - - -
-
{ .chat-citation-pills(); } -.loading-indicator { - padding: 8px 0; -} - -.loading-typing { - display: flex; - align-items: center; - gap: 4px; - - span { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--embed-primary, var(--td-brand-color)); - 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; - } - } -} - -@keyframes typingBounce { - - 0%, - 60%, - 100% { - transform: translateY(0); - } - - 30% { - transform: translateY(-8px); - } -} - .embed-citation-float { position: absolute; z-index: 10000; diff --git a/frontend/src/views/embed/EmbedChatCore.vue b/frontend/src/views/embed/EmbedChatCore.vue index 864c63b9..fbac0f31 100644 --- a/frontend/src/views/embed/EmbedChatCore.vue +++ b/frontend/src/views/embed/EmbedChatCore.vue @@ -80,12 +80,9 @@
-
-
- - - -
+
+
@@ -446,11 +443,13 @@ watch( background: var(--td-bg-color-container); text-align: left; cursor: pointer; - transition: border-color 0.15s ease, background 0.15s ease; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); + transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; &:hover { - border-color: var(--td-brand-color-3, var(--td-brand-color)); - background: color-mix(in srgb, var(--td-brand-color) 4%, var(--td-bg-color-container)); + border-color: var(--td-brand-color); + background: var(--td-bg-color-container-hover); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); } &--skeleton { @@ -512,12 +511,34 @@ watch( } .embed-chat__typing { - height: 41px; + min-height: 28px; display: flex; align-items: center; padding-left: 4px; } +.embed-chat__typing-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: embedChatTypingSpin 0.8s linear infinite; +} + +@keyframes embedChatTypingSpin { + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: reduce) { + .embed-chat__typing-spinner { + animation: none; + } +} + .embed-chat__input { flex-shrink: 0; padding: 8px 16px 16px; @@ -559,29 +580,6 @@ watch( 100% { background-position: -200% 0; } } -.loading-typing { - display: flex; - align-items: center; - gap: 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; } - } -} - -@keyframes typingBounce { - 0%, 60%, 100% { transform: translateY(0); } - 30% { transform: translateY(-8px); } -} - .scroll-to-bottom-btn { position: absolute; left: 50%; diff --git a/frontend/src/views/embed/EmbedPage.vue b/frontend/src/views/embed/EmbedPage.vue index 027e2f6c..268c1cad 100644 --- a/frontend/src/views/embed/EmbedPage.vue +++ b/frontend/src/views/embed/EmbedPage.vue @@ -181,10 +181,6 @@ watch(headerTitle, (title) => { :deep(.embed-send-btn:not(.disabled)) { background: var(--embed-primary, var(--td-brand-color)); } - - :deep(.loading-typing span) { - background: var(--embed-primary, var(--td-brand-color)); - } } .embed-header {