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(knowledge-base): regenerate child chunks not working completely (#27934)

breath5745e816a9f6fa
diff --git a/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx b/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx
index 95bb339db91..f90fd7ac60a 100644
--- a/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx
+++ b/web/app/components/datasets/documents/detail/completed/common/regeneration-modal.tsx
@@ -121,7 +121,7 @@ const RegenerationModal: FC<IRegenerationModalProps> = ({
})
return (
- <Modal isShow={isShow} onClose={noop} className='!max-w-[480px] !rounded-2xl'>
+ <Modal isShow={isShow} onClose={noop} className='!max-w-[480px] !rounded-2xl' wrapperClassName='!z-[10000]'>
{!loading && !updateSucceeded && <DefaultContent onCancel={onCancel} onConfirm={onConfirm} />}
{loading && !updateSucceeded && <RegeneratingContent />}
{!loading && updateSucceeded && <RegenerationCompletedContent onClose={onClose} />}
diff --git a/web/app/components/datasets/documents/detail/completed/index.tsx b/web/app/components/datasets/documents/detail/completed/index.tsx
index 8fa167f9769..09c63d54a1d 100644
--- a/web/app/components/datasets/documents/detail/completed/index.tsx
+++ b/web/app/components/datasets/documents/detail/completed/index.tsx
@@ -124,6 +124,7 @@ const Completed: FC<ICompletedProps> = ({
const [limit, setLimit] = useState(DEFAULT_LIMIT)
const [fullScreen, setFullScreen] = useState(false)
const [showNewChildSegmentModal, setShowNewChildSegmentModal] = useState(false)
+ const [isRegenerationModalOpen, setIsRegenerationModalOpen] = useState(false)
const segmentListRef = useRef<HTMLDivElement>(null)
const childSegmentListRef = useRef<HTMLDivElement>(null)
@@ -669,6 +670,7 @@ const Completed: FC<ICompletedProps> = ({
onClose={onCloseSegmentDetail}
showOverlay={false}
needCheckChunks
+ modal={isRegenerationModalOpen}
>
<SegmentDetail
key={currSegment.segInfo?.id}
@@ -677,6 +679,7 @@ const Completed: FC<ICompletedProps> = ({
isEditMode={currSegment.isEditMode}
onUpdate={handleUpdateSegment}
onCancel={onCloseSegmentDetail}
+ onModalStateChange={setIsRegenerationModalOpen}
/>
</FullScreenDrawer>
{/* Create New Segment */}
diff --git a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx b/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
index bbd9df1adc3..5e5ae6b485a 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
+++ b/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
@@ -27,6 +27,7 @@ type ISegmentDetailProps = {
onCancel: () => void
isEditMode?: boolean
docForm: ChunkingMode
+ onModalStateChange?: (isOpen: boolean) => void
}
/**
@@ -38,6 +39,7 @@ const SegmentDetail: FC<ISegmentDetailProps> = ({
onCancel,
isEditMode,
docForm,
+ onModalStateChange,
}) => {
const { t } = useTranslation()
const [question, setQuestion] = useState(isEditMode ? segInfo?.content || '' : segInfo?.sign_content || '')
@@ -68,11 +70,19 @@ const SegmentDetail: FC<ISegmentDetailProps> = ({
const handleRegeneration = useCallback(() => {
setShowRegenerationModal(true)
- }, [])
+ onModalStateChange?.(true)
+ }, [onModalStateChange])
const onCancelRegeneration = useCallback(() => {
setShowRegenerationModal(false)
- }, [])
+ onModalStateChange?.(false)
+ }, [onModalStateChange])
+
+ const onCloseAfterRegeneration = useCallback(() => {
+ setShowRegenerationModal(false)
+ onModalStateChange?.(false)
+ onCancel() // Close the edit drawer
+ }, [onCancel, onModalStateChange])
const onConfirmRegeneration = useCallback(() => {
onUpdate(segInfo?.id || '', question, answer, keywords, true)
@@ -161,7 +171,7 @@ const SegmentDetail: FC<ISegmentDetailProps> = ({
isShow={showRegenerationModal}
onConfirm={onConfirmRegeneration}
onCancel={onCancelRegeneration}
- onClose={onCancelRegeneration}
+ onClose={onCloseAfterRegeneration}
/>
)
}