Skip to content

Commit c1c41ba

Browse files
Merge pull request #296 from microsoft/Bugs-fixing
fix: Bug fixes of #19515,#19330,#19278
2 parents 974bea8 + a76c584 commit c1c41ba

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
3838
);
3939
const agents = planData?.agents || [];
4040

41+
React.useEffect(() => {
42+
// Initialize steps and counts from planData
43+
setSteps(planData.steps || []);
44+
setCompletedCount(planData?.plan.completed || 0);
45+
setTotal(planData?.plan.total_steps || 1);
46+
setProgress(
47+
(planData?.plan.completed || 0) / (planData?.plan.total_steps || 1)
48+
);
49+
}, [planData]);
50+
4151
const renderStatusIcon = (status: string) => {
4252
switch (status) {
4353
case "completed":
@@ -59,17 +69,6 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
5969
...step,
6070
human_approval_status: "accepted" as HumanFeedbackStatus,
6171
};
62-
63-
// Create a new array with the updated step
64-
const updatedSteps = steps.map((s) =>
65-
s.id === step.id ? updatedStep : s
66-
);
67-
68-
// Update local state to reflect changes immediately
69-
70-
setSteps(updatedSteps);
71-
setCompletedCount(completedCount + 1); // Increment completed count
72-
setProgress((completedCount + 1) / total); // Update progress
7372
// Then call the main approval function
7473
// This could be your existing OnApproveStep function that handles API calls, etc.
7574
await OnApproveStep(updatedStep, total, completedCount + 1, true);
@@ -88,15 +87,6 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
8887
human_approval_status: "rejected" as HumanFeedbackStatus,
8988
};
9089

91-
// Create a new array with the updated step
92-
const updatedSteps = steps.map((s) =>
93-
s.id === step.id ? updatedStep : s
94-
);
95-
96-
// Update local state to reflect changes immediately
97-
setSteps(updatedSteps);
98-
setCompletedCount(completedCount + 1); // Increment completed count
99-
setProgress((completedCount + 1) / total); // Update progress
10090
// Then call the main rejection function
10191
// This could be your existing OnRejectStep function that handles API calls, etc.
10292
await OnApproveStep(updatedStep, total, completedCount + 1, false);

src/frontend/src/coral/components/Progress/ProgressCircle.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface ProgressCircleProps {
66
strokeWidth?: number;
77
backgroundColor?: string;
88
fillColor?: string;
9+
borderColor?: string;
910
}
1011

1112
const ProgressCircle: React.FC<ProgressCircleProps> = ({
@@ -14,6 +15,7 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
1415
strokeWidth = 8,
1516
backgroundColor = "var(--colorNeutralBackground6)",
1617
fillColor = "var(--colorPaletteSeafoamBorderActive)",
18+
borderColor = "var(--colorNeutralStroke1)",
1719
}) => {
1820
const circleRef = useRef<SVGCircleElement>(null);
1921
const [hasMounted, setHasMounted] = useState(false);
@@ -53,6 +55,16 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
5355
fill="none"
5456
stroke={backgroundColor}
5557
strokeWidth={strokeWidth}
58+
style={{ stroke: backgroundColor, strokeWidth, strokeDasharray: "none", strokeDashoffset: 0, strokeLinecap: "round", filter: "none" }}
59+
/>
60+
<circle
61+
cx={size / 2}
62+
cy={size / 2}
63+
r={radius+4}
64+
fill="none"
65+
stroke={borderColor}
66+
strokeWidth={1}
67+
style={{ pointerEvents: "none" }}
5668
/>
5769
<circle
5870
ref={circleRef}
@@ -67,6 +79,15 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
6779
strokeLinecap="round"
6880
transform={`rotate(-90 ${size / 2} ${size / 2})`}
6981
/>
82+
<circle
83+
cx={size / 2}
84+
cy={size / 2}
85+
r={radius-4}
86+
fill="none"
87+
stroke={borderColor}
88+
strokeWidth={1}
89+
style={{ pointerEvents: "none" }}
90+
/>
7091
</svg>
7192

7293
{progress >= 1 && (

src/frontend/src/pages/PlanPage.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const PlanPage: React.FC = () => {
3434

3535
const [input, setInput] = useState("");
3636
const [planData, setPlanData] = useState<ProcessedPlanData | any>(null);
37+
const [allPlans, setAllPlans] = useState<ProcessedPlanData[]>([]);
3738
const [loading, setLoading] = useState<boolean>(true);
3839
const [submittingChatDisableInput, setSubmitting] = useState<boolean>(false);
3940
const [error, setError] = useState<Error | null>(null);
@@ -55,6 +56,14 @@ const PlanPage: React.FC = () => {
5556
return () => clearInterval(interval);
5657
}, [loading]);
5758

59+
60+
useEffect(() => {
61+
const currentPlan = allPlans.find(
62+
(plan) => plan.plan.id === planId
63+
);
64+
setPlanData(currentPlan || null);
65+
}, [allPlans,planId]);
66+
5867
const loadPlanData = useCallback(
5968
async (navigate: boolean = true) => {
6069
if (!planId) return;
@@ -70,8 +79,15 @@ const PlanPage: React.FC = () => {
7079

7180
setError(null);
7281
const data = await PlanDataService.fetchPlanData(planId,navigate);
73-
console.log("Fetched plan data:", data);
74-
setPlanData(data);
82+
let plans = [...allPlans];
83+
const existingIndex = plans.findIndex(p => p.plan.id === data.plan.id);
84+
if (existingIndex !== -1) {
85+
plans[existingIndex] = data;
86+
} else {
87+
plans.push(data);
88+
}
89+
setAllPlans(plans);
90+
//setPlanData(data);
7591
} catch (err) {
7692
console.log("Failed to load plan data:", err);
7793
setError(
@@ -87,7 +103,6 @@ const PlanPage: React.FC = () => {
87103
const handleOnchatSubmit = useCallback(
88104
async (chatInput: string) => {
89105

90-
console.log("handleOnchatSubmit called with input:", chatInput);
91106
if (!chatInput.trim()) {
92107
showToast("Please enter a clarification", "error");
93108
return;

0 commit comments

Comments
 (0)