@@ -24,6 +24,7 @@ export const ConversationManager: React.FC = () => {
2424 const [ selectedConversation , setSelectedConversation ] = useState < string | null > ( null ) ;
2525 const [ messageInput , setMessageInput ] = useState ( '' ) ;
2626 const [ activeConversations , setActiveConversations ] = useState < Map < string , RemoteConversation > > ( new Map ( ) ) ;
27+ const [ currentAgent , setCurrentAgent ] = useState < AgentBase | null > ( null ) ;
2728
2829 // Initialize conversation manager
2930 useEffect ( ( ) => {
@@ -67,9 +68,27 @@ export const ConversationManager: React.FC = () => {
6768 const createConversation = async ( ) => {
6869 if ( ! manager ) return ;
6970
71+ // Validate required settings
72+ if ( ! settings . apiKey . trim ( ) ) {
73+ setError ( 'LLM API Key is required. Please configure it in settings.' ) ;
74+ return ;
75+ }
76+
77+ if ( ! settings . modelName . trim ( ) ) {
78+ setError ( 'Model name is required. Please configure it in settings.' ) ;
79+ return ;
80+ }
81+
7082 setLoading ( true ) ;
7183 setError ( null ) ;
7284 try {
85+ console . log ( 'Settings values:' , {
86+ modelName : settings . modelName ,
87+ apiKey : settings . apiKey ? `${ settings . apiKey . substring ( 0 , 10 ) } ...` : 'EMPTY' ,
88+ agentServerUrl : settings . agentServerUrl ,
89+ agentServerApiKey : settings . agentServerApiKey ? `${ settings . agentServerApiKey . substring ( 0 , 10 ) } ...` : 'EMPTY'
90+ } ) ;
91+
7392 const agent : AgentBase = {
7493 name : 'CodeActAgent' ,
7594 llm : {
@@ -78,6 +97,16 @@ export const ConversationManager: React.FC = () => {
7897 } ,
7998 } ;
8099
100+ console . log ( 'Creating conversation with agent:' , {
101+ name : agent . name ,
102+ model : agent . llm . model ,
103+ hasApiKey : ! ! agent . llm . api_key ,
104+ apiKeyValue : agent . llm . api_key
105+ } ) ;
106+
107+ // Store the current agent configuration
108+ setCurrentAgent ( agent ) ;
109+
81110 const conversation = await manager . createConversation ( agent , {
82111 initialMessage : 'Hello! I\'m ready to help you with your tasks.' ,
83112 maxIterations : 50 ,
@@ -143,16 +172,21 @@ export const ConversationManager: React.FC = () => {
143172 let conversation = activeConversations . get ( conversationId ) ;
144173
145174 if ( ! conversation ) {
175+ console . log ( 'Loading conversation:' , conversationId ) ;
146176 // Load the conversation if not already active
147177 conversation = await manager . loadConversation ( conversationId ) ;
148178 setActiveConversations ( prev => new Map ( prev . set ( conversationId , conversation ! ) ) ) ;
149179 }
150180
181+ console . log ( 'Sending message to conversation:' , conversationId , 'Message:' , message ) ;
151182 await conversation . sendMessage ( message ) ;
183+
184+ console . log ( 'Running conversation:' , conversationId ) ;
152185 await conversation . run ( ) ;
153186
154187 setMessageInput ( '' ) ;
155188 } catch ( err ) {
189+ console . error ( 'Error sending message:' , err ) ;
156190 setError ( err instanceof Error ? err . message : 'Failed to send message' ) ;
157191 }
158192 } ;
0 commit comments