Fix: Fixed an issue where renaming a chat would create a new chat #3221 (#9563)

### What problem does this PR solve?

Fix: Fixed an issue where renaming a chat would create a new chat #3221
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu 2025-08-19 18:33:55 +08:00 committed by GitHub
parent 33f3e05b75
commit e15e39f183
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -23,8 +23,13 @@ export const useShowFormDrawer = () => {
const handleShow = useCallback(
(e: React.MouseEvent<Element>, nodeId: string) => {
const tool = get(e.target, 'dataset.tool');
// TODO: Operator type judgment should be used
if (nodeId.startsWith(Operator.Tool) && !tool) {
return;
}
setClickedNodeId(nodeId);
setClickedToolId(get(e.target, 'dataset.tool'));
setClickedToolId(tool);
showFormDrawer();
},
[setClickedNodeId, setClickedToolId, showFormDrawer],

View File

@ -1,7 +1,7 @@
import { useSetModalState } from '@/hooks/common-hooks';
import { useSetDialog } from '@/hooks/use-chat-request';
import { IDialog } from '@/interfaces/database/chat';
import { isEmpty } from 'lodash';
import { isEmpty, omit } from 'lodash';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@ -44,7 +44,9 @@ export const useRenameChat = () => {
const onChatRenameOk = useCallback(
async (name: string) => {
const nextChat = {
...(isEmpty(chat) ? InitialData : chat),
...(isEmpty(chat)
? InitialData
: { ...omit(chat, 'nickname', 'tenant_avatar'), dialog_id: chat.id }),
name,
};
const ret = await setDialog(nextChat);