Open History to see the last commit
1import { ClockIcon, XIcon } from 'lucide-react'
2import type { QueueProps } from '@tanstack/ai-react/ui'
3import type { chatOptions } from '@/chat/options'
4import { Button } from '@/components/ui/button'
5
6function queuedLabel(
7 content: QueueProps<typeof chatOptions>['item']['content'],
8) {
9 if (typeof content === 'string') return content
10 if (typeof content.content === 'string') return content.content
11 const text = content.content.find((part) => part.type === 'text')
12 if (text?.type === 'text') return text.content
13 return 'Queued message'
14}
15
16export function ChatQueueItem({ item }: QueueProps<typeof chatOptions>) {
17 return (
18 <div className="flex items-center gap-2 rounded-md border bg-secondary/40 px-2 py-1.5 text-xs">
19 <ClockIcon className="text-muted-foreground size-3 shrink-0" />
20 <span className="text-muted-foreground min-w-0 flex-1 truncate">
21 {queuedLabel(item.content)}
22 </span>
23 <Button
24 aria-label="Cancel queued message"
25 onClick={() => item.cancelQueued()}
26 size="icon-sm"
27 type="button"
28 variant="ghost"
29 >
30 <XIcon className="size-3" />
31 </Button>
32 </div>
33 )
34}