GitHub

Original file line numberDiff line numberDiff line change

@@ -96,6 +96,14 @@ const slots = defineSlots<ChatMessagesSlots>()

9696
9797

const getProxySlots = () => omit(slots, ['default', 'indicator', 'viewport'])

9898
99+

const showIndicator = computed(() => {

100+

if (props.status === 'submitted') return true

101+

if (props.status !== 'streaming') return false

102+
103+

const lastMessage = props.messages?.[props.messages.length - 1]

104+

return lastMessage?.role === 'assistant' && !lastMessage.parts?.length

105+

})

106+
99107

const appConfig = useAppConfig() as ChatMessages['AppConfig']

100108

const uiProp = useComponentUI('chatMessages', props)

101109

@@ -311,7 +319,7 @@ onMounted(() => {

311319

</slot>

312320
313321

<UChatMessage

314-

v-if="status === 'submitted'"

322+

v-if="showIndicator"

315323

id="indicator"

316324

role="assistant"

317325

v-bind="{ ...assistantProps, actions: undefined, parts: [] }"

Read the original on github.com ↗