Reproduction: Simply send a message and switch tab or window. Status will forever be "streaming".
<template>
<div class="flex flex-col w-full max-w-md py-24 mx-auto stretch">
<div v-for="m in showMessages" :key="m.id" class="whitespace-pre-wrap">
{{ m.role === 'user' ? 'User: ' : 'AI: ' }}
{{ m.content }}
</div>
<div>
Status is: {{ status }}
</div>
<form @submit.prevent="send">
<input
class="fixed bottom-0 w-full max-w-md p-2 mb-8 border border-gray-300 rounded shadow-xl"
v-model="input"
placeholder="Say something..."
/>
</form>
</div>
</template>
<script setup lang="ts">
import { useChat } from '@ai-sdk/vue';
const { messages, input, status, append } = useChat();
const api_key = ref(null)
const send = () => { // I use send() because it allows me to edit the body
if (!api_key.value){
api_key.value = prompt("Please add your openai API key (it's not saved)")
}
append({ role: 'user', content:input.value }, { body: { thread_id: "something something", api_key:api_key.value } })
input.value = null
}
const showMessages = computed(() => messages.value.filter(mx => mx.content.length))
</script>
Description
Reproduction: Simply send a message and switch tab or window. Status will forever be "streaming".
2025-05-02_13.50.34.mp4
code: