From e0267ac13e28f436d4c7fca5937e82dbfbada7cd Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Wed, 6 Dec 2023 10:34:20 +0800 Subject: [PATCH] fix: update conversation data after edit Signed-off-by: Lin Wang --- public/components/chat_window_header_title.tsx | 6 +++++- public/tabs/history/chat_history_search_list.tsx | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/public/components/chat_window_header_title.tsx b/public/components/chat_window_header_title.tsx index 096dc409..a71cae4d 100644 --- a/public/components/chat_window_header_title.tsx +++ b/public/components/chat_window_header_title.tsx @@ -40,10 +40,14 @@ export const ChatWindowHeaderTitle = React.memo(() => { (status: 'updated' | string, newTitle?: string) => { if (status === 'updated') { chatContext.setTitle(newTitle); + const sessions = core.services.sessions.sessions$.getValue(); + if (sessions?.objects.find((session) => session.id === chatContext.sessionId)) { + core.services.sessions.reload(); + } } setRenameModalOpen(false); }, - [chatContext] + [chatContext, core.services.sessions] ); const button = ( diff --git a/public/tabs/history/chat_history_search_list.tsx b/public/tabs/history/chat_history_search_list.tsx index 2f703bf3..979fd54f 100644 --- a/public/tabs/history/chat_history_search_list.tsx +++ b/public/tabs/history/chat_history_search_list.tsx @@ -16,6 +16,7 @@ import React, { useCallback, useState } from 'react'; import { ChatHistoryList, ChatHistoryListProps } from './chat_history_list'; import { EditConversationNameModal } from '../../components/edit_conversation_name_modal'; import { DeleteConversationConfirmModal } from './delete_conversation_confirm_modal'; +import { useChatContext } from '../../contexts'; interface ChatHistorySearchListProps extends Pick< @@ -45,6 +46,7 @@ export const ChatHistorySearchList = ({ onHistoryDeleted, onChangeItemsPerPage, }: ChatHistorySearchListProps) => { + const { sessionId, setTitle } = useChatContext(); const [editingConversation, setEditingConversation] = useState<{ id: string; title: string; @@ -52,13 +54,16 @@ export const ChatHistorySearchList = ({ const [deletingConversation, setDeletingConversation] = useState<{ id: string } | null>(null); const handleEditConversationModalClose = useCallback( - (status: 'updated' | string) => { + (status: 'updated' | string, newTitle?: string) => { if (status === 'updated') { onRefresh(); + if (sessionId === editingConversation?.id) { + setTitle(newTitle); + } } setEditingConversation(null); }, - [setEditingConversation, onRefresh] + [setEditingConversation, onRefresh, editingConversation, sessionId, setTitle] ); const handleDeleteConversationConfirmModalClose = useCallback(