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
Update available: an open page learns when the site has a newer version
Adarsh38dacaf9e86b
diff --git a/next.config.ts b/next.config.tsindex 7d3dfff1..a8485081 100644--- a/next.config.ts+++ b/next.config.ts@@ -5,6 +5,9 @@ const COVER_VERSION = { type: "query" as const, key: "v", value: "[0-9a-f]{8}" }const nextConfig: NextConfig = {/* config options here */+ // Which build this is (the deploy's commit; a local build gets its time): a page loaded from an older build sees the+ // server's newer one at /api/version and offers Update (src/components/update-available.tsx).+ env: { NEXT_PUBLIC_FUOBE_BUILD: process.env.GITHUB_SHA?.slice(0, 12) || `local-${Date.now().toString(36)}` },cacheComponents: true,poweredByHeader: false,partialPrefetching: true,diff --git a/src/app/api/version/route.ts b/src/app/api/version/route.tsnew file mode 100644index 00000000..e959e1dc--- /dev/null+++ b/src/app/api/version/route.ts@@ -0,0 +1,7 @@+/**+ * The build this server runs (next.config.ts NEXT_PUBLIC_FUOBE_BUILD, fixed when it was built). A page loaded from an+ * older build compares its own and offers Update. Open to everyone (src/proxy.ts OPEN): it says nothing but the build.+ */+export function GET() {+ return Response.json({ build: process.env.NEXT_PUBLIC_FUOBE_BUILD ?? null }, { headers: { "Cache-Control": "no-store" } });+}diff --git a/src/components/update-available.tsx b/src/components/update-available.tsxnew file mode 100644index 00000000..3eccce42--- /dev/null+++ b/src/components/update-available.tsx@@ -0,0 +1,59 @@+"use client";++import { RefreshCw } from "lucide-react";+import { useEffect, useState } from "react";+import { cn } from "@/lib/utils";++/** The build this page was loaded from (next.config.ts). */+const LOADED = process.env.NEXT_PUBLIC_FUOBE_BUILD;++/** How often an open page asks which build the server runs (and each time the tab comes back into view). */+const EVERY_MS = 3 * 60_000;++/**+ * "Update available": shown when the site has a newer version than the one this page was loaded with (a tab left open+ * across a deploy). A click loads the page again, fresh.+ */+export function UpdateAvailable({ className }: { className?: string }) {+ const [newer, setNewer] = useState(false);+ useEffect(() => {+ if (!LOADED) return;+ let done = false;+ const check = async () => {+ if (done || document.visibilityState !== "visible") return;+ try {+ const r = await fetch("/api/version", { cache: "no-store" });+ const { build } = (await r.json()) as { build?: string | null };+ if (!done && build && build !== LOADED) {+ done = true;+ setNewer(true);+ }+ } catch {+ // Offline for a moment: the next check asks again.+ }+ };+ const timer = window.setInterval(() => void check(), EVERY_MS);+ const onVisible = () => void check();+ document.addEventListener("visibilitychange", onVisible);+ void check();+ return () => {+ window.clearInterval(timer);+ document.removeEventListener("visibilitychange", onVisible);+ };+ }, []);+ if (!newer) return null;+ return (+ <button+ type="button"+ onClick={() => window.location.reload()}+ className={cn(+ "inline-flex h-8 items-center gap-1.5 rounded-full bg-brand-faint px-3 text-[13px] font-medium text-brand-text transition-colors hover:bg-brand-faint-hover focus-visible:ring-4 focus-visible:ring-brand-faint focus-visible:outline-none",+ className,+ )}+ title="A newer version of Fuobe is ready. Load it now."+ >+ <RefreshCw className="size-3.5" />+ Update available+ </button>+ );+}diff --git a/src/proxy.ts b/src/proxy.tsindex 27bacfa4..e3011f59 100644--- a/src/proxy.ts+++ b/src/proxy.ts@@ -43,7 +43,7 @@ import { authStoreFailed } from "@/server/auth-store";* Paths that work signed out: the login page and its API (and share links: openShare). Sign-up and* "who am I" answer for themselves whether public sign-up is on.*/-const OPEN = new Set(["/login", "/api/auth/login", "/api/auth/signup", "/api/auth/me", "/api/gpu/pair/start", "/api/gpu/pair/poll"]);+const OPEN = new Set(["/login", "/api/auth/login", "/api/auth/signup", "/api/auth/me", "/api/gpu/pair/start", "/api/gpu/pair/poll", "/api/version"]);/*** A worker's token (src/server/computer/workers.ts) works only on the routes a computer runs jobs through; the route