diff --git a/src/renderer/src/pages/home/Tabs/index.tsx b/src/renderer/src/pages/home/Tabs/index.tsx index fb29766528..4b59278840 100644 --- a/src/renderer/src/pages/home/Tabs/index.tsx +++ b/src/renderer/src/pages/home/Tabs/index.tsx @@ -4,12 +4,10 @@ import { useRuntime } from '@renderer/hooks/useRuntime' import { useNavbarPosition, useSettings } from '@renderer/hooks/useSettings' import { useShowTopics } from '@renderer/hooks/useStore' import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService' -import { useAppDispatch } from '@renderer/store' -import { setActiveTabIdAction } from '@renderer/store/runtime' import { Assistant, Topic } from '@renderer/types' import { Tab } from '@renderer/types/chat' import { classNames, uuid } from '@renderer/utils' -import { FC, useCallback, useEffect } from 'react' +import { FC, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -47,21 +45,9 @@ const HomeTabs: FC = ({ const { t } = useTranslation() const { chat } = useRuntime() - const { activeTabId: tab, activeTopicOrSession } = chat - const dispatch = useAppDispatch() - - const setTab = useCallback( - (tab: Tab) => { - dispatch(setActiveTabIdAction(tab)) - }, - [dispatch] - ) - - useEffect(() => { - setTab(position === 'left' ? _tab || 'assistants' : 'topic') - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) + const { activeTopicOrSession } = chat + const [tab, setTab] = useState(position === 'left' ? _tab || 'assistants' : 'topic') const borderStyle = '0.5px solid var(--color-border)' const border = position === 'left' @@ -113,7 +99,6 @@ const HomeTabs: FC = ({ if (position === 'left' && topicPosition === 'right' && tab === 'topic') { setTab('assistants') } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [position, tab, topicPosition, forceToSeeAllTab]) return ( @@ -137,7 +122,7 @@ const HomeTabs: FC = ({ {position === 'right' && topicPosition === 'right' && ( setTab('topic')}> - {t('common.topics')} + {activeTopicOrSession === 'topic' ? t('common.topics') : t('agent.session.label_other')} setTab('settings')}> {t('settings.title')} diff --git a/src/renderer/src/store/runtime.ts b/src/renderer/src/store/runtime.ts index 00c0e43229..499a102525 100644 --- a/src/renderer/src/store/runtime.ts +++ b/src/renderer/src/store/runtime.ts @@ -1,7 +1,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { AppLogo, UserAvatar } from '@renderer/config/env' import type { MinAppType, Topic, WebSearchStatus } from '@renderer/types' -import { Tab } from '@renderer/types/chat' import type { UpdateInfo } from 'builder-util-runtime' export interface ChatState { @@ -15,7 +14,6 @@ export interface ChatState { activeSessionId: Record /** meanwhile active Assistants or Agents */ activeTopicOrSession: 'topic' | 'session' - activeTabId: Tab /** topic ids that are currently being renamed */ renamingTopics: string[] /** topic ids that are newly renamed */ @@ -86,7 +84,6 @@ const initialState: RuntimeState = { chat: { isMultiSelectMode: false, selectedMessageIds: [], - activeTabId: 'assistants', activeTopic: null, activeAgentId: null, activeTopicOrSession: 'topic', @@ -162,9 +159,6 @@ const runtimeSlice = createSlice({ const { agentId, sessionId } = action.payload state.chat.activeSessionId[agentId] = sessionId }, - setActiveTabIdAction: (state, action: PayloadAction) => { - state.chat.activeTabId = action.payload - }, setActiveTopicOrSessionAction: (state, action: PayloadAction<'topic' | 'session'>) => { state.chat.activeTopicOrSession = action.payload }, @@ -208,7 +202,6 @@ export const { setActiveTopic, setActiveAgentId, setActiveSessionIdAction, - setActiveTabIdAction, setActiveTopicOrSessionAction, setRenamingTopics, setNewlyRenamedTopics,