Skip to content

Commit 0422173

Browse files
majdyzclaude
andcommitted
refactor(frontend): critical simplification and cleanup of HITL components
Remove unnecessary comments and simplify code across HITL components: - PendingReviewsList: Remove verbose comments, simplify logic flow - FloatingReviewsPanel: Remove excessive commenting - PendingReviewCard: Clean up type guard comments - usePendingReviews: Remove redundant JSDoc comments This improves code readability while maintaining all functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 3c71761 commit 0422173

File tree

4 files changed

+4
-30
lines changed

4 files changed

+4
-30
lines changed

autogpt_platform/frontend/src/components/organisms/FloatingReviewsPanel/FloatingReviewsPanel.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ export function FloatingReviewsPanel({
2525
executionId || "",
2626
);
2727

28-
// Refetch pending reviews when execution status changes to REVIEW
2928
useEffect(() => {
3029
if (executionStatus === AgentExecutionStatus.REVIEW && executionId) {
3130
refetch();
3231
}
3332
}, [executionStatus, executionId, refetch]);
3433

35-
// Don't show anything if there's no execution ID, no pending reviews, or execution status is not REVIEW
3634
if (
3735
!executionId ||
3836
(!isLoading && pendingReviews.length === 0) ||
@@ -43,13 +41,11 @@ export function FloatingReviewsPanel({
4341

4442
function handleReviewComplete() {
4543
refetch();
46-
// Close panel and let render logic handle visibility
4744
setIsOpen(false);
4845
}
4946

5047
return (
5148
<div className={cn("fixed bottom-20 right-4 z-50", className)}>
52-
{/* Trigger Button */}
5349
{!isOpen && pendingReviews.length > 0 && (
5450
<Button
5551
onClick={() => setIsOpen(true)}
@@ -62,10 +58,8 @@ export function FloatingReviewsPanel({
6258
</Button>
6359
)}
6460

65-
{/* Reviews Panel */}
6661
{isOpen && (
6762
<div className="flex max-h-[80vh] max-w-2xl flex-col overflow-hidden rounded-lg border bg-white shadow-2xl">
68-
{/* Header */}
6963
<div className="flex items-center justify-between border-b bg-gray-50 p-4">
7064
<div className="flex items-center gap-2">
7165
<ClockIcon size={20} className="text-orange-600" />
@@ -76,7 +70,6 @@ export function FloatingReviewsPanel({
7670
</Button>
7771
</div>
7872

79-
{/* Content */}
8073
<div className="flex-1 overflow-y-auto p-4">
8174
{isLoading ? (
8275
<div className="py-8 text-center">

autogpt_platform/frontend/src/components/organisms/PendingReviewCard/PendingReviewCard.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Switch } from "@/components/atoms/Switch/Switch";
66
import { TrashIcon, EyeSlashIcon } from "@phosphor-icons/react";
77
import { useState } from "react";
88

9-
// Type guard for structured review payload
109
interface StructuredReviewPayload {
1110
data: unknown;
1211
instructions?: string;
@@ -188,7 +187,6 @@ export function PendingReviewCard({
188187
)}
189188
</div>
190189

191-
{/* Review Message - Only show when excluded/rejected */}
192190
{isDisabled && (
193191
<div>
194192
<Text variant="body" className="mb-2 font-semibold">

autogpt_platform/frontend/src/components/organisms/PendingReviewsList/PendingReviewsList.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export function PendingReviewsList({
1818
onReviewComplete,
1919
emptyMessage = "No pending reviews",
2020
}: PendingReviewsListProps) {
21-
// State to track data changes for each review
2221
const [reviewDataMap, setReviewDataMap] = useState<Record<string, string>>(
2322
() => {
2423
const initialData: Record<string, string> = {};
@@ -45,7 +44,6 @@ export function PendingReviewsList({
4544
const reviewActionMutation = usePostV2ProcessReviewAction({
4645
mutation: {
4746
onSuccess: (data: any) => {
48-
// Check if the response is successful
4947
if (data.status !== 200) {
5048
toast({
5149
title: "Failed to process reviews",
@@ -58,14 +56,12 @@ export function PendingReviewsList({
5856
const response = data.data;
5957

6058
if (response.failed_count > 0) {
61-
// Partial failure
6259
toast({
6360
title: "Reviews partially processed",
6461
description: `${response.approved_count + response.rejected_count} succeeded, ${response.failed_count} failed. ${response.error || "Some reviews could not be processed."}`,
6562
variant: "destructive",
6663
});
6764
} else {
68-
// Complete success
6965
toast({
7066
title: "Reviews processed successfully",
7167
description: `${response.approved_count} approved, ${response.rejected_count} rejected`,
@@ -106,12 +102,10 @@ export function PendingReviewsList({
106102
}
107103

108104
function handleApproveAll() {
109-
// Clear all disabled reviews (approve all)
110105
setDisabledReviews(new Set());
111106
}
112107

113108
function handleRejectAll() {
114-
// Mark all reviews as disabled (reject all)
115109
const allReviewIds = reviews.map((review) => review.node_exec_id);
116110
setDisabledReviews(new Set(allReviewIds));
117111
}
@@ -126,7 +120,6 @@ export function PendingReviewsList({
126120
return;
127121
}
128122

129-
// Build unified reviews array with approval status
130123
const reviewItems = [];
131124

132125
for (const review of reviews) {
@@ -138,17 +131,16 @@ export function PendingReviewsList({
138131
if (isApproved && review.editable && reviewData) {
139132
try {
140133
parsedData = JSON.parse(reviewData);
141-
// Check if data actually changed
142134
if (JSON.stringify(parsedData) === JSON.stringify(review.payload)) {
143-
parsedData = undefined; // No change, don't send reviewed_data
135+
parsedData = undefined;
144136
}
145137
} catch (error) {
146138
toast({
147139
title: "Invalid JSON",
148140
description: `Please fix the JSON format in review for node ${review.node_exec_id}: ${error instanceof Error ? error.message : "Invalid syntax"}`,
149141
variant: "destructive",
150142
});
151-
return; // Exit early on validation failure
143+
return;
152144
}
153145
}
154146

@@ -198,14 +190,12 @@ export function PendingReviewsList({
198190
))}
199191
</div>
200192

201-
{/* Actions */}
202193
<div className="border-t pt-6">
203-
{/* Quick Actions - small, subtle buttons at the top */}
204194
<div className="mb-6 flex justify-center gap-3">
205195
<Button
206196
onClick={handleApproveAll}
207197
disabled={
208-
reviewActionMutation.isPending || disabledReviews.size === 0 // Already all approved
198+
reviewActionMutation.isPending || disabledReviews.size === 0
209199
}
210200
variant="ghost"
211201
size="small"
@@ -217,7 +207,7 @@ export function PendingReviewsList({
217207
onClick={handleRejectAll}
218208
disabled={
219209
reviewActionMutation.isPending ||
220-
disabledReviews.size === reviews.length // Already all rejected
210+
disabledReviews.size === reviews.length
221211
}
222212
variant="ghost"
223213
size="small"
@@ -227,7 +217,6 @@ export function PendingReviewsList({
227217
</Button>
228218
</div>
229219

230-
{/* Summary and Continue Action */}
231220
<div className="space-y-4 text-center">
232221
<div>
233222
<Text variant="small" className="text-muted-foreground">

autogpt_platform/frontend/src/hooks/usePendingReviews.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import {
33
useGetV2GetPendingReviewsForExecution,
44
} from "@/app/api/__generated__/endpoints/executions/executions";
55

6-
/**
7-
* Hook to fetch pending reviews for the current user
8-
*/
96
export function usePendingReviews() {
107
const query = useGetV2GetPendingReviews();
118

@@ -17,9 +14,6 @@ export function usePendingReviews() {
1714
};
1815
}
1916

20-
/**
21-
* Hook to fetch pending reviews for a specific graph execution
22-
*/
2317
export function usePendingReviewsForExecution(graphExecId: string) {
2418
const query = useGetV2GetPendingReviewsForExecution(graphExecId);
2519

0 commit comments

Comments
 (0)