From 37847b04b2bba885d20de0b9e6212c10e3b1d4b0 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Sun, 15 Mar 2026 18:18:08 +0800 Subject: [PATCH] feat: enhance AgentStreamDisplay with auto-scrolling and improved styling - Added a streaming steps container to the AgentStreamDisplay component, allowing for better organization of streaming events. - Implemented auto-scrolling functionality to keep the latest events in view during streaming. - Enhanced CSS styles for the streaming steps container and event items, including custom scrollbar styles for improved user experience. These changes improve the usability and visual appeal of the AgentStreamDisplay, facilitating a smoother interaction during event streaming. --- .../chat/components/AgentStreamDisplay.vue | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index 278e46d7..4fdf7e0d 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -145,6 +145,7 @@ +
+
@@ -472,6 +474,7 @@ const sanitizeForDisplay = (text: string): string => { // 根元素引用 const rootElement = ref(null); +const streamingStepsContainer = ref(null); // 图片预览状态 const imagePreviewVisible = ref(false); @@ -644,6 +647,13 @@ watch(eventStream, (stream) => { } }); } + // Auto-scroll streaming steps container to bottom during streaming + if (!hasAnswerStarted.value && streamingStepsContainer.value) { + const el = streamingStepsContainer.value; + if (el.scrollHeight > el.clientHeight) { + el.scrollTop = el.scrollHeight; + } + } }); }, { immediate: true, deep: true }); @@ -1864,6 +1874,31 @@ const handleAddToKnowledge = (answerEvent: any) => { position: relative; } +// Streaming steps container +.streaming-steps-container { + &.streaming-steps-constrained { + max-height: 400px; + overflow-y: auto; + + &::-webkit-scrollbar { + width: 4px; + } + + &::-webkit-scrollbar-track { + background: transparent; + } + + &::-webkit-scrollbar-thumb { + background: var(--td-bg-color-component-disabled); + border-radius: 2px; + + &:hover { + background: var(--td-text-color-placeholder); + } + } + } +} + // Event items (flat, no timeline) .event-item { position: relative; @@ -1933,6 +1968,25 @@ const handleAddToKnowledge = (answerEvent: any) => { position: relative; padding-left: 12px; // indent for branch lines margin-top: 6px; // gap from root + max-height: 400px; + overflow-y: auto; + + &::-webkit-scrollbar { + width: 4px; + } + + &::-webkit-scrollbar-track { + background: transparent; + } + + &::-webkit-scrollbar-thumb { + background: var(--td-bg-color-component-disabled); + border-radius: 2px; + + &:hover { + background: var(--td-text-color-placeholder); + } + } } .tree-child { @@ -1942,12 +1996,13 @@ const handleAddToKnowledge = (answerEvent: any) => { margin-bottom: 6px; // gap between children // vertical trunk line (continues for non-last children) + // bottom: -6px extends the line through the margin-bottom gap between siblings &::before { content: ''; position: absolute; left: 0; top: 0; - bottom: 0; + bottom: -6px; width: 0; border-left: 1px dashed var(--td-component-stroke); }