Skip to content

Commit 7dbf4e3

Browse files
committed
Update plan model and status handling across backend and frontend
Refactored Plan model fields in frontend to match backend, replacing 'title' and 'description' with 'initial_goal' and updating status fields. Adjusted backend to ensure plan completion only when total steps are greater than zero. Updated API and TaskService to use new fields and status logic for consistency.
1 parent f76bb3f commit 7dbf4e3

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

src/backend/common/models/messages_kernel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ def update_step_counts(self):
232232
self.completed = status_counts[StepStatus.completed]
233233
self.failed = status_counts[StepStatus.failed]
234234

235-
# Mark the plan as complete if the sum of completed and failed steps equals the total number of steps
236-
if self.completed + self.failed == self.total_steps:
235+
236+
if self.total_steps > 0 and (self.completed + self.failed) == self.total_steps:
237237
self.overall_status = PlanStatus.completed
238+
# Mark the plan as complete if the sum of completed and failed steps equals the total number of steps
239+
238240

239241

240242
# Message classes for communication between agents

src/backend/v3/api/router.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,16 @@ async def get_plans(request: Request):
10301030

10311031
all_plans = await memory_store.get_all_plans_by_team_id(team_id=current_team.team_id)
10321032

1033-
return all_plans
1033+
steps_for_all_plans = []
1034+
# Create list of PlanWithSteps and update step counts
1035+
list_of_plans_with_steps = []
1036+
for plan in all_plans:
1037+
plan_with_steps = PlanWithSteps(**plan.model_dump(), steps=[])
1038+
plan_with_steps.overall_status
1039+
plan_with_steps.update_step_counts()
1040+
list_of_plans_with_steps.append(plan_with_steps)
1041+
1042+
return list_of_plans_with_steps
10341043

10351044

10361045
# Get plans is called in the initial side rendering of the frontend

src/frontend/src/models/plan.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export interface BaseModel {
88
/** Unique identifier */
99
id: string;
1010
/** Timestamp when created */
11-
created_at: string;
11+
1212
/** Timestamp when last updated */
13-
updated_at: string;
13+
timestamp: string;
1414
}
1515

1616
/**
@@ -24,11 +24,10 @@ export interface Plan extends BaseModel {
2424
/** User identifier */
2525
user_id: string;
2626
/** Plan title */
27-
title: string;
28-
/** Plan description */
29-
description: string;
27+
initial_goal: string;
28+
3029
/** Current status of the plan */
31-
status: PlanStatus;
30+
overall_status: PlanStatus;
3231
/** Human clarification request text */
3332
human_clarification_request?: string;
3433
/** Human clarification response text */

src/frontend/src/services/TaskService.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export class TaskService {
2727
plansData.forEach((plan) => {
2828
const task: Task = {
2929
id: plan.session_id,
30-
name: plan.title,
30+
name: plan.initial_goal,
3131
completed_steps: plan.completed,
3232
total_steps: plan.total_steps,
33-
status: PlanDataService.isPlanComplete(plan) ? "completed" : "inprogress",
33+
status: plan.overall_status === PlanStatus.COMPLETED ? "completed" : "inprogress",
3434
date: new Intl.DateTimeFormat(undefined, {
3535
dateStyle: "long",
3636
// timeStyle: "short",
37-
}).format(new Date(plan.updated_at)),
37+
}).format(new Date(plan.timestamp)),
3838
};
3939

4040
// Categorize based on plan status and completion

0 commit comments

Comments
 (0)