File tree Expand file tree Collapse file tree 4 files changed +9
-0
lines changed Expand file tree Collapse file tree 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() {
157157 clearExtraContext ( ) ;
158158 } ;
159159
160+ // for vscode context
161+ textarea . refOnSubmit . current = sendNewMessage ;
162+
160163 const handleEditMessage = async ( msg : Message , content : string ) => {
161164 if ( ! viewingChat ) return ;
162165 setCurrNodeId ( msg . id ) ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export interface ChatTextareaApi {
3737 setValue : ( value : string ) => void ;
3838 focus : ( ) => void ;
3939 ref : React . RefObject < HTMLTextAreaElement > ;
40+ refOnSubmit : React . MutableRefObject < ( ( ) => void ) | null > ; // Submit handler
4041 onInput : ( event : React . FormEvent < HTMLTextAreaElement > ) => void ; // Input handler
4142}
4243
@@ -46,6 +47,7 @@ export interface ChatTextareaApi {
4647export function useChatTextarea ( initValue : string ) : ChatTextareaApi {
4748 const [ savedInitValue , setSavedInitValue ] = useState < string > ( initValue ) ;
4849 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
50+ const onSubmitRef = useRef < ( ( ) => void ) | null > ( null ) ;
4951
5052 // Effect to set initial value and height on mount or when initValue changes
5153 useEffect ( ( ) => {
@@ -91,6 +93,7 @@ export function useChatTextarea(initValue: string): ChatTextareaApi {
9193 }
9294 } ,
9395 ref : textareaRef ,
96+ refOnSubmit : onSubmitRef ,
9497 onInput : handleInput ,
9598 } ;
9699}
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ export const useVSCodeContext = (textarea: ChatTextareaApi) => {
3333 } ) ;
3434 }
3535 textarea . focus ( ) ;
36+ setTimeout ( ( ) => {
37+ textarea . refOnSubmit . current ?.( ) ;
38+ } , 10 ) ; // wait for setExtraContext to finish
3639 }
3740 } ;
3841
You can’t perform that action at this time.
0 commit comments