@@ -1015,15 +1015,40 @@ export const Chat = ({
10151015 onBashHistoryUp : navigateUp ,
10161016 onBashHistoryDown : navigateDown ,
10171017 onPasteImage : ( ) => {
1018- // Show placeholder immediately so user sees the banner right away
1018+ // Show placeholder immediately for instant feedback
10191019 const placeholderPath = addClipboardPlaceholder ( )
10201020
1021- // Check and process clipboard image in background
1021+ // Check and process clipboard in background
10221022 setTimeout ( ( ) => {
1023- // Check if clipboard actually has an image
10241023 if ( ! hasClipboardImage ( ) ) {
1025- // No image - quietly remove placeholder (brief flash is acceptable)
1024+ // No image - remove placeholder and simulate text paste
10261025 useChatStore . getState ( ) . removePendingImage ( placeholderPath )
1026+
1027+ // Read text from clipboard and insert it
1028+ try {
1029+ const { spawnSync } = require ( 'child_process' )
1030+ const textResult = spawnSync (
1031+ process . platform === 'darwin' ? 'pbpaste' :
1032+ process . platform === 'win32' ? 'powershell' : 'xclip' ,
1033+ process . platform === 'win32' ? [ '-Command' , 'Get-Clipboard' ] :
1034+ process . platform === 'linux' ? [ '-selection' , 'clipboard' , '-o' ] : [ ] ,
1035+ { encoding : 'utf-8' , timeout : 1000 }
1036+ )
1037+ if ( textResult . status === 0 && textResult . stdout ) {
1038+ const text = textResult . stdout
1039+ setInputValue ( ( prev ) => {
1040+ const before = prev . text . slice ( 0 , prev . cursorPosition )
1041+ const after = prev . text . slice ( prev . cursorPosition )
1042+ return {
1043+ text : before + text + after ,
1044+ cursorPosition : before . length + text . length ,
1045+ lastEditDueToNav : false ,
1046+ }
1047+ } )
1048+ }
1049+ } catch {
1050+ // Ignore errors - text paste just won't work
1051+ }
10271052 return
10281053 }
10291054
@@ -1040,7 +1065,7 @@ export const Chat = ({
10401065 void addPendingImageFromFile ( result . imagePath , cwd , placeholderPath )
10411066 } , 0 )
10421067
1043- return true
1068+ return true // Always consume - we handle text paste ourselves if needed
10441069 } ,
10451070 } ) ,
10461071 [
0 commit comments