Skip to content

Commit

Permalink
🐛 fix: 修复官方助手聊天产生新的 session
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed May 13, 2024
1 parent 7b409c9 commit 618dfbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/features/MarketInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AgentCard from '@/components/agent/AgentCard';
import SystemRole from '@/components/agent/SystemRole';
import { SIDEBAR_MAX_WIDTH, SIDEBAR_WIDTH } from '@/constants/common';
import { agentListSelectors, useAgentStore } from '@/store/agent';
import { useConfigStore } from '@/store/config';
import { marketStoreSelectors, useMarketStore } from '@/store/market';
import { useSessionStore } from '@/store/session';

Expand Down Expand Up @@ -36,6 +37,7 @@ const Header = () => {
marketStoreSelectors.currentAgentItem(s),
],
);
const [closePanel] = useConfigStore((s) => [s.closePanel]);
const [subscribe, unsubscribe, subscribed] = useAgentStore((s) => [
s.subscribe,
s.unsubscribe,
Expand All @@ -55,6 +57,7 @@ const Header = () => {
onClick={() => {
createSession(currentAgentItem);
router.push('/chat');
closePanel('market');
}}
type={'primary'}
>
Expand Down
4 changes: 4 additions & 0 deletions src/store/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ export const createSessonStore: StateCreator<SessionStore, [['zustand/devtools',
},
createSession: (agent: Agent) => {
const { sessionList } = get();
if (agent.agentId === LOBE_VIDOL_DEFAULT_AGENT_ID) {
set({ activeId: agent.agentId });
return;
}

const newSessionList = produce(sessionList, (draft) => {
const index = draft.findIndex((session) => session.agentId === agent.agentId);
Expand Down

0 comments on commit 618dfbb

Please sign in to comment.