@@ -26,6 +26,7 @@ import { usageQueryKeys } from '../use-usage-query'
2626
2727import type {
2828 PendingAttachment ,
29+ PendingFileAttachment ,
2930 PendingImageAttachment ,
3031 PendingTextAttachment ,
3132} from '../../types/store'
@@ -144,6 +145,10 @@ export const prepareUserMessage = async (params: {
144145 ( a ) : a is PendingTextAttachment => a . kind === 'text' ,
145146 )
146147
148+ const pendingFileAttachments = allAttachments . filter (
149+ ( a ) : a is PendingFileAttachment => a . kind === 'file' ,
150+ )
151+
147152 // Append text attachments to the content
148153 let finalContent = content
149154 if ( pendingTextAttachments . length > 0 ) {
@@ -155,6 +160,23 @@ export const prepareUserMessage = async (params: {
155160 : textAttachmentContent
156161 }
157162
163+ // Append file/folder attachments to the content
164+ if ( pendingFileAttachments . length > 0 ) {
165+ const fileAttachmentContent = pendingFileAttachments
166+ . filter ( ( att ) => att . status === 'ready' )
167+ . map ( ( att ) =>
168+ att . isDirectory
169+ ? `[Directory: ${ att . path } ]\n${ att . content } `
170+ : `[File: ${ att . path } ]\n${ att . content } ` ,
171+ )
172+ . join ( '\n\n' )
173+ if ( fileAttachmentContent ) {
174+ finalContent = finalContent
175+ ? `${ finalContent } \n\n${ fileAttachmentContent } `
176+ : fileAttachmentContent
177+ }
178+ }
179+
158180 const { attachments : imageAttachments , messageContent } = await processImagesForMessage ( {
159181 content : finalContent ,
160182 pendingImages,
@@ -172,8 +194,18 @@ export const prepareUserMessage = async (params: {
172194 charCount : att . charCount ,
173195 } ) )
174196
197+ // Convert pending file attachments to stored file attachments for display
198+ const fileAttachmentsForMessage = pendingFileAttachments
199+ . filter ( ( att ) => att . status === 'ready' )
200+ . map ( ( att ) => ( {
201+ path : att . path ,
202+ filename : att . filename ,
203+ isDirectory : att . isDirectory ,
204+ note : att . note ,
205+ } ) )
206+
175207 // Pass original content (not finalContent) for display, but finalContent goes to agent
176- const userMessage = getUserMessage ( content , imageAttachments , textAttachmentsForMessage )
208+ const userMessage = getUserMessage ( content , imageAttachments , textAttachmentsForMessage , fileAttachmentsForMessage )
177209 const userMessageId = userMessage . id
178210 if ( imageAttachments . length > 0 ) {
179211 userMessage . attachments = imageAttachments
0 commit comments