diff --git a/src/components/Sidebar/B4aSidebar.react.js b/src/components/Sidebar/B4aSidebar.react.js index d89a87204..b915164b7 100644 --- a/src/components/Sidebar/B4aSidebar.react.js +++ b/src/components/Sidebar/B4aSidebar.react.js @@ -7,6 +7,7 @@ */ import AppsManager from 'lib/AppsManager'; import FooterMenu from 'components/Sidebar/FooterMenu.react'; +import axios from 'axios'; import React, { useEffect, useState, useContext, useRef } from 'react'; // import SidebarHeader from 'components/Sidebar/SidebarHeader.react'; import B4aSidebarSection from 'components/Sidebar/B4aSidebarSection.react'; @@ -41,6 +42,7 @@ const B4aSidebar = ({ const currentApp = useContext(CurrentApp); const [appsMenuOpen, setAppsMenuOpen] = useState(false); const [aiToolsMenuOpen, setAiToolsMenuOpen] = useState(false); + const [isPayingAgent, setIsPayingAgent] = useState(false); const [collapsed, setCollapsed] = useState(() => { return isSidebarCollapsed !== undefined ? isSidebarCollapsed : isMobile(); }); @@ -85,6 +87,24 @@ const B4aSidebar = ({ } }, []); + useEffect(() => { + let cancelled = false; + (async () => { + try { + const base = new URL(b4aSettings.CONTAINERS_API_PATH, window.location.origin).origin; + const { data } = await axios.get(`${base}/agents-subscription/me`, { withCredentials: true }); + if (!cancelled) { + setIsPayingAgent(Boolean(data && data.isPaying)); + } + } catch (e) { + if (!cancelled) { + setIsPayingAgent(false); + } + } + })(); + return () => { cancelled = true; }; + }, []); + useEffect(() => { isSidebarCollapsed = collapsed; }, [collapsed]); @@ -322,10 +342,12 @@ const B4aSidebar = ({
- - - AI Agent - + {isPayingAgent && ( + + + AI Agent + + )} Model Context Protocol