Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | import type { Boolean, EmptyRequest } from "@shared/proto/cline/common"
import { useEffect } from "react"
import ChatView from "./components/chat/ChatView"
import HistoryView from "./components/history/HistoryView"
import MapPanel from "./components/map/MapPanel"
import MapView from "./components/map/MapView"
import McpView from "./components/mcp/configuration/McpConfigurationView"
import SettingsView from "./components/settings/SettingsView"
import WelcomeView from "./components/welcome/WelcomeView"
import { useExtensionState } from "./context/ExtensionStateContext"
import { Providers } from "./Providers"
import { UiServiceClient } from "./services/grpc-client"
// Check if running in standalone map mode (separate panel)
const isStandaloneMapMode = () => {
return typeof window !== "undefined" && (window as any).AIHYDRO_MAP_STANDALONE === true
}
const AppContent = () => {
// Otherwise, render normal app UI
const {
didHydrateState,
showWelcome,
shouldShowAnnouncement,
showMcp,
mcpTab,
showSettings,
showHistory,
showMap,
showAnnouncement,
setShowAnnouncement,
setShouldShowAnnouncement,
closeMcpView,
navigateToHistory,
hideSettings,
hideHistory,
hideMap,
hideAnnouncement,
} = useExtensionState()
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])
// Show loading screen with spinner
if (!didHydrateState) {
return (
<div className="flex h-screen w-full items-center justify-center bg-[var(--vscode-editor-background)]">
<div className="flex flex-col items-center space-y-4">
<div className="h-8 w-8 animate-spin rounded-full border-2 border-[var(--vscode-progressBar-background)] border-t-transparent"></div>
<div className="text-sm text-[var(--vscode-descriptionForeground)]">Loading AI-Hydro...</div>
</div>
</div>
)
}
if (showWelcome) {
return <WelcomeView />
}
return (
<div className="flex h-screen w-full flex-col">
{showSettings && <SettingsView onDone={hideSettings} />}
{showHistory && <HistoryView onDone={hideHistory} />}
{showMcp && <McpView initialTab={mcpTab} onDone={closeMcpView} />}
{showMap && <MapPanel />}
{/* Do not conditionally load ChatView, it's expensive and there's state we don't want to lose (user input, disableInput, askResponse promise, etc.) */}
<ChatView
hideAnnouncement={hideAnnouncement}
isHidden={showSettings || showHistory || showMcp || showMap}
showAnnouncement={showAnnouncement}
showHistoryView={navigateToHistory}
/>
</div>
)
}
const App = () => {
// Check if in standalone map mode and render directly with Providers
if (isStandaloneMapMode()) {
return (
<Providers>
<div className="flex h-screen w-full">
<MapView height={window.innerHeight} width={window.innerWidth} />
</div>
</Providers>
)
}
return (
<Providers>
<AppContent />
</Providers>
)
}
export default App
|