@@ -88,9 +88,11 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
88
88
const apiMetrics = useMemo ( ( ) => getApiMetrics ( modifiedMessages ) , [ modifiedMessages ] )
89
89
90
90
const [ inputValue , setInputValue ] = useState ( "" )
91
+ const [ lastInputValue , setLastInputValue ] = useState ( "" )
91
92
const textAreaRef = useRef < HTMLTextAreaElement > ( null )
92
93
const [ textAreaDisabled , setTextAreaDisabled ] = useState ( false )
93
94
const [ selectedImages , setSelectedImages ] = useState < string [ ] > ( [ ] )
95
+ const [ lastInputImages , setLastInputImages ] = useState < string [ ] > ( [ ] )
94
96
95
97
// 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)
96
98
const [ clineAsk , setClineAsk ] = useState < ClineAsk | undefined > ( undefined )
@@ -327,6 +329,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
327
329
328
330
const handleChatReset = useCallback ( ( ) => {
329
331
// Only reset message-specific state, preserving mode.
332
+ setLastInputValue ( inputValue )
333
+ setLastInputImages ( selectedImages )
330
334
setInputValue ( "" )
331
335
setTextAreaDisabled ( true )
332
336
setSelectedImages ( [ ] )
@@ -336,7 +340,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
336
340
// setPrimaryButtonText(undefined)
337
341
// setSecondaryButtonText(undefined)
338
342
disableAutoScrollRef . current = false
339
- } , [ ] )
343
+ } , [ inputValue , selectedImages ] )
340
344
341
345
const handleSendMessage = useCallback (
342
346
( text : string , images : string [ ] ) => {
@@ -507,6 +511,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
507
511
textAreaRef . current ?. focus ( )
508
512
}
509
513
break
514
+ case "PearAIKeysNotFound" :
515
+ setInputValue ( lastInputValue )
516
+ setTextAreaDisabled ( false )
517
+ setSelectedImages ( lastInputImages )
518
+ setEnableButtons ( true )
519
+ disableAutoScrollRef . current = true
520
+ break
510
521
}
511
522
break
512
523
case "selectedImages" :
@@ -547,6 +558,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
547
558
handleSetChatBoxMessage ,
548
559
handlePrimaryButtonClick ,
549
560
handleSecondaryButtonClick ,
561
+ lastInputValue ,
562
+ lastInputImages ,
563
+ setInputValue ,
564
+ setTextAreaDisabled ,
565
+ setSelectedImages ,
566
+ setEnableButtons ,
550
567
] ,
551
568
)
552
569
0 commit comments