delete segment will refresh all the list #5129

Closed
opened 2026-02-21 18:09:30 -05:00 by yindo · 0 comments
Owner

Originally created by @nadirvishun on GitHub (Aug 20, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

When segmenting documents, tables are often divided into several sections or related information is split up, so it is necessary to manually optimize the segmented content frequently. However, when a segment is deleted, all lists are refreshed and returned to the first page. When there are many segments, I need to scroll down for a long time to locate the position where the deletion occurred in order to continue with subsequent work. Therefore, it is necessary to remove the paragraph directly from the front-end list after deletion, without the need to refresh the entire list.
image

2. Additional context or comments

change delete event like this:

const onDelete = async (segId: string) => {
    const [e] = await asyncRunSafe<CommonResponse>(deleteSegment({ datasetId, documentId, segmentId: segId }) as Promise<CommonResponse>)
    if (!e) {
      notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
      //------------remove------------
      //resetList()
      //------------add---------------
      //change allSegments
      for (const item of allSegments) {
        let index = item.findIndex(e => e.id === segId)
        if (index !== -1) {
          item.splice(index, 1)
          break
        }
      }
      setAllSegments([...allSegments])
      //change lastSegmentsRes
      if (lastSegmentsRes !== undefined) {
        let index = lastSegmentsRes.data.findIndex(e => e.id === segId)
        if (index !== -1) {
          lastSegmentsRes.data.splice(index, 1)
        }
      }
      //change total
      if (total) {
        setTotal(total - 1)
      }
    }
    else {
      notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
    }
  }

The test results are as follows, I'm not clear why the front-end design needs to be grouped for display, rather than just arranging everything in a list?
image

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @nadirvishun on GitHub (Aug 20, 2024). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. When segmenting documents, tables are often divided into several sections or related information is split up, so it is necessary to manually optimize the segmented content frequently. However, when a segment is deleted, all lists are refreshed and returned to the first page. When there are many segments, I need to scroll down for a long time to locate the position where the deletion occurred in order to continue with subsequent work. Therefore, it is necessary to remove the paragraph directly from the front-end list after deletion, without the need to refresh the entire list. ![image](https://github.com/user-attachments/assets/ac26d67c-42a4-405f-bb1d-7faff88bbf77) ### 2. Additional context or comments change delete event like this: ``` const onDelete = async (segId: string) => { const [e] = await asyncRunSafe<CommonResponse>(deleteSegment({ datasetId, documentId, segmentId: segId }) as Promise<CommonResponse>) if (!e) { notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) //------------remove------------ //resetList() //------------add--------------- //change allSegments for (const item of allSegments) { let index = item.findIndex(e => e.id === segId) if (index !== -1) { item.splice(index, 1) break } } setAllSegments([...allSegments]) //change lastSegmentsRes if (lastSegmentsRes !== undefined) { let index = lastSegmentsRes.data.findIndex(e => e.id === segId) if (index !== -1) { lastSegmentsRes.data.splice(index, 1) } } //change total if (total) { setTotal(total - 1) } } else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) } } ``` The test results are as follows, I'm not clear why the front-end design needs to be grouped for display, rather than just arranging everything in a list? ![image](https://github.com/user-attachments/assets/33d41815-a6d8-4fdf-a853-04a778b53fd2) ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 18:09:30 -05:00
yindo closed this issue 2026-02-21 18:09:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5129