-
Notifications
You must be signed in to change notification settings - Fork 6.9k
chat item soft delete #6216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chat item soft delete #6216
Conversation
Preview mcp_server Image: |
Preview sandbox Image: |
Preview fastgpt Image: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements soft delete functionality for chat items, allowing deleted chat messages to be retained in the database with a deleteTime timestamp instead of being permanently removed. In the logs view, deleted items are grouped and displayed in collapsible sections.
Key Changes:
- Converted hard delete to soft delete by adding a
deleteTimefield to chat items instead of removing them from the database - Added UI support for viewing deleted chat items in collapsible groups (logs view only)
- Updated queries to filter out soft-deleted items by default, with an optional
includeDeletedparameter
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/app/src/pages/api/core/chat/item/delete.ts | Changed from hard delete to soft delete using updateOne with deleteTime |
| projects/app/src/pages/api/core/chat/getRecords_v2.ts | Added includeDeleted parameter to support fetching deleted records |
| projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx | Enabled includeDeleted flag for log viewing |
| projects/app/src/global/core/chat/api.d.ts | Added includeDeleted type definition to API request types |
| projects/app/src/components/core/chat/ChatContainer/utils.ts | Added utility function to group chat items by delete status |
| projects/app/src/components/core/chat/ChatContainer/DeletedItemsCollapse.tsx | New component for displaying collapsed deleted items |
| projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx | Added logic to render deleted items in collapsible groups for log type chats |
| packages/web/i18n/zh-Hant/app.json | Added Traditional Chinese translations for collapse/expand actions |
| packages/web/i18n/zh-CN/app.json | Added Simplified Chinese translations for collapse/expand actions |
| packages/web/i18n/en/app.json | Added English translations for collapse/expand actions |
| packages/service/core/chat/controller.ts | Updated getChatItems to support includeDeleted and filter by deleteTime |
| packages/service/core/chat/chatItemSchema.ts | Added deleteTime field and updated indexes |
| packages/global/openapi/core/chat/controler/api.ts | Added coerce.boolean for loadCustomFeedbacks parameter |
| packages/global/core/chat/type.d.ts | Added deleteTime field to ChatItemSchemaType and ChatSiteItemType |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await MongoChatItem.updateOne( | ||
| { | ||
| appId, | ||
| chatId, | ||
| dataId: contentId | ||
| }).session(session); | ||
|
|
||
| if (item?.obj === ChatRoleEnum.Human && delFile) { | ||
| const s3ChatSource = getS3ChatSource(); | ||
| for (const value of item.value) { | ||
| if (value.type === ChatItemValueTypeEnum.file && value.file?.key) { | ||
| await s3ChatSource.deleteChatFileByKey(value.file.key); | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| $set: { deleteTime: new Date() } | ||
| } | ||
| }); | ||
| ); |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updateOne operation does not check if the update was successful or if the record exists. Consider checking the result of the updateOne operation to verify that a record was actually updated and return an appropriate error if the contentId doesn't exist.
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
Outdated
Show resolved
Hide resolved
| processedRecords, | ||
| toggleDeletedGroup, | ||
| itemRefs, | ||
| chatRecords, |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chatRecords dependency in the RecordsBox useMemo is redundant since processedRecords already depends on chatRecords and is included in the dependency array. Including both can cause unnecessary re-renders. Consider removing chatRecords from this dependency array.
| chatRecords, |
* refactor: fastgpt object storage & global proxy (#6155) * feat: migrate to fastgpt storage sdk * chore: rename env variable * chore: move to sdk dir * docs: object storage * CHORE * chore: storage mocks * chore: update docker-compose * fix: global proxy agent * fix: update COS proxy * refactor: use fetch instead of http.request * fix: axios request base url * fix: axios proxy request behavior * fix: bumps axios * fix: patch axios for proxy * fix: replace axios with proxied axios * fix: upload txt file encoding * clean code * fix: use "minio" for minio adapter (#6205) * fix: use minio client to delete files when using minio vendor (#6206) * doc * feat: filter citations and add response button control (#6170) * feat: filter citations and add response button control * i18n * fix * fix test * perf: chat api code * fix: workflow edge overlap and auto-align in folded loop nodes (#6204) * fix: workflow edge overlap and auto-align in folded loop nodes * sort * fix * fix edge * fix icon * perf: s3 file name * perf: admin get app api * perf: catch user error * fix: refactor useOrg hook to use debounced search key (#6180) * chore: comment minio adapter (#6207) * chore: filename with suffix random id * perf: s3 storage code * fix: encode filename when copy object --------- Co-authored-by: archer <[email protected]> * fix: node card link * json * perf: chat index; * index * chat item soft delete (#6216) * chat item soft delete * temp * fix * remove code * perf: delete chat item --------- Co-authored-by: archer <[email protected]> * feat: select wheather filter sensitive info when export apps (#6222) * fix some bugs (#6210) * fix v4.14.5 bugs * type * fix * fix * custom feedback * fix * code * fix * remove invalid function --------- Co-authored-by: archer <[email protected]> * perf: test * fix file default local upload (#6223) * docs: improve object storage introduction (#6224) * doc --------- Co-authored-by: roy <[email protected]> Co-authored-by: heheer <[email protected]> Co-authored-by: Finley Ge <[email protected]>
No description provided.