The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Home: the setup guide is in the page from the start, so it no longer pushes Home down
Claude9f530e130090
diff --git a/src/components/get-started.tsx b/src/components/get-started.tsxindex 1cce4d9b..5818a2cb 100644--- a/src/components/get-started.tsx+++ b/src/components/get-started.tsx@@ -3,11 +3,11 @@import { useQueryClient } from "@tanstack/react-query";import { AudioLines, Bot, Clapperboard, Cloud, Copy, Cpu, ExternalLink, ImageIcon, Megaphone, Mic2, Sparkles, Video, Wand2, X } from "lucide-react";import Link from "next/link";-import { useState } from "react";+import { useId, useState } from "react";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { ConnectField, useSettings } from "@/components/connect-field";-import { saveSettings, type StatusInfo } from "@/lib/api";+import { saveSettings, useEngineMode, type StatusInfo } from "@/lib/api";import { copyWithToast } from "@/lib/clipboard";import { COMFY_INSTALL_COMMAND, COMFY_INSTALL_DOCS, FAL_KEYS_URL, nothingConnected } from "@/lib/connections";import { cn } from "@/lib/utils";@@ -58,7 +58,8 @@ export function GetStarted({intents = true,className,}: {- status: StatusInfo;+ /** Undefined while it loads (Home's static shell): the guide is drawn for this browser's engine mode. */+ status?: StatusInfo;/** What a first image and clip cost on the paid route (starterPriceLine on the server). */prices?: string;/** "Just try it": after the guide is put away (Home focuses its composer). */@@ -75,7 +76,9 @@ export function GetStarted({const settings = useSettings().data;const get = (n: string) => settings?.find((s) => s.name === n);const [hiding, setHiding] = useState(false);- const mode = status.engineMode;+ const titleId = useId();+ const cachedMode = useEngineMode();+ const mode = status?.engineMode ?? cachedMode;const hide = async () => {setHiding(true);@@ -94,14 +97,14 @@ export function GetStarted({const connected = (what: string) => (r: { detail: string }) => toast.success(`${what} connected`, { description: r.detail });return (- <div className={cn("w-full animate-fade-up rounded-2xl border bg-muted/40 p-4 text-left sm:p-5", className)} aria-labelledby="get-started-title">+ <section className={cn("w-full animate-fade-up rounded-2xl border bg-muted/40 p-4 text-left sm:p-5", className)} aria-labelledby={titleId}><div className="flex items-start gap-3"><div className="min-w-0 flex-1">- <h2 id="get-started-title" className="font-heading text-[24px] leading-tight">+ <h2 id={titleId} className="font-heading text-[24px] leading-tight">Get started</h2><p className="mt-1 text-[13px] text-muted-foreground">- {nothingConnected(status)+ {!status || nothingConnected(status)? "Nothing is connected yet, so every run is a free demo with placeholder results. Connect a model to make the real thing:": "Three ways to make things with Fuobe. Connect another one, or check one you set up:"}</p>@@ -201,6 +204,6 @@ export function GetStarted({</ul></div>)}- </div>+ </section>);}diff --git a/src/components/home-view.tsx b/src/components/home-view.tsxindex b0e2dac3..2d50f14e 100644--- a/src/components/home-view.tsx+++ b/src/components/home-view.tsx@@ -19,7 +19,7 @@ import {ZoomIn,} from "lucide-react";import { useRouter } from "next/navigation";-import { lazy, Suspense, useRef, useState } from "react";+import { lazy, Suspense, useEffect, useRef, useState } from "react";import { GetStarted } from "@/components/get-started";import { PageShell } from "@/components/page-shell";import { PresetCard } from "@/components/preset-gallery";@@ -27,7 +27,7 @@ import { MediaThumb } from "@/components/studio/result-media";import { useEngine, useGenerations, useHydrated, useStatus } from "@/lib/api";import { EngineSwitch } from "@/components/studio/engine-switch";import type { Generation } from "@/lib/catalog/types";-import { connectedEngines, nothingConnected as noConnection, showFirstRun } from "@/lib/connections";+import { connectedEngines, FIRST_RUN_KEY, FIRST_RUN_SCRIPT, nothingConnected as noConnection, showFirstRun } from "@/lib/connections";import type { StartQuote } from "@/lib/starter-prices";import { userTitle } from "@/lib/library";import type { PresetCardData } from "@/lib/preset-cards";@@ -139,6 +139,15 @@ function CardRow({ cards, href, engine }: { cards: PresetCardData[]; href: (c: P);}+/**+ * Runs while the HTML is parsed, ahead of the guide: hides the shell's guide before the first paint+ * in a browser that already put it away. On the client it renders as inert text/plain (React warns+ * about executable scripts it renders itself), like the sidebar's state script.+ */+function FirstRunScript() {+ return <script type={typeof window === "undefined" ? "text/javascript" : "text/plain"} suppressHydrationWarning dangerouslySetInnerHTML={{ __html: FIRST_RUN_SCRIPT }} />;+}+export function HomeView({counts,motions,@@ -168,8 +177,18 @@ export function HomeView({const statusData = useStatus().data;const status = hydrated ? statusData : undefined;const nothingConnected = !!status && noConnection(status);- // Until something is connected (or it's put away): three ways to start, under the composer.+ // Until something is connected (or it's put away): three ways to start, under the composer. It's+ // in the static shell too (no status yet), so it doesn't push the page down when the status+ // arrives; FirstRunScript hides it before the first paint in a browser that has put it away.const firstRun = showFirstRun(status);+ const guide = !status || firstRun;+ useEffect(() => {+ if (!status) return;+ try {+ localStorage.setItem(FIRST_RUN_KEY, firstRun ? "1" : "0");+ } catch {}+ document.documentElement.setAttribute("data-first-run", firstRun ? "1" : "0");+ }, [status, firstRun]);const locked = engineMode === "both" ? undefined : engineMode;@@ -257,17 +276,20 @@ export function HomeView({)}</p>)}- {firstRun && status ? (- <GetStarted- className="mt-6 max-w-[960px]"- status={status}- prices={prices}- onDemo={focusComposer}- onMode={(id) => {- setMode(MODES.find((m) => m.id === id) ?? MODES[0]);- focusComposer();- }}- />+ {guide ? (+ <>+ <FirstRunScript />+ <GetStarted+ className={cn("mt-6 max-w-[960px]", !status && "[html[data-first-run='0']_&]:hidden")}+ status={status}+ prices={prices}+ onDemo={focusComposer}+ onMode={(id) => {+ setMode(MODES.find((m) => m.id === id) ?? MODES[0]);+ focusComposer();+ }}+ />+ </>) : nothingConnected && (<p className="mt-4 text-[13px] text-muted-foreground">You’re in <span className="font-medium text-foreground">demo mode</span> — outputs are placeholders.{" "}diff --git a/src/lib/connections.ts b/src/lib/connections.tsindex ca0bb3dd..10ef4707 100644--- a/src/lib/connections.ts+++ b/src/lib/connections.ts@@ -113,6 +113,16 @@ export function showFirstRun(s: ConnectionState | undefined): boolean {return !!s && !s.onboarded && nothingConnected(s);}+/**+ * This browser's last answer to showFirstRun ("1" or "0"). Home paints the guide in its static+ * shell, before the status is known, so it doesn't push the page down when it arrives; the+ * pre-paint script hides it there when this browser already knows it isn't wanted.+ */+export const FIRST_RUN_KEY = "fuobe:first-run";++/** Runs while Home's HTML is parsed: `<html data-first-run="0">` when the guide was put away here before. */+export const FIRST_RUN_SCRIPT = `(function(){try{if(localStorage.getItem("${FIRST_RUN_KEY}")==="0")document.documentElement.setAttribute("data-first-run","0")}catch(e){}})()`;+export const ENGINE_MODE_LABEL: Record<EngineModeName, string> = { both: "Open source + paid", open: "Open source only", cloud: "Paid APIs only" };export interface ConnectionItem {diff --git a/tests/connections.test.ts b/tests/connections.test.tsindex 63c43385..a3e722da 100644--- a/tests/connections.test.ts+++ b/tests/connections.test.ts@@ -2,7 +2,7 @@ import fs from "node:fs";import os from "node:os";import path from "node:path";import { afterAll, describe, expect, it, vi } from "vitest";-import { candidateValues, connectionSummary, isTestProvider, nothingConnected, settingProblem, showFirstRun, type ConnectionState } from "@/lib/connections";+import { candidateValues, connectionSummary, FIRST_RUN_KEY, FIRST_RUN_SCRIPT, isTestProvider, nothingConnected, settingProblem, showFirstRun, type ConnectionState } from "@/lib/connections";/** Settings' "Save & test", the first-run guide's rule and the connection status strip (R4-02, R4-03, R4-33). */@@ -99,6 +99,27 @@ describe("first-run guide and status strip", () => {expect(nothingConnected(state(["higgsfield"], "cloud"))).toBe(false);});+ it("hides Home's shell guide before the first paint only where this browser put it away", () => {+ const run = (stored: string | null | Error) => {+ const attrs: Record<string, string> = {};+ const localStorage = {+ getItem: (k: string) => {+ if (stored instanceof Error) throw stored;+ return k === FIRST_RUN_KEY ? stored : null;+ },+ };+ const document = { documentElement: { setAttribute: (k: string, v: string) => (attrs[k] = v) } };+ new Function("localStorage", "document", FIRST_RUN_SCRIPT)(localStorage, document);+ return attrs["data-first-run"];+ };+ expect(run("0")).toBe("0");+ // A first visit, or a guide still wanted: the shell keeps it, so it doesn't push the page down later.+ expect(run(null)).toBeUndefined();+ expect(run("1")).toBeUndefined();+ // Storage blocked (a private window): nothing breaks.+ expect(run(new Error("denied"))).toBeUndefined();+ });+it("says what each connection is doing, and which ones the mode doesn't use", () => {const s = connectionSummary(state(["replicate", "comfyui"], "open"));expect(s.map((c) => [c.id, c.text, c.ok, c.unused])).toEqual([