🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
fix: Agent swtich UI
Rene Wang3efe8dbfedf2
diff --git a/src/features/PageEditor/Copilot/Conversation.tsx b/src/features/PageEditor/Copilot/Conversation.tsxindex 632fef31992..b365ef2529f 100644--- a/src/features/PageEditor/Copilot/Conversation.tsx+++ b/src/features/PageEditor/Copilot/Conversation.tsx@@ -12,14 +12,16 @@ import CopilotToolbar from './Toolbar';import Welcome from './Welcome';interface ConversationProps {+ // Default agent idagentId: string;}const actions: ActionKeys[] = ['model', 'search'];const Conversation = memo<ConversationProps>(({ agentId }) => {- const [activeAgentId, setActiveAgentId] = useAgentStore((s) => [+ const [activeAgentId, setActiveAgentId, useFetchAgentConfig] = useAgentStore((s) => [s.activeAgentId,s.setActiveAgentId,+ s.useFetchAgentConfig,]);const [isHovered, setIsHovered] = useState(false);@@ -31,6 +33,10 @@ const Conversation = memo<ConversationProps>(({ agentId }) => {const currentAgentId = activeAgentId || agentId;+ // Fetch agent config when activeAgentId changes to ensure it's loaded in the store+ // This is needed when user switches to a different agent+ useFetchAgentConfig(true, currentAgentId);+// Get agent's model info for vision support checkconst model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(currentAgentId)(s));const provider = useAgentStore((s) =>diff --git a/src/features/PageEditor/Copilot/Welcome.tsx b/src/features/PageEditor/Copilot/Welcome.tsxindex a4e400a529e..0a568bac77a 100644--- a/src/features/PageEditor/Copilot/Welcome.tsx+++ b/src/features/PageEditor/Copilot/Welcome.tsx@@ -24,7 +24,7 @@ const AgentBuilderWelcome = memo(() => {}}width={'100%'}>- <Avatar avatar={agent.avatar || DEFAULT_INBOX_AVATAR} shape={'square'} size={78} />+ <Avatar avatar={agent?.avatar || DEFAULT_INBOX_AVATAR} shape={'square'} size={78} /><Text fontSize={24} weight={'bold'}>{t('pageCopilot.title')}</Text>diff --git a/src/features/PageEditor/PageAgentProvider.tsx b/src/features/PageEditor/PageAgentProvider.tsxindex 6fe8dcfae65..5989e8777c4 100644--- a/src/features/PageEditor/PageAgentProvider.tsx+++ b/src/features/PageEditor/PageAgentProvider.tsx@@ -2,6 +2,7 @@ import { type ReactNode, memo, useMemo } from 'react';import { ConversationProvider } from '@/features/Conversation';import { useOperationState } from '@/hooks/useOperationState';+import { useAgentStore } from '@/store/agent';import { useChatStore } from '@/store/chat';import { type MessageMapKeyInput, messageMapKey } from '@/store/chat/utils/messageMapKey';@@ -11,16 +12,25 @@ interface PageAgentProviderProps {}const PageAgentProvider = memo<PageAgentProviderProps>(({ pageAgentId, children }) => {const activeTopicId = useChatStore((s) => s.activeTopicId);+ const [activeAgentId, agentMap] = useAgentStore((s) => [s.activeAgentId, s.agentMap]);// Build conversation context for page agent// Using topic dimension for message management (1 agent can have multiple topics)+ // Use activeAgentId only if it exists in agentMap (is loaded), otherwise fall back to pageAgentId+ const selectedAgentId = useMemo(() => {+ if (activeAgentId && agentMap[activeAgentId]) {+ return activeAgentId;+ }+ return pageAgentId;+ }, [activeAgentId, agentMap, pageAgentId]);+const context = useMemo<MessageMapKeyInput>(() => ({- agentId: pageAgentId,+ agentId: selectedAgentId,scope: 'page',topicId: activeTopicId, // No topic initially, can be extended later}),- [pageAgentId, activeTopicId],+ [selectedAgentId, activeTopicId],);// Get messages from ChatStore based on context