Skip to content

Commit af9e5b5

Browse files
Bug fix of #20489
1 parent b3073cc commit af9e5b5

File tree

1 file changed

+81
-32
lines changed

1 file changed

+81
-32
lines changed

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

Lines changed: 81 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,45 +146,94 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
146146
<Caption1>{functionOrDetails}</Caption1>
147147
)}
148148
</Body1>
149-
<div className="task-details-action-buttons">
149+
<div className="task-details-action-buttons">
150150
{step.human_approval_status !== "accepted" &&
151151
step.human_approval_status !== "rejected" && (
152-
<> <Tooltip relationship="label" content={canInteract?"Approve":"You must first provide feedback to the planner"}>
153-
<Button
154-
icon={<Checkmark20Regular />}
155-
appearance="subtle"
156-
onClick={
157-
canInteract
158-
? () => preOnApproved(step)
159-
: undefined
160-
}
161-
className={
162-
canInteract
163-
? "task-details-action-button"
164-
: "task-details-action-button-disabled"
152+
<>
153+
<Tooltip relationship="label" content={canInteract ? "Approve" : "You must first provide feedback to the planner"}>
154+
<Button
155+
icon={<Checkmark20Regular />}
156+
appearance="subtle"
157+
onClick={
158+
canInteract
159+
? async (e) => {
160+
// Disable buttons for this step
161+
setSteps((prev) =>
162+
prev.map((s) =>
163+
s.id === step.id
164+
? { ...s, _isActionLoading: true }
165+
: s
166+
)
167+
);
168+
try {
169+
await preOnApproved(step);
170+
} finally {
171+
// Remove loading state after API call
172+
setSteps((prev) =>
173+
prev.map((s) =>
174+
s.id === step.id
175+
? { ...s, _isActionLoading: false }
176+
: s
177+
)
178+
);
179+
}
165180
}
166-
/>
181+
: undefined
182+
}
183+
disabled={
184+
!canInteract ||
185+
!!step._isActionLoading
186+
}
187+
className={
188+
canInteract
189+
? "task-details-action-button"
190+
: "task-details-action-button-disabled"
191+
}
192+
/>
167193
</Tooltip>
168194

169-
<Tooltip relationship="label" content={canInteract?"Reject":"You must first provide feedback to the planner"}>
170-
<Button
171-
icon={<Dismiss20Regular />}
172-
appearance="subtle"
173-
onClick={
174-
canInteract
175-
? () => preOnRejected(step)
176-
: undefined
177-
}
178-
className={
179-
canInteract
180-
? "task-details-action-button"
181-
: "task-details-action-button-disabled"
195+
<Tooltip relationship="label" content={canInteract ? "Reject" : "You must first provide feedback to the planner"}>
196+
<Button
197+
icon={<Dismiss20Regular />}
198+
appearance="subtle"
199+
onClick={
200+
canInteract
201+
? async (e) => {
202+
setSteps((prev) =>
203+
prev.map((s) =>
204+
s.id === step.id
205+
? { ...s, _isActionLoading: true }
206+
: s
207+
)
208+
);
209+
try {
210+
await preOnRejected(step);
211+
} finally {
212+
setSteps((prev) =>
213+
prev.map((s) =>
214+
s.id === step.id
215+
? { ...s, _isActionLoading: false }
216+
: s
217+
)
218+
);
182219
}
183-
/>
184-
</Tooltip></>
185-
220+
}
221+
: undefined
222+
}
223+
disabled={
224+
!canInteract ||
225+
!!step._isActionLoading
226+
}
227+
className={
228+
canInteract
229+
? "task-details-action-button"
230+
: "task-details-action-button-disabled"
231+
}
232+
/>
233+
</Tooltip>
234+
</>
186235
)}
187-
</div>
236+
</div>
188237
</div>
189238
</div>
190239
);

0 commit comments

Comments
 (0)