Bug Fix: Fix workflow knowledge retrieval cache bug (#23597)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
yunqiqiliang
2025-08-08 11:42:20 +08:00
committed by GitHub
parent 1c60b7f070
commit f73ec60311
3 changed files with 26 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { RiMoreFill } from '@remixicon/react'
import { mutate } from 'swr'
import cn from '@/utils/classnames'
import Confirm from '@/app/components/base/confirm'
import { ToastContext } from '@/app/components/base/toast'
@@ -57,6 +58,19 @@ const DatasetCard = ({
const onConfirmDelete = useCallback(async () => {
try {
await deleteDataset(dataset.id)
// Clear SWR cache to prevent stale data in knowledge retrieval nodes
mutate(
(key) => {
if (typeof key === 'string') return key.includes('/datasets')
if (typeof key === 'object' && key !== null)
return key.url === '/datasets' || key.url?.includes('/datasets')
return false
},
undefined,
{ revalidate: true },
)
notify({ type: 'success', message: t('dataset.datasetDeleted') })
if (onSuccess)
onSuccess()