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.
This commit is contained in:
wizardchen
2026-07-16 18:10:31 +08:00
committed by lyingbug
parent 7ddac0385f
commit a270d40cd5
9 changed files with 53 additions and 394 deletions
@@ -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;
}
}
}
}
@@ -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', () => {
@@ -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/)
})
@@ -419,11 +419,12 @@
<div v-if="showAgentActivityIndicator" class="tree-child tree-child-last streaming-loading-node">
<div class="tree-branch"></div>
<div class="tree-child-content">
<div class="loading-indicator">
<div class="loading-typing">
<span></span>
<span></span>
<span></span>
<div class="action-card action-pending">
<div class="action-header no-results">
<div class="action-title">
<t-icon class="action-title-icon" name="lightbulb" />
<span class="action-name">{{ t('chat.thinkingAlt') }}</span>
</div>
</div>
</div>
</div>
@@ -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);
@@ -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/)
@@ -4,11 +4,12 @@
<div class="tree-child tree-child-last streaming-loading-node">
<div class="tree-branch" />
<div class="tree-child-content">
<div class="loading-indicator">
<div class="loading-typing">
<span />
<span />
<span />
<div class="action-card action-pending">
<div class="action-header no-results">
<div class="action-title">
<t-icon class="action-title-icon" name="lightbulb" />
<span class="action-name">{{ t('chat.thinkingAlt') }}</span>
</div>
</div>
</div>
</div>
@@ -34,14 +34,6 @@
<div class="ai-markdown-template markdown-content" v-stable-html="renderedHTML">
</div>
</div>
<!-- Streaming indicator (non-Agent mode) -->
<div v-if="hasActualContent && !session.is_completed" class="loading-indicator">
<div class="loading-typing">
<span></span>
<span></span>
<span></span>
</div>
</div>
<!-- 复制和添加到知识库按钮 - 非 Agent 模式下显示 -->
<div v-if="answerFullyRendered && (content || session.content)" class="answer-toolbar">
<t-button size="small" variant="outline" shape="round" @click.stop="handleCopyAnswer"
@@ -426,53 +418,6 @@ onBeforeUnmount(() => {
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;
+22 -36
View File
@@ -97,13 +97,9 @@
@dismiss="(set) => dismissSuggestions(session, set)" />
</div>
</div>
<div v-if="showGlobalTypingIndicator"
style="height: 41px;display: flex;align-items: center;padding-left: 4px;">
<div class="loading-typing">
<span></span>
<span></span>
<span></span>
</div>
<div v-if="showGlobalTypingIndicator" class="chat-global-wait" role="status"
:aria-label="t('chat.thinkingAlt')">
<span class="chat-global-wait__spinner" aria-hidden="true"></span>
</div>
</div>
</div>
@@ -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;
}
}
@@ -79,9 +79,6 @@
</div>
<div class="test-case">
<div ref="streamContainer" class="test-rendered markdown-content" v-html="streamHtml"></div>
<div v-if="isStreaming" class="loading-typing">
<span></span><span></span><span></span>
</div>
</div>
</section>
@@ -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;