@@ -115,7 +115,8 @@ export const Chat = ({
115115
116116 // Message pagination - show last N messages with "Load previous" button
117117 const MESSAGE_BATCH_SIZE = 15
118- const [ visibleMessageCount , setVisibleMessageCount ] = useState ( MESSAGE_BATCH_SIZE )
118+ const [ visibleMessageCount , setVisibleMessageCount ] =
119+ useState ( MESSAGE_BATCH_SIZE )
119120
120121 const queryClient = useQueryClient ( )
121122 const [ , startUiTransition ] = useTransition ( )
@@ -638,17 +639,16 @@ export const Chat = ({
638639 ensureQueueActiveBeforeSubmit ( )
639640
640641 const preserveInput = options ?. preserveInputValue === true
641- const previousInputValue =
642- preserveInput
643- ? ( ( ) => {
644- const {
645- inputValue : text ,
646- cursorPosition,
647- lastEditDueToNav,
648- } = useChatStore . getState ( )
649- return { text, cursorPosition, lastEditDueToNav }
650- } ) ( )
651- : null
642+ const previousInputValue = preserveInput
643+ ? ( ( ) => {
644+ const {
645+ inputValue : text ,
646+ cursorPosition,
647+ lastEditDueToNav,
648+ } = useChatStore . getState ( )
649+ return { text, cursorPosition, lastEditDueToNav }
650+ } ) ( )
651+ : null
652652 const preservedPendingImages =
653653 preserveInput && useChatStore . getState ( ) . pendingImages . length > 0
654654 ? [ ...useChatStore . getState ( ) . pendingImages ]
@@ -717,11 +717,9 @@ export const Chat = ({
717717 // Mark this followup as clicked (persisted per toolCallId)
718718 useChatStore . getState ( ) . markFollowupClicked ( toolCallId , index )
719719
720- // Fill the input with the followup prompt so the user can modify it before sending
721- setInputValue ( {
722- text : prompt ,
723- cursorPosition : prompt . length ,
724- lastEditDueToNav : false ,
720+ // Send the followup prompt directly, preserving the user's current input
721+ void onSubmitPrompt ( prompt , agentMode , {
722+ preserveInputValue : true ,
725723 } )
726724 }
727725
@@ -732,7 +730,7 @@ export const Chat = ({
732730 handleFollowupClick ,
733731 )
734732 }
735- } , [ setInputValue ] )
733+ } , [ onSubmitPrompt , agentMode ] )
736734
737735 // handleSlashItemClick is defined later after feedback/publish stores are available
738736
@@ -839,7 +837,12 @@ export const Chat = ({
839837 }
840838 }
841839 } ,
842- [ saveCurrentInput , openFeedbackForMessage , openPublishMode , preSelectAgents ] ,
840+ [
841+ saveCurrentInput ,
842+ openFeedbackForMessage ,
843+ openPublishMode ,
844+ preSelectAgents ,
845+ ] ,
843846 )
844847
845848 // Click handler for slash menu items - executes command immediately
@@ -943,12 +946,7 @@ export const Chat = ({
943946 const handleSubmit = useCallback ( async ( ) => {
944947 const result = await onSubmitPrompt ( inputValue , agentMode )
945948 handleCommandResult ( result )
946- } , [
947- onSubmitPrompt ,
948- inputValue ,
949- agentMode ,
950- handleCommandResult ,
951- ] )
949+ } , [ onSubmitPrompt , inputValue , agentMode , handleCommandResult ] )
952950
953951 const totalMentionMatches = agentMatches . length + fileMatches . length
954952 const historyNavUpEnabled =
@@ -1256,7 +1254,8 @@ export const Chat = ({
12561254 return topLevelMessages . slice ( - visibleMessageCount )
12571255 } , [ topLevelMessages , visibleMessageCount ] )
12581256
1259- const hiddenMessageCount = topLevelMessages . length - visibleTopLevelMessages . length
1257+ const hiddenMessageCount =
1258+ topLevelMessages . length - visibleTopLevelMessages . length
12601259
12611260 const handleLoadPreviousMessages = useCallback ( ( ) => {
12621261 setVisibleMessageCount ( ( prev ) => prev + MESSAGE_BATCH_SIZE )
0 commit comments