import React from "react"; import { createPortal } from "react-dom"; import { useTranslation } from "react-i18next"; import { I18nKey } from "#/i18n/declaration"; import { getEnvironmentSwitchSnapshot, subscribeEnvironmentSwitch, } from "./environment-switch-store"; // Re-export the store API so existing call sites and tests that import from // this module keep working unchanged. export { ENVIRONMENT_SWITCH_DURATION_MS, ENVIRONMENT_SWITCH_SETACTIVE_DELAY_MS, triggerEnvironmentSwitch, dismissEnvironmentSwitch, __resetEnvironmentSwitchOverlayForTests, } from "./environment-switch-store"; function EnvironmentSwitchIcon({ className }: { className?: string }) { return ( ); } export function EnvironmentSwitchOverlay() { const { t } = useTranslation("openhands"); const { visible, target } = React.useSyncExternalStore( subscribeEnvironmentSwitch, getEnvironmentSwitchSnapshot, getEnvironmentSwitchSnapshot, ); if (!visible || typeof document === "undefined") return null; return createPortal(
{t(I18nKey.BACKEND$SWITCHING_TO, { environment: target })}