Skip to content

Commit ba12990

Browse files
committed
Team load functioning
1 parent 55f5ef4 commit ba12990

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

src/backend/v3/common/services/team_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def get_team_configuration(
198198
"""
199199
try:
200200
# Get the specific configuration using the team-specific method
201-
team_config = await self.memory_context.get_team_by_id(team_id)
201+
team_config = await self.memory_context.get_team(team_id)
202202

203203
if team_config is None:
204204
return None

src/backend/v3/magentic_agents/magentic_agent_factory.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ async def get_agents(self, team_config_input: TeamConfiguration) -> List:
133133
# self.logger.info(f"Loading team configuration from: {file_path}")
134134

135135
try:
136-
# team = self.parse_team_config(file_path)
137-
# self.logger.info(f"Parsed team '{team.name}' with {len(team.agents)} agents")
138136

139137
initalized_agents = []
140138

@@ -146,7 +144,7 @@ async def get_agents(self, team_config_input: TeamConfiguration) -> List:
146144
initalized_agents.append(agent)
147145
self._agent_list.append(agent) # Keep track for cleanup
148146

149-
self.logger.info(f"✅ Agent {i}/{len(team.agents)} created: {agent_cfg.name}")
147+
self.logger.info(f"✅ Agent {i}/{len(team_config_input.agents)} created: {agent_cfg.name}")
150148

151149
except (UnsupportedModelError, InvalidConfigurationError) as e:
152150
self.logger.warning(f"Skipped agent {agent_cfg.name}: {e}")
@@ -155,7 +153,7 @@ async def get_agents(self, team_config_input: TeamConfiguration) -> List:
155153
self.logger.error(f"Failed to create agent {agent_cfg.name}: {e}")
156154
continue
157155

158-
self.logger.info(f"Successfully created {len(initalized_agents)}/{len(team.agents)} agents for team '{team.name}'")
156+
self.logger.info(f"Successfully created {len(initalized_agents)}/{len(team_config_input.agents)} agents for team '{team_config_input.name}'")
159157
return initalized_agents
160158

161159
except Exception as e:

src/frontend/src/pages/HomePage.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { TaskService } from '../services/TaskService';
2121
import { TeamConfig } from '../models/Team';
2222
import { TeamService } from '../services/TeamService';
2323
import InlineToaster, { useInlineToaster } from "../components/toast/InlineToaster";
24-
import { initializeTeam } from '@/api/config';
2524

2625
/**
2726
* HomePage component - displays task lists and provides navigation
@@ -83,14 +82,14 @@ useEffect(() => {
8382
console.log('Initializing team from backend...');
8483

8584
// Call the backend init_team endpoint (takes ~20 seconds)
86-
const initResponse = await initializeTeam();
85+
const initResponse = await TeamService.initializeTeam();
8786

88-
if (initResponse.status === 'Request started successfully' && initResponse.team_id) {
89-
console.log('Team initialization completed:', initResponse.team_id);
87+
if (initResponse.data?.status === 'Request started successfully' && initResponse.data?.team_id) {
88+
console.log('Team initialization completed:', initResponse.data?.team_id);
9089

9190
// Now fetch the actual team details using the team_id
9291
const teams = await TeamService.getUserTeams();
93-
const initializedTeam = teams.find(team => team.team_id === initResponse.team_id);
92+
const initializedTeam = teams.find(team => team.team_id === initResponse.data?.team_id);
9493

9594
if (initializedTeam) {
9695
setSelectedTeam(initializedTeam);
@@ -158,7 +157,7 @@ useEffect(() => {
158157
};
159158

160159
initTeam();
161-
}, [showToast]);
160+
}, []);
162161

163162
/**
164163
* Handle new task creation from the "New task" button

src/frontend/src/services/TeamService.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,46 @@ export class TeamService {
1919
}
2020
}
2121

22+
/**
23+
* Initialize user's team with default HR team configuration
24+
* This calls the backend /init_team endpoint which sets up the default team
25+
*/
26+
static async initializeTeam(): Promise<{
27+
success: boolean;
28+
data?: {
29+
status: string;
30+
team_id: string;
31+
};
32+
error?: string;
33+
}> {
34+
try {
35+
console.log('Calling /v3/init_team endpoint...');
36+
const response = await apiClient.get('/v3/init_team');
37+
38+
console.log('Team initialization response:', response);
39+
40+
return {
41+
success: true,
42+
data: response
43+
};
44+
} catch (error: any) {
45+
console.error('Team initialization failed:', error);
46+
47+
let errorMessage = 'Failed to initialize team';
48+
49+
if (error.response?.data?.detail) {
50+
errorMessage = error.response.data.detail;
51+
} else if (error.message) {
52+
errorMessage = error.message;
53+
}
54+
55+
return {
56+
success: false,
57+
error: errorMessage
58+
};
59+
}
60+
}
61+
2262
static getStoredTeam(): TeamConfig | null {
2363
if (typeof window === 'undefined' || !window.localStorage) return null;
2464
try {

src/frontend/src/services/WebSocketService.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class WebSocketService {
5858
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
5959
const wsHost = process.env.REACT_APP_WS_HOST || '127.0.0.1:8000';
6060
const processId = crypto.randomUUID(); // Generate unique process ID for this session
61-
const wsUrl = `${wsProtocol}//${wsHost}/socket/${processId}`;
61+
const wsUrl = `${wsProtocol}//${wsHost}/api/v3/socket/${processId}`;
6262

6363
console.log('Connecting to WebSocket:', wsUrl);
6464

0 commit comments

Comments
 (0)