import { Progress } from "antd"; import { type CSSProperties } from "react"; import { useTheme } from "../contexts/ThemeContext"; import { useTranslation } from "react-i18next"; import styles from "./BackendLoadingPage.module.less"; import { type BackendReadyStatus } from "./useBackendReadyPolling"; const BRAND_COLOR = "#ff7f16"; const ERROR_COLOR = "#ff4d4f"; interface BackendLoadingPageProps { status: BackendReadyStatus; elapsed: number; totalSec: number; errorMessage?: string; onRetry?: () => void; statusText?: string; hintText?: string; retryLabel?: string; showRetry?: boolean; retryDisabled?: boolean; } export default function BackendLoadingPage({ status, elapsed, totalSec, errorMessage, onRetry, statusText: statusTextOverride, hintText, retryLabel, showRetry = true, retryDisabled = false, }: BackendLoadingPageProps) { const { isDark } = useTheme(); const { t } = useTranslation(); const hasFailed = status === "timeout" || status === "error"; const statusText = statusTextOverride || (status === "error" ? t("startup.error", "Backend failed to start.") : status === "checking" ? elapsed === 0 ? t("startup.starting", "Starting backend...") : t("startup.checking", "Connecting to backend...") : t("startup.timeout", { seconds: elapsed, defaultValue: "Backend failed to start within {{seconds}} seconds.", })); const percent = Math.min(Math.round((elapsed / totalSec) * 100), 100); const style = { "--qwenpaw-brand-color": BRAND_COLOR, "--qwenpaw-error-color": ERROR_COLOR, } as CSSProperties; return (