Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat(chat): polish follow-up suggestion loading and answer toolbar timing

wizardchen28ebcf2525c9
diff --git a/frontend/src/components/chat/FollowUpSuggestions.test.ts b/frontend/src/components/chat/FollowUpSuggestions.test.ts
new file mode 100644
index 000000000..6d694a7c3
--- /dev/null
+++ b/frontend/src/components/chat/FollowUpSuggestions.test.ts
@@ -0,0 +1,25 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { readFileSync } from 'node:fs'
+
+const component = readFileSync(new URL('./FollowUpSuggestions.vue', import.meta.url), 'utf8')
+
+test('does not insert a separate status row while the first suggestions are loading', () => {
+ assert.match(component, /<transition name="follow-up-card">/)
+ assert.match(component, /v-if="suggestionSet\?\.status === 'ready'"/)
+ assert.doesNotMatch(component, /follow-ups-loading/)
+ assert.doesNotMatch(component, /follow-ups__skeletons/)
+})
+
+test('keeps the existing follow-up card visible while regenerating', () => {
+ assert.match(component, /:disabled="loading"/)
+ assert.match(component, /loading \? 'loading' : 'refresh'/)
+ assert.match(component, /class="follow-ups__list"/)
+})
+
+test('carries the lightbulb into the expanding question card', () => {
+ assert.match(component, /class="follow-ups__title"/)
+ assert.match(component, /name="lightbulb"/)
+ assert.match(component, /\.follow-up-card-enter-from/)
+ assert.match(component, /clip-path: inset\(0 0 55%/)
+})
diff --git a/frontend/src/components/chat/FollowUpSuggestions.vue b/frontend/src/components/chat/FollowUpSuggestions.vue
index b1ea36fa1..707f1a6ec 100644
--- a/frontend/src/components/chat/FollowUpSuggestions.vue
+++ b/frontend/src/components/chat/FollowUpSuggestions.vue
@@ -1,28 +1,30 @@
<template>
- <div v-if="loading || suggestionSet?.status === 'ready'" class="follow-ups" aria-live="polite">
- <div class="follow-ups__header">
- <span>{{ t('chat.followUpQuestions') }}</span>
- <div class="follow-ups__actions">
- <button v-if="allowRegenerate" type="button" :disabled="loading" @click="emit('regenerate')">
- <t-icon :name="loading ? 'loading' : 'refresh'" :class="{ 'is-spinning': loading }" />
- <span>{{ t('chat.refreshSuggestedQuestions') }}</span>
- </button>
- <button type="button" :aria-label="t('common.close')" @click="dismiss">
- <t-icon name="close" />
+ <transition name="follow-up-card">
+ <div v-if="suggestionSet?.status === 'ready'" class="follow-ups" aria-live="polite">
+ <div class="follow-ups__header">
+ <span class="follow-ups__title">
+ <t-icon name="lightbulb" />
+ <span>{{ t('chat.followUpQuestions') }}</span>
+ </span>
+ <div class="follow-ups__actions">
+ <button v-if="allowRegenerate" type="button" :disabled="loading" @click="emit('regenerate')">
+ <t-icon :name="loading ? 'loading' : 'refresh'" :class="{ 'is-spinning': loading }" />
+ <span>{{ t('chat.refreshSuggestedQuestions') }}</span>
+ </button>
+ <button type="button" :aria-label="t('common.close')" @click="dismiss">
+ <t-icon name="close" />
+ </button>
+ </div>
+ </div>
+ <div class="follow-ups__list">
+ <button v-for="item in suggestionSet?.questions || []" :key="item.id" type="button"
+ class="follow-ups__item" @click="emit('select', item)">
+ <span>{{ item.text }}</span>
+ <t-icon name="arrow-up-right" />
</button>
</div>
</div>
- <div v-if="loading && !suggestionSet?.questions?.length" class="follow-ups__skeletons">
- <span v-for="n in 3" :key="n" :style="{ width: skeletonWidths[n - 1] }" />
- </div>
- <div v-else class="follow-ups__list">
- <button v-for="item in suggestionSet?.questions || []" :key="item.id" type="button"
- class="follow-ups__item" @click="emit('select', item)">
- <span>{{ item.text }}</span>
- <t-icon name="arrow-up-right" />
- </button>
- </div>
- </div>
+ </transition>
</template>
<script setup lang="ts">
@@ -43,7 +45,6 @@ const emit = defineEmits<{
}>()
const { t } = useI18n()
const impressed = new Set<string>()
-const skeletonWidths = ['92%', '78%', '85%']
watch(
() => props.suggestionSet,
@@ -79,6 +80,17 @@ const dismiss = () => {
font-size: 13px;
font-weight: 600;
}
+.follow-ups__title {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+}
+.follow-ups__title .t-icon {
+ width: 14px;
+ height: 14px;
+ color: var(--td-text-color-placeholder);
+ font-size: 14px;
+}
.follow-ups__actions { display: flex; gap: 4px; }
.follow-ups__actions button {
display: inline-flex;
@@ -122,23 +134,29 @@ const dismiss = () => {
transform: translateY(-1px);
}
.follow-ups__item:hover .t-icon { color: var(--td-brand-color); }
-.follow-ups__skeletons { display: flex; flex-direction: column; gap: 6px; }
-.follow-ups__skeletons span {
- height: 38px;
- border-radius: 8px;
- background: linear-gradient(
- 100deg,
- var(--td-bg-color-component) 30%,
- var(--td-bg-color-container-hover, rgba(255, 255, 255, .35)) 50%,
- var(--td-bg-color-component) 70%
- );
- background-size: 200% 100%;
- animation: shimmer 3s ease-in-out infinite;
-}
.is-spinning { animation: spin 1s linear infinite; }
-@keyframes shimmer {
- 0% { background-position: 200% 0; }
- 100% { background-position: -200% 0; }
-}
@keyframes spin { to { transform: rotate(360deg); } }
+
+.follow-up-card-enter-active {
+ transform-origin: 24px 0;
+ transition:
+ opacity .22s ease .04s,
+ transform .28s cubic-bezier(.22, .61, .36, 1) .04s,
+ clip-path .28s cubic-bezier(.22, .61, .36, 1) .04s;
+ will-change: opacity, transform, clip-path;
+}
+.follow-up-card-enter-from {
+ opacity: 0;
+ transform: translateY(-7px) scale(.985);
+ clip-path: inset(0 0 55% 0 round 12px);
+}
+.follow-up-card-enter-to {
+ opacity: 1;
+ transform: translateY(0) scale(1);
+ clip-path: inset(0 0 0 0 round 12px);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .follow-up-card-enter-active { transition: none; }
+}
</style>
diff --git a/frontend/src/components/css/chat-message-shared.less b/frontend/src/components/css/chat-message-shared.less
index dd4f86744..3430ce6dc 100644
--- a/frontend/src/components/css/chat-message-shared.less
+++ b/frontend/src/components/css/chat-message-shared.less
@@ -89,6 +89,75 @@
}
}
+.answer-toolbar__follow-up-loading {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ height: 18px;
+ margin-left: 5px;
+ padding-left: 9px;
+ border-left: 1px solid var(--td-component-stroke);
+ color: var(--td-text-color-placeholder);
+ font-size: 12px;
+ line-height: 18px;
+ white-space: nowrap;
+
+ .t-icon {
+ flex: none;
+ width: 14px;
+ height: 14px;
+ font-size: 14px;
+ }
+
+ .answer-toolbar__follow-up-label {
+ background-image: linear-gradient(100deg,
+ var(--td-text-color-placeholder) 0%,
+ var(--td-text-color-placeholder) 36%,
+ var(--td-text-color-primary) 50%,
+ var(--td-text-color-placeholder) 64%,
+ var(--td-text-color-placeholder) 100%);
+ background-size: 200% 100%;
+ background-clip: text;
+ -webkit-background-clip: text;
+ color: transparent;
+ -webkit-text-fill-color: transparent;
+ animation: followUpToolbarShimmer 1.5s linear infinite;
+ will-change: background-position;
+ }
+}
+
+@keyframes followUpToolbarShimmer {
+ from { background-position: 100% 50%; }
+ to { background-position: -100% 50%; }
+}
+
+.follow-up-toolbar-loading-enter-active,
+.follow-up-toolbar-loading-leave-active {
+ transform-origin: left center;
+ transition: opacity .16s ease, transform .16s cubic-bezier(.4, 0, .2, 1);
+}
+
+.follow-up-toolbar-loading-enter-from {
+ opacity: 0;
+ transform: translateX(-3px) scale(.92);
+}
+
+.follow-up-toolbar-loading-leave-to {
+ opacity: 0;
+ transform: translate(4px, 3px) scale(.82);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .answer-toolbar__follow-up-label {
+ animation: none;
+ background-image: none;
+ color: var(--td-text-color-secondary);
+ -webkit-text-fill-color: currentColor;
+ }
+ .follow-up-toolbar-loading-enter-active,
+ .follow-up-toolbar-loading-leave-active { transition: none; }
+}
+
:deep(.streaming-image-loading) {
display: inline-block;
position: relative;
diff --git a/frontend/src/i18n/embed.ts b/frontend/src/i18n/embed.ts
index 2bf31d71c..e1e86871e 100644
--- a/frontend/src/i18n/embed.ts
+++ b/frontend/src/i18n/embed.ts
@@ -78,6 +78,7 @@ const messages = {
"suggestedQuestions": "你可以这样问我",
"suggestedQuestionsLoading": "正在加载推荐问题...",
"followUpQuestions": "接下来可以继续问",
+ "followUpQuestionsLoading": "整理后续问题",
"refreshSuggestedQuestions": "换一批推荐问题",
"inputPlaceholder": "请输入您的消息...",
"send": "发送",
@@ -553,6 +554,7 @@ const messages = {
"suggestedQuestions": "You can ask me",
"suggestedQuestionsLoading": "Loading suggestions...",
"followUpQuestions": "Continue with a follow-up",
+ "followUpQuestionsLoading": "Preparing follow-ups",
"refreshSuggestedQuestions": "Refresh suggestions",
"inputPlaceholder": "Enter your message...",
"send": "Send",
@@ -1012,7 +1014,9 @@ const koEmbedPublish = {
},
chat: {
suggestedQuestions: '이렇게 물어보세요',
+ suggestedQuestionsLoading: '추천 질문 로딩 중...',
followUpQuestions: '이어서 질문해 보세요',
+ followUpQuestionsLoading: '후속 질문 준비 중',
refreshSuggestedQuestions: '추천 질문 새로고침',
imageTooMany: '이미지는 최대 5장까지 업로드할 수 있습니다',
imageTypeSizeError: 'JPG/PNG/GIF/WEBP만 지원하며, 각 파일은 10MB 이하여야 합니다',
@@ -1097,7 +1101,9 @@ const ruEmbedPublish = {
},
chat: {
suggestedQuestions: 'Вы можете спросить так',
+ suggestedQuestionsLoading: 'Загрузка предложений...',
followUpQuestions: 'Продолжите уточняющим вопросом',
+ followUpQuestionsLoading: 'Подготовка уточнений',
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 2c08731f5..41a95b2c2 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -3085,6 +3085,7 @@ export default {
newChat: 'New Chat',
suggestedQuestions: 'You can ask me',
followUpQuestions: 'Continue with a follow-up',
+ followUpQuestionsLoading: 'Preparing follow-ups',
suggestedQuestionsLoading: 'Loading suggestions...',
refreshSuggestedQuestions: 'Refresh suggestions',
inputPlaceholder: 'Enter your message...',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index a279df7e4..e3f786b1a 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -899,6 +899,7 @@ export default {
newChat: "새 대화",
suggestedQuestions: "이렇게 물어보세요",
followUpQuestions: "이어서 질문해 보세요",
+ followUpQuestionsLoading: "후속 질문 준비 중",
suggestedQuestionsLoading: "추천 질문 로딩 중...",
refreshSuggestedQuestions: "추천 질문 새로고침",
inputPlaceholder: "메시지를 입력하세요...",
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index c4d2840ba..f4aa25a55 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -3769,6 +3769,7 @@ export default {
newChat: 'Новый чат',
suggestedQuestions: 'Вы можете спросить меня',
followUpQuestions: 'Продолжите уточняющим вопросом',
+ followUpQuestionsLoading: 'Подготовка уточнений',
suggestedQuestionsLoading: 'Загрузка предложений...',
refreshSuggestedQuestions: 'Обновить предложения',
inputPlaceholder: 'Введите ваше сообщение...',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 8d6c384da..15a8cbe3f 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -897,6 +897,7 @@ export default {
newChat: "新对话",
suggestedQuestions: "你可以这样问我",
followUpQuestions: "接下来可以继续问",
+ followUpQuestionsLoading: "整理后续问题",
suggestedQuestionsLoading: "正在加载推荐问题...",
refreshSuggestedQuestions: "换一批推荐问题",
inputPlaceholder: "请输入您的消息...",
diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue
index f1f80dadc..da46e6efa 100644
--- a/frontend/src/views/chat/components/AgentStreamDisplay.vue
+++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue
@@ -289,7 +289,8 @@
<div v-stable-html="renderAnswerContent(event === activeAnswerEventRef ? typedAnswer : event.content)">
</div>
</div>
- <div v-if="event.done && event.content && event.content.trim() && !embeddedMode" class="answer-toolbar">
+ <div v-if="answerFullyRendered && event.done && event.content && event.content.trim() && !embeddedMode"
+ class="answer-toolbar">
<t-button size="small" variant="outline" shape="round" @click.stop="handleCopyAnswer(event)"
:title="$t('agent.copy')">
<t-icon name="copy" />
@@ -305,6 +306,13 @@
</t-tooltip>
<ChatRequestInfoButton v-if="showRequestInfo && isConversationDone" :session="session"
:session-id="sessionId" />
+ <transition name="follow-up-toolbar-loading">
+ <span v-if="followUpLoading" class="answer-toolbar__follow-up-loading" role="status"
+ aria-live="polite">
+ <t-icon name="lightbulb" />
+ <span class="answer-toolbar__follow-up-label">{{ t('chat.followUpQuestionsLoading') }}</span>
+ </span>
+ </transition>
</div>
</div>
@@ -750,6 +758,7 @@ const props = defineProps<{
embedSessionSig?: string;
embedVisitorId?: string;
ragMode?: boolean;
+ followUpLoading?: boolean;
}>();
const embedAuthProps = computed(() => ({
diff --git a/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs b/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs
new file mode 100644
index 000000000..7168fdb5b
--- /dev/null
+++ b/frontend/src/views/chat/components/answerToolbarCompletion.test.mjs
@@ -0,0 +1,37 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { readFileSync } from 'node:fs'
+
+const botMessage = readFileSync(new URL('./botmsg.vue', import.meta.url), 'utf8')
+const agentStream = readFileSync(new URL('./AgentStreamDisplay.vue', import.meta.url), 'utf8')
+const chatView = readFileSync(new URL('../index.vue', import.meta.url), 'utf8')
+const sharedStyles = readFileSync(
+ new URL('../../../components/css/chat-message-shared.less', import.meta.url),
+ 'utf8',
+)
+
+test('non-agent actions wait for the typewriter buffer to finish', () => {
+ assert.match(botMessage, /const answerFullyRendered = computed/)
+ assert.match(botMessage, /typedAnswer\.value\.length >= answerText\.value\.length/)
+ assert.match(botMessage, /v-if="answerFullyRendered && \(content \|\| session\.content\)"/)
+})
+
+test('agent actions reuse the fully-rendered answer state', () => {
+ assert.match(agentStream, /const answerFullyRendered = computed/)
+ assert.match(agentStream, /typedAnswer\.value\.length >= activeAnswerMarkdown\.value\.length/)
+ assert.match(agentStream, /v-if="answerFullyRendered && event\.done/)
+})
+
+test('follow-up loading is shown compactly inside both answer toolbars', () => {
+ assert.match(chatView, /:follow-up-loading="Boolean\(session\.suggestionLoading/)
+ assert.match(botMessage, /class="answer-toolbar__follow-up-loading"/)
+ assert.match(agentStream, /class="answer-toolbar__follow-up-loading"/)
+ assert.match(botMessage, /class="answer-toolbar__follow-up-label"/)
+ assert.match(botMessage, /transition name="follow-up-toolbar-loading"/)
+ assert.match(agentStream, /transition name="follow-up-toolbar-loading"/)
+ assert.match(sharedStyles, /border-left: 1px solid/)
+ assert.match(sharedStyles, /font-size: 12px/)
+ assert.match(sharedStyles, /followUpToolbarShimmer 1\.5s linear infinite/)
+ assert.match(sharedStyles, /background-clip: text/)
+ assert.match(sharedStyles, /follow-up-toolbar-loading-leave-to/)
+})
diff --git a/frontend/src/views/chat/components/botmsg.vue b/frontend/src/views/chat/components/botmsg.vue
index 3585e3650..7fb020a7f 100644
--- a/frontend/src/views/chat/components/botmsg.vue
+++ b/frontend/src/views/chat/components/botmsg.vue
@@ -17,12 +17,12 @@
<div v-if="session.isRagMode" class="rag-answer-stack">
<RagPipelineProgress :session="session" :embedded-mode="embeddedMode" />
<AgentStreamDisplay v-if="session.isAgentMode" :session="session" :session-id="sessionId"
- :user-query="userQuery" :rag-mode="true" />
+ :user-query="userQuery" :rag-mode="true" :follow-up-loading="followUpLoading" />
</div>
<template v-else>
<docInfo v-if="session.knowledge_references?.length" :session="session"></docInfo>
<AgentStreamDisplay :session="session" :session-id="sessionId" :user-query="userQuery"
- v-if="session.isAgentMode" />
+ v-if="session.isAgentMode" :follow-up-loading="followUpLoading" />
</template>
<deepThink :deepSession="session" v-if="session.showThink && !session.isAgentMode"></deepThink>
</div>
@@ -43,7 +43,7 @@
</div>
</div>
<!-- 复制和添加到知识库按钮 - 非 Agent 模式下显示 -->
- <div v-if="session.is_completed && (content || session.content)" class="answer-toolbar">
+ <div v-if="answerFullyRendered && (content || session.content)" class="answer-toolbar">
<t-button size="small" variant="outline" shape="round" @click.stop="handleCopyAnswer"
:title="$t('agent.copy')">
<t-icon name="copy" />
@@ -59,6 +59,13 @@
</t-button>
</t-tooltip>
<ChatRequestInfoButton v-if="showRequestInfo" :session="session" :session-id="sessionId" />
+ <transition name="follow-up-toolbar-loading">
+ <span v-if="followUpLoading" class="answer-toolbar__follow-up-loading" role="status"
+ aria-live="polite">
+ <t-icon name="lightbulb" />
+ <span class="answer-toolbar__follow-up-label">{{ t('chat.followUpQuestionsLoading') }}</span>
+ </span>
+ </transition>
</div>
<div v-if="isImgLoading" class="img_loading"><t-loading size="small"></t-loading><span>{{
$t('common.loading') }}</span></div>
@@ -155,6 +162,10 @@ const props = defineProps({
sessionId: {
type: String,
default: ''
+ },
+ followUpLoading: {
+ type: Boolean,
+ default: false
}
});
@@ -195,6 +206,13 @@ const { displayed: typedAnswer } = useTypewriter(
() => Boolean(props.session?.is_completed),
);
+// The backend completion event can arrive while the local typewriter still has
+// buffered text to reveal. Treat the answer as visually complete only after the
+// displayed text has caught up, so actions never appear beside a moving answer.
+const answerFullyRendered = computed(() =>
+ Boolean(props.session?.is_completed) && typedAnswer.value.length >= answerText.value.length
+);
+
// 单次渲染整个 Markdown 内容(替代 token-by-token,修复 KaTeX 公式在 streaming 时闪烁消失的问题)
const renderedHTML = computed(() => {
const text = typedAnswer.value;
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue
index c7c00660b..12b52b1d1 100644
--- a/frontend/src/views/chat/index.vue
+++ b/frontend/src/views/chat/index.vue
@@ -83,7 +83,9 @@
<div v-if="session.role == 'assistant' && shouldRenderAssistantMessage(session)">
<botmsg :content="session.content" :session="session" :session-id="session_id"
:user-query="getUserQuery(index)" @scroll-bottom="scrollToBottom"
- :isFirstEnter="isFirstEnter" :embeddedMode="embeddedMode"></botmsg>
+ :isFirstEnter="isFirstEnter" :embeddedMode="embeddedMode"
+ :follow-up-loading="Boolean(session.suggestionLoading && !session.suggestionSet?.questions?.length)">
+ </botmsg>
<FollowUpSuggestions v-if="!session.suggestionsDismissed"
:suggestion-set="session.suggestionSet"
:loading="session.suggestionLoading"
@@ -348,7 +350,6 @@ const loadFollowUpSuggestions = async (message, ensure = false, regenerate = fal
message.suggestionSet = null;
} finally {
message.suggestionLoading = false;
- nextTick(() => scrollToBottom());
}
};
diff --git a/frontend/src/views/embed/EmbedChatCore.vue b/frontend/src/views/embed/EmbedChatCore.vue
index 7ac6087da..864c63b98 100644
--- a/frontend/src/views/embed/EmbedChatCore.vue
+++ b/frontend/src/views/embed/EmbedChatCore.vue
@@ -199,7 +199,6 @@ const loadFollowUpSuggestions = async (
message.suggestionSet = null
} finally {
message.suggestionLoading = false
- scrollToBottom()
}
}