File tree 4 files changed +9
-0
lines changed
4 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,9 @@ export default function ChatScreen() {
157
157
clearExtraContext ( ) ;
158
158
} ;
159
159
160
+ // for vscode context
161
+ textarea . refOnSubmit . current = sendNewMessage ;
162
+
160
163
const handleEditMessage = async ( msg : Message , content : string ) => {
161
164
if ( ! viewingChat ) return ;
162
165
setCurrNodeId ( msg . id ) ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export interface ChatTextareaApi {
37
37
setValue : ( value : string ) => void ;
38
38
focus : ( ) => void ;
39
39
ref : React . RefObject < HTMLTextAreaElement > ;
40
+ refOnSubmit : React . MutableRefObject < ( ( ) => void ) | null > ; // Submit handler
40
41
onInput : ( event : React . FormEvent < HTMLTextAreaElement > ) => void ; // Input handler
41
42
}
42
43
@@ -46,6 +47,7 @@ export interface ChatTextareaApi {
46
47
export function useChatTextarea ( initValue : string ) : ChatTextareaApi {
47
48
const [ savedInitValue , setSavedInitValue ] = useState < string > ( initValue ) ;
48
49
const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
50
+ const onSubmitRef = useRef < ( ( ) => void ) | null > ( null ) ;
49
51
50
52
// Effect to set initial value and height on mount or when initValue changes
51
53
useEffect ( ( ) => {
@@ -91,6 +93,7 @@ export function useChatTextarea(initValue: string): ChatTextareaApi {
91
93
}
92
94
} ,
93
95
ref : textareaRef ,
96
+ refOnSubmit : onSubmitRef ,
94
97
onInput : handleInput ,
95
98
} ;
96
99
}
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ export const useVSCodeContext = (textarea: ChatTextareaApi) => {
33
33
} ) ;
34
34
}
35
35
textarea . focus ( ) ;
36
+ setTimeout ( ( ) => {
37
+ textarea . refOnSubmit . current ?.( ) ;
38
+ } , 10 ) ; // wait for setExtraContext to finish
36
39
}
37
40
} ;
38
41
You can’t perform that action at this time.
0 commit comments