Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(web): align dialog mutation cleanup with session lifetime (#44623)
yyh5f16a632706e
diff --git a/web/app/components/app/tracing/__tests__/provider-config-modal.spec.tsx b/web/app/components/app/tracing/__tests__/provider-config-modal.spec.tsxindex 41b7de3449b..df7773dd727 100644--- a/web/app/components/app/tracing/__tests__/provider-config-modal.spec.tsx+++ b/web/app/components/app/tracing/__tests__/provider-config-modal.spec.tsx@@ -539,6 +539,31 @@ describe('ProviderConfigModal', () => {).toBeInTheDocument()})+ it('clears a removal error on reopening while preserving the provider draft', async () => {+ request.mockRejectedValueOnce(+ await httpErrorFromResponse(Response.json({ message: 'Removal failed' }, { status: 400 })),+ )+ const user = userEvent.setup()+ renderProviderConfigModal({ payload: validConfigs.langfuse })+ const host = screen.getByRole('textbox', { name: 'Host' })+ await user.clear(host)+ await user.type(host, 'https://draft.langfuse.com')+ await user.click(screen.getByRole('button', { name: 'common.operation.remove' }))+ await user.click(+ within(screen.getByRole('alertdialog')).getByRole('button', {+ name: 'common.operation.remove',+ }),+ )+ expect(await screen.findByRole('alert')).toHaveTextContent('Removal failed')+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))+ await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())++ expect(host).toHaveValue('https://draft.langfuse.com')+ await user.click(screen.getByRole('button', { name: 'common.operation.remove' }))+ expect(within(screen.getByRole('alertdialog')).queryByRole('alert')).not.toBeInTheDocument()+ expect(request).toHaveBeenCalledOnce()+ })+it('keeps the draft and returns focus to Remove when confirmation is canceled', async () => {const user = userEvent.setup()renderProviderConfigModal({diff --git a/web/app/components/app/tracing/provider-config-modal.tsx b/web/app/components/app/tracing/provider-config-modal.tsxindex cf5130d8595..01434f988fd 100644--- a/web/app/components/app/tracing/provider-config-modal.tsx+++ b/web/app/components/app/tracing/provider-config-modal.tsx@@ -753,6 +753,9 @@ export function ProviderConfigModal({onOpenChange={(open, details) => {if (!open && removeConfig.isPending) details.cancel()}}+ onOpenChangeComplete={(open) => {+ if (!open) removeConfig.reset()+ }}><AlertDialogTrigger render={<Button tone="destructive" disabled={pending} />}>{t(($) => $['operation.remove'], { ns: 'common' })}diff --git a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsxindex 6a776415f10..fbfa6cd8b2e 100644--- a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx+++ b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx@@ -107,7 +107,6 @@ const SystemModel: FC<SystemModelSelectorProps> = ({: undefined)const handleOpenChange = (nextOpen: boolean) => {if (saveMutation.isPending) return- saveMutation.reset()setManuallyOpen(nextOpen)if (!nextOpen && activeDialog === 'system-models') void setActiveDialog(null)}@@ -141,6 +140,9 @@ const SystemModel: FC<SystemModelSelectorProps> = ({}handleOpenChange(nextOpen)}}+ onOpenChangeComplete={(open) => {+ if (!open) saveMutation.reset()+ }}><DialogTriggerrender={<Button variant={notConfigured ? 'primary' : 'secondary'} size="small" />}diff --git a/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx b/web/app/components/header/account-setting/workflow-log-archives-page/index.tsxindex 6a4969ad3d2..509cdd13376 100644--- a/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx+++ b/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx@@ -523,11 +523,16 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth{isCurrentWorkspaceOwner && (<AlertDialogopen={deleteDialogOpen}- onOpenChange={(open) => {- if (deleteArchiveMutation.isPending) return- if (open) deleteArchiveMutation.reset()+ onOpenChange={(open, details) => {+ if (deleteArchiveMutation.isPending) {+ details.cancel()+ return+ }setDeleteDialogOpen(open)}}+ onOpenChangeComplete={(open) => {+ if (!open) deleteArchiveMutation.reset()+ }}><AlertDialogTriggerrender={diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsxindex 44c625a6208..c7a0df30e0d 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/index.spec.tsx@@ -351,7 +351,25 @@ describe('AgentFiles', () => {expect(screen.queryByText('diagram.png')).not.toBeInTheDocument()})- it('should upload through the two-step config file flow and persist config_files in draft state', async () => {+ it('keeps both upload stages open until the committed file reaches the draft', async () => {+ let finishUpload!: () => void+ let finishCommit!: () => void+ const upload = new Promise<void>((resolve) => {+ finishUpload = resolve+ })+ const commit = new Promise<void>((resolve) => {+ finishCommit = resolve+ })+ const uploadFile = mocks.uploadFileMutationFn.getMockImplementation()!+ const commitFile = mocks.commitFileMutationFn.getMockImplementation()!+ mocks.uploadFileMutationFn.mockImplementationOnce(async (input) => {+ await upload+ return uploadFile(input)+ })+ mocks.commitFileMutationFn.mockImplementationOnce(async (input) => {+ await commit+ return commitFile(input)+ })const user = userEvent.setup()renderAgentFiles({ initialDraft: defaultAgentSoulConfigFormState })@@ -381,6 +399,14 @@ describe('AgentFiles', () => {)})+ await user.keyboard('{Escape}')+ await user.click(+ within(screen.getByRole('dialog')).getByRole('button', { name: 'common.operation.close' }),+ )+ expect(screen.getByRole('dialog')).toBeInTheDocument()+ expect(mocks.commitFileMutationFn).not.toHaveBeenCalled()+ finishUpload()+await waitFor(() => {expect(mocks.commitFileMutationFn).toHaveBeenCalledExactlyOnceWith({@@ -399,6 +425,11 @@ describe('AgentFiles', () => {)})+ await user.keyboard('{Escape}')+ expect(screen.getByRole('dialog')).toBeInTheDocument()+ finishCommit()+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+const snapshot = JSON.parse(screen.getByLabelText('config snapshot').textContent ?? '{}')expect(snapshot.config_files).toEqual([expect.objectContaining({diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsxindex be6b900a122..3adda7c66a8 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx@@ -13,6 +13,7 @@ import { cn } from '@langgenius/dify-ui/cn'import {Dialog,DialogBody,+ DialogClose,DialogContent,DialogDescription,DialogFooter,@@ -297,7 +298,6 @@ export function AgentFileUploadDialog({onSuccess: (committedFile) => {toast.success(t(($) => $['agentDetail.configure.files.upload.success']))onUploaded(toAgentFileNode(committedFile.file))- setFile(undefined)onOpenChange(false)},onError: () => {@@ -312,18 +312,18 @@ export function AgentFileUploadDialog({)}- const handleOpenChange = (nextOpen: boolean) => {- if (!nextOpen) {- uploadFileMutation.reset()- commitAgentFileMutation.reset()- commitWorkflowAgentFileMutation.reset()- setFile(undefined)- }- onOpenChange(nextOpen)- }-return (- <Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>+ <Dialog+ open={open}+ onOpenChange={(nextOpen, details) => {+ if (!nextOpen && isUploading) details.cancel()+ else onOpenChange(nextOpen)+ }}+ onOpenChangeComplete={(open) => {+ if (!open) setFile(undefined)+ }}+ disablePointerDismissal+ ><DialogContent backdropProps={{ forceRender: true, className: 'fixed' }}><DialogHeader><DialogTitle>{t(($) => $['agentDetail.configure.files.upload.title'])}</DialogTitle>@@ -336,9 +336,9 @@ export function AgentFileUploadDialog({<AgentFileUploader file={file} onChange={setFile} /></DialogBody><DialogFooter>- <Button type="button" onClick={() => handleOpenChange(false)} disabled={isUploading}>+ <DialogClose render={<Button disabled={isUploading} />}>{tCommon(($) => $['operation.cancel'])}- </Button>+ </DialogClose><Buttontype="button"variant="primary"diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsxindex 3e9b9b43411..9fe75ba76bb 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/__tests__/index.spec.tsx@@ -2,7 +2,7 @@ import type { SkillResponse } from '@dify/contracts/api/console/workspaces/typesimport type { AgentConfigApiContext } from '../../config-context'import type { AgentSoulConfigFormState } from '@/features/agent-v2/agent-composer/form-state'import { QueryClient, QueryClientProvider, skipToken } from '@tanstack/react-query'-import { fireEvent, render, screen, waitFor } from '@testing-library/react'+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { useAtomValue } from 'jotai'import { useState } from 'react'@@ -635,7 +635,16 @@ describe('AgentSkills', () => {expect(screen.queryByText('Tender Analyzer')).not.toBeInTheDocument()})- it('should upload a skill through the config endpoint and add it to the draft UI', async () => {+ it('keeps the skill upload open until the uploaded skill reaches the draft', async () => {+ let finishUpload!: () => void+ const upload = new Promise<void>((resolve) => {+ finishUpload = resolve+ })+ const uploadSkill = mocks.uploadSkillMutationFn.getMockImplementation()!+ mocks.uploadSkillMutationFn.mockImplementationOnce(async (input) => {+ await upload+ return uploadSkill(input)+ })const user = userEvent.setup()renderAgentSkills({ initialDraft: defaultAgentSoulConfigFormState })@@ -670,7 +679,14 @@ describe('AgentSkills', () => {)})- expect(screen.getByText('Invoice Helper')).toBeInTheDocument()+ await user.keyboard('{Escape}')+ await user.click(+ within(screen.getByRole('dialog')).getByRole('button', { name: 'common.operation.close' }),+ )+ expect(screen.getByRole('dialog')).toBeInTheDocument()+ finishUpload()+ expect(await screen.findByText('Invoice Helper')).toBeInTheDocument()+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())const snapshot = JSON.parse(screen.getByLabelText('config snapshot').textContent ?? '{}')expect(snapshot.config_skills).toEqual([expect.objectContaining({diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsxindex b1930b8d24c..254f17f2450 100644--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx@@ -10,6 +10,7 @@ import { cn } from '@langgenius/dify-ui/cn'import {Dialog,DialogBody,+ DialogClose,DialogContent,DialogDescription,DialogFooter,@@ -275,7 +276,6 @@ export function AgentSkillUploadDialog({) => {toast.success(t(($) => $['agentDetail.configure.skills.upload.success']))onUploaded?.(toUploadedSkill(response, file))- setFile(undefined)onOpenChange(false)},}@@ -317,17 +317,21 @@ export function AgentSkillUploadDialog({)}- const handleOpenChange = (nextOpen: boolean) => {- if (!nextOpen) {- uploadAgentSkillMutation.reset()- uploadWorkflowSkillMutation.reset()- setFile(undefined)- }- onOpenChange(nextOpen)- }-return (- <Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>+ <Dialog+ open={open}+ onOpenChange={(nextOpen, details) => {+ if (!nextOpen && uploadSkillMutation.isPending) details.cancel()+ else onOpenChange(nextOpen)+ }}+ onOpenChangeComplete={(open) => {+ if (!open) {+ uploadSkillMutation.reset()+ setFile(undefined)+ }+ }}+ disablePointerDismissal+ ><DialogContent backdropProps={{ forceRender: true, className: 'fixed' }}><DialogHeader><DialogTitle>{t(($) => $['agentDetail.configure.skills.upload.title'])}</DialogTitle>@@ -344,13 +348,9 @@ export function AgentSkillUploadDialog({/></DialogBody><DialogFooter>- <Button- type="button"- onClick={() => handleOpenChange(false)}- disabled={uploadSkillMutation.isPending}- >+ <DialogClose render={<Button disabled={uploadSkillMutation.isPending} />}>{tCommon(($) => $['operation.cancel'])}- </Button>+ </DialogClose><Buttontype="button"variant="primary"diff --git a/web/features/agent-v2/agent-detail/sidebar-actions.tsx b/web/features/agent-v2/agent-detail/sidebar-actions.tsxindex 000caaaf416..d28702fb297 100644--- a/web/features/agent-v2/agent-detail/sidebar-actions.tsx+++ b/web/features/agent-v2/agent-detail/sidebar-actions.tsx@@ -121,10 +121,7 @@ export function AgentDetailSidebarActions({ agent }: { agent: AgentDetailSidebar<DropdownMenuItemvariant="destructive"className="gap-2"- onClick={() => {- deletion.reset()- setIsDeleteOpen(true)- }}+ onClick={() => setIsDeleteOpen(true)}><span aria-hidden className="i-ri-delete-bin-line size-4 shrink-0" /><span>{tCommon(($) => $['operation.delete'])}</span>@@ -149,6 +146,9 @@ export function AgentDetailSidebarActions({ agent }: { agent: AgentDetailSidebarif (!open && deletion.isPending) details.cancel()else setIsDeleteOpen(open)}}+ onOpenChangeComplete={(open) => {+ if (!open) deletion.reset()+ }}><AlertDialogContent><DeleteAgentFormdiff --git a/web/features/agent-v2/roster/components/agent-roster-list.tsx b/web/features/agent-v2/roster/components/agent-roster-list.tsxindex 6ca0bbd6455..799d25619e1 100644--- a/web/features/agent-v2/roster/components/agent-roster-list.tsx+++ b/web/features/agent-v2/roster/components/agent-roster-list.tsx@@ -494,10 +494,7 @@ export function AgentRosterList({ label, state }: AgentRosterListProps) {<AgentRosterItemkey={agent.id}agent={agent}- onDelete={(target) => {- deletion.reset()- deleteDialog.openWithPayload(target)- }}+ onDelete={(target) => deleteDialog.openWithPayload(target)}/>))}</ul>@@ -526,6 +523,9 @@ export function AgentRosterList({ label, state }: AgentRosterListProps) {if (!open && deletion.isPending && details.reason !== 'imperative-action')details.cancel()}}+ onOpenChangeComplete={(open) => {+ if (!open) deletion.reset()+ }}>{({ payload }) => (<AlertDialogContent>diff --git a/web/features/new-rag/list/knowledge-space-actions.tsx b/web/features/new-rag/list/knowledge-space-actions.tsxindex a1e9606c0d0..8eb3cce2853 100644--- a/web/features/new-rag/list/knowledge-space-actions.tsx+++ b/web/features/new-rag/list/knowledge-space-actions.tsx@@ -81,13 +81,7 @@ export function KnowledgeSpaceActions({{canDelete && (<>{canEdit && <DropdownMenuSeparator />}- <DropdownMenuItem- variant="destructive"- onClick={() => {- deleteMutation.reset()- setDeleteOpen(true)- }}- >+ <DropdownMenuItem variant="destructive" onClick={() => setDeleteOpen(true)}><span aria-hidden className="mr-1 i-ri-delete-bin-line size-4" />{tCommon(($) => $['operation.delete'])}</DropdownMenuItem>@@ -104,6 +98,9 @@ export function KnowledgeSpaceActions({if (!open && deleteMutation.isPending) details.cancel()else setDeleteOpen(open)}}+ onOpenChangeComplete={(open) => {+ if (!open) deleteMutation.reset()+ }}><AlertDialogContent><DeleteKnowledgeFormdiff --git a/web/features/new-rag/quality/__tests__/page.spec.tsx b/web/features/new-rag/quality/__tests__/page.spec.tsxindex 405354760eb..3ebb946977a 100644--- a/web/features/new-rag/quality/__tests__/page.spec.tsx+++ b/web/features/new-rag/quality/__tests__/page.spec.tsx@@ -1265,7 +1265,7 @@ describe('QualityPage', () => {expect(importButton).toBeEnabled()})- it('locks the CSV selection while an import is in flight', async () => {+ it('locks the CSV selection during import and starts fresh after closing the result', async () => {const importResult = deferred<{ active_count: number; draft_count: number; items: [] }>()serviceMock.bulkImport.mockReturnValue(importResult.promise)const user = userEvent.setup()@@ -1301,6 +1301,28 @@ describe('QualityPage', () => {expect(await screen.findByText('knowledgeQuality.qualityPage.importComplete'),).toBeInTheDocument()++ await user.click(+ within(screen.getByRole('dialog'))+ .getAllByRole('button', {+ name: 'knowledgeQuality.qualityPage.closeDialog',+ })+ .at(-1)!,+ )+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ await user.click(screen.getByRole('button', { name: 'knowledgeQuality.qualityPage.importCsv' }))++ const reopened = within(screen.getByRole('dialog'))+ expect(+ reopened.queryByText('knowledgeQuality.qualityPage.importComplete'),+ ).not.toBeInTheDocument()+ expect(reopened.queryByText('first.csv')).not.toBeInTheDocument()+ expect(+ reopened.getByLabelText('knowledgeQuality.qualityPage.chooseCsv', { selector: 'input' }),+ ).toBeEnabled()+ expect(+ reopened.getByRole('button', { name: 'knowledgeQuality.qualityPage.importCsv' }),+ ).toBeDisabled()})it('freezes the golden-question draft while a save is pending', async () => {diff --git a/web/features/new-rag/quality/golden-question-import-dialog.tsx b/web/features/new-rag/quality/golden-question-import-dialog.tsxindex 15720a0fc5e..4a02808d9aa 100644--- a/web/features/new-rag/quality/golden-question-import-dialog.tsx+++ b/web/features/new-rag/quality/golden-question-import-dialog.tsx@@ -35,7 +35,9 @@ export function GoldenQuestionImportDialog({}) {return (<Dialog open={open} onOpenChange={onOpenChange}>- <GoldenQuestionImportSession onOpenChange={onOpenChange} />+ <DialogContent className="w-180">+ <GoldenQuestionImportSession onOpenChange={onOpenChange} />+ </DialogContent></Dialog>)}@@ -113,7 +115,7 @@ function GoldenQuestionImportSession({ onOpenChange }: { onOpenChange: (open: bo}return (- <DialogContent className="w-180">+ <><DialogHeader><DialogTitle>{t(($) => $['qualityPage.importTitle'], { ns: 'knowledgeQuality' })}@@ -233,6 +235,6 @@ function GoldenQuestionImportSession({ onOpenChange }: { onOpenChange: (open: bo</DialogFooter></>)}- </DialogContent>+ </>)}diff --git a/web/features/new-rag/settings/delete-knowledge.tsx b/web/features/new-rag/settings/delete-knowledge.tsxindex cd259c9d305..78423b6f92c 100644--- a/web/features/new-rag/settings/delete-knowledge.tsx+++ b/web/features/new-rag/settings/delete-knowledge.tsx@@ -59,7 +59,9 @@ export function DeleteKnowledgeAction() {onOpenChange={(nextOpen, details) => {if (!nextOpen && mutation.isPending && details.reason !== 'imperative-action')details.cancel()- else if (nextOpen) mutation.reset()+ }}+ onOpenChangeComplete={(open) => {+ if (!open) mutation.reset()}}><div className="h-px bg-divider-subtle" />