Skip to content

Commit 9cc880f

Browse files
Merge pull request #292 from microsoft/Bugs-fixing
fix: p2/p3 Bug fixes
2 parents 34f5a49 + 516dac4 commit 9cc880f

File tree

9 files changed

+171
-125
lines changed

9 files changed

+171
-125
lines changed

src/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
content="MACAE - Multi-Agent Custom Automation Engine"
1111
/>
1212
<link rel="apple-touch-icon" href="/logo192.png" />
13-
<link rel="manifest" href="/manifest.json" />
13+
<!-- <link rel="manifest" href="/manifest.json" /> -->
1414
<title>Multi-Agent - Custom Automation Engine</title>
1515
</head>
1616
<body>

src/frontend/src/api/apiService.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class APIService {
160160

161161
if (useCache) {
162162
const cachedPlan = this._cache.get<{ plan_with_steps: PlanWithSteps; messages: PlanMessage[] }>(cacheKey);
163-
//if (cachedPlan) return cachedPlan;
163+
if (cachedPlan) return cachedPlan;
164164

165165
return this._requestTracker.trackRequest(cacheKey, fetcher);
166166
}

src/frontend/src/components/content/TaskDetails.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
118118
</div>
119119
</div>
120120
<div>
121-
<Body1Strong>{planData.plan.initial_goal}</Body1Strong>
121+
<Tooltip content={planData.plan.initial_goal} relationship={"label"}>
122+
<Body1Strong
123+
className="goal-text"
124+
>
125+
{planData.plan.initial_goal}
126+
</Body1Strong>
127+
</Tooltip>
122128
<br />
123129
<Text size={200}>
124130
{completedCount} of {total} completed

src/frontend/src/components/content/TaskList.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ const TaskList: React.FC<TaskListProps> = ({
4545
<div className="task-name-truncated" title={task.name}>
4646
{task.name}
4747
</div>
48-
49-
50-
{task.date && (
48+
{task.date && task.status == "completed" &&(
5149
<Caption1 className="task-list-task-date">{task.date}</Caption1>
5250
)}
51+
{task.status == "inprogress" &&(
52+
<Caption1 className="task-list-task-date">{`${task?.completed_steps} of ${task?.total_steps} completed`}</Caption1>
53+
)}
5354
</div>
5455
<Menu>
5556
<MenuTrigger>

src/frontend/src/models/taskList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export interface Task {
33
name: string;
44
status: 'inprogress' | 'completed';
55
date?: string;
6+
completed_steps?: number;
7+
total_steps?: number;
68
}
79

810
export interface TaskListProps {

src/frontend/src/pages/PlanPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const PlanPage: React.FC = () => {
6969
}
7070

7171
setError(null);
72-
const data = await PlanDataService.fetchPlanData(planId);
72+
const data = await PlanDataService.fetchPlanData(planId,navigate);
7373
console.log("Fetched plan data:", data);
7474
setPlanData(data);
7575
} catch (err) {
@@ -146,7 +146,7 @@ const PlanPage: React.FC = () => {
146146

147147

148148
useEffect(() => {
149-
loadPlanData();
149+
loadPlanData(true);
150150
}, [loadPlanData]);
151151

152152
const handleNewTaskButton = () => {
Lines changed: 142 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,160 @@
1-
import { PlanWithSteps, Step, AgentType, ProcessedPlanData, PlanMessage } from '@/models';
2-
import { apiService } from '@/api';
3-
1+
import {
2+
PlanWithSteps,
3+
Step,
4+
AgentType,
5+
ProcessedPlanData,
6+
PlanMessage,
7+
} from "@/models";
8+
import { apiService } from "@/api";
49

510
/**
611
* Service for processing and managing plan data operations
712
*/
8-
export class PlanDataService { /**
9-
* Fetch plan details by plan ID and process the data
10-
* @param planId Plan ID to fetch
11-
* @returns Promise with processed plan data
12-
*/
13-
static async fetchPlanData(planId: string): Promise<ProcessedPlanData> {
14-
try {
15-
// Use optimized getPlanById method for better performance
16-
const planBody = await apiService.getPlanById(planId);
17-
return this.processPlanData(planBody.plan_with_steps, planBody.messages || []);
18-
} catch (error) {
19-
console.log('Failed to fetch plan data:', error);
20-
throw error;
21-
}
13+
export class PlanDataService {
14+
/**
15+
* Fetch plan details by plan ID and process the data
16+
* @param planId Plan ID to fetch
17+
* @returns Promise with processed plan data
18+
*/
19+
static async fetchPlanData(
20+
planId: string,
21+
useCache: boolean
22+
): Promise<ProcessedPlanData> {
23+
try {
24+
// Use optimized getPlanById method for better performance
25+
const planBody = await apiService.getPlanById(planId, useCache);
26+
return this.processPlanData(
27+
planBody.plan_with_steps,
28+
planBody.messages || []
29+
);
30+
} catch (error) {
31+
console.log("Failed to fetch plan data:", error);
32+
throw error;
2233
}
34+
}
2335

24-
/**
25-
* Process plan data to extract agents, steps, and clarification status
26-
* @param plan PlanWithSteps object to process
27-
* @returns Processed plan data
28-
*/
29-
static processPlanData(plan: PlanWithSteps, messages: PlanMessage[]): ProcessedPlanData {
30-
// Extract unique agents from steps
31-
const uniqueAgents = new Set<AgentType>();
32-
plan.steps.forEach(step => {
33-
if (step.agent) {
34-
uniqueAgents.add(step.agent);
35-
}
36-
});
36+
/**
37+
* Process plan data to extract agents, steps, and clarification status
38+
* @param plan PlanWithSteps object to process
39+
* @returns Processed plan data
40+
*/
41+
static processPlanData(
42+
plan: PlanWithSteps,
43+
messages: PlanMessage[]
44+
): ProcessedPlanData {
45+
// Extract unique agents from steps
46+
const uniqueAgents = new Set<AgentType>();
47+
plan.steps.forEach((step) => {
48+
if (step.agent) {
49+
uniqueAgents.add(step.agent);
50+
}
51+
});
3752

38-
// Convert Set to Array for easier handling
39-
const agents = Array.from(uniqueAgents);
53+
// Convert Set to Array for easier handling
54+
const agents = Array.from(uniqueAgents);
4055

41-
// Get all steps
42-
const steps = plan.steps;
56+
// Get all steps
57+
const steps = plan.steps;
4358

44-
// Check if human_clarification_request is not null
45-
const hasClarificationRequest = plan.human_clarification_request != null && plan.human_clarification_request.trim().length > 0;
46-
const hasClarificationResponse = plan.human_clarification_response != null && plan.human_clarification_response.trim().length > 0;
47-
const enableChat = hasClarificationRequest && !hasClarificationResponse;
48-
const enableStepButtons = (hasClarificationRequest && hasClarificationResponse) || (!hasClarificationRequest && !hasClarificationResponse);
49-
return {
50-
plan,
51-
agents,
52-
steps,
53-
hasClarificationRequest,
54-
hasClarificationResponse,
55-
enableChat,
56-
enableStepButtons,
57-
messages
58-
};
59-
}
59+
// Check if human_clarification_request is not null
60+
const hasClarificationRequest =
61+
plan.human_clarification_request != null &&
62+
plan.human_clarification_request.trim().length > 0;
63+
const hasClarificationResponse =
64+
plan.human_clarification_response != null &&
65+
plan.human_clarification_response.trim().length > 0;
66+
const enableChat = hasClarificationRequest && !hasClarificationResponse;
67+
const enableStepButtons =
68+
(hasClarificationRequest && hasClarificationResponse) ||
69+
(!hasClarificationRequest && !hasClarificationResponse);
70+
return {
71+
plan,
72+
agents,
73+
steps,
74+
hasClarificationRequest,
75+
hasClarificationResponse,
76+
enableChat,
77+
enableStepButtons,
78+
messages,
79+
};
80+
}
6081

61-
/**
62-
* Get steps for a specific agent type
63-
* @param plan Plan with steps
64-
* @param agentType Agent type to filter by
65-
* @returns Array of steps for the specified agent
66-
*/
67-
static getStepsForAgent(plan: PlanWithSteps, agentType: AgentType): Step[] {
68-
return apiService.getStepsForAgent(plan, agentType);
69-
}
82+
/**
83+
* Get steps for a specific agent type
84+
* @param plan Plan with steps
85+
* @param agentType Agent type to filter by
86+
* @returns Array of steps for the specified agent
87+
*/
88+
static getStepsForAgent(plan: PlanWithSteps, agentType: AgentType): Step[] {
89+
return apiService.getStepsForAgent(plan, agentType);
90+
}
7091

71-
/**
72-
* Get steps that are awaiting human feedback
73-
* @param plan Plan with steps
74-
* @returns Array of steps awaiting feedback
75-
*/
76-
static getStepsAwaitingFeedback(plan: PlanWithSteps): Step[] {
77-
return apiService.getStepsAwaitingFeedback(plan);
78-
}
92+
/**
93+
* Get steps that are awaiting human feedback
94+
* @param plan Plan with steps
95+
* @returns Array of steps awaiting feedback
96+
*/
97+
static getStepsAwaitingFeedback(plan: PlanWithSteps): Step[] {
98+
return apiService.getStepsAwaitingFeedback(plan);
99+
}
79100

80-
/**
81-
* Check if plan is complete
82-
* @param plan Plan with steps
83-
* @returns Boolean indicating if plan is complete
84-
*/
85-
static isPlanComplete(plan: PlanWithSteps): boolean {
86-
return apiService.isPlanComplete(plan);
87-
}
101+
/**
102+
* Check if plan is complete
103+
* @param plan Plan with steps
104+
* @returns Boolean indicating if plan is complete
105+
*/
106+
static isPlanComplete(plan: PlanWithSteps): boolean {
107+
return apiService.isPlanComplete(plan);
108+
}
88109

89-
/**
90-
* Get plan completion percentage
91-
* @param plan Plan with steps
92-
* @returns Completion percentage (0-100)
93-
*/
94-
static getPlanCompletionPercentage(plan: PlanWithSteps): number {
95-
return apiService.getPlanCompletionPercentage(plan);
96-
}
97-
98-
/**
99-
* Approve a plan step
100-
* @param step Step to approve
101-
* @returns Promise with API response
102-
*/
103-
static async stepStatus(step: Step, action: boolean): Promise<{ status: string }> {
104-
try {
110+
/**
111+
* Get plan completion percentage
112+
* @param plan Plan with steps
113+
* @returns Completion percentage (0-100)
114+
*/
115+
static getPlanCompletionPercentage(plan: PlanWithSteps): number {
116+
return apiService.getPlanCompletionPercentage(plan);
117+
}
105118

106-
107-
return apiService.stepStatus(
108-
step.plan_id,
109-
step.session_id,
110-
action, // approved
111-
step.id
112-
);
113-
} catch (error) {
114-
console.log('Failed to change step status:', error);
115-
throw error;
116-
}
119+
/**
120+
* Approve a plan step
121+
* @param step Step to approve
122+
* @returns Promise with API response
123+
*/
124+
static async stepStatus(
125+
step: Step,
126+
action: boolean
127+
): Promise<{ status: string }> {
128+
try {
129+
return apiService.stepStatus(
130+
step.plan_id,
131+
step.session_id,
132+
action, // approved
133+
step.id
134+
);
135+
} catch (error) {
136+
console.log("Failed to change step status:", error);
137+
throw error;
117138
}
139+
}
118140

119-
120-
/**
121-
* Submit human clarification for a plan
122-
* @param planId Plan ID
123-
* @param sessionId Session ID
124-
* @param clarification Clarification text
125-
* @returns Promise with API response
126-
*/
127-
static async submitClarification(planId: string, sessionId: string, clarification: string) {
128-
try {
129-
return apiService.submitClarification(planId, sessionId, clarification);
130-
} catch (error) {
131-
console.log('Failed to submit clarification:', error);
132-
throw error;
133-
}
141+
/**
142+
* Submit human clarification for a plan
143+
* @param planId Plan ID
144+
* @param sessionId Session ID
145+
* @param clarification Clarification text
146+
* @returns Promise with API response
147+
*/
148+
static async submitClarification(
149+
planId: string,
150+
sessionId: string,
151+
clarification: string
152+
) {
153+
try {
154+
return apiService.submitClarification(planId, sessionId, clarification);
155+
} catch (error) {
156+
console.log("Failed to submit clarification:", error);
157+
throw error;
134158
}
159+
}
135160
}

src/frontend/src/services/TaskService.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class TaskService {
2424
const task: Task = {
2525
id: plan.session_id,
2626
name: plan.initial_goal,
27+
completed_steps: plan.completed,
28+
total_steps: plan.total_steps,
2729
status: apiService.isPlanComplete(plan) ? 'completed' : 'inprogress',
2830
date: new Date(plan.timestamp).toLocaleDateString('en-US', {
2931
month: 'short',

src/frontend/src/styles/TaskDetails.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,14 @@
146146
}
147147
.strikethrough {
148148
text-decoration: line-through;
149+
}
150+
151+
.goal-text {
152+
display: -webkit-box !important;
153+
-webkit-line-clamp: 2 !important;
154+
-webkit-box-orient: vertical !important;
155+
overflow: hidden !important;
156+
text-overflow: ellipsis !important;
157+
white-space: normal !important;
158+
max-width: 300px;
149159
}

0 commit comments

Comments
 (0)