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
Sidebar: an account sees its email and can sign out; New creation starts over
Adarshf16b25a40259
diff --git a/docs/public-signup.md b/docs/public-signup.mdindex a6dec965..c2481a6b 100644--- a/docs/public-signup.md+++ b/docs/public-signup.md@@ -184,7 +184,9 @@ cloudflared tunnel --url http://localhost:8188 # or: ngrok http 8188- **What a visitor sees.** For a guest or an account, `GET /api/status` describes its own GPU(`viewer`), with the open engine and no Demo mode. It says nothing about the studio's ownComfyUI, providers, keys or local AI servers. The sidebar shows **Your GPU · Connect** (a guest- signs up first), or the account's ComfyUI as online or offline with its GPU and VRAM.+ signs up first), or the account's ComfyUI as online or offline with its GPU and VRAM. At the foot+ of the sidebar an account sees its email, which opens a menu with Settings, Your GPU (`/connect`)+ and Sign out.`GET /api/models` lists the open-source models for a visitor, and the studios price a visitor'srun as it would go on its own GPU. The studio's own settings page isn't shown to visitors.diff --git a/src/app/globals.css b/src/app/globals.cssindex 1178625a..e714b134 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -336,9 +336,13 @@[data-collapsible="icon"] [data-nav-group] [data-nav-items] { display: flex; }[data-collapsible="icon"] [data-nav-group][data-open] [data-nav-items] > li { display: revert-layer; }-/* A vertical scroller with more below the fold fades out at the bottom (app-sidebar.tsx). */-.fade-bottom[data-more-below] {- mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);+/*+ * A vertical scroller fades out at an edge with more past it (app-sidebar.tsx). --fade-t and --fade-b+ * are as deep as what's hidden there, up to 24px and 40px (scrollFades in src/lib/nav.ts).+ */+.fade-y[data-more-above],+.fade-y[data-more-below] {+ mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-t, 0px), #000 calc(100% - var(--fade-b, 0px)), transparent);}/* ---------------------------------------------------------------------------------------------diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsxindex 257b1401..17df4df7 100644--- a/src/components/app-sidebar.tsx+++ b/src/components/app-sidebar.tsx@@ -4,7 +4,7 @@ import { useLinkStatus } from "next/link";import { usePathname, useSearchParams } from "next/navigation";import { useTheme } from "next-themes";import { Fragment, Suspense, useCallback, useEffect, useRef, useState } from "react";-import { ChevronRight, Clapperboard, LogIn, Moon, Plus, Search, Sun, UserPlus, X } from "lucide-react";+import { ChevronRight, ChevronsUpDown, Clapperboard, Cpu, LogIn, LogOut, Moon, Plus, Search, Settings2, Sun, UserPlus, X } from "lucide-react";import {Sidebar,SidebarContent,@@ -23,15 +23,23 @@ import {useSidebar,} from "@/components/ui/sidebar";import { Button } from "@/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import { Kbd } from "@/components/ui/kbd";import { CommandPalette, CommandPaletteProvider, useCommandPalette } from "@/components/command-palette";import { IntentLink } from "@/components/intent-link";import { JobNotifications } from "@/components/job-notifications";import { NAV, type NavGroupDef } from "@/components/nav-items";import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";-import { CONNECT_GPU_EVENT, signInHref, useEngineMode, useIsGuest, useStatus, type StatusInfo } from "@/lib/api";+import { CONNECT_GPU_EVENT, signInHref, useEngineMode, useIsGuest, useStatus, useViewer, type StatusInfo } from "@/lib/api";import { useModKey } from "@/lib/keys";-import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, parseClosed, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";+import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, NEW_CREATION_HREF, parseClosed, scrollFades, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";import { cn } from "@/lib/utils";const NO_SEARCH = new URLSearchParams();@@ -261,13 +269,22 @@ export function StudioChrome({ children }: { children: React.ReactNode }) {);}-/** Keeps data-more-below on a vertical scroller in sync, so a fade hints at items below the fold. */-function useMoreBelow<T extends HTMLElement>() {+/**+ * Keeps a vertical scroller's fades (.fade-y) in sync: data-more-above / data-more-below, and how deep+ * each fade is (scrollFades), so a fade hints at items past the edge without dimming a row that fits.+ */+function useScrollFades<T extends HTMLElement>() {const ref = useRef<T>(null);useEffect(() => {const el = ref.current;if (!el) return;- const update = () => el.toggleAttribute("data-more-below", el.scrollTop + el.clientHeight < el.scrollHeight - 2);+ const update = () => {+ const { above, below } = scrollFades(el);+ el.toggleAttribute("data-more-above", above > 0);+ el.toggleAttribute("data-more-below", below > 0);+ el.style.setProperty("--fade-t", `${above}px`);+ el.style.setProperty("--fade-b", `${below}px`);+ };update();el.addEventListener("scroll", update, { passive: true });const ro = new ResizeObserver(update);@@ -368,6 +385,61 @@ function YourGpuChip({ viewer }: { viewer: NonNullable<StatusInfo["viewer"]> }));}+/**+ * Who is signed in (public sign-up): an account's email, with Settings, Your GPU and Sign out. Nothing+ * for the owner or a guest. In the rail it's the initial alone; on a phone the menu opens upward.+ */+function AccountRow() {+ const account = useViewer().data?.account;+ const { isMobile } = useSidebar();+ if (!account) return null;+ return (+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton className="h-9 px-1.5 text-[13px] group-data-[collapsible=icon]:p-1! data-[state=open]:bg-sidebar-accent" aria-label={`Account: ${account.email}`}>+ <span aria-hidden className="grid size-6 shrink-0 place-items-center rounded-full bg-brand-faint text-[11px] font-semibold text-brand-text">+ {account.email.charAt(0).toUpperCase()}+ </span>+ <span className="min-w-0 flex-1 truncate" title={account.email}>+ {account.email}+ </span>+ <ChevronsUpDown className="text-muted-foreground" />+ </SidebarMenuButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent side={isMobile ? "top" : "right"} align="end" className="min-w-56">+ <DropdownMenuLabel className="font-normal">+ <span className="block text-[11px]">Signed in as</span>+ <span className="block text-[13px] break-all text-foreground">{account.email}</span>+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuItem asChild>+ <IntentLink href="/settings">+ <Settings2 /> Settings+ </IntentLink>+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <IntentLink href="/connect">+ <Cpu /> Your GPU+ </IntentLink>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ onSelect={async () => {+ await fetch("/api/auth/logout", { method: "POST" });+ window.location.reload();+ }}+ >+ <LogOut /> Sign out+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ </SidebarMenu>+ );+}+/** The GitHub mark (lucide has no brand icons). */function GitHubMark() {return (@@ -384,7 +456,7 @@ export function AppSidebar() {const closeOnLink = (e: React.MouseEvent) => {if (isMobile && (e.target as Element).closest("a[href]")) setOpenMobile(false);};- const content = useMoreBelow<HTMLDivElement>();+ const content = useScrollFades<HTMLDivElement>();const status = useStatus().data;const cloud = status && (status.providers.fal?.configured || status.providers.replicate?.configured);const comfy = status?.providers.comfyui?.configured;@@ -429,7 +501,7 @@ export function AppSidebar() {<SearchRow /><SidebarMenuItem><SidebarMenuButton asChild tooltip="New creation" className="h-8 text-[13px] has-[[data-pending]]:bg-sidebar-accent">- <IntentLink href="/" eager>+ <IntentLink href={NEW_CREATION_HREF} eager><Plus /><NavLabel>New creation</NavLabel></IntentLink>@@ -437,7 +509,7 @@ export function AppSidebar() {</SidebarMenuItem></SidebarMenu></SidebarHeader>- <SidebarContent ref={content} onClick={closeOnLink} className="scrollbar-none fade-bottom group-data-[collapsible=icon]:overflow-y-auto">+ <SidebarContent ref={content} onClick={closeOnLink} className="scrollbar-none fade-y group-data-[collapsible=icon]:overflow-y-auto">{NAV.map((group, i) => {const id = groupId(group.label);return (@@ -495,6 +567,7 @@ export function AppSidebar() {</SidebarMenuButton></SidebarMenuItem></SidebarMenu>+ <AccountRow /></SidebarFooter></nav><SidebarRail />diff --git a/src/components/command-palette.tsx b/src/components/command-palette.tsxindex 581d1dee..2ff92174 100644--- a/src/components/command-palette.tsx+++ b/src/components/command-palette.tsx@@ -15,6 +15,7 @@ import type { Generation } from "@/lib/catalog/types";import { indexEntries, KIND_LABELS, rankPalette, skillEntries, type PaletteEntry, type PaletteIndex, type PaletteKind } from "@/lib/command-search";import { useModKey } from "@/lib/keys";import { userTitle } from "@/lib/library";+import { NEW_CREATION_HREF } from "@/lib/nav";import { cn } from "@/lib/utils";// The viewer is only needed once a recent creation is opened from the palette.@@ -213,7 +214,7 @@ function PaletteBody({ onPick, onOpenRecent, onClose }: { onPick: (e: PaletteEnt<><CommandGroup>{/* Enter on an empty query keeps what ⌘K always did: a new creation. */}- <CommandItem value="new" onSelect={() => onPick({ key: "new", kind: "page", label: "New creation", href: "/" })} className="h-9 gap-2.5 text-[14px]">+ <CommandItem value="new" onSelect={() => onPick({ key: "new", kind: "page", label: "New creation", href: NEW_CREATION_HREF })} className="h-9 gap-2.5 text-[14px]"><Plus className="text-muted-foreground" />New creation<span data-slot="command-shortcut" className="ml-auto text-[12px] text-muted-foreground">Home</span>diff --git a/src/components/home-view.tsx b/src/components/home-view.tsxindex f174c127..1e230c0c 100644--- a/src/components/home-view.tsx+++ b/src/components/home-view.tsx@@ -18,8 +18,8 @@ import {Wand2,ZoomIn,} from "lucide-react";-import { useRouter } from "next/navigation";-import { lazy, Suspense, useEffect, useRef, useState } from "react";+import { useRouter, useSearchParams } from "next/navigation";+import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";import { GetStarted } from "@/components/get-started";import { PageShell } from "@/components/page-shell";import { Skeleton } from "@/components/ui/skeleton";@@ -33,6 +33,7 @@ import type { Generation } from "@/lib/catalog/types";import { issueStartToken, START_PARAM } from "@/lib/composer";import { FIRST_RUN_KEY, FIRST_RUN_SCRIPT, nothingConnected as noConnection, showFirstRun, startLine, type StartQuote } from "@/lib/connections";import { userTitle } from "@/lib/library";+import { NEW_CREATION_PARAM } from "@/lib/nav";import type { PresetCardData } from "@/lib/preset-cards";import { cn } from "@/lib/utils";@@ -151,6 +152,21 @@ function FirstRunScript() {return <script type={typeof window === "undefined" ? "text/javascript" : "text/plain"} suppressHydrationWarning dangerouslySetInnerHTML={{ __html: FIRST_RUN_SCRIPT }} />;}+/**+ * "New creation" (the sidebar, ⌘K) opens Home with ?new=1: the composer starts empty and takes the+ * focus, and the flag leaves the address. It reads the URL, so it sits under Suspense.+ */+function NewCreation({ onNew }: { onNew: () => void }) {+ const router = useRouter();+ const fresh = useSearchParams().has(NEW_CREATION_PARAM);+ useEffect(() => {+ if (!fresh) return;+ onNew();+ router.replace("/", { scroll: false });+ }, [fresh, onNew, router]);+ return null;+}+export function HomeView({counts,motions,@@ -206,9 +222,16 @@ export function HomeView({// What Start will run, and what it costs, before it's pressed (or why it's a demo, and the engine that would run it).const runsFor = status ? startLine(status, quotes?.[mode.id], engine, mode.id as "image" | "video" | "edit") : null;const focusComposer = () => requestAnimationFrame(() => box.current?.focus());+ const startOver = useCallback(() => {+ setPrompt("");+ requestAnimationFrame(() => box.current?.focus());+ }, []);return (<PageShell>+ <Suspense fallback={null}>+ <NewCreation onNew={startOver} />+ </Suspense><div className="flex flex-col items-center pt-[8vh] text-center"><h1 className="font-heading text-display text-balance sm:text-[44px]">What will you create today?</h1><p className="mt-2 text-[15px] text-muted-foreground">diff --git a/src/lib/nav.ts b/src/lib/nav.tsindex e9e04615..557c2bcc 100644--- a/src/lib/nav.ts+++ b/src/lib/nav.ts@@ -12,6 +12,20 @@ export const SIDEBAR_COOKIE = "sidebar_state";export const groupId = (label: string) => label.toLowerCase().replace(/[^a-z0-9]+/g, "-");+/** "New creation" (the sidebar and ⌘K): Home with a fresh composer, so it does more than the Home row. Home drops the flag. */+export const NEW_CREATION_PARAM = "new";+export const NEW_CREATION_HREF = `/?${NEW_CREATION_PARAM}=1`;++/**+ * How deep the sidebar's fades are, in px: as much as is hidden past each edge, up to 24 at the top+ * and 40 at the bottom. So a few pixels of padding past the edge never dim the last row, and a row+ * the edge cuts through is always faded, never cut sharp.+ */+export function scrollFades(el: { scrollTop: number; clientHeight: number; scrollHeight: number }): { above: number; below: number } {+ const depth = (hidden: number, max: number) => (hidden < 1 ? 0 : Math.round(Math.min(hidden, max)));+ return { above: depth(el.scrollTop, 24), below: depth(el.scrollHeight - el.clientHeight - el.scrollTop, 40) };+}+function pathMatches(path: string, pathname: string) {return path === "/" ? pathname === "/" : pathname === path || pathname.startsWith(`${path}/`);}diff --git a/tests/e2e/shell.mjs b/tests/e2e/shell.mjsindex 015facdd..e4320b9c 100644--- a/tests/e2e/shell.mjs+++ b/tests/e2e/shell.mjs@@ -12,6 +12,10 @@// without changing the remembered state; opened by hand, it stays open inside that studio only.// 6. Deep links into Settings (/settings#comfyui) scroll to the section after a client navigation.// 7. Galleries: "Show more" pressed from the keyboard moves focus to the first new card.+// 8. New creation on Home starts over (empty composer, focused); the sidebar's bottom fade is never+// deeper than what's hidden below it.+// 9. With public sign-up on: an account sees its email in the sidebar, and its menu signs it out+// (a throwaway qa account, deleted at the end).import assert from "node:assert/strict";import path from "node:path";import { DESKTOP, launch, openRoute, PHONE, root } from "./_browser.mjs";@@ -189,6 +193,51 @@ try {assert.equal(focused, await cards.nth(before).getAttribute("href"));await ctx.close();}+ {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ step("New creation on Home clears the prompt, focuses the composer and leaves no flag in the address");+ await openRoute(page, `${app}/`);+ const box = page.getByRole("textbox", { name: "Describe what to create" });+ await box.fill("a red fox");+ await page.getByRole("navigation", { name: "Main" }).getByRole("link", { name: "New creation" }).click();+ await page.waitForFunction(() => location.search === "" && document.activeElement?.getAttribute("aria-label") === "Describe what to create", null, { timeout: 10_000 });+ assert.equal(await box.inputValue(), "");++ step("the sidebar's bottom fade is no deeper than what's hidden below it");+ const fade = await page.locator('[data-sidebar="content"]').evaluate((el) => ({+ hidden: el.scrollHeight - el.clientHeight - el.scrollTop,+ depth: parseFloat(el.style.getPropertyValue("--fade-b")) || 0,+ }));+ assert.ok(fade.depth <= Math.max(0, Math.ceil(fade.hidden)) && fade.depth <= 40, `fade ${fade.depth}px for ${fade.hidden}px hidden`);+ await ctx.close();+ }+ if (!(await fetch(`${app}/api/auth/me`).then((r) => r.json()).catch(() => null))?.publicSignup) {+ step("(skipped: the account row needs public sign-up)");+ } else {+ const ctx = await browser.newContext(DESKTOP);+ const page = await ctx.newPage();+ step("an account sees its email in the sidebar, and its menu signs it out");+ const email = `qa-shell-${Date.now().toString(36)}@example.com`;+ const password = `Qa-${Math.random().toString(36).slice(2)}-${Date.now()}`;+ try {+ assert.ok((await ctx.request.post(`${app}/api/auth/signup`, { data: { email, password } })).ok(), "signed up");+ await openRoute(page, `${app}/`);+ const nav = page.getByRole("navigation", { name: "Main" });+ await nav.getByText(email).waitFor({ timeout: 15_000 });+ await nav.getByRole("button", { name: `Account: ${email}` }).click();+ const menu = page.getByRole("menu");+ for (const name of ["Settings", "Your GPU", "Sign out"]) await menu.getByRole("menuitem", { name }).waitFor();+ await menu.getByRole("menuitem", { name: "Sign out" }).click();+ await nav.getByRole("link", { name: "Log in" }).waitFor({ timeout: 15_000 });+ assert.equal(await nav.getByText(email).count(), 0, "signed out");+ } finally {+ await ctx.request.post(`${app}/api/auth/login`, { data: { email, password } }).catch(() => {});+ const gone = await ctx.request.delete(`${app}/api/auth/me`, { data: { password } }).catch(() => null);+ if (gone?.status() !== 204) console.warn(` (couldn't delete ${email}: ${gone?.status()})`);+ await ctx.close();+ }+ }console.log("\nShell checks passed.");} catch (e) {console.error(`\nFAILED: ${e.message}`);diff --git a/tests/nav.test.ts b/tests/nav.test.tsindex 2671bdc9..03ff0664 100644--- a/tests/nav.test.ts+++ b/tests/nav.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { NAV } from "@/components/nav-items";-import { DEFAULT_NAV_CLOSED, fullScreenStudio, groupId, navActive, parseClosed, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";+import { DEFAULT_NAV_CLOSED, fullScreenStudio, groupId, navActive, NEW_CREATION_HREF, NEW_CREATION_PARAM, parseClosed, scrollFades, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";const q = (s = "") => new URLSearchParams(s);const LIBRARY = ["/library", "/library?tab=favorites"];@@ -148,3 +148,31 @@ describe("the remembered choice's cookie", () => {expect(sidebarOpenFromCookie(sidebarCookie(true).split(";")[0])).toBe(true);});});++describe("New creation", () => {+ it("opens Home with its own flag, and Home stays lit while it's in the address", () => {+ const url = new URL(NEW_CREATION_HREF, "http://localhost");+ expect(url.pathname).toBe("/");+ expect(url.searchParams.has(NEW_CREATION_PARAM)).toBe(true);+ expect(navActive("/", url.pathname, url.searchParams)).toBe(true);+ });+});++describe("the sidebar's fades", () => {+ it("are as deep as what's hidden past each edge, up to 24px above and 40px below", () => {+ expect(scrollFades({ scrollTop: 0, clientHeight: 637, scrollHeight: 637 })).toEqual({ above: 0, below: 0 });+ expect(scrollFades({ scrollTop: 0, clientHeight: 500, scrollHeight: 900 })).toEqual({ above: 0, below: 40 });+ expect(scrollFades({ scrollTop: 10, clientHeight: 500, scrollHeight: 900 })).toEqual({ above: 10, below: 40 });+ expect(scrollFades({ scrollTop: 400, clientHeight: 500, scrollHeight: 900 })).toEqual({ above: 24, below: 0 });+ // A row the edge cuts through fades as far as it's cut.+ expect(scrollFades({ scrollTop: 0, clientHeight: 620, scrollHeight: 640 })).toEqual({ above: 0, below: 20 });+ });++ it("never dim the last row for a few pixels of padding past the edge", () => {+ // fuobe.com at 1440×900: 3px of the last group's padding below the edge used to fade the last 40px.+ expect(scrollFades({ scrollTop: 0, clientHeight: 637, scrollHeight: 640 }).below).toBe(3);+ // Sub-pixel leftovers at either end are no fade at all.+ expect(scrollFades({ scrollTop: 0.4, clientHeight: 500, scrollHeight: 500.9 })).toEqual({ above: 0, below: 0 });+ expect(scrollFades({ scrollTop: 399.5, clientHeight: 500, scrollHeight: 900 }).below).toBe(0);+ });+});