diff --git a/src/renderer/src/hooks/useAssistant.ts b/src/renderer/src/hooks/useAssistant.ts index 513b67cd..1074569a 100644 --- a/src/renderer/src/hooks/useAssistant.ts +++ b/src/renderer/src/hooks/useAssistant.ts @@ -1,3 +1,4 @@ +import { db } from '@renderer/databases' import { getDefaultTopic } from '@renderer/services/AssistantService' import { useAppDispatch, useAppSelector } from '@renderer/store' import { @@ -50,8 +51,20 @@ export function useAssistant(id: string) { dispatch(removeTopic({ assistantId: assistant.id, topic })) }, moveTopic: (topic: Topic, toAssistant: Assistant) => { - dispatch(addTopic({ assistantId: toAssistant.id, topic: { ...topic } })) + dispatch(addTopic({ assistantId: toAssistant.id, topic: { ...topic, assistantId: toAssistant.id } })) dispatch(removeTopic({ assistantId: assistant.id, topic })) + // update topic messages in database + db.topics + .where('id') + .equals(topic.id) + .modify((dbTopic) => { + if (dbTopic.messages) { + dbTopic.messages = dbTopic.messages.map((message) => ({ + ...message, + assistantId: toAssistant.id + })) + } + }) }, updateTopic: (topic: Topic) => dispatch(updateTopic({ assistantId: assistant.id, topic })), updateTopics: (topics: Topic[]) => dispatch(updateTopics({ assistantId: assistant.id, topics })), diff --git a/src/renderer/src/pages/history/HistoryPage.tsx b/src/renderer/src/pages/history/HistoryPage.tsx index a4e75471..bc0f45c9 100644 --- a/src/renderer/src/pages/history/HistoryPage.tsx +++ b/src/renderer/src/pages/history/HistoryPage.tsx @@ -21,6 +21,7 @@ let _message: Message | undefined const TopicsPage: FC = () => { const { t } = useTranslation() const [search, setSearch] = useState(_search) + const [searchKeywords, setSearchKeywords] = useState(_search) const [stack, setStack] = useState(_stack) const [topic, setTopic] = useState(_topic) const [message, setMessage] = useState(_message) @@ -40,6 +41,7 @@ const TopicsPage: FC = () => { } const onSearch = () => { + setSearchKeywords(search) setStack(['topics', 'search']) setTopic(undefined) } @@ -84,7 +86,7 @@ const TopicsPage: FC = () => { /> { const SearchMessage: FC = ({ message, ...props }) => { const navigate = NavigationService.navigate! + const { messageStyle } = useSettings() const { t } = useTranslation() if (!message) { @@ -22,7 +24,7 @@ const SearchMessage: FC = ({ message, ...props }) => { } return ( - +