chat / client /src /components /SidePanel /Agents /AgentPanelSwitch.tsx
helloya20's picture
Upload 2345 files
f0743f4 verified
import { useEffect } from 'react';
import { AgentPanelProvider, useAgentPanelContext } from '~/Providers/AgentPanelContext';
import { Panel, isEphemeralAgent } from '~/common';
import VersionPanel from './Version/VersionPanel';
import { useChatContext } from '~/Providers';
import ActionsPanel from './ActionsPanel';
import AgentPanel from './AgentPanel';
import MCPPanel from './MCPPanel';
export default function AgentPanelSwitch() {
return (
<AgentPanelProvider>
<AgentPanelSwitchWithContext />
</AgentPanelProvider>
);
}
function AgentPanelSwitchWithContext() {
const { conversation } = useChatContext();
const { activePanel, setCurrentAgentId } = useAgentPanelContext();
useEffect(() => {
const agent_id = conversation?.agent_id ?? '';
if (!isEphemeralAgent(agent_id)) {
setCurrentAgentId(agent_id);
}
}, [setCurrentAgentId, conversation?.agent_id]);
if (activePanel === Panel.actions) {
return <ActionsPanel />;
}
if (activePanel === Panel.version) {
return <VersionPanel />;
}
if (activePanel === Panel.mcp) {
return <MCPPanel />;
}
return <AgentPanel />;
}