Skip to content

Commit 462f574

Browse files
fix(stage-ui): fix placeholder check logic (close #898) (#909)
--------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent b22acdb commit 462f574

File tree

1 file changed

+8
-1
lines changed
  • packages/stage-ui/src/components/scenarios/chat

1 file changed

+8
-1
lines changed

packages/stage-ui/src/components/scenarios/chat/history.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ onMounted(scrollToBottom)
4848
const streaming = computed<ChatAssistantMessage & { context?: ContextMessage } & { createdAt?: number }>(() => props.streamingMessage ?? { role: 'assistant', content: '', slices: [], tool_results: [], createdAt: Date.now() })
4949
const showStreamingPlaceholder = computed(() => (streaming.value.slices?.length ?? 0) === 0 && !streaming.value.content)
5050
const streamingTs = computed(() => streaming.value?.createdAt)
51+
function shouldShowPlaceholder(message: ChatHistoryItem) {
52+
const ts = streamingTs.value
53+
if (ts == null)
54+
return false
55+
56+
return message.context?.createdAt === ts || message.createdAt === ts
57+
}
5158
const renderMessages = computed<ChatHistoryItem[]>(() => {
5259
if (!props.sending)
5360
return props.messages
@@ -80,7 +87,7 @@ const renderMessages = computed<ChatHistoryItem[]>(() => {
8087
<ChatAssistantItem
8188
:message="message"
8289
:label="labels.assistant"
83-
:show-placeholder="message.context?.createdAt === streamingTs ? showStreamingPlaceholder : false"
90+
:show-placeholder="shouldShowPlaceholder(message) && showStreamingPlaceholder"
8491
:variant="variant"
8592
/>
8693
</div>

0 commit comments

Comments
 (0)