import React, { useCallback, useRef } from 'react'; import Sidebar from './Sidebar/Sidebar'; import ChatArea from './ChatArea/ChatArea'; import InputSection from './ChatArea/InputSection'; import DropZoneOverlay from './ChatArea/DropZoneOverlay'; import MobileHeader from './Header/MobileHeader'; import LoginModal from './Modals/LoginModal'; import RateLimitModal from './Modals/RateLimitModal'; import ConfirmDeleteModal from './Modals/ConfirmDeleteModal'; import ProposeChangesModal from './Modals/ProposeChangesModal'; import ProfileLogo from './Logos/ProfileLogo'; import SettingsModal from './Modals/SettingsModal'; import UpgradeModal from './Modals/UpgradeModal'; import WorkflowsLibraryModal from './Workflows/WorkflowsLibraryModal'; import { useFeatureFlag } from '../featureFlags'; import Footer from './Footer/Footer'; import { useAuth } from '../contexts/AuthContext'; import { useIsMobileSidebarOpen } from '../contexts/UIContext'; import { useCurrentConversationId } from '../contexts/ChatContext'; import useRenderTracker from '../hooks/useRenderTracker'; import MobileSidebar from './Sidebar/MobileSidebar'; import { ALLOW_ACTIONPANEL_AI_REQUESTS, TARGET_ENV, IS_WORDPRESS, SETUP_COMPLETED } from '../constants'; import AssistantDisabledGate from './AssistantDisabledGate'; import InitialSetupGate from './InitialSetupGate'; import { useAppRoute } from '../hooks/useAppRoute'; import { usePluginSettings } from '../contexts/PluginSettingsContext'; import WebNavigationLinks from './Header/WebNavigationLinks'; import { useConversationRouteSync } from '../hooks/useConversationRouteSync'; const ATIBA_CONTACT_URL = IS_WORDPRESS ? 'https://atiba.com/get-quote' : 'https://atiba.com/get-quote?utm_source=wpassistant&utm_medium=referral&utm_campaign=wpassistant&utm_id=10219074-wpassistant'; const WPAssistant: React.FC = () => { const isMobileSidebarOpen = useIsMobileSidebarOpen(); const currentConversationId = useCurrentConversationId(); const pluginSettings = usePluginSettings(); const billingEnabled = useFeatureFlag('billing'); const workflowsEnabled = useFeatureFlag('workflows') && IS_WORDPRESS; const { openSettingsRoute } = useAppRoute(); const { isLoggedIn, userInfo, } = useAuth(); const setupCompleted = TARGET_ENV === 'wordpress' ? pluginSettings.setupCompleted : SETUP_COMPLETED; const allowActionPanelAiRequests = TARGET_ENV === 'wordpress' ? pluginSettings.allowActionPanelAiRequests : ALLOW_ACTIONPANEL_AI_REQUESTS; useRenderTracker('WPAssistant', { isLoggedIn, userInfo, }); useConversationRouteSync(); // Memoized handler const handleSettingsOpen = useCallback(() => { openSettingsRoute('account'); }, [openSettingsRoute]); const scrollRef = useRef(null); const scrollToBottom = useCallback((behavior: ScrollBehavior) => { const el = scrollRef.current; if (el) { el.scrollTo({ top: el.scrollHeight, behavior }); } }, []); // Calculate whether banner is showing const openAssistantSettings = useCallback(() => { openSettingsRoute('assistant'); }, [openSettingsRoute]); if (TARGET_ENV === 'wordpress' && !setupCompleted) { return (
); } if (TARGET_ENV === 'wordpress' && !allowActionPanelAiRequests) { return (
); } return (
{billingEnabled && } {workflowsEnabled && }
{isMobileSidebarOpen && ( )}
{/* Soft brand wash bleeding from the very top, behind the (transparent) header and the scroll content. */}
{/* Header sits in normal flow (not overlaying the scroll area) so the conversation scrollbar starts cleanly below it instead of vanishing behind it. It's transparent, so the top glow still shows through. */}
{!IS_WORDPRESS && ( )} {isLoggedIn && userInfo && ( )}
{currentConversationId && (
)}
{currentConversationId && ( )} {!IS_WORDPRESS && (
Still stuck? Atiba can help. Contact us here.
)}
); }; export default WPAssistant;