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.
This commit is contained in:
@@ -145,6 +145,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Event Stream (non-tree mode: before answer starts, or answer events) -->
|
<!-- Event Stream (non-tree mode: before answer starts, or answer events) -->
|
||||||
|
<div ref="streamingStepsContainer" class="streaming-steps-container" :class="{ 'streaming-steps-constrained': !hasAnswerStarted && !isConversationDone }">
|
||||||
<template v-for="(event, index) in displayEvents" :key="getEventKey(event, index)">
|
<template v-for="(event, index) in displayEvents" :key="getEventKey(event, index)">
|
||||||
<div v-if="event && event.type" class="event-item" :class="{ 'event-answer': event.type === 'answer' }">
|
<div v-if="event && event.type" class="event-item" :class="{ 'event-answer': event.type === 'answer' }">
|
||||||
|
|
||||||
@@ -297,6 +298,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Loading Indicator -->
|
<!-- Loading Indicator -->
|
||||||
<div v-if="!isConversationDone && eventStream.length > 0" class="loading-indicator">
|
<div v-if="!isConversationDone && eventStream.length > 0" class="loading-indicator">
|
||||||
@@ -472,6 +474,7 @@ const sanitizeForDisplay = (text: string): string => {
|
|||||||
|
|
||||||
// 根元素引用
|
// 根元素引用
|
||||||
const rootElement = ref<HTMLElement | null>(null);
|
const rootElement = ref<HTMLElement | null>(null);
|
||||||
|
const streamingStepsContainer = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
// 图片预览状态
|
// 图片预览状态
|
||||||
const imagePreviewVisible = ref(false);
|
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 });
|
}, { immediate: true, deep: true });
|
||||||
|
|
||||||
@@ -1864,6 +1874,31 @@ const handleAddToKnowledge = (answerEvent: any) => {
|
|||||||
position: relative;
|
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 items (flat, no timeline)
|
||||||
.event-item {
|
.event-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -1933,6 +1968,25 @@ const handleAddToKnowledge = (answerEvent: any) => {
|
|||||||
position: relative;
|
position: relative;
|
||||||
padding-left: 12px; // indent for branch lines
|
padding-left: 12px; // indent for branch lines
|
||||||
margin-top: 6px; // gap from root
|
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 {
|
.tree-child {
|
||||||
@@ -1942,12 +1996,13 @@ const handleAddToKnowledge = (answerEvent: any) => {
|
|||||||
margin-bottom: 6px; // gap between children
|
margin-bottom: 6px; // gap between children
|
||||||
|
|
||||||
// vertical trunk line (continues for non-last children)
|
// vertical trunk line (continues for non-last children)
|
||||||
|
// bottom: -6px extends the line through the margin-bottom gap between siblings
|
||||||
&::before {
|
&::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: -6px;
|
||||||
width: 0;
|
width: 0;
|
||||||
border-left: 1px dashed var(--td-component-stroke);
|
border-left: 1px dashed var(--td-component-stroke);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user