@@ -88,9 +88,11 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
8888 const apiMetrics = useMemo ( ( ) => getApiMetrics ( modifiedMessages ) , [ modifiedMessages ] )
8989
9090 const [ inputValue , setInputValue ] = useState ( "" )
91+ const [ lastInputValue , setLastInputValue ] = useState ( "" )
9192 const textAreaRef = useRef < HTMLTextAreaElement > ( null )
9293 const [ textAreaDisabled , setTextAreaDisabled ] = useState ( false )
9394 const [ selectedImages , setSelectedImages ] = useState < string [ ] > ( [ ] )
95+ const [ lastInputImages , setLastInputImages ] = useState < string [ ] > ( [ ] )
9496
9597 // we need to hold on to the ask because useEffect > lastMessage will always let us know when an ask comes in and handle it, but by the time handleMessage is called, the last message might not be the ask anymore (it could be a say that followed)
9698 const [ clineAsk , setClineAsk ] = useState < ClineAsk | undefined > ( undefined )
@@ -327,6 +329,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
327329
328330 const handleChatReset = useCallback ( ( ) => {
329331 // Only reset message-specific state, preserving mode.
332+ setLastInputValue ( inputValue )
333+ setLastInputImages ( selectedImages )
330334 setInputValue ( "" )
331335 setTextAreaDisabled ( true )
332336 setSelectedImages ( [ ] )
@@ -336,7 +340,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
336340 // setPrimaryButtonText(undefined)
337341 // setSecondaryButtonText(undefined)
338342 disableAutoScrollRef . current = false
339- } , [ ] )
343+ } , [ inputValue , selectedImages ] )
340344
341345 const handleSendMessage = useCallback (
342346 ( text : string , images : string [ ] ) => {
@@ -507,6 +511,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
507511 textAreaRef . current ?. focus ( )
508512 }
509513 break
514+ case "PearAIKeysNotFound" :
515+ setInputValue ( lastInputValue )
516+ setTextAreaDisabled ( false )
517+ setSelectedImages ( lastInputImages )
518+ setEnableButtons ( true )
519+ disableAutoScrollRef . current = true
520+ break
510521 }
511522 break
512523 case "selectedImages" :
@@ -547,6 +558,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
547558 handleSetChatBoxMessage ,
548559 handlePrimaryButtonClick ,
549560 handleSecondaryButtonClick ,
561+ lastInputValue ,
562+ lastInputImages ,
563+ setInputValue ,
564+ setTextAreaDisabled ,
565+ setSelectedImages ,
566+ setEnableButtons ,
550567 ] ,
551568 )
552569
0 commit comments