import { ButtonAction } from "@/components/ButtonActionLoader"; import { CodeBlock } from "@/components/CodeBlock"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { ScrollArea } from "@/components/ui/scroll-area"; import { TableCell, TableRow } from "@/components/ui/table"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getInputsFromWorkflow } from "@/lib/getInputsFromWorkflow"; import { getRelativeTime } from "@/lib/getRelativeTime"; import { removePublicShareDeployment } from "@/server/curdDeploments"; import type { findAllDeployments } from "@/server/findAllRuns"; import { ExternalLink } from "lucide-react"; import { headers } from "next/headers"; import Link from "next/link"; const curlTemplate = ` curl --request POST \ --url \ --header "Content-Type: application/json" \ --data "{ "deployment_id": "" }" `; const curlTemplate_checkStatus = ` curl --request GET \ --url "/api/run?run_id=xxx" \ --header "Content-Type: application/json" `; const jsTemplate = ` const { run_id } = await fetch("", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, body: JSON.stringify({ deployment_id: "", inputs: {} }), }).then(response => response.json()) `; const jsTemplate_checkStatus = ` const run_id = ""; const output = fetch("?run_id=" + run_id, { method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + process.env.COMFY_DEPLOY_API_KEY, }, }).then(response => response.json()) `; const clientTemplate = ` const client = new ComfyDeployClient({ apiBase: "", apiToken: process.env.COMFY_DEPLOY_API_KEY!, }); export async function generateTextures(scrImageId: string) { const result = await client.run("", { input_image: "", }); if (!result || !result.run_id) return { error: "run id not found" }; return { id: result.run_id }; } `; const clientTemplate_checkStatus = ` const run_id = ""; while (true) { const run = await client.getRun(run_id); await new Promise((resolve) => setTimeout(resolve, 3000)); if (!run) continue; run.outputs.map((val) => { if (!val.data.image) return; }); } `; export function DeploymentDisplay({ deployment, }: { deployment: Awaited>[0]; }) { const headersList = headers(); const host = headersList.get("host") || ""; const protocol = headersList.get("x-forwarded-proto") || ""; const domain = `${protocol}://${host}`; const workflowInput = getInputsFromWorkflow(deployment.version); return ( {deployment.environment} {deployment.version?.version} {deployment.machine?.name} {getRelativeTime(deployment.updated_at)} {deployment.environment} Deployment Code for your deployment client {deployment.environment !== "public-share" ? ( client js curl
Trigger the workflow with  comfy deploy wrapper
Copy the wrapper to your project, and import the function
Check the status of the run, and retrieve the outputs
Trigger the workflow Check the status of the run, and retrieve the outputs
) : (
)}
); } function formatCode( codeTemplate: string, deployment: Awaited>[0], domain: string, inputs?: ReturnType ) { if (inputs && inputs.length > 0) { codeTemplate = codeTemplate.replace( "inputs: {}", `inputs: ${JSON.stringify( Object.fromEntries( inputs.map((x) => { return [x?.input_id, ""]; }) ), null, 2 ) .split("\n") .map((line, index) => (index === 0 ? line : ` ${line}`)) // Add two spaces indentation except for the first line .join("\n")}` ); } else { codeTemplate = codeTemplate.replace( ` inputs: {}`, "" ); } return codeTemplate .replace("", `${domain ?? "http://localhost:3000"}/api/run`) .replace("", deployment.id) .replace("", domain ?? "http://localhost:3000"); }