Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix: keep archive deletion loading until completion (#44203)

非法操作b68912cea63b
diff --git a/web/app/components/header/account-setting/workflow-log-archives-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/workflow-log-archives-page/__tests__/index.spec.tsx
index 031b981beb6..321af195197 100644
--- a/web/app/components/header/account-setting/workflow-log-archives-page/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/workflow-log-archives-page/__tests__/index.spec.tsx
@@ -364,66 +364,79 @@ describe('WorkflowLogArchivesPage', () => {
}
})
- it('allows a confirmed retry after observing an active deletion for one minute', async () => {
- const user = userEvent.setup()
- vi.useFakeTimers()
- try {
- renderPage({ ...archiveData, months: [{ ...archiveMonth, deletion_status: 'pending' }] })
- await act(async () => vi.advanceTimersByTimeAsync(59_999))
- expect(
- screen.getByRole('button', { name: 'appLog.archives.delete.deleting 2025-03' }),
- ).toHaveAttribute('aria-disabled', 'true')
- await act(async () => vi.advanceTimersByTimeAsync(1))
- } finally {
- vi.useRealTimers()
- }
+ it.each(['pending', 'processing'] as const)(
+ 'keeps a long-running %s deletion disabled and polling without offering retry',
+ async (status) => {
+ const user = userEvent.setup()
+ vi.useFakeTimers()
+ try {
+ const deletingArchiveData = {
+ ...archiveData,
+ months: [{ ...archiveMonth, deletion_status: status }],
+ }
+ archiveRequests.list.mockResolvedValue(deletingArchiveData)
+ renderPage(deletingArchiveData)
- await user.click(screen.getByRole('button', { name: 'appLog.archives.delete.retry 2025-03' }))
- const dialog = await screen.findByRole('alertdialog')
- expect(archiveRequests.delete).not.toHaveBeenCalled()
- expect(screen.queryByRole('alert')).not.toBeInTheDocument()
- await user.click(
- within(dialog).getByRole('button', { name: 'appLog.archives.delete.confirm' }),
- )
+ await act(async () => vi.advanceTimersByTimeAsync(300_000))
+ const pollCount = archiveRequests.list.mock.calls.length
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
- expect(archiveRequests.delete).toHaveBeenCalledWith({ params: { year: 2025, month: 3 } })
- expect(
- screen.getByRole('button', { name: 'appLog.archives.delete.deleting 2025-03' }),
- ).toHaveAttribute('aria-disabled', 'true')
- expect(
- screen.getByRole('button', { name: 'appLog.archives.action.prepareDownload 2025-03' }),
- ).toHaveAttribute('aria-disabled', 'true')
- })
+ await act(async () => vi.advanceTimersByTimeAsync(3001))
+ expect(archiveRequests.list.mock.calls.length).toBeGreaterThan(pollCount)
+ const deletion = screen.getByRole('button', {
+ name: 'appLog.archives.delete.deleting 2025-03',
+ })
+ const download = screen.getByRole('button', {
+ name: 'appLog.archives.action.prepareDownload 2025-03',
+ })
+ expect(deletion).toHaveAttribute('aria-disabled', 'true')
+ expect(download).toHaveAttribute('aria-disabled', 'true')
+ expect(
+ screen.queryByRole('button', {
+ name: 'appLog.archives.delete.retry 2025-03',
+ }),
+ ).not.toBeInTheDocument()
+ expect(screen.queryByRole('alert')).not.toBeInTheDocument()
+ } finally {
+ vi.useRealTimers()
+ }
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'appLog.archives.delete.deleting 2025-03',
+ }),
+ )
+ await user.click(
+ screen.getByRole('button', {
+ name: 'appLog.archives.action.prepareDownload 2025-03',
+ }),
+ )
+ expect(archiveRequests.delete).not.toHaveBeenCalled()
+ expect(archiveRequests.prepareDownload).not.toHaveBeenCalled()
+ expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument()
+ },
+ )
- it('shows a request error when retrying an active deletion fails', async () => {
- const user = userEvent.setup()
- archiveRequests.delete.mockRejectedValueOnce(new Error('Network unavailable'))
+ it('offers retry only after the server reports that an active deletion failed', async () => {
vi.useFakeTimers()
try {
renderPage({ ...archiveData, months: [{ ...archiveMonth, deletion_status: 'processing' }] })
- await act(async () => vi.advanceTimersByTimeAsync(60_000))
+ expect(
+ screen.getByRole('button', { name: 'appLog.archives.delete.deleting 2025-03' }),
+ ).toHaveAttribute('aria-disabled', 'true')
+
+ archiveRequests.list.mockResolvedValue({
+ ...archiveData,
+ months: [{ ...archiveMonth, deletion_status: 'failed' }],
+ })
+ await act(async () => vi.advanceTimersByTimeAsync(3001))
+ expect(screen.getByRole('alert')).toHaveTextContent('appLog.archives.delete.failed')
+ expect(
+ screen.getByRole('button', { name: 'appLog.archives.delete.retry 2025-03' }),
+ ).not.toHaveAttribute('aria-disabled', 'true')
+ expect(archiveRequests.delete).not.toHaveBeenCalled()
} finally {
vi.useRealTimers()
}
-
- await user.click(screen.getByRole('button', { name: 'appLog.archives.delete.retry 2025-03' }))
- const dialog = await screen.findByRole('alertdialog')
- await user.click(
- within(dialog).getByRole('button', { name: 'appLog.archives.delete.confirm' }),
- )
-
- expect(await within(dialog).findByRole('alert')).toHaveTextContent(
- 'appLog.archives.delete.requestFailed',
- )
- expect(
- within(dialog).getByRole('button', { name: 'appLog.archives.delete.deleting' }),
- ).toHaveAttribute('aria-disabled', 'true')
- await user.click(within(dialog).getByRole('button', { name: 'common.operation.cancel' }))
- await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
- expect(
- screen.getByRole('button', { name: 'appLog.archives.action.prepareDownload 2025-03' }),
- ).toHaveAttribute('aria-disabled', 'true')
})
it('removes a month immediately when deletion is already completed', async () => {
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.tsx
index 13b661723ac..8324a80a26c 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
@@ -42,7 +42,6 @@ const byteFormatter = new Intl.NumberFormat(undefined, {
})
const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']
const DOWNLOAD_TASK_POLLING_INTERVAL = 3000
-const DELETION_RETRY_DELAY = 60_000
const ARCHIVE_MONTH_PAGE_SIZE = 20
function formatNumber(value: number) {
@@ -335,7 +334,6 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
const deleteActionLabelId = useId()
const confirmDeleteLabelId = useId()
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
- const [deletionRetryAvailable, setDeletionRetryAvailable] = useState(false)
const [downloadTask, setDownloadTask] = useState<WorkflowRunArchiveDownloadTaskResponse | null>(
null,
)
@@ -346,16 +344,9 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
}),
)
const isDeletionActive = isDeletingStatus(archive.deletion_status)
- const canRetryDeletion = isDeletionActive && deletionRetryAvailable
- const isDeleting = deleteArchiveMutation.isPending || (isDeletionActive && !canRetryDeletion)
+ const isDeleting = deleteArchiveMutation.isPending || isDeletionActive
const isDownloadUnavailable = deleteArchiveMutation.isPending || archive.deletion_status != null
- useEffect(() => {
- if (!isDeletionActive || deleteArchiveMutation.isPending) return
-
- const timer = setTimeout(() => setDeletionRetryAvailable(true), DELETION_RETRY_DELAY)
- return () => clearTimeout(timer)
- }, [isDeletionActive, deleteArchiveMutation.isPending, deleteArchiveMutation.submittedAt])
const cachedTask = downloadTask ?? archive.download_task ?? null
const downloadTaskId = cachedTask?.download_id
const taskQuery = useQuery(
@@ -444,7 +435,6 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
const deleteArchive = () => {
if (!isCurrentWorkspaceOwner || isDeleting) return
- setDeletionRetryAvailable(false)
deleteArchiveMutation.mutate(
{ params: { year: archive.year, month: archive.month } },
{ onSuccess: () => setDeleteDialogOpen(false) },
@@ -519,7 +509,7 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
<span id={deleteActionLabelId}>
{isDeleting
? t(($) => $['archives.delete.deleting'], { ns: 'appLog' })
- : archive.deletion_status === 'failed' || canRetryDeletion
+ : archive.deletion_status === 'failed'
? t(($) => $['archives.delete.retry'], { ns: 'appLog' })
: t(($) => $['operation.delete'], { ns: 'common' })}
</span>
@@ -546,7 +536,6 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
</AlertDialogCancelButton>
<AlertDialogConfirmButton
loading={isDeleting}
- disabled={isDeletionActive && !canRetryDeletion}
aria-labelledby={confirmDeleteLabelId}
onClick={deleteArchive}
>