Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions src/frontend/src/components/content/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
);
const agents = planData?.agents || [];

React.useEffect(() => {
// Initialize steps and counts from planData
setSteps(planData.steps || []);
setCompletedCount(planData?.plan.completed || 0);
setTotal(planData?.plan.total_steps || 1);
setProgress(
(planData?.plan.completed || 0) / (planData?.plan.total_steps || 1)
);
}, [planData]);

const renderStatusIcon = (status: string) => {
switch (status) {
case "completed":
Expand All @@ -59,17 +69,6 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
...step,
human_approval_status: "accepted" as HumanFeedbackStatus,
};

// Create a new array with the updated step
const updatedSteps = steps.map((s) =>
s.id === step.id ? updatedStep : s
);

// Update local state to reflect changes immediately

setSteps(updatedSteps);
setCompletedCount(completedCount + 1); // Increment completed count
setProgress((completedCount + 1) / total); // Update progress
// Then call the main approval function
// This could be your existing OnApproveStep function that handles API calls, etc.
await OnApproveStep(updatedStep, total, completedCount + 1, true);
Expand All @@ -88,15 +87,6 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
human_approval_status: "rejected" as HumanFeedbackStatus,
};

// Create a new array with the updated step
const updatedSteps = steps.map((s) =>
s.id === step.id ? updatedStep : s
);

// Update local state to reflect changes immediately
setSteps(updatedSteps);
setCompletedCount(completedCount + 1); // Increment completed count
setProgress((completedCount + 1) / total); // Update progress
// Then call the main rejection function
// This could be your existing OnRejectStep function that handles API calls, etc.
await OnApproveStep(updatedStep, total, completedCount + 1, false);
Expand Down
21 changes: 21 additions & 0 deletions src/frontend/src/coral/components/Progress/ProgressCircle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface ProgressCircleProps {
strokeWidth?: number;
backgroundColor?: string;
fillColor?: string;
borderColor?: string;
}

const ProgressCircle: React.FC<ProgressCircleProps> = ({
Expand All @@ -14,6 +15,7 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
strokeWidth = 8,
backgroundColor = "var(--colorNeutralBackground6)",
fillColor = "var(--colorPaletteSeafoamBorderActive)",
borderColor = "var(--colorNeutralStroke1)",
}) => {
const circleRef = useRef<SVGCircleElement>(null);
const [hasMounted, setHasMounted] = useState(false);
Expand Down Expand Up @@ -53,6 +55,16 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
fill="none"
stroke={backgroundColor}
strokeWidth={strokeWidth}
style={{ stroke: backgroundColor, strokeWidth, strokeDasharray: "none", strokeDashoffset: 0, strokeLinecap: "round", filter: "none" }}
/>
<circle
cx={size / 2}
cy={size / 2}
r={radius+4}
fill="none"
stroke={borderColor}
strokeWidth={1}
style={{ pointerEvents: "none" }}
/>
<circle
ref={circleRef}
Expand All @@ -67,6 +79,15 @@ const ProgressCircle: React.FC<ProgressCircleProps> = ({
strokeLinecap="round"
transform={`rotate(-90 ${size / 2} ${size / 2})`}
/>
<circle
cx={size / 2}
cy={size / 2}
r={radius-4}
fill="none"
stroke={borderColor}
strokeWidth={1}
style={{ pointerEvents: "none" }}
/>
</svg>

{progress >= 1 && (
Expand Down
21 changes: 18 additions & 3 deletions src/frontend/src/pages/PlanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const PlanPage: React.FC = () => {

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


useEffect(() => {
const currentPlan = allPlans.find(
(plan) => plan.plan.id === planId
);
setPlanData(currentPlan || null);
}, [allPlans,planId]);

const loadPlanData = useCallback(
async (navigate: boolean = true) => {
if (!planId) return;
Expand All @@ -70,8 +79,15 @@ const PlanPage: React.FC = () => {

setError(null);
const data = await PlanDataService.fetchPlanData(planId,navigate);
console.log("Fetched plan data:", data);
setPlanData(data);
let plans = [...allPlans];
const existingIndex = plans.findIndex(p => p.plan.id === data.plan.id);
if (existingIndex !== -1) {
plans[existingIndex] = data;
} else {
plans.push(data);
}
setAllPlans(plans);
//setPlanData(data);
} catch (err) {
console.log("Failed to load plan data:", err);
setError(
Expand All @@ -87,7 +103,6 @@ const PlanPage: React.FC = () => {
const handleOnchatSubmit = useCallback(
async (chatInput: string) => {

console.log("handleOnchatSubmit called with input:", chatInput);
if (!chatInput.trim()) {
showToast("Please enter a clarification", "error");
return;
Expand Down
Loading