Skip to content

Commit f58c816

Browse files
committed
Refactor plan retrieval and task list UI
Added get_all_plans_by_team_id_status to CosmosDBClient and DatabaseBase for filtering plans by team and status. Updated backend API to use this method for completed plans. Refactored frontend TaskList and related components to remove in-progress tasks and simplify UI, and fixed agent type usage in PlanPage.
1 parent b0b90de commit f58c816

File tree

11 files changed

+71
-61
lines changed

11 files changed

+71
-61
lines changed

src/backend/common/database/cosmosdb.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,17 @@ async def get_all_plans_by_team_id(self, team_id: str) -> List[Plan]:
269269
]
270270
return await self.query_items(query, parameters, Plan)
271271

272+
273+
async def get_all_plans_by_team_id_status(self, team_id: str, status: str) -> List[Plan]:
274+
"""Retrieve all plans for a specific team."""
275+
query = "SELECT * FROM c WHERE c.team_id=@team_id AND c.data_type=@data_type and c.user_id=@user_id and c.overall_status=@status"
276+
parameters = [
277+
{"name": "@user_id", "value": self.user_id},
278+
{"name": "@team_id", "value": team_id},
279+
{"name": "@data_type", "value": DataType.plan},
280+
{"name": "@status", "value": status},
281+
]
282+
return await self.query_items(query, parameters, Plan)
272283
# Step Operations
273284
async def add_step(self, step: Step) -> None:
274285
"""Add a step to CosmosDB."""

src/backend/common/database/database_base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ async def add_plan(self, plan: Plan) -> None:
8181
"""Add a plan to the database."""
8282
pass
8383

84-
8584
@abstractmethod
8685
async def update_plan(self, plan: Plan) -> None:
8786
"""Update a plan in the database."""
@@ -106,10 +105,19 @@ async def get_plan(self, plan_id: str) -> Optional[Plan]:
106105
async def get_all_plans(self) -> List[Plan]:
107106
"""Retrieve all plans for the user."""
108107
pass
108+
109109
@abstractmethod
110110
async def get_all_plans_by_team_id(self, team_id: str) -> List[Plan]:
111111
"""Retrieve all plans for a specific team."""
112112
pass
113+
114+
@abstractmethod
115+
async def get_all_plans_by_team_id_status(
116+
self, team_id: str, status: str
117+
) -> List[Plan]:
118+
"""Retrieve all plans for a specific team."""
119+
pass
120+
113121
@abstractmethod
114122
async def get_data_by_type_and_session_id(
115123
self, data_type: str, session_id: str
@@ -206,4 +214,4 @@ async def set_current_team(self, current_team: UserCurrentTeam) -> None:
206214
@abstractmethod
207215
async def update_current_team(self, current_team: UserCurrentTeam) -> None:
208216
"""Update the current team for a user."""
209-
pass
217+
pass

src/backend/v3/api/router.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,14 @@ async def plan_approval(
381381
# orchestration_config.plans[human_feedback.m_plan_id],
382382
# )
383383
try:
384-
result = await PlanService.handle_plan_approval(human_feedback, user_id)
385-
print("Plan approval processed:", result)
384+
result = await PlanService.handle_plan_approval(
385+
human_feedback, user_id
386+
)
387+
print("Plan approval processed:", result)
386388
except ValueError as ve:
387-
print(f"ValueError processing plan approval: {ve}")
389+
print(f"ValueError processing plan approval: {ve}")
388390
except Exception as e:
389-
print(f"Error processing plan approval: {e}")
391+
print(f"Error processing plan approval: {e}")
390392
track_event_if_configured(
391393
"PlanApprovalReceived",
392394
{
@@ -397,7 +399,7 @@ async def plan_approval(
397399
"feedback": human_feedback.feedback,
398400
},
399401
)
400-
402+
401403
return {"status": "approval recorded"}
402404
else:
403405
logging.warning(
@@ -424,9 +426,9 @@ async def user_clarification(
424426
)
425427
# Set the approval in the orchestration config
426428
if user_id and human_feedback.request_id:
427-
### validate rai
428-
if human_feedback.answer != None or human_feedback.answer !="":
429-
if not await rai_success(human_feedback.answer, False):
429+
### validate rai
430+
if human_feedback.answer != None or human_feedback.answer != "":
431+
if not await rai_success(human_feedback.answer, False):
430432
track_event_if_configured(
431433
"RAI failed",
432434
{
@@ -451,9 +453,6 @@ async def user_clarification(
451453
},
452454
)
453455

454-
455-
456-
457456
if (
458457
orchestration_config
459458
and human_feedback.request_id in orchestration_config.clarifications
@@ -890,7 +889,6 @@ async def delete_team_config(team_id: str, request: Request):
890889
raise HTTPException(status_code=500, detail="Internal server error occurred")
891890

892891

893-
894892
@app_v3.post("/select_team")
895893
async def select_team(selection: TeamSelectionRequest, request: Request):
896894
"""
@@ -980,6 +978,7 @@ async def select_team(selection: TeamSelectionRequest, request: Request):
980978
)
981979
raise HTTPException(status_code=500, detail="Internal server error occurred")
982980

981+
983982
# Get plans is called in the initial side rendering of the frontend
984983
@app_v3.get("/plans")
985984
async def get_plans(request: Request):
@@ -1058,9 +1057,10 @@ async def get_plans(request: Request):
10581057
if not current_team:
10591058
return []
10601059

1061-
all_plans = await memory_store.get_all_plans_by_team_id(team_id=current_team.team_id)
1060+
all_plans = await memory_store.get_all_plans_by_team_id_status(
1061+
team_id=current_team.team_id, status=PlanStatus.completed
1062+
)
10621063

1063-
steps_for_all_plans = []
10641064
# Create list of PlanWithSteps and update step counts
10651065
list_of_plans_with_steps = []
10661066
for plan in all_plans:
@@ -1074,7 +1074,7 @@ async def get_plans(request: Request):
10741074

10751075
# Get plans is called in the initial side rendering of the frontend
10761076
@app_v3.get("/plan")
1077-
async def get_plan_by_id(request: Request, plan_id: str):
1077+
async def get_plan_by_id(request: Request, plan_id: str):
10781078
"""
10791079
Retrieve plans for the current user.
10801080

src/frontend/src/components/content/PlanChat.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
174174
setInput={setInput}
175175
submittingChatDisableInput={submittingChatDisableInput}
176176
OnChatSubmit={OnChatSubmit}
177-
showChatInput={true}
178177
waitingForPlan={waitingForPlan}
179178
loading={false} />
180179
</div>

src/frontend/src/components/content/PlanChatBody.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Button } from "@fluentui/react-components";
44
import { SendRegular } from "@fluentui/react-icons";
55

66
interface SimplifiedPlanChatProps extends PlanChatProps {
7-
showChatInput: boolean;
87
waitingForPlan: boolean;
98
}
109
const PlanChatBody: React.FC<SimplifiedPlanChatProps> = ({
@@ -13,12 +12,10 @@ const PlanChatBody: React.FC<SimplifiedPlanChatProps> = ({
1312
setInput,
1413
submittingChatDisableInput,
1514
OnChatSubmit,
16-
showChatInput,
1715
waitingForPlan
1816
}) => {
19-
if (!showChatInput) {
20-
return null;
21-
}
17+
console.log("Rendering PlanChatBody", { planData, input, submittingChatDisableInput, waitingForPlan });
18+
2219
return (
2320

2421
<div style={{

src/frontend/src/components/content/PlanPanelLeft.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ const PlanPanelLeft: React.FC<PlanPanelLefProps> = ({
200200

201201
<br />
202202
<TaskList
203-
inProgressTasks={inProgressTasks}
204203
completedTasks={completedTasks}
205204
onTaskSelect={handleTaskSelect}
206205
loading={plansLoading}

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from "@fluentui/react-components";
1919

2020
const TaskList: React.FC<TaskListProps> = ({
21-
inProgressTasks,
2221
completedTasks,
2322
onTaskSelect,
2423
loading,
@@ -82,18 +81,8 @@ const TaskList: React.FC<TaskListProps> = ({
8281
<Accordion defaultOpenItems="1" collapsible>
8382
<AccordionItem value="1">
8483
<AccordionHeader expandIconPosition="end">
85-
In progress
84+
Completed
8685
</AccordionHeader>
87-
<AccordionPanel>
88-
{loading
89-
? Array.from({ length: 5 }, (_, i) =>
90-
renderSkeleton(`in-progress-${i}`)
91-
)
92-
: inProgressTasks.map(renderTaskItem)}
93-
</AccordionPanel>
94-
</AccordionItem>
95-
<AccordionItem value="2">
96-
<AccordionHeader expandIconPosition="end">Completed</AccordionHeader>
9786
<AccordionPanel>
9887
{loading
9988
? Array.from({ length: 5 }, (_, i) =>
@@ -102,6 +91,7 @@ const TaskList: React.FC<TaskListProps> = ({
10291
: completedTasks.map(renderTaskItem)}
10392
</AccordionPanel>
10493
</AccordionItem>
94+
10595
</Accordion>
10696
</div>
10797
);

src/frontend/src/components/content/streaming/StreamingBufferMessage.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import rehypePrism from "rehype-prism";
99

1010
const renderBufferMessage = (streamingMessageBuffer: string) => {
1111
const [isExpanded, setIsExpanded] = useState(false);
12-
12+
1313
if (!streamingMessageBuffer || streamingMessageBuffer.trim() === "") return null;
14-
15-
const previewText = streamingMessageBuffer.length > 500
14+
15+
const previewText = streamingMessageBuffer.length > 500
1616
? streamingMessageBuffer.substring(0, 500) + "..."
1717
: streamingMessageBuffer;
18-
18+
1919
return (
2020
<div style={{
2121
backgroundColor: 'var(--colorNeutralBackground2)',
@@ -24,16 +24,16 @@ const renderBufferMessage = (streamingMessageBuffer: string) => {
2424
padding: '16px',
2525
marginBottom: '16px'
2626
}}>
27-
28-
<div style={{
29-
display: 'flex',
30-
justifyContent: 'space-between',
27+
28+
<div style={{
29+
display: 'flex',
30+
justifyContent: 'space-between',
3131
alignItems: 'center',
3232
marginBottom: isExpanded ? '16px' : '8px'
3333
}}>
34-
<div style={{
35-
display: 'flex',
36-
alignItems: 'center',
34+
<div style={{
35+
display: 'flex',
36+
alignItems: 'center',
3737
gap: '12px'
3838
}}>
3939
<CheckmarkCircle20Regular style={{
@@ -43,18 +43,18 @@ const renderBufferMessage = (streamingMessageBuffer: string) => {
4343
height: '20px',
4444
flexShrink: 0
4545
}} />
46-
<span style={{
47-
fontWeight: '500',
46+
<span style={{
47+
fontWeight: '500',
4848
color: 'var(--colorNeutralForeground1)',
4949
fontSize: '14px',
5050
lineHeight: '20px'
5151
}}>
5252
AI Thinking Process
5353
</span>
5454
</div>
55-
56-
<Button
57-
appearance="secondary"
55+
56+
<Button
57+
appearance="secondary"
5858
size="small"
5959
// icon={isExpanded ? <ChevronDownRegular /> : <ChevronRightRegular />}
6060
onClick={() => setIsExpanded(!isExpanded)}
@@ -69,13 +69,13 @@ const renderBufferMessage = (streamingMessageBuffer: string) => {
6969
Details
7070
</Button>
7171
</div>
72-
72+
7373
{!isExpanded && (
7474
<div style={{
7575
display: 'flex',
7676
alignItems: 'flex-start',
7777
gap: '8px',
78-
marginLeft: '32px'
78+
marginLeft: '32px'
7979
}}>
8080
<ArrowTurnDownRightRegular style={{
8181
color: 'var(--colorNeutralForeground3)',
@@ -88,11 +88,17 @@ const renderBufferMessage = (streamingMessageBuffer: string) => {
8888
fontSize: '14px',
8989
lineHeight: '1.4'
9090
}}>
91-
{previewText}
91+
<ReactMarkdown
92+
remarkPlugins={[remarkGfm]}
93+
rehypePlugins={[rehypePrism]}
94+
>
95+
{previewText}
96+
</ReactMarkdown>
97+
9298
</div>
9399
</div>
94100
)}
95-
101+
96102
{isExpanded && (
97103
<div style={{
98104
// backgroundColor: 'var(--colorNeutralBackground1)',

src/frontend/src/models/enums.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,5 @@ export enum WebsocketMessageType {
255255
export enum AgentMessageType {
256256
HUMAN_AGENT = "Human_Agent",
257257
AI_AGENT = "AI_Agent",
258-
}
258+
}
259+

src/frontend/src/models/taskList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export interface Task {
88
}
99

1010
export interface TaskListProps {
11-
inProgressTasks: Task[];
1211
completedTasks: Task[];
1312
onTaskSelect: (taskId: string) => void;
1413
loading?: boolean;

0 commit comments

Comments
 (0)