From e15e39f1836363dd1bdef61c1e4e803225be3f83 Mon Sep 17 00:00:00 2001 From: balibabu Date: Tue, 19 Aug 2025 18:33:55 +0800 Subject: [PATCH] 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) --- web/src/pages/agent/hooks/use-show-drawer.tsx | 7 ++++++- web/src/pages/next-chats/hooks/use-rename-chat.ts | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/web/src/pages/agent/hooks/use-show-drawer.tsx b/web/src/pages/agent/hooks/use-show-drawer.tsx index 7eae28e38..6789e86ba 100644 --- a/web/src/pages/agent/hooks/use-show-drawer.tsx +++ b/web/src/pages/agent/hooks/use-show-drawer.tsx @@ -23,8 +23,13 @@ export const useShowFormDrawer = () => { const handleShow = useCallback( (e: React.MouseEvent, 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], diff --git a/web/src/pages/next-chats/hooks/use-rename-chat.ts b/web/src/pages/next-chats/hooks/use-rename-chat.ts index a0d87cb77..c0db14233 100644 --- a/web/src/pages/next-chats/hooks/use-rename-chat.ts +++ b/web/src/pages/next-chats/hooks/use-rename-chat.ts @@ -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);