Skip to content

Commit 55f5ef4

Browse files
committed
Merge branch 'macae-UIWS-wip2' of https://github.com/microsoft/Multi-Agent-Custom-Automation-Engine-Solution-Accelerator into macae-v3-dev-marktayl
2 parents 330c56c + 7c4a25a commit 55f5ef4

File tree

10 files changed

+300
-423
lines changed

10 files changed

+300
-423
lines changed

src/backend/app_kernel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"http://localhost:3000", # Add this for local development
7575
"https://localhost:3000", # Add this if using HTTPS locally
7676
"http://127.0.0.1:3000",
77+
"http://127.0.0.1:3001",
7778
], # Allow all origins for development; restrict in production
7879
allow_credentials=True,
7980
allow_methods=["*"],

src/frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import './App.css';
33
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
4-
import { HomePage, PlanPage, PlanCreatePage } from './pages';
4+
import { HomePage, PlanPage } from './pages';
55
import { useWebSocket } from './hooks/useWebSocket';
66

77
function App() {

src/frontend/src/api/apiService.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ export class APIService {
114114
* @param inputTask The task description and optional session ID
115115
* @returns Promise with the response containing plan ID and status
116116
*/
117-
async createPlan(inputTask: InputTask): Promise<{ plan_id: string; status: string; session_id: string }> {
118-
return apiClient.post(API_ENDPOINTS.CREATE_PLAN, inputTask);
117+
// async createPlan(inputTask: InputTask): Promise<{ plan_id: string; status: string; session_id: string }> {
118+
// return apiClient.post(API_ENDPOINTS.CREATE_PLAN, inputTask);
119+
// }
120+
121+
async createPlan(inputTask: InputTask): Promise<{ status: string; session_id: string }> {
122+
return apiClient.post(API_ENDPOINTS.CREATE_PLAN, inputTask);
119123
}
120124

121125
/**

src/frontend/src/components/content/HomeInput.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { TeamConfig } from "../../models/Team";
1717
import { TaskService } from "../../services/TaskService";
1818
import { NewTaskService } from "../../services/NewTaskService";
1919
import { RAIErrorCard, RAIErrorData } from "../errors";
20+
import { apiService } from "../../api/apiService";
2021

2122
import ChatInput from "@/coral/modules/ChatInput";
2223
import InlineToaster, { useInlineToaster } from "../toast/InlineToaster";
@@ -83,13 +84,16 @@ const HomeInput: React.FC<HomeInputProps> = ({
8384
textareaRef.current.style.height = "auto";
8485
}
8586

86-
if (response.plan_id && response.plan_id !== null) {
87+
if (response.session_id && response.session_id !== null) {
8788
showToast("Plan created!", "success");
8889
dismissToast(id);
8990

9091
// Navigate to create page (no team ID in URL anymore)
9192
console.log('HomeInput: Navigating to plan creation with team:', selectedTeam?.name);
92-
navigate(`/plan/${response.plan_id}`);
93+
console.log('HomeInput: Navigating to plan creation with session:', response.session_id);
94+
console.log('HomeInput: Plan created with session:', response.session_id);
95+
96+
navigate(`/plan/${response.session_id}`);
9397
} else {
9498
showToast("Failed to create plan", "error");
9599
dismissToast(id);

src/frontend/src/pages/HomePage.tsx

Lines changed: 117 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ 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';
2425

2526
/**
2627
* HomePage component - displays task lists and provides navigation
@@ -35,43 +36,129 @@ const HomePage: React.FC = () => {
3536
/**
3637
* Load teams and set default team on component mount
3738
*/
38-
useEffect(() => {
39-
const loadDefaultTeam = async () => {
40-
let defaultTeam = TeamService.getStoredTeam();
41-
if (defaultTeam) {
42-
setSelectedTeam(defaultTeam);
43-
console.log('Default team loaded from storage:', defaultTeam.name);
39+
// useEffect(() => {
40+
// const loadDefaultTeam = async () => {
41+
// let defaultTeam = TeamService.getStoredTeam();
42+
// if (defaultTeam) {
43+
// setSelectedTeam(defaultTeam);
44+
// console.log('Default team loaded from storage:', defaultTeam.name);
45+
46+
// setIsLoadingTeam(false);
47+
// return true;
48+
// }
49+
// setIsLoadingTeam(true);
50+
// try {
51+
// const teams = await TeamService.getUserTeams();
52+
// console.log('All teams loaded:', teams);
53+
// if (teams.length > 0) {
54+
// // Always prioritize "Business Operations Team" as default
55+
// const hrTeam = teams.find(team => team.name === "Human Resources Team");
56+
// defaultTeam = hrTeam || teams[0];
57+
58+
// TeamService.storageTeam(defaultTeam);
59+
// setSelectedTeam(defaultTeam);
60+
// console.log('Default team loaded:', defaultTeam.name, 'with', defaultTeam.starting_tasks?.length || 0, 'starting tasks');
61+
// console.log('Team logo:', defaultTeam.logo);
62+
// console.log('Team description:', defaultTeam.description);
63+
64+
// } else {
65+
// console.log('No teams found - user needs to upload a team configuration');
66+
// // Even if no teams are found, we clear the loading state to show the "no team" message
67+
// }
68+
// } catch (error) {
69+
// console.error('Error loading default team:', error);
70+
// } finally {
71+
// setIsLoadingTeam(false);
72+
// }
73+
// };
74+
75+
// loadDefaultTeam();
76+
// }, []);
4477

45-
setIsLoadingTeam(false);
46-
return true;
78+
useEffect(() => {
79+
const initTeam = async () => {
80+
setIsLoadingTeam(true);
81+
82+
try {
83+
console.log('Initializing team from backend...');
84+
85+
// Call the backend init_team endpoint (takes ~20 seconds)
86+
const initResponse = await initializeTeam();
87+
88+
if (initResponse.status === 'Request started successfully' && initResponse.team_id) {
89+
console.log('Team initialization completed:', initResponse.team_id);
90+
91+
// Now fetch the actual team details using the team_id
92+
const teams = await TeamService.getUserTeams();
93+
const initializedTeam = teams.find(team => team.team_id === initResponse.team_id);
94+
95+
if (initializedTeam) {
96+
setSelectedTeam(initializedTeam);
97+
TeamService.storageTeam(initializedTeam);
98+
99+
console.log('Team loaded successfully:', initializedTeam.name);
100+
console.log('Team agents:', initializedTeam.agents?.length || 0);
101+
102+
showToast(
103+
`${initializedTeam.name} team initialized successfully with ${initializedTeam.agents?.length || 0} agents`,
104+
"success"
105+
);
106+
} else {
107+
// Fallback: if we can't find the specific team, use HR team or first available
108+
console.log('Specific team not found, using default selection logic');
109+
const hrTeam = teams.find(team => team.name === "Human Resources Team");
110+
const defaultTeam = hrTeam || teams[0];
111+
112+
if (defaultTeam) {
113+
setSelectedTeam(defaultTeam);
114+
TeamService.storageTeam(defaultTeam);
115+
showToast(
116+
`${defaultTeam.name} team loaded as default`,
117+
"success"
118+
);
119+
}
120+
}
121+
122+
} else {
123+
throw new Error('Invalid response from init_team endpoint');
47124
}
48-
setIsLoadingTeam(true);
125+
126+
} catch (error) {
127+
console.error('Error initializing team from backend:', error);
128+
showToast("Team initialization failed, using fallback", "warning");
129+
130+
// Fallback to the old client-side method
49131
try {
132+
console.log('Using fallback: client-side team loading...');
50133
const teams = await TeamService.getUserTeams();
51-
console.log('All teams loaded:', teams);
52134
if (teams.length > 0) {
53-
// Always prioritize "Business Operations Team" as default
54-
const businessOpsTeam = teams.find(team => team.name === "Business Operations Team");
55-
defaultTeam = businessOpsTeam || teams[0];
56-
TeamService.storageTeam(defaultTeam);
135+
const hrTeam = teams.find(team => team.name === "Human Resources Team");
136+
const defaultTeam = hrTeam || teams[0];
57137
setSelectedTeam(defaultTeam);
58-
console.log('Default team loaded:', defaultTeam.name, 'with', defaultTeam.starting_tasks?.length || 0, 'starting tasks');
59-
console.log('Team logo:', defaultTeam.logo);
60-
console.log('Team description:', defaultTeam.description);
61-
console.log('Is Business Operations Team:', defaultTeam.name === "Business Operations Team");
138+
TeamService.storageTeam(defaultTeam);
139+
140+
showToast(
141+
`${defaultTeam.name} team loaded (fallback mode)`,
142+
"info"
143+
);
62144
} else {
63145
console.log('No teams found - user needs to upload a team configuration');
64-
// Even if no teams are found, we clear the loading state to show the "no team" message
146+
showToast(
147+
"No teams found. Please upload a team configuration.",
148+
"warning"
149+
);
65150
}
66-
} catch (error) {
67-
console.error('Error loading default team:', error);
68-
} finally {
69-
setIsLoadingTeam(false);
151+
} catch (fallbackError) {
152+
console.error('Fallback team loading also failed:', fallbackError);
153+
showToast("Failed to load team configuration", "error");
70154
}
71-
};
155+
} finally {
156+
setIsLoadingTeam(false);
157+
}
158+
};
72159

73-
loadDefaultTeam();
74-
}, []);
160+
initTeam();
161+
}, [showToast]);
75162

76163
/**
77164
* Handle new task creation from the "New task" button
@@ -109,12 +196,12 @@ const HomePage: React.FC = () => {
109196
console.log('Teams refreshed after upload:', teams.length);
110197

111198
if (teams.length > 0) {
112-
// Always keep "Business Operations Team" as default, even after new uploads
113-
const businessOpsTeam = teams.find(team => team.name === "Business Operations Team");
114-
const defaultTeam = businessOpsTeam || teams[0];
199+
// Always keep "Human Resources Team" as default, even after new uploads
200+
const hrTeam = teams.find(team => team.name === "Human Resources Team");
201+
const defaultTeam = hrTeam || teams[0];
115202
setSelectedTeam(defaultTeam);
116203
console.log('Default team after upload:', defaultTeam.name);
117-
console.log('Business Operations Team remains default');
204+
console.log('Human Resources Team remains default');
118205
showToast(
119206
`Team uploaded successfully! ${defaultTeam.name} remains your default team.`,
120207
"success"

0 commit comments

Comments
 (0)