@@ -474,9 +474,23 @@ export const useSendMessage = ({
474474 ]
475475 const uniqueImagePaths = [ ...new Set ( allImagePaths ) ]
476476
477- // Process all images
477+ // Build attachments from pending images first (for UI display)
478+ // These show in the user message regardless of processing success
479+ const attachments = pendingImages . map ( ( img ) => ( {
480+ path : img . path ,
481+ filename : img . filename ,
482+ } ) )
483+
484+ // Clear pending images immediately after capturing them
485+ // This ensures the banner hides when sending, regardless of processing outcome
486+ if ( pendingImages . length > 0 ) {
487+ useChatStore . getState ( ) . clearPendingImages ( )
488+ }
489+
490+ // Process all images for SDK
491+ const projectRoot = getProjectRoot ( )
478492 const imagePartsPromises = uniqueImagePaths . map ( ( imagePath ) =>
479- processImageFile ( imagePath , getProjectRoot ( ) ) . then ( ( result ) => {
493+ processImageFile ( imagePath , projectRoot ) . then ( ( result ) => {
480494 if ( result . success && result . imagePart ) {
481495 return {
482496 type : 'image' as const ,
@@ -487,6 +501,12 @@ export const useSendMessage = ({
487501 path : imagePath ,
488502 }
489503 }
504+ if ( ! result . success ) {
505+ logger . warn (
506+ { imagePath, error : result . error } ,
507+ 'Failed to process image for SDK' ,
508+ )
509+ }
490510 return null
491511 } ) ,
492512 )
@@ -496,12 +516,6 @@ export const useSendMessage = ({
496516 ( part ) : part is NonNullable < typeof part > => part !== null ,
497517 )
498518
499- // Build attachments array for display in user message
500- const attachments = validImageParts . map ( ( img ) => ( {
501- path : img . path ,
502- filename : img . filename || 'image' ,
503- } ) )
504-
505519 // Build message content array for SDK
506520 let messageContent : MessageContent [ ] | undefined
507521 if ( validImageParts . length > 0 ) {
@@ -522,11 +536,8 @@ export const useSendMessage = ({
522536 0 ,
523537 ) ,
524538 } ,
525- `📎 ${ validImageParts . length } image(s) attached` ,
539+ `📎 ${ validImageParts . length } image(s) attached to SDK message ` ,
526540 )
527-
528- // Clear pending images after successful processing
529- useChatStore . getState ( ) . clearPendingImages ( )
530541 }
531542
532543 // Create user message and capture its ID for later updates
0 commit comments