+
{
items.map((segItem) => {
const isLast = items[items.length - 1].id === segItem.id
@@ -67,6 +68,8 @@ const SegmentList: FC = ({
}
)
-}
+})
+
+SegmentList.displayName = 'SegmentList'
export default SegmentList
diff --git a/web/app/components/datasets/documents/detail/new-segment.tsx b/web/app/components/datasets/documents/detail/new-segment.tsx
index 7ab3d7ecd4..413e3de3c8 100644
--- a/web/app/components/datasets/documents/detail/new-segment.tsx
+++ b/web/app/components/datasets/documents/detail/new-segment.tsx
@@ -1,11 +1,13 @@
-import { memo, useState } from 'react'
+import { memo, useRef, useState } from 'react'
import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector'
import { useParams } from 'next/navigation'
import { RiCloseLine, RiExpandDiagonalLine } from '@remixicon/react'
import { useKeyPress } from 'ahooks'
+import { useShallow } from 'zustand/react/shallow'
import { SegmentIndexTag, useSegmentListContext } from './completed'
+import { useStore as useAppStore } from '@/app/components/app/store'
import Button from '@/app/components/base/button'
import AutoHeightTextarea from '@/app/components/base/auto-height-textarea/common'
import { ToastContext } from '@/app/components/base/toast'
@@ -21,12 +23,14 @@ type NewSegmentModalProps = {
onCancel: () => void
docForm: string
onSave: () => void
+ viewNewlyAddedChunk: () => void
}
const NewSegmentModal: FC
= ({
onCancel,
docForm,
onSave,
+ viewNewlyAddedChunk,
}) => {
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
@@ -36,6 +40,20 @@ const NewSegmentModal: FC = ({
const [keywords, setKeywords] = useState([])
const [loading, setLoading] = useState(false)
const [fullScreen, toggleFullScreen] = useSegmentListContext(s => [s.fullScreen, s.toggleFullScreen])
+ const { appSidebarExpand } = useAppStore(useShallow(state => ({
+ appSidebarExpand: state.appSidebarExpand,
+ })))
+ const refreshTimer = useRef(null)
+
+ const CustomButton = <>
+
+
+ >
const handleCancel = () => {
onCancel()
@@ -68,9 +86,18 @@ const NewSegmentModal: FC = ({
setLoading(true)
try {
await addSegment({ datasetId, documentId, body: params })
- notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
+ notify({
+ type: 'success',
+ message: t('datasetDocuments.segment.chunkAdded'),
+ className: `!w-[296px] !bottom-0 ${appSidebarExpand === 'expand' ? '!left-[216px]' : '!left-14'}
+ !top-auto !right-auto !mb-[52px] !ml-11`,
+ duration: 6000,
+ customComponent: CustomButton,
+ })
handleCancel()
- onSave()
+ refreshTimer.current = setTimeout(() => {
+ onSave()
+ }, 6000)
}
finally {
setLoading(false)
diff --git a/web/i18n/en-US/dataset-documents.ts b/web/i18n/en-US/dataset-documents.ts
index a0bcb5bba0..2427e03faa 100644
--- a/web/i18n/en-US/dataset-documents.ts
+++ b/web/i18n/en-US/dataset-documents.ts
@@ -350,6 +350,8 @@ const translation = {
newQaSegment: 'New Q&A Segment',
addChunk: 'Add Chunk',
delete: 'Delete this chunk ?',
+ chunkAdded: '1 chunk added',
+ viewAddedChunk: 'View',
},
}
diff --git a/web/i18n/zh-Hans/dataset-documents.ts b/web/i18n/zh-Hans/dataset-documents.ts
index 355c4bee7f..349ec58340 100644
--- a/web/i18n/zh-Hans/dataset-documents.ts
+++ b/web/i18n/zh-Hans/dataset-documents.ts
@@ -348,6 +348,8 @@ const translation = {
newQaSegment: '新问答分段',
addChunk: '新增分段',
delete: '删除这个分段?',
+ chunkAdded: '新增一个分段',
+ viewAddedChunk: '查看',
},
}
diff --git a/web/service/knowledge/use-segment.ts b/web/service/knowledge/use-segment.ts
index f926468349..65ae2c17d3 100644
--- a/web/service/knowledge/use-segment.ts
+++ b/web/service/knowledge/use-segment.ts
@@ -5,7 +5,7 @@ import type { ChildSegmentResponse, SegmentsResponse } from '@/models/datasets'
const NAME_SPACE = 'segment'
-const useSegmentListKey = [NAME_SPACE, 'chunkList']
+export const useSegmentListKey = [NAME_SPACE, 'chunkList']
export const useSegmentList = (
payload: {