import React from "react"; import { FaArrowRotateRight } from "react-icons/fa6"; import { FaExternalLinkAlt, FaHome } from "react-icons/fa"; import { useActiveHost } from "#/hooks/query/use-active-host"; import { PathForm } from "#/components/features/served-host/path-form"; function ServedApp() { const { activeHost } = useActiveHost(); const [refreshKey, setRefreshKey] = React.useState(0); const [currentActiveHost, setCurrentActiveHost] = React.useState< string | null >(null); const [path, setPath] = React.useState("hello"); const formRef = React.useRef(null); const handleOnBlur = () => { if (formRef.current) { const formData = new FormData(formRef.current); const urlInputValue = formData.get("url")?.toString(); if (urlInputValue) { const url = new URL(urlInputValue); setCurrentActiveHost(url.origin); setPath(url.pathname); } } }; const resetUrl = () => { setCurrentActiveHost(activeHost); setPath(""); if (formRef.current) { formRef.current.reset(); } }; React.useEffect(() => { resetUrl(); }, [activeHost]); const fullUrl = `${currentActiveHost}/${path}`; if (!currentActiveHost) { return (
If you tell OpenHands to start a web server, the app will appear here.
); } return (