import { Button } from "@cloudflare/kumo"; import { ArrowSquareOutIcon, ArrowClockwiseIcon, SpinnerGapIcon } from "@phosphor-icons/react"; import flowMark from "../assets/flow-mark.svg"; import hfLogo from "../assets/hf-logo.svg"; import { useEffect, useState } from "react"; import { pendingShare } from "../lib/deepLink"; import { isEmbedded, newTabUrl } from "../lib/hfAuth"; import { fetchShare } from "../lib/share"; import { useAuthStore } from "../store/useAuthStore"; import { useSyncStore } from "../store/useSyncStore"; const LOGO = ; /** Someone opened a share link while signed out: say what it is before asking them to sign in. */ function SharePreview() { const [info, setInfo] = useState<{ owner: string; title: string } | null>(null); useEffect(() => { const id = pendingShare(); if (!id) return; let live = true; void fetchShare(id) .then((s) => live && setInfo({ owner: s.owner, title: s.title })) .catch(() => undefined); return () => { live = false; }; }, []); if (!info) return null; return (

@{info.owner} shared “{info.title}” with you. Sign in to open your own copy.

); } /** * Everything before the editor: signed out, signing in (embedded: in a new tab), and loading the * account's storage. Flow keeps workflows only in the user's Hugging Face bucket, so there is no * signed-out editor. */ export function SignInGate() { const user = useAuthStore((s) => s.user); const busy = useAuthStore((s) => s.busy); const configured = useAuthStore((s) => s.configured); const pending = useAuthStore((s) => s.pending); const error = useAuthStore((s) => s.error); const bootError = useSyncStore((s) => s.bootError); const auth = useAuthStore.getState(); let body: React.ReactNode; if (user && bootError) { body = ( <>

{bootError}

); } else if (user || busy) { body = (

{user ? "Loading your workflows…" : "Signing in…"}

); } else if (!configured) { body =

Sign-in isn't configured for this deployment (no OAuth client id).

; } else if (pending === "tab") { body = ( <>

Signed in in the new tab? Continue there: it's the full app, and your work saves to your account either way.

{error && (

{error}

)}

Didn't see a tab?{" "} Open the sign-in tab {" "} ·{" "}

); } else { body = ( <> {error && (

{error}

)}

{isEmbedded ? "Opens Flow in a new tab to sign in. " : ""}Flow is still in beta and hasn't launched yet. It's an independent tool, not made by Hugging Face. Runs use your own quota; workflows save to a private bucket on your account.

); } return (

Flow

Beta

A visual editor for chaining Hugging Face Spaces into workflows and running them from one canvas.

{!user && } {body}
); }