import type { Boolean, EmptyRequest } from "@shared/proto/cline/common" import { useEffect } from "react" import AccountView from "./components/account/AccountView" import ChatView from "./components/chat/ChatView" import HistoryView from "./components/history/HistoryView" import McpView from "./components/mcp/configuration/McpConfigurationView" import OnboardingView from "./components/onboarding/OnboardingView" import SettingsView from "./components/settings/SettingsView" import WelcomeView from "./components/welcome/WelcomeView" import WorktreesView from "./components/worktrees/WorktreesView" import { useClineAuth } from "./context/ClineAuthContext" import { useExtensionState } from "./context/ExtensionStateContext" import { Providers } from "./Providers" import { UiServiceClient } from "./services/grpc-client" const AppContent = () => { const { didHydrateState, showWelcome, shouldShowAnnouncement, showMcp, mcpTab, showSettings, settingsTargetSection, showHistory, showAccount, showWorktrees, showAnnouncement, onboardingModels, setShowAnnouncement, setShouldShowAnnouncement, closeMcpView, navigateToHistory, hideSettings, hideHistory, hideAccount, hideWorktrees, hideAnnouncement, } = useExtensionState() const { clineUser, organizations, activeOrganization } = useClineAuth() useEffect(() => { if (shouldShowAnnouncement) { setShowAnnouncement(true) // Use the gRPC client instead of direct WebviewMessage UiServiceClient.onDidShowAnnouncement({} as EmptyRequest) .then((response: Boolean) => { setShouldShowAnnouncement(response.value) }) .catch((error) => { console.error("Failed to acknowledge announcement:", error) }) } }, [shouldShowAnnouncement, setShouldShowAnnouncement, setShowAnnouncement]) if (!didHydrateState) { return null } if (showWelcome) { return onboardingModels ? : } return (
{showSettings && } {showHistory && } {showMcp && } {showAccount && ( )} {showWorktrees && } {/* Do not conditionally load ChatView, it's expensive and there's state we don't want to lose (user input, disableInput, askResponse promise, etc.) */}
) } const App = () => { return ( ) } export default App