- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Form
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Pin Input
- Popover
- Progress
- Questionnaire
- Radio Group
- Range Calendar
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Stepper
- Switch
- Table
- Tabs
- Tags Input
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
Renamed Button to Action in components/ui/button/Button.vue.
Updated the Button page to say Action.
<script setup lang="ts">
import { useIntervalFn } from '@vueuse/core'
import { computed, ref } from 'vue'
import { Bubble, BubbleContent } from '@/components/ui/bubble'
import { Button } from '@/components/ui/button'
import { Marker, MarkerContent } from '@/components/ui/marker'
import { Message, MessageContent } from '@/components/ui/message'
interface ChatMessage {
id: string
role: 'user' | 'assistant'
text: string
checkpoint?: { label: string }
}
// The scripted conversation. A checkpoint is data on the agent's turn.
const transcript: ChatMessage[] = [
{
id: 'm1',
role: 'user',
text: 'Rename the button component to action.',
},
{
id: 'm2',
role: 'assistant',
text: 'Renamed Button to Action in components/ui/button/Button.vue.',
checkpoint: { label: 'Button renamed' },
},
{
id: 'm3',
role: 'user',
text: 'Update the docs to match.',
},
{
id: 'm4',
role: 'assistant',
text: 'Updated the Button page to say Action.',
},
]
const messages = ref<ChatMessage[]>(transcript.map(message => ({ ...message })))
// Stream the scripted reply a few characters at a time.
let reply: ChatMessage | undefined
let cursor = 0
const { isActive: busy, pause, resume } = useIntervalFn(() => {
if (!reply)
return
cursor = Math.min(reply.text.length, cursor + 3)
const last = messages.value.at(-1)
if (last?.id === reply.id)
last.text = reply.text.slice(0, cursor)
if (cursor >= reply.text.length)
pause()
}, 20, { immediate: false })
// The next scripted message the person can send.
const nextMessage = computed(() => {
const message = transcript[messages.value.length]
return message?.role === 'user' ? message : undefined
})
function restore(messageId: string) {
const index = messages.value.findIndex(message => message.id === messageId)
if (index === -1)
return
messages.value = messages.value.slice(0, index + 1)
}
function sendMessage(message: ChatMessage) {
const next = transcript[messages.value.length + 1]
messages.value = [...messages.value, { ...message }]
if (!next || next.role !== 'assistant')
return
messages.value = [...messages.value, { ...next, text: '' }]
reply = next
cursor = 0
resume()
}
</script>
<template>
<div class="flex min-h-72 w-full max-w-sm flex-col gap-4 py-6 text-sm">
<template v-for="(message, index) in messages" :key="message.id">
<Message v-if="message.role === 'user'" align="end">
<MessageContent>
<Bubble align="end" variant="muted">
<BubbleContent>{{ message.text }}</BubbleContent>
</Bubble>
</MessageContent>
</Message>
<Message v-else>
<MessageContent>
<p>{{ message.text }}</p>
</MessageContent>
</Message>
<Marker v-if="message.checkpoint" variant="separator">
<MarkerContent class="inline-flex items-center gap-2">
{{ message.checkpoint.label }}
<Button
v-if="index < messages.length - 1"
size="xs"
variant="outline"
:aria-label="`Restore to ${message.checkpoint.label}`"
@click="restore(message.id)"
>
Restore
</Button>
</MarkerContent>
</Marker>
</template>
<Button
v-if="!busy && nextMessage"
variant="outline"
size="sm"
class="mt-auto self-start"
@click="sendMessage(nextMessage)"
>
Continue
</Button>
</div>
</template>Checkpoint is a point in the conversation you can return to. It is a Marker after a turn, with a Restore button. Restore keeps that turn and drops every message after it.
Installation
Checkpoint is built with the Marker and Button components.
pnpm dlx shadcn-vue@latest add marker button
Usage
Render a marker after the turn, with a button that restores it.
<template>
<Marker variant="separator">
<MarkerContent class="inline-flex items-center gap-2">
{{ label }}
<Button size="xs" variant="outline" @click="restore">
Restore
</Button>
</MarkerContent>
</Marker>
</template>See Marker.
AI SDK
Restore replaces the thread with the messages up to and including that turn. Every later turn is removed. Send a new message to continue from there.
const index = chat.messages.findIndex(message => message.id === messageId)
chat.messages = chat.messages.slice(0, index + 1)Stream the checkpoint as a data part on the agent's turn. Send the same id again only when you mean to update that checkpoint.
const stream = createUIMessageStream({
execute: async ({ writer }) => {
writer.write({
type: 'data-checkpoint',
id: 'rename',
data: { label: 'Button renamed' },
})
},
})const checkpoint = message.parts.find(part => part.type === 'data-checkpoint')Migrating from AI Elements Vue
If you added Checkpoint from AI Elements Vue, your project has a components/ai-elements/checkpoint/ folder. Paste this prompt into your coding agent to rebuild it on Marker and Button. Every export keeps its name and props, so the code that uses it keeps working.
Migrate components/ai-elements/checkpoint/ from AI Elements Vue to the shadcn-vue Marker and Button components.
Keep every export, with the same name and props, so the code that imports it keeps working. Only change how each part renders.
1. Install the components: npx shadcn-vue@latest add marker button
2. Read https://www.shadcn-vue.com/docs/ai-elements/checkpoint and build Checkpoint the same way.
3. Rebuild each part:
- Checkpoint renders a Marker with variant="separator" and a MarkerContent, instead of a Separator.
- CheckpointIcon renders a MarkerIcon.
- CheckpointTrigger renders a Button with size="xs" and variant="outline", like "Restore". Keep its tooltip prop on the Tooltip.
4. Remove the imports the files no longer use.
5. Run vue-tsc and fix any errors.Sponsors
Your logo hereshadcn-vue is free and open source. Sponsorship keeps it maintained.
Become a sponsor