1-
2- import { useState , useEffect } from 'react' ;
3- import { Message , chatTranslations } from '../types/chat' ;
1+ import { useEffect , useState } from 'react' ;
2+ import { chatTranslations , Message } from '../types/chat' ;
43import mcpTools from '../utils/mcpTools' ;
54// The API endpoint URL
65const API_URL = 'https://chat-598109592614.europe-west1.run.app' ;
@@ -10,8 +9,7 @@ export const useChat = () => {
109 const [ isLoading , setIsLoading ] = useState ( false ) ;
1110
1211 const getCurrentRole = ( ) => {
13- const chatWrapper = document . getElementById ( 'chat-wrapper' ) ;
14- return chatWrapper ?. getAttribute ( 'role' ) || 'bot' ;
12+ return document . getElementById ( 'role' ) ?. getAttribute ( 'value' ) ;
1513 } ;
1614
1715
@@ -98,11 +96,17 @@ export const useChat = () => {
9896 }
9997 } ;
10098
101- const sendMessage = ( messageText : string ) => {
99+ const sendMessage = ( messageText : string , sender : "user" | "model" = 'user' ) => {
100+ // FIXME should have proper tool to invoke role change
101+ if ( messageText . trim ( ) === '' && sender === 'model' ) {
102+ handleAgentResponse ( messages ) ;
103+ return ;
104+ }
105+
102106 const userMessage : Message = {
103107 id : Math . random ( ) . toString ( 36 ) . substring ( 2 , 15 ) ,
104108 text : messageText ,
105- sender : 'user' ,
109+ sender : sender ,
106110 timestamp : new Date ( )
107111 } ;
108112
0 commit comments