11"use client" ;
22
33import type { AttachmentData } from "@/components/ai-elements/attachments" ;
4- import type { PromptInputMessage } from "@/components/ai-elements/prompt-input" ;
5- import type { SourceDocumentUIPart } from "ai" ;
6-
74import {
85 Attachment ,
96 AttachmentInfo ,
@@ -24,6 +21,7 @@ import {
2421 ModelSelectorName ,
2522 ModelSelectorTrigger ,
2623} from "@/components/ai-elements/model-selector" ;
24+ import type { PromptInputMessage } from "@/components/ai-elements/prompt-input" ;
2725import {
2826 PromptInput ,
2927 PromptInputBody ,
@@ -52,6 +50,7 @@ import {
5250 usePromptInputReferencedSources ,
5351} from "@/components/ai-elements/prompt-input" ;
5452import { Button } from "@/components/ui/button" ;
53+ import type { SourceDocumentUIPart } from "ai" ;
5554import {
5655 AtSignIcon ,
5756 CheckIcon ,
@@ -174,29 +173,24 @@ ModelItem.displayName = "ModelItem";
174173
175174interface SourceCommandItemProps {
176175 source : SourceDocumentUIPart ;
177- index : number ;
178176 onAdd : ( source : SourceDocumentUIPart ) => void ;
179177}
180178
181- const SourceCommandItem = memo (
182- ( { source, index, onAdd } : SourceCommandItemProps ) => {
183- const handleSelect = useCallback ( ( ) => onAdd ( source ) , [ onAdd , source ] ) ;
184- return (
185- < PromptInputCommandItem
186- key = { `${ source . title } -${ index } ` }
187- onSelect = { handleSelect }
188- >
189- < GlobeIcon className = "text-primary" />
190- < div className = "flex flex-col" >
191- < span className = "font-medium text-sm" > { source . title } </ span >
192- < span className = "text-muted-foreground text-xs" >
193- { source . filename }
194- </ span >
195- </ div >
196- </ PromptInputCommandItem >
197- ) ;
198- }
199- ) ;
179+ const SourceCommandItem = memo ( ( { source, onAdd } : SourceCommandItemProps ) => {
180+ const handleSelect = useCallback ( ( ) => onAdd ( source ) , [ onAdd , source ] ) ;
181+ return (
182+ < PromptInputCommandItem
183+ key = { `${ source . filename } -${ source . title } ` }
184+ onSelect = { handleSelect }
185+ >
186+ < GlobeIcon className = "text-primary" />
187+ < div className = "flex flex-col" >
188+ < span className = "font-medium text-sm" > { source . title } </ span >
189+ < span className = "text-muted-foreground text-xs" > { source . filename } </ span >
190+ </ div >
191+ </ PromptInputCommandItem >
192+ ) ;
193+ } ) ;
200194
201195SourceCommandItem . displayName = "SourceCommandItem" ;
202196
@@ -318,10 +312,9 @@ const SampleFilesMenu = () => {
318312 s . title === source . title && s . filename === source . filename
319313 )
320314 )
321- . map ( ( source , index ) => (
315+ . map ( ( source ) => (
322316 < SourceCommandItem
323- index = { index }
324- key = { `${ source . title } -${ index } ` }
317+ key = { `${ source . filename } -${ source . title } ` }
325318 onAdd = { handleAdd }
326319 source = { source }
327320 />
0 commit comments