Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix toast dismissal to target specific toast IDs instead of all toasts (#11455)

sp.wack49f360d0212b
diff --git a/frontend/src/hooks/mutation/use-unified-stop-conversation.ts b/frontend/src/hooks/mutation/use-unified-stop-conversation.ts
index bb638c1522..a3cc2bfd1d 100644
--- a/frontend/src/hooks/mutation/use-unified-stop-conversation.ts
+++ b/frontend/src/hooks/mutation/use-unified-stop-conversation.ts
@@ -50,7 +50,10 @@ export const useUnifiedPauseConversationSandbox = () => {
return stopV0Conversation(variables.conversationId);
},
onMutate: async () => {
- toast.loading(t(I18nKey.TOAST$STOPPING_CONVERSATION), TOAST_OPTIONS);
+ const toastId = toast.loading(
+ t(I18nKey.TOAST$STOPPING_CONVERSATION),
+ TOAST_OPTIONS,
+ );
await queryClient.cancelQueries({ queryKey: ["user", "conversations"] });
const previousConversations = queryClient.getQueryData([
@@ -58,10 +61,12 @@ export const useUnifiedPauseConversationSandbox = () => {
"conversations",
]);
- return { previousConversations };
+ return { previousConversations, toastId };
},
onError: (_, __, context) => {
- toast.dismiss();
+ if (context?.toastId) {
+ toast.dismiss(context.toastId);
+ }
toast.error(t(I18nKey.TOAST$FAILED_TO_STOP_CONVERSATION), TOAST_OPTIONS);
if (context?.previousConversations) {
@@ -74,8 +79,10 @@ export const useUnifiedPauseConversationSandbox = () => {
onSettled: (_, __, variables) => {
invalidateConversationQueries(queryClient, variables.conversationId);
},
- onSuccess: (_, variables) => {
- toast.dismiss();
+ onSuccess: (_, variables, context) => {
+ if (context?.toastId) {
+ toast.dismiss(context.toastId);
+ }
toast.success(t(I18nKey.TOAST$CONVERSATION_STOPPED), TOAST_OPTIONS);
updateConversationStatusInCache(