diff --git a/src/renderer/src/components/app/MainSidebar.tsx b/src/renderer/src/components/app/MainSidebar.tsx index bc8a1a640b..60c957490f 100644 --- a/src/renderer/src/components/app/MainSidebar.tsx +++ b/src/renderer/src/components/app/MainSidebar.tsx @@ -48,7 +48,6 @@ const MainSidebar: FC = () => { const [isAppMenuExpanded, setIsAppMenuExpanded] = useState(false) const location = useLocation() - const state = location.state const { pathname } = location const { activeAssistant, activeTopic, setActiveAssistant, setActiveTopic } = useChat() @@ -58,12 +57,6 @@ const MainSidebar: FC = () => { NavigationService.setNavigate(navigate) }, [navigate]) - useEffect(() => { - state?.assistant && setActiveAssistant(state?.assistant) - state?.topic && setActiveTopic(state?.topic) - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [state]) - useEffect(() => { const unsubscribe = EventEmitter.on(EVENT_NAMES.SWITCH_ASSISTANT, (assistantId: string) => { const newAssistant = assistants.find((a) => a.id === assistantId) @@ -78,7 +71,7 @@ const MainSidebar: FC = () => { }, [assistants, setActiveAssistant]) useEffect(() => { - const canMinimize = topicPosition == 'left' ? !showAssistants : !showAssistants && !showTopics + const canMinimize = !showAssistants && !showTopics window.api.window.setMinimumSize(canMinimize ? 520 : 1080, 600) return () => { @@ -86,6 +79,10 @@ const MainSidebar: FC = () => { } }, [showAssistants, showTopics, topicPosition]) + useEffect(() => { + setIsAppMenuExpanded(false) + }, [activeAssistant.id, activeTopic.id]) + const onAvatarClick = () => { navigate('/settings/provider') } @@ -111,10 +108,6 @@ const MainSidebar: FC = () => { const isRoutes = (path: string): boolean => pathname.startsWith(path) - if (location.pathname !== '/') { - return null - } - const onChageTab = (tab: Tab) => { setTab(tab) setIsAppMenuExpanded(false) @@ -124,6 +117,10 @@ const MainSidebar: FC = () => { return null } + if (location.pathname !== '/') { + return null + } + return ( diff --git a/src/renderer/src/hooks/useChat.tsx b/src/renderer/src/hooks/useChat.tsx index 5c92759e3e..be44bccb77 100644 --- a/src/renderer/src/hooks/useChat.tsx +++ b/src/renderer/src/hooks/useChat.tsx @@ -4,7 +4,6 @@ import { setActiveAssistant, setActiveTopic } from '@renderer/store/runtime' import { loadTopicMessagesThunk } from '@renderer/store/thunk/messageThunk' import { Assistant } from '@renderer/types' import { Topic } from '@renderer/types' -import { find } from 'lodash' import { useEffect } from 'react' import { useAssistants } from './useAssistant' @@ -23,11 +22,9 @@ export const useChat = () => { }, [activeTopic, dispatch]) useEffect(() => { - // activeTopic not in assistant.topics - if (activeAssistant && !find(activeAssistant.topics, { id: activeTopic?.id })) { - dispatch(setActiveTopic(activeAssistant.topics[0])) - } - }, [activeTopic?.id, activeAssistant, dispatch]) + const firstTopic = activeAssistant.topics[0] + firstTopic && dispatch(setActiveTopic(firstTopic)) + }, [activeAssistant, dispatch]) return { activeAssistant, diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 83b3373093..b0e01a4c15 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -14,7 +14,7 @@ import { useAssistant } from '@renderer/hooks/useAssistant' import { useKnowledgeBases } from '@renderer/hooks/useKnowledge' import { useMCPServers } from '@renderer/hooks/useMCPServers' import { useMessageOperations, useTopicLoading } from '@renderer/hooks/useMessageOperations' -import { modelGenerating, useRuntime } from '@renderer/hooks/useRuntime' +import { useRuntime } from '@renderer/hooks/useRuntime' import { useMessageStyle, useSettings } from '@renderer/hooks/useSettings' import { useShortcut, useShortcutDisplay } from '@renderer/hooks/useShortcuts' import { useSidebarIconShow } from '@renderer/hooks/useSidebarIcon' @@ -405,8 +405,6 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = } const addNewTopic = useCallback(async () => { - await modelGenerating() - const topic = getDefaultTopic(assistant.id) await db.topics.add({ id: topic.id, messages: [] })