import { Trans, useLingui } from "@lingui/react/macro"; import type { Bot, ComputerStatus } from "@rakazo/contracts"; import { Button, cn } from "@rakazo/ui-web"; import { X } from "lucide-react"; import { useEffect, useState } from "react"; import { agentPointerFeed } from "../../lib/agent-pointer"; import { LocalBrowserPreview } from "./LocalBrowserPreview"; import { OoComputerBrowser } from "./OoComputerBrowser"; export type InAppBrowserMode = "oo" | "local"; export function InAppBrowser({ onClose, active, computer, embeddedScreenUrl, computerScreenError, sandboxProvider, booting, onRefreshScreen, onOpenComputer, hideCloseButton = false, }: { onClose: () => void; active: Bot | null; computer: ComputerStatus | null; embeddedScreenUrl: string | null; computerScreenError: React.ReactNode; sandboxProvider: string | undefined; booting: boolean; onRefreshScreen: () => Promise; onOpenComputer?: () => void; hideCloseButton?: boolean; }) { const { t } = useLingui(); const [mode, setMode] = useState("oo"); useEffect(() => { if (!active?.id) return; return agentPointerFeed.subscribe(active.id, () => { setMode("oo"); }); }, [active?.id]); return (
{!hideCloseButton ? ( ) : null}
{mode === "local" ? ( ) : active ? ( ) : (
Select an Oo to open its browser.
)}
); }