fix: show persistent error when workflow draft save fails (#39293)

This commit is contained in:
Joel 2026-07-20 16:48:38 +08:00 committed by GitHub
parent b3f163fb0f
commit e77ee82526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 52 additions and 2 deletions

View File

@ -38,6 +38,7 @@ const collaborationBridge = vi.hoisted(() => ({
}))
const toastInfoMock = vi.hoisted(() => vi.fn())
const toastErrorMock = vi.hoisted(() => vi.fn())
const workflowCommentState = vi.hoisted(() => ({
comments: [] as Array<Record<string, unknown>>,
@ -188,6 +189,7 @@ vi.mock('@/service/workflow', () => ({
vi.mock('@langgenius/dify-ui/toast', () => ({
toast: {
error: toastErrorMock,
info: toastInfoMock,
},
}))
@ -606,6 +608,22 @@ describe('Workflow edge event wiring', () => {
expect(store.getState().contextMenuTarget).toBeUndefined()
})
it('should show a persistent error toast when saving the draft on unmount fails', () => {
workflowHookMocks.handleSyncWorkflowDraft.mockImplementationOnce(
(_sync, _notRefreshWhenSyncError, callback) => {
callback?.onError?.()
},
)
const { unmount } = renderSubject()
unmount()
expect(toastErrorMock).toHaveBeenCalledWith('workflow.common.draftSaveFailed', {
timeout: 0,
})
})
it('should render confirm description and clear showConfirm when cancelled', async () => {
const onConfirm = vi.fn()
const { store } = renderSubject({

View File

@ -364,9 +364,18 @@ export const Workflow: FC<WorkflowProps> = memo(
useEffect(() => {
return () => {
handleSyncWorkflowDraft(true, true)
handleSyncWorkflowDraft(true, true, {
onError: () => {
toast.error(
t(($) => $['common.draftSaveFailed'], { ns: 'workflow' }),
{
timeout: 0,
},
)
},
})
}
}, [handleSyncWorkflowDraft])
}, [handleSyncWorkflowDraft, t])
const handlePendingCommentPositionChange = useCallback(
(position: NonNullable<WorkflowSliceShape['pendingComment']>) => {

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "سير العمل الحالي",
"common.debugAndPreview": "معاينة",
"common.disconnect": "قطع الاتصال",
"common.draftSaveFailed": "فشل حفظ المسودة",
"common.duplicate": "تكرار",
"common.editing": "تعديل",
"common.effectVarConfirm.content": "يتم استخدام المتغير في عقد أخرى. هل ما زلت تريد إزالته؟",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Aktueller Arbeitsablauf",
"common.debugAndPreview": "Vorschau",
"common.disconnect": "Trennen",
"common.draftSaveFailed": "Entwurf konnte nicht gespeichert werden",
"common.duplicate": "Duplizieren",
"common.editing": "Bearbeitung",
"common.effectVarConfirm.content": "Die Variable wird in anderen Knoten verwendet. Möchten Sie sie trotzdem entfernen?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Current Workflow",
"common.debugAndPreview": "Preview",
"common.disconnect": "Disconnect",
"common.draftSaveFailed": "Draft save failed",
"common.duplicate": "Duplicate",
"common.editing": "Editing",
"common.effectVarConfirm.content": "The variable is used in other nodes. Do you still want to remove it?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Flujo de trabajo actual",
"common.debugAndPreview": "Vista previa",
"common.disconnect": "Desconectar",
"common.draftSaveFailed": "Error al guardar el borrador",
"common.duplicate": "Duplicar",
"common.editing": "Editando",
"common.effectVarConfirm.content": "La variable se utiliza en otros nodos. ¿Aún quieres eliminarla?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "گردش کار فعلی",
"common.debugAndPreview": "اشکال‌زدایی و پیش‌نمایش",
"common.disconnect": "قطع اتصال",
"common.draftSaveFailed": "ذخیره پیش‌نویس ناموفق بود",
"common.duplicate": "تکثیر",
"common.editing": "در حال ویرایش",
"common.effectVarConfirm.content": "این متغیر در گره‌های دیگر استفاده شده است. آیا مطمئنید می‌خواهید آن را حذف کنید؟",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Flux de travail actuel",
"common.debugAndPreview": "Aperçu",
"common.disconnect": "Déconnecter",
"common.draftSaveFailed": "Échec de lenregistrement du brouillon",
"common.duplicate": "Dupliquer",
"common.editing": "Édition",
"common.effectVarConfirm.content": "La variable est utilisée dans d'autres nœuds. Voulez-vous toujours la supprimer?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "वर्तमान कार्यप्रवाह",
"common.debugAndPreview": "पूर्वावलोकन",
"common.disconnect": "अलग करना",
"common.draftSaveFailed": "ड्राफ़्ट सहेजना विफल रहा",
"common.duplicate": "डुप्लिकेट करें",
"common.editing": "संपादन",
"common.effectVarConfirm.content": "वेरिएबल अन्य नोड्स में उपयोग किया जाता है। क्या आप अभी भी इसे हटाना चाहते हैं?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Alur Kerja Saat Ini",
"common.debugAndPreview": "Pratayang",
"common.disconnect": "Lepaskan",
"common.draftSaveFailed": "Gagal menyimpan draf",
"common.duplicate": "Duplikat",
"common.editing": "Mengedit",
"common.effectVarConfirm.content": "Variabel ini digunakan di node lain. Apakah Anda masih ingin menghapusnya?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Flusso di lavoro corrente",
"common.debugAndPreview": "Anteprima",
"common.disconnect": "Disconnettere",
"common.draftSaveFailed": "Salvataggio della bozza non riuscito",
"common.duplicate": "Duplica",
"common.editing": "Modifica in corso",
"common.effectVarConfirm.content": "La variabile è utilizzata in altri nodi. Vuoi comunque rimuoverla?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "現在のワークフロー",
"common.debugAndPreview": "プレビュー",
"common.disconnect": "接続解除",
"common.draftSaveFailed": "下書きの保存に失敗しました",
"common.duplicate": "複製",
"common.editing": "編集中",
"common.effectVarConfirm.content": "他のノードで変数が使用されています。それでも削除しますか?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "현재 워크플로",
"common.debugAndPreview": "미리보기",
"common.disconnect": "연결 해제",
"common.draftSaveFailed": "초안 저장에 실패했습니다",
"common.duplicate": "복제",
"common.editing": "편집 중",
"common.effectVarConfirm.content": "변수가 다른 노드에서 사용되고 있습니다. 그래도 제거하시겠습니까?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Current Workflow",
"common.debugAndPreview": "Preview",
"common.disconnect": "Disconnect",
"common.draftSaveFailed": "Opslaan van concept mislukt",
"common.duplicate": "Duplicate",
"common.editing": "Editing",
"common.effectVarConfirm.content": "The variable is used in other nodes. Do you still want to remove it?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Bieżący przepływ pracy",
"common.debugAndPreview": "Podgląd",
"common.disconnect": "Odłączyć",
"common.draftSaveFailed": "Nie udało się zapisać wersji roboczej",
"common.duplicate": "Duplikuj",
"common.editing": "Edytowanie",
"common.effectVarConfirm.content": "Zmienna jest używana w innych węzłach. Czy na pewno chcesz ją usunąć?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Fluxo de trabalho atual",
"common.debugAndPreview": "Visualizar",
"common.disconnect": "Desligar",
"common.draftSaveFailed": "Falha ao salvar o rascunho",
"common.duplicate": "Duplicar",
"common.editing": "Editando",
"common.effectVarConfirm.content": "A variável é usada em outros nós. Você ainda deseja removê-la?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Flux de lucru curent",
"common.debugAndPreview": "Previzualizare",
"common.disconnect": "Deconecta",
"common.draftSaveFailed": "Salvarea schiței a eșuat",
"common.duplicate": "Duplică",
"common.editing": "Editare",
"common.effectVarConfirm.content": "Variabila este utilizată în alte noduri. Doriți să o eliminați oricum?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Текущий рабочий процесс",
"common.debugAndPreview": "Предпросмотр",
"common.disconnect": "Разъединять",
"common.draftSaveFailed": "Не удалось сохранить черновик",
"common.duplicate": "Дублировать",
"common.editing": "Редактирование",
"common.effectVarConfirm.content": "Переменная используется в других узлах. Вы все еще хотите удалить ее?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Trenutni potek dela",
"common.debugAndPreview": "Predogled",
"common.disconnect": "Odklop",
"common.draftSaveFailed": "Shranjevanje osnutka ni uspelo",
"common.duplicate": "Podvojiti",
"common.editing": "Urejanje",
"common.effectVarConfirm.content": "Spremenljivka se uporablja v drugih vozliščih. Ali jo še vedno želite odstraniti?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "เวิร์กโฟลว์ปัจจุบัน",
"common.debugAndPreview": "ดูตัวอย่าง",
"common.disconnect": "ยก เลิก",
"common.draftSaveFailed": "บันทึกฉบับร่างไม่สำเร็จ",
"common.duplicate": "สำเนา",
"common.editing": "แก้ไข",
"common.effectVarConfirm.content": "ตัวแปรนี้ใช้ในโหนดอื่น คุณยังต้องการลบออกหรือไม่?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Mevcut İş Akışı",
"common.debugAndPreview": "Önizleme",
"common.disconnect": "Bağlantıyı Kes",
"common.draftSaveFailed": "Taslak kaydedilemedi",
"common.duplicate": "Çoğalt",
"common.editing": "Düzenleme",
"common.effectVarConfirm.content": "Değişken diğer düğümlerde kullanılıyor. Yine de kaldırmak istiyor musunuz?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Поточний робочий процес",
"common.debugAndPreview": "Попередній перегляд",
"common.disconnect": "Відключити",
"common.draftSaveFailed": "Не вдалося зберегти чернетку",
"common.duplicate": "Дублювати",
"common.editing": "Редагування",
"common.effectVarConfirm.content": "Змінна використовується в інших вузлах. Ви все ще хочете її видалити?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "Quy trình làm việc hiện tại",
"common.debugAndPreview": "Xem trước",
"common.disconnect": "Ngắt kết nối",
"common.draftSaveFailed": "Lưu bản nháp thất bại",
"common.duplicate": "Nhân bản",
"common.editing": "Đang chỉnh sửa",
"common.effectVarConfirm.content": "Biến được sử dụng trong các nút khác. Bạn có chắc chắn muốn xóa nó không?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "整个工作流",
"common.debugAndPreview": "预览",
"common.disconnect": "断开连接",
"common.draftSaveFailed": "草稿保存失败",
"common.duplicate": "复制",
"common.editing": "编辑中",
"common.effectVarConfirm.content": "该变量在其他节点中使用。您是否仍要删除它?",

View File

@ -169,6 +169,7 @@
"common.currentWorkflow": "當前工作流程",
"common.debugAndPreview": "預覽",
"common.disconnect": "斷開",
"common.draftSaveFailed": "草稿儲存失敗",
"common.duplicate": "複製",
"common.editing": "編輯中",
"common.effectVarConfirm.content": "該變數在其他節點中使用。您是否仍要刪除它?",