File tree Expand file tree Collapse file tree
src/app/(app)/projects/[projectId]/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,6 +154,19 @@ function isUserMessageMarker(data: unknown): data is UserMessageMarker {
154154 ) ;
155155}
156156
157+ function isFileUIPart ( part : unknown ) : part is FileUIPart {
158+ if ( ! part || typeof part !== "object" ) return false ;
159+ const value = part as Partial < FileUIPart > ;
160+ const hasValidFilename =
161+ value . filename === undefined || typeof value . filename === "string" ;
162+ return (
163+ value . type === "file" &&
164+ typeof value . mediaType === "string" &&
165+ hasValidFilename &&
166+ typeof value . url === "string"
167+ ) ;
168+ }
169+
157170function ChatComposerAttachments ( ) {
158171 const attachments = usePromptInputAttachments ( ) ;
159172
@@ -222,7 +235,7 @@ function reconstructMessages(
222235 if ( ! seenUserMessageIds . has ( marker . id ) ) {
223236 seenUserMessageIds . add ( marker . id ) ;
224237 const markerParts : AppUIMessage [ "parts" ] = [
225- ...( marker . files ?? [ ] ) ,
238+ ...( marker . files ?. filter ( isFileUIPart ) ?? [ ] ) ,
226239 ...( marker . content . length > 0
227240 ? [ { text : marker . content , type : "text" as const } ]
228241 : [ ] ) ,
You can’t perform that action at this time.
0 commit comments