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
Assist and Library: fixes from the site check (batch 3)
Adarshfb7f42f581d2
diff --git a/src/app/api/assets/route.ts b/src/app/api/assets/route.tsindex 88181793..172452f5 100644--- a/src/app/api/assets/route.ts+++ b/src/app/api/assets/route.ts@@ -1,11 +1,17 @@import { connection } from "next/server";import { listAssets } from "@/server/storage";import { cursorFrom } from "@/server/library";+import { requestViewer } from "@/server/auth";import type { MediaKind } from "@/lib/catalog/types";-/** Stored files, newest first: source / kind filters, limit, and paging with before=<createdAt>:<id> of the last one. */+/**+ * Stored files, newest first: source / kind filters, limit, and paging with before=<createdAt>:<id> of the last one.+ * An account (public sign-up) lists its own files only; a guest none (the proxy answers it first).+ */export async function GET(request: Request) {await connection();+ const viewer = requestViewer(request);+ if (viewer.kind === "guest") return Response.json({ items: [] });const u = new URL(request.url);return Response.json({items: listAssets({@@ -13,6 +19,7 @@ export async function GET(request: Request) {kind: (u.searchParams.get("kind") as MediaKind | null) ?? undefined,limit: Number(u.searchParams.get("limit") ?? 60),...cursorFrom(u.searchParams.get("before")),+ accountId: viewer.kind === "account" ? viewer.account.id : null,}),});}diff --git a/src/app/api/assist/skills/[name]/download/route.ts b/src/app/api/assist/skills/[name]/download/route.tsindex 0a803b35..4bb36c07 100644--- a/src/app/api/assist/skills/[name]/download/route.ts+++ b/src/app/api/assist/skills/[name]/download/route.ts@@ -1,5 +1,6 @@import { connection } from "next/server";-import { skillArchive, skillMarkdown } from "@/server/skills";+import { isGuest } from "@/lib/guest-access";+import { getSkill, skillArchive, skillMarkdown } from "@/server/skills";/*** The skill to keep or share: SKILL.md (upload it on another Fuobe, or use it with Claude), or with `?format=zip` the@@ -8,6 +9,8 @@ import { skillArchive, skillMarkdown } from "@/server/skills";export async function GET(req: Request, ctx: RouteContext<"/api/assist/skills/[name]/download">) {await connection();const { name } = await ctx.params;+ // A guest or an account (public sign-up) downloads the built-in skills, not the owner's own.+ if (isGuest(req) && getSkill(name)?.source !== "builtin") return Response.json({ error: "No such skill" }, { status: 404 });const sp = new URL(req.url).searchParams;if (sp.get("format") === "zip") {const data = skillArchive(name, { examples: sp.get("examples") === "1" });diff --git a/src/app/api/assist/skills/[name]/recipe/route.ts b/src/app/api/assist/skills/[name]/recipe/route.tsindex 1dff251a..082d3dcd 100644--- a/src/app/api/assist/skills/[name]/recipe/route.ts+++ b/src/app/api/assist/skills/[name]/recipe/route.ts@@ -1,12 +1,17 @@import { connection } from "next/server";+import { isGuest } from "@/lib/guest-access";import { recipeFailure } from "@/server/recipe-routes";import { recipeView, saveRecipe } from "@/server/recipes";+import { getSkill } from "@/server/skills";/** A skill's recipe with where it runs and what was checked (engines, ready, needs a re-check). */-export async function GET(_req: Request, ctx: RouteContext<"/api/assist/skills/[name]/recipe">) {+export async function GET(request: Request, ctx: RouteContext<"/api/assist/skills/[name]/recipe">) {await connection();+ const { name } = await ctx.params;+ // A guest or an account (public sign-up) sees the built-in skills' recipes, not the owner's own.+ if (isGuest(request) && getSkill(name)?.source !== "builtin") return Response.json({ error: "No such skill" }, { status: 404 });try {- return Response.json(recipeView((await ctx.params).name));+ return Response.json(recipeView(name));} catch (e) {return recipeFailure(e);}diff --git a/src/app/api/assist/skills/[name]/route.ts b/src/app/api/assist/skills/[name]/route.tsindex 252200dc..9f7348fe 100644--- a/src/app/api/assist/skills/[name]/route.ts+++ b/src/app/api/assist/skills/[name]/route.ts@@ -1,5 +1,6 @@import { connection } from "next/server";import { z } from "zod";+import { isGuest } from "@/lib/guest-access";import { deleteSkill, getSkill, setSkillEnabled, SkillError, updateSkill } from "@/server/skills";const Patch = z.object({@@ -14,10 +15,12 @@ const Patch = z.object({const fail = (e: unknown) => Response.json({ error: (e as Error).message }, { status: e instanceof SkillError ? e.status : 500 });-export async function GET(_req: Request, ctx: RouteContext<"/api/assist/skills/[name]">) {+export async function GET(request: Request, ctx: RouteContext<"/api/assist/skills/[name]">) {await connection();const s = getSkill((await ctx.params).name);- return s ? Response.json(s) : Response.json({ error: "No such skill" }, { status: 404 });+ // A guest or an account (public sign-up) sees the built-in skills, not the owner's own.+ if (!s || (isGuest(request) && s.source !== "builtin")) return Response.json({ error: "No such skill" }, { status: 404 });+ return Response.json(s);}/** Switch a skill on or off, or edit one of your own. */diff --git a/src/app/api/generations/bulk/route.ts b/src/app/api/generations/bulk/route.tsindex 1478d64c..4e14639c 100644--- a/src/app/api/generations/bulk/route.ts+++ b/src/app/api/generations/bulk/route.ts@@ -1,4 +1,7 @@import { z } from "zod";+import { ACCOUNT_LIBRARY_MESSAGE, GUEST_RUN_MESSAGE, LIBRARY_MESSAGE } from "@/lib/guest-access";+import { generationAccount } from "@/server/account-library";+import { requestViewer } from "@/server/auth";import { deleteForever, moveToFolder, restoreGenerations, setFavorites, setPinned, setReview, trashGenerations } from "@/server/library";const Body = z.object({@@ -10,11 +13,21 @@ const Body = z.object({review: z.enum(["in-progress", "needs-review", "approved", "rejected"]).nullable().optional(),});+/** What an account (public sign-up) may do to its own runs here: no Trash, folders or restore (the owner's library has those). */+const ACCOUNT_ACTIONS = new Set(["favorite", "unfavorite", "pin", "unpin", "review"]);+/** One action on many generations: Trash / Restore / Delete forever / (un)favorite / move to a folder / (un)pin / review status. */export async function POST(request: Request) {+ const viewer = requestViewer(request);+ if (viewer.kind === "guest") return Response.json({ error: GUEST_RUN_MESSAGE }, { status: 401 });const parsed = Body.safeParse(await request.json().catch(() => null));if (!parsed.success) return Response.json({ error: "Pick something first" }, { status: 400 });const { action, ids, folderId, review } = parsed.data;+ // An account (the proxy lets its bulk changes through to here): its own runs only, and only a like, a pin or a review.+ if (viewer.kind === "account") {+ if (!ACCOUNT_ACTIONS.has(action)) return Response.json({ error: LIBRARY_MESSAGE, code: "library" }, { status: 403 });+ if (ids.some((id) => generationAccount(id) !== viewer.account.id)) return Response.json({ error: ACCOUNT_LIBRARY_MESSAGE }, { status: 403 });+ }try {const count =action === "trash"diff --git a/src/app/api/generations/facets/route.ts b/src/app/api/generations/facets/route.tsindex 3d81521f..949d9a7d 100644--- a/src/app/api/generations/facets/route.ts+++ b/src/app/api/generations/facets/route.ts@@ -1,8 +1,15 @@import { connection } from "next/server";+import { NO_FACETS } from "@/lib/guest-access";+import { requestViewer } from "@/server/auth";import { libraryFacets } from "@/server/library";-/** Counts for the Library's filter menus: models used, kinds, favorites, failed, pinned, review statuses, helper steps, Trash. `steps=1` counts the steps in. */+/**+ * Counts for the Library's filter menus: models used, kinds, favorites, failed, pinned, review statuses, helper steps, Trash. `steps=1` counts the steps in.+ * An account (public sign-up) counts its own runs only; a guest none (the proxy answers it first).+ */export async function GET(request: Request) {await connection();- return Response.json(libraryFacets({ steps: new URL(request.url).searchParams.get("steps") === "1" }));+ const viewer = requestViewer(request);+ if (viewer.kind === "guest") return Response.json(NO_FACETS);+ return Response.json(libraryFacets({ steps: new URL(request.url).searchParams.get("steps") === "1", account: viewer.kind === "account" ? viewer.account.id : undefined }));}diff --git a/src/app/providers.tsx b/src/app/providers.tsxindex 740cb3a2..31fa50fd 100644--- a/src/app/providers.tsx+++ b/src/app/providers.tsx@@ -12,9 +12,16 @@ const GuidedFixHost = dynamic(() => import("@/components/gpu/guided-fix").then((import { Toaster } from "@/components/ui/sonner";import { TooltipProvider } from "@/components/ui/tooltip";+/** Answers a retry can't change: signed out, not allowed, not there. */+const NO_RETRY = new Set([401, 403, 404]);+export function Providers({ children }: { children: React.ReactNode }) {const [client] = useState(- () => new QueryClient({ defaultOptions: { queries: { staleTime: 5_000, refetchOnWindowFocus: true, retry: 1 } } }),+ () =>+ new QueryClient({+ // One retry for a failed read, but not for a refusal or a missing thing (it would answer the same, and log twice).+ defaultOptions: { queries: { staleTime: 5_000, refetchOnWindowFocus: true, retry: (n, e) => n < 1 && !NO_RETRY.has((e as { status?: number }).status ?? 0) } },+ }),);// Signed in or out in another tab: this one asks who is looking again (its sidebar, its studios' refusals).useEffect(() => {diff --git a/src/components/assist-view.tsx b/src/components/assist-view.tsxindex c4023655..158de973 100644--- a/src/components/assist-view.tsx+++ b/src/components/assist-view.tsx@@ -20,6 +20,7 @@ import { ScheduleDialog } from "@/components/assist/schedule-dialog";import { ProjectDot, RailButton } from "@/components/assist/shell";import { SkillIcon } from "@/components/assist/skill-icon";import { Transcript } from "@/components/assist/transcript";+import { AssistVisitorNote } from "@/components/assist/visitor-note";import { useAssistActions, useAssistThread, useEngine } from "@/lib/api";import { ASSIST_SUGGESTIONS, modeLabel, type AssistAvailability, type AssistModeChoice, type AssistProject, type AssistThread, type SkillSummary } from "@/lib/assist";import type { Generation } from "@/lib/catalog/types";@@ -187,6 +188,7 @@ export function AssistView() {<h2 className="font-heading text-display text-balance">What are we creating today?</h2><p className="mt-2 text-[14px] text-pretty text-muted-foreground">Describe the whole job. Assist picks the models, shows you the plan and cost, then runs every step. Type / to use a skill.</p></div>+ <AssistVisitorNote className="mb-4" /><AssistComposerkey={draft.key}initialText={draft.text}diff --git a/src/components/assist/memory-view.tsx b/src/components/assist/memory-view.tsxindex 8bf223f9..69c2e53e 100644--- a/src/components/assist/memory-view.tsx+++ b/src/components/assist/memory-view.tsx@@ -22,6 +22,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@import { SidebarTrigger } from "@/components/ui/sidebar";import { Skeleton } from "@/components/ui/skeleton";import { Textarea } from "@/components/ui/textarea";+import { useIsOwner } from "@/lib/api";import { copyText } from "@/lib/clipboard";import { guessCategory, MEMORY_CATEGORIES, MEMORY_HINTS, MEMORY_MAX_CHARS, parseMemoryImport, type AssistMemory, type AssistProject, type MemoryCategory, type MemoryScope } from "@/lib/assist";import { timeAgo } from "@/lib/format";@@ -30,6 +31,7 @@ import { toastError } from "@/lib/refusals";import { radioKeys, radioTab } from "@/components/studio/radio-keys";import { useMemories, useMemoryActions, useProjects } from "./hooks";import { ProjectDot, RailButton } from "./shell";+import { AssistVisitorNote } from "./visitor-note";/** Where memories live: personal, or one project's. */type Place = { scope: "personal" } | { scope: "project"; projectId: string } | { scope: "all" };@@ -50,6 +52,8 @@ export function MemoryView({ projectId }: { projectId?: string } = {}) {const memories = useMemories({ scope: place.scope, projectId: place.scope === "project" ? place.projectId : null });const [adding, setAdding] = useState(false);const [importing, setImporting] = useState(false);+ // A guest or an account (public sign-up): Assist's memory is the owner's, so no Add or Import.+ const owner = useIsOwner();const list = (memories.data ?? []).filter((m) => category === "all" || m.category === category);const counts = useMemo(() => {const c = new Map<string, number>();@@ -65,19 +69,22 @@ export function MemoryView({ projectId }: { projectId?: string } = {}) {<SidebarTrigger className="md:hidden" /><RailButton /><h1 className="font-heading text-[22px] leading-none">Memory</h1>- <div className="ml-auto flex items-center gap-1.5">- <Button variant="outline" size="sm" onClick={() => setImporting(true)} aria-label="Import memories">- <Import /> <span className="hidden sm:inline">Import</span>- </Button>- <Button size="sm" onClick={() => setAdding(true)}>- <Plus /> <span className="hidden sm:inline">Add a memory</span>- <span className="sm:hidden">Add</span>- </Button>- </div>+ {owner && (+ <div className="ml-auto flex items-center gap-1.5">+ <Button variant="outline" size="sm" onClick={() => setImporting(true)} aria-label="Import memories">+ <Import /> <span className="hidden sm:inline">Import</span>+ </Button>+ <Button size="sm" onClick={() => setAdding(true)}>+ <Plus /> <span className="hidden sm:inline">Add a memory</span>+ <span className="sm:hidden">Add</span>+ </Button>+ </div>+ )}</header>)}<div className={cn("w-full max-w-[900px] min-w-0 flex-1 px-3 pb-16 sm:px-6", projectId ? "pt-2" : "pt-4 md:pt-8")}>{!projectId && <p className="max-w-2xl text-[15px] text-pretty text-muted-foreground">Learning from every chat. Assist follows these in every reply, and saves new ones when you tell it something worth keeping{" "}— it asks first while Ask first is on.</p>}+ {!projectId && <AssistVisitorNote className="mt-4 max-w-2xl" />}{projectId && (<div className="flex flex-wrap items-center justify-between gap-2"><p className="text-[13px] text-muted-foreground">Only this project's chats see these.</p>@@ -154,14 +161,16 @@ export function MemoryView({ projectId }: { projectId?: string } = {}) {<EmptyTitle className="font-heading text-[22px] font-normal">{category === "all" ? "Nothing remembered yet" : `No ${category.toLowerCase()} memories`}</EmptyTitle><EmptyDescription>Tell Assist “remember that I always want 9:16” in a chat, add one here, or bring over what another assistant knows about you.</EmptyDescription></EmptyHeader>- <EmptyContent className="flex-row justify-center">- <Button variant="outline" onClick={() => setImporting(true)}>- <Import /> Import- </Button>- <Button onClick={() => setAdding(true)}>- <Plus /> Add a memory- </Button>- </EmptyContent>+ {owner && (+ <EmptyContent className="flex-row justify-center">+ <Button variant="outline" onClick={() => setImporting(true)}>+ <Import /> Import+ </Button>+ <Button onClick={() => setAdding(true)}>+ <Plus /> Add a memory+ </Button>+ </EmptyContent>+ )}</Empty>)}</div>diff --git a/src/components/assist/project-dialog.tsx b/src/components/assist/project-dialog.tsxindex f64f43a4..396f0632 100644--- a/src/components/assist/project-dialog.tsx+++ b/src/components/assist/project-dialog.tsx@@ -31,7 +31,7 @@ export function ProjectDialog({}) {return (<Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent className="max-h-[min(90svh,760px)] gap-0 overflow-hidden p-0 sm:max-w-[560px]">+ <DialogContent className="flex max-h-[min(90svh,760px)] flex-col gap-0 overflow-hidden p-0 sm:max-w-[560px]">{/* Remount per opening so the form starts from the project as it is now. */}{open && <Form project={project} onDone={(p) => (onOpenChange(false), p && onSaved?.(p))} />}</DialogContent>diff --git a/src/components/assist/schedule-dialog.tsx b/src/components/assist/schedule-dialog.tsxindex 7f2d3f6c..4331c27b 100644--- a/src/components/assist/schedule-dialog.tsx+++ b/src/components/assist/schedule-dialog.tsx@@ -81,7 +81,7 @@ function tomorrowAt9(now: number): string {export function ScheduleDialog({ open, onOpenChange, schedule, seed }: { open: boolean; onOpenChange: (open: boolean) => void; schedule?: ScheduleView; seed?: ScheduleSeed }) {return (<Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent className="max-h-[min(92svh,820px)] gap-0 overflow-hidden p-0 sm:max-w-[600px]">{open && <Form schedule={schedule} seed={seed} onDone={() => onOpenChange(false)} />}</DialogContent>+ <DialogContent className="flex max-h-[min(92svh,820px)] flex-col gap-0 overflow-hidden p-0 sm:max-w-[600px]">{open && <Form schedule={schedule} seed={seed} onDone={() => onOpenChange(false)} />}</DialogContent></Dialog>);}diff --git a/src/components/assist/scheduled-view.tsx b/src/components/assist/scheduled-view.tsxindex 1a4c0996..1eaf76f5 100644--- a/src/components/assist/scheduled-view.tsx+++ b/src/components/assist/scheduled-view.tsx@@ -23,12 +23,14 @@ import { Skeleton } from "@/components/ui/skeleton";import { Switch } from "@/components/ui/switch";import { useNow } from "@/components/studio/use-now";import { describeRule, formatWhen, untilText, zoneLabel, type ScheduleResult, type ScheduleView } from "@/lib/assist-schedule";+import { useIsOwner } from "@/lib/api";import { formatCost, timeAgo } from "@/lib/format";import { cn } from "@/lib/utils";import { toastError } from "@/lib/refusals";import { useProjects, useScheduleActions, useSchedules } from "./hooks";import { ScheduleDialog } from "./schedule-dialog";import { ProjectDot, RailButton } from "./shell";+import { AssistVisitorNote } from "./visitor-note";const RESULT: Record<ScheduleResult["status"], { icon: typeof Clock; tone: string }> = {running: { icon: Loader2, tone: "text-brand-text" },@@ -47,6 +49,8 @@ export function ScheduledView({ projectId }: { projectId?: string } = {}) {const schedules = useSchedules(projectId);const [creating, setCreating] = useState(false);const list = schedules.data ?? [];+ // A guest or an account (public sign-up): scheduled tasks are the owner's, so nothing to schedule.+ const owner = useIsOwner();return (<div className={cn("flex min-w-0 flex-col", !projectId && "min-h-svh")}>@@ -55,19 +59,24 @@ export function ScheduledView({ projectId }: { projectId?: string } = {}) {<SidebarTrigger className="md:hidden" /><RailButton /><h1 className="font-heading text-[22px] leading-none">Scheduled</h1>- <div className="ml-auto">- <Button size="sm" onClick={() => setCreating(true)}>- <Plus /> <span className="hidden sm:inline">Schedule a task</span>- <span className="sm:hidden">New</span>- </Button>- </div>+ {owner && (+ <div className="ml-auto">+ <Button size="sm" onClick={() => setCreating(true)}>+ <Plus /> <span className="hidden sm:inline">Schedule a task</span>+ <span className="sm:hidden">New</span>+ </Button>+ </div>+ )}</header>)}<div className={cn("w-full max-w-[900px] min-w-0 flex-1 px-3 pb-16 sm:px-6", projectId ? "pt-2" : "pt-4 md:pt-8")}>{!projectId ? (- <p className="max-w-2xl text-[15px] text-pretty text-muted-foreground">- Prompts that run by themselves — daily ad variations, a weekly competitor scan, a content calendar. Each run is a new chat; it asks before spending unless you let it run within a cap.- </p>+ <>+ <p className="max-w-2xl text-[15px] text-pretty text-muted-foreground">+ Prompts that run by themselves — daily ad variations, a weekly competitor scan, a content calendar. Each run is a new chat; it asks before spending unless you let it run within a cap.+ </p>+ <AssistVisitorNote className="mt-4 max-w-2xl" />+ </>) : (<div className="flex flex-wrap items-center justify-between gap-2"><p className="text-[13px] text-muted-foreground">Runs here follow the project's instructions and sources.</p>@@ -97,14 +106,16 @@ export function ScheduledView({ projectId }: { projectId?: string } = {}) {<EmptyMedia variant="icon"><CalendarClock /></EmptyMedia>- <EmptyTitle>No scheduled tasks yet</EmptyTitle>+ <EmptyTitle className="font-heading text-[22px] font-normal">No scheduled tasks yet</EmptyTitle><EmptyDescription>Schedule a prompt here, or with the Schedule button in any chat. You choose whether each run asks you first.</EmptyDescription></EmptyHeader>- <EmptyContent>- <Button size="sm" onClick={() => setCreating(true)}>- <Plus /> Schedule a task- </Button>- </EmptyContent>+ {owner && (+ <EmptyContent>+ <Button size="sm" onClick={() => setCreating(true)}>+ <Plus /> Schedule a task+ </Button>+ </EmptyContent>+ )}</Empty>)}</div>diff --git a/src/components/assist/shell.tsx b/src/components/assist/shell.tsxindex 185ca3aa..32d13881 100644--- a/src/components/assist/shell.tsx+++ b/src/components/assist/shell.tsx@@ -9,6 +9,7 @@ import { Input } from "@/components/ui/input";import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";import { Skeleton } from "@/components/ui/skeleton";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";+import { useIsOwner } from "@/lib/api";import { timeAgo } from "@/lib/format";import { cn } from "@/lib/utils";import { ChatMenu } from "./chat-menu";@@ -97,6 +98,8 @@ function Rail({ onNavigate }: { onNavigate?: () => void }) {const chats = useChats(q ? { q } : { project: "none" });const projects = useProjects();const [creating, setCreating] = useState(false);+ // A guest or an account (public sign-up): Assist's projects are the owner's.+ const owner = useIsOwner();return (<div className="flex min-h-0 flex-1 flex-col">@@ -128,14 +131,16 @@ function Rail({ onNavigate }: { onNavigate?: () => void }) {<h2 id="rail-projects" className="text-[11px] font-medium tracking-wide text-muted-foreground uppercase">Projects</h2>- <Tooltip>- <TooltipTrigger asChild>- <Button variant="ghost" size="icon-xs" onClick={() => setCreating(true)} aria-label="New project">- <FolderPlus />- </Button>- </TooltipTrigger>- <TooltipContent>New project</TooltipContent>- </Tooltip>+ {owner && (+ <Tooltip>+ <TooltipTrigger asChild>+ <Button variant="ghost" size="icon-xs" onClick={() => setCreating(true)} aria-label="New project">+ <FolderPlus />+ </Button>+ </TooltipTrigger>+ <TooltipContent>New project</TooltipContent>+ </Tooltip>+ )}</div>{projects.isLoading ? (<Skeleton className="mx-2.5 h-6" />@@ -159,10 +164,12 @@ function Rail({ onNavigate }: { onNavigate?: () => void }) {);})}</ul>- ) : (+ ) : owner ? (<button onClick={() => setCreating(true)} className="w-full rounded-lg px-2.5 py-1.5 text-left text-[12px] text-muted-foreground hover:bg-accent hover:text-foreground">Group chats with shared instructions and sources →</button>+ ) : (+ <p className="px-2.5 py-1.5 text-[12px] text-muted-foreground">Projects group chats with shared instructions and sources.</p>)}</section>)}diff --git a/src/components/assist/skills-view.tsx b/src/components/assist/skills-view.tsxindex 3501d68d..3d24848c 100644--- a/src/components/assist/skills-view.tsx+++ b/src/components/assist/skills-view.tsx@@ -28,6 +28,7 @@ import { Skeleton } from "@/components/ui/skeleton";import { Switch } from "@/components/ui/switch";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { Textarea } from "@/components/ui/textarea";+import { useIsOwner, useIsVisitor } from "@/lib/api";import { SKILL_LIMITS, SKILL_NAME_RE, skillSlug, type Skill, type SkillSummary } from "@/lib/assist";import { cn } from "@/lib/utils";import { refusalShown, toastError } from "@/lib/refusals";@@ -36,6 +37,7 @@ import { useRecipe, useRecipeActions, useSkill, useSkillActions, useSkills, typeimport { RunSkillDialog } from "./run-skill-dialog";import { RailButton } from "./shell";import { SKILL_ICONS, SkillIcon } from "./skill-icon";+import { AssistVisitorNote } from "./visitor-note";/*** Skills (Supercomputer's Skills page): Built-in and My skills, each switchable; create one, upload@@ -55,9 +57,12 @@ function Skills() {const router = useRouter();const pathname = usePathname();const params = useSearchParams();- const viewing = params.get("skill");- // ?run=<name>: the skill's Run form (a deep link, ⌘K's "Run …", the skill's Run… button).- const running = params.get("run");+ // A guest or an account (public sign-up) reads the built-in skills; making, switching and running them are the owner's.+ const visitor = useIsVisitor();+ const owner = useIsOwner();+ // ?run=<name>: the skill's Run form (a deep link, ⌘K's "Run …", the skill's Run… button); a visitor gets the skill itself.+ const viewing = params.get("skill") ?? (visitor ? params.get("run") : null);+ const running = owner ? params.get("run") : null;const [tab, setTab] = useState<"builtin" | "user">("builtin");const [query, setQuery] = useState("");const q = useDeferredValue(query.trim().toLowerCase());@@ -78,6 +83,8 @@ function Skills() {router.replace(`${pathname}?run=${name}`, { scroll: false });};+ const toggle = (s: SkillSummary, on: boolean) => void actions.toggle(s.name, on).catch((e) => toastError(e));+const upload = async (f: File, replace = false) => {setUploading(true);try {@@ -102,31 +109,34 @@ function Skills() {<SidebarTrigger className="md:hidden" /><RailButton /><h1 className="font-heading text-[22px] leading-none">Skills</h1>- <div className="ml-auto flex items-center gap-1.5">- <input- ref={file}- type="file"- accept=".zip,.skill,.md,text/markdown,application/zip"- hidden- onChange={(e) => {- const f = e.target.files?.[0];- e.target.value = "";- if (f) void upload(f);- }}- />- <Button variant="outline" size="sm" onClick={() => file.current?.click()} disabled={uploading} aria-label="Upload a skill">- {uploading ? <Loader2 className="animate-spin" /> : <Upload />} <span className="hidden sm:inline">Upload</span>- </Button>- <Button size="sm" onClick={() => setEditing("new")}>- <Plus /> <span className="hidden sm:inline">Create skill</span>- <span className="sm:hidden">New</span>- </Button>- </div>+ {owner && (+ <div className="ml-auto flex items-center gap-1.5">+ <input+ ref={file}+ type="file"+ accept=".zip,.skill,.md,text/markdown,application/zip"+ hidden+ onChange={(e) => {+ const f = e.target.files?.[0];+ e.target.value = "";+ if (f) void upload(f);+ }}+ />+ <Button variant="outline" size="sm" onClick={() => file.current?.click()} disabled={uploading} aria-label="Upload a skill">+ {uploading ? <Loader2 className="animate-spin" /> : <Upload />} <span className="hidden sm:inline">Upload</span>+ </Button>+ <Button size="sm" onClick={() => setEditing("new")}>+ <Plus /> <span className="hidden sm:inline">Create skill</span>+ <span className="sm:hidden">New</span>+ </Button>+ </div>+ )}</header><div className="mx-auto w-full max-w-[1100px] min-w-0 flex-1 px-3 pt-4 pb-16 sm:px-6 md:pt-8"><p className="max-w-2xl text-[15px] text-pretty text-muted-foreground">Playbooks Assist loads for whole kinds of jobs. Type <span className="rounded bg-muted px-1 font-mono text-[13px]">/name</span> at the start of a message to use one, or let Assist pick it. Skills also reach other agents through Fuobe's MCP server.</p>+ <AssistVisitorNote className="mt-4 max-w-2xl" /><Tabs value={tab} onValueChange={(v) => setTab(v as typeof tab)} className="mt-6 gap-4"><div className="flex flex-wrap items-center gap-3"><TabsList>@@ -143,14 +153,14 @@ function Skills() {</div></div><TabsContent value="builtin">- <SkillGrid loading={skills.isLoading} list={filter(builtin)} onOpen={open} onToggle={(s, v) => void actions.toggle(s.name, v).catch((e) => toastError(e))} empty={<NoMatch onClear={() => setQuery("")} />} />+ <SkillGrid loading={skills.isLoading} list={filter(builtin)} onOpen={open} onToggle={owner ? toggle : undefined} empty={<NoMatch onClear={() => setQuery("")} />} /></TabsContent><TabsContent value="user"><SkillGridloading={skills.isLoading}list={filter(own)}onOpen={open}- onToggle={(s, v) => void actions.toggle(s.name, v).catch((e) => toastError(e))}+ onToggle={owner ? toggle : undefined}empty={q ? (<NoMatch onClear={() => setQuery("")} />@@ -160,14 +170,16 @@ function Skills() {<EmptyTitle className="font-heading text-[22px] font-normal">No skills of your own yet</EmptyTitle><EmptyDescription>Save a prompt or workflow you repeat as a skill, or upload one — a .zip or .skill archive, or a single SKILL.md.</EmptyDescription></EmptyHeader>- <EmptyContent className="flex-row justify-center">- <Button variant="outline" onClick={() => file.current?.click()}>- <FileUp /> Upload- </Button>- <Button onClick={() => setEditing("new")}>- <Plus /> Create skill- </Button>- </EmptyContent>+ {owner && (+ <EmptyContent className="flex-row justify-center">+ <Button variant="outline" onClick={() => file.current?.click()}>+ <FileUp /> Upload+ </Button>+ <Button onClick={() => setEditing("new")}>+ <Plus /> Create skill+ </Button>+ </EmptyContent>+ )}</Empty>)}@@ -175,7 +187,7 @@ function Skills() {</TabsContent></Tabs></div>- <SkillDetail name={viewing} onClose={() => open(null)} onEdit={(s) => (open(null), setEditing(s))} onRun={(name) => run(name, name)} />+ <SkillDetail name={viewing} owner={owner} onClose={() => open(null)} onEdit={(s) => (open(null), setEditing(s))} onRun={(name) => run(name, name)} /><RunSkillDialogname={running}onClose={() => {@@ -219,7 +231,8 @@ function NoMatch({ onClear }: { onClear: () => void }) {);}-function SkillGrid({ list, loading, onOpen, onToggle, empty }: { list: SkillSummary[]; loading: boolean; onOpen: (name: string) => void; onToggle: (s: SkillSummary, on: boolean) => void; empty: React.ReactNode }) {+/** `onToggle`: each card's on/off switch (left out for a visitor, who can't switch the owner's skills). */+function SkillGrid({ list, loading, onOpen, onToggle, empty }: { list: SkillSummary[]; loading: boolean; onOpen: (name: string) => void; onToggle?: (s: SkillSummary, on: boolean) => void; empty: React.ReactNode }) {if (loading)return (<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">@@ -243,7 +256,7 @@ function SkillGrid({ list, loading, onOpen, onToggle, empty }: { list: SkillSumm</h2><p className="truncate font-mono text-[11px] text-muted-foreground">/{s.name}</p></div>- <Switch size="sm" checked={s.enabled} onCheckedChange={(v) => onToggle(s, v)} aria-label={`${s.enabled ? "Switch off" : "Switch on"} ${s.title}`} className="relative z-10" />+ {onToggle && <Switch size="sm" checked={s.enabled} onCheckedChange={(v) => onToggle(s, v)} aria-label={`${s.enabled ? "Switch off" : "Switch on"} ${s.title}`} className="relative z-10" />}</div><p className="mt-3 line-clamp-3 text-[13px] text-muted-foreground">{s.description}</p>{(s.recipe || s.files.length > 0) && (@@ -304,7 +317,8 @@ function RecipeStatus({ skill }: { skill: Skill }) {);}-function SkillDetail({ name, onClose, onEdit, onRun }: { name: string | null; onClose: () => void; onEdit: (s: Skill) => void; onRun: (name: string) => void }) {+/** `owner`: the studio's owner (a visitor reads and downloads a skill; copying, editing, using and running it are the owner's). */+function SkillDetail({ name, owner, onClose, onEdit, onRun }: { name: string | null; owner: boolean; onClose: () => void; onEdit: (s: Skill) => void; onRun: (name: string) => void }) {const skill = useSkill(name);const actions = useSkillActions();const router = useRouter();@@ -316,7 +330,11 @@ function SkillDetail({ name, onClose, onEdit, onRun }: { name: string | null; on{!s ? (<div className="space-y-3 p-6"><DialogTitle className="sr-only">Skill</DialogTitle>- {skill.isError ? <p className="text-[14px] text-muted-foreground">This skill doesn't exist anymore.</p> : <Skeleton className="h-40" />}+ {skill.isError ? (+ <p className="text-[14px] text-muted-foreground">{(skill.error as { status?: number } | null)?.status === 404 ? "This skill doesn’t exist anymore." : skill.error?.message}</p>+ ) : (+ <Skeleton className="h-40" />+ )}</div>) : (<>@@ -391,22 +409,24 @@ function SkillDetail({ name, onClose, onEdit, onRun }: { name: string | null; on</a></Button>)}- <Button- variant="ghost"- size="sm"- onClick={async () => {- try {- const c = await actions.duplicate(s.name);- toast.success(`Copied as /${c.name}`, { duration: 2000 });- onEdit(c);- } catch (e) {- toastError(e);- }- }}- >- <Copy /> Duplicate- </Button>- {s.source === "user" && (+ {owner && (+ <Button+ variant="ghost"+ size="sm"+ onClick={async () => {+ try {+ const c = await actions.duplicate(s.name);+ toast.success(`Copied as /${c.name}`, { duration: 2000 });+ onEdit(c);+ } catch (e) {+ toastError(e);+ }+ }}+ >+ <Copy /> Duplicate+ </Button>+ )}+ {owner && s.source === "user" && (<><Button variant="ghost" size="sm" onClick={() => onEdit(s)}><Pencil /> Edit@@ -417,7 +437,7 @@ function SkillDetail({ name, onClose, onEdit, onRun }: { name: string | null; on</>)}</div>- {s.recipe ? (+ {!owner ? null : s.recipe ? (<div className="flex flex-wrap gap-1.5"><Button variant="ghost" size="sm" onClick={() => router.push(`/assist?skill=${s.name}`)} disabled={!s.enabled}><MessageSquarePlus /> Use in a new chatdiff --git a/src/components/assist/visitor-note.tsx b/src/components/assist/visitor-note.tsxnew file mode 100644index 00000000..4bd7220d--- /dev/null+++ b/src/components/assist/visitor-note.tsx@@ -0,0 +1,26 @@+"use client";++import { Info } from "lucide-react";+import { useIsVisitor } from "@/lib/api";+import { FUOBE_REPO } from "@/lib/connections";+import { cn } from "@/lib/utils";++/**+ * On a public studio, for a guest or an account: Assist is the owner's here (it plans with the owner's AI), so the+ * Assist pages say so once and leave out what only the owner can do. The server answers the same (ASSIST_OWNER_MESSAGE).+ */+export function AssistVisitorNote({ className }: { className?: string }) {+ if (!useIsVisitor()) return null;+ return (+ <div role="note" className={cn("flex items-start gap-2.5 rounded-xl border bg-muted/50 px-3.5 py-2.5 text-left text-[13px] text-muted-foreground", className)}>+ <Info className="mt-0.5 size-4 shrink-0" aria-hidden />+ <p className="min-w-0 text-pretty">+ Assist runs on the studio owner's AI, so only the owner can use it here. Fuobe is{" "}+ <a href={FUOBE_REPO} target="_blank" rel="noreferrer" className="text-foreground underline underline-offset-2">+ open source+ </a>+ : run it yourself for your own chats, skills, memory and schedules.+ </p>+ </div>+ );+}diff --git a/src/components/library-view.tsx b/src/components/library-view.tsxindex b1e4aa01..ba8c9769 100644--- a/src/components/library-view.tsx+++ b/src/components/library-view.tsx@@ -39,7 +39,7 @@ import {} from "@/components/ui/dropdown-menu";import { Kbd } from "@/components/ui/kbd";import { Skeleton } from "@/components/ui/skeleton";-import { BULK_MAX, useCreateGeneration, useFolders, useGenerationActions, useIsVisitor, useLibrary, useLibraryFacets, useShares, useStatus, useUploads, type Asset, type FeedFilter } from "@/lib/api";+import { BULK_MAX, useCreateGeneration, useFolders, useGenerationActions, useIsOwner, useIsVisitor, useLibrary, useLibraryFacets, useShares, useStatus, useUploads, type Asset, type FeedFilter } from "@/lib/api";import type { Generation, MediaKind, ReviewStatus } from "@/lib/catalog/types";import { keyCombo, useModKey } from "@/lib/keys";import { buildEntries, folderAndDescendants, reviewInfo, splitByDate, toggleAll, TRASH_DAYS, type LibraryEntry } from "@/lib/library";@@ -269,8 +269,14 @@ function Inner() {const pinnedLib = useLibrary(useMemo(() => ({ ...filter, pinned: true, limit: 200 }), [filter]), { enabled: split });const lib = useLibrary(useMemo(() => (trash || uploadsTab ? filter : { ...filter, pinned: filters.pinned }), [filter, trash, uploadsTab, filters.pinned]), { enabled: !sharedTab });const shares = useShares();- const share = useShare();- const skillBuilder = useSkillBuilder();+ // A guest or an account (public sign-up): likes, pins and reviews of its own results, but no folders, share links,+ // Trash or skills here (they're the studio owner's). Left out until /api/auth/me says it's the owner, so a visitor+ // never sees them flash in and out.+ const owner = useIsOwner();+ const shareApi = useShare();+ const share = owner ? shareApi : null;+ const builder = useSkillBuilder();+ const skillBuilder = owner ? builder : null;const uploads = useUploads();const pinnedItems = useMemo(() => (split ? (pinnedLib.data?.pages.flat() ?? []) : []), [split, pinnedLib.data]);const mainItems = useMemo(() => {@@ -444,7 +450,9 @@ function Inner() {if (t.kinds) return f.kinds[t.kinds[0]] || undefined;return undefined;};- const visibleTabs = TABS.filter((t) => !t.kinds || t.id === "images" || t.id === "videos" || t.id === "audio" || (facets.data?.kinds[t.kinds[0]] ?? 0) > 0 || tab.id === t.id);+ const visibleTabs = TABS.filter(+ (t) => !(!owner && (t.id === "shared" || t.id === "trash") && tab.id !== t.id) && (!t.kinds || t.id === "images" || t.id === "videos" || t.id === "audio" || (facets.data?.kinds[t.kinds[0]] ?? 0) > 0 || tab.id === t.id),+ );const allFav = selectedGens.length > 0 && selectedGens.every((g) => g.favorite);const allPinned = selectedGens.length > 0 && selectedGens.every((g) => g.pinnedAt);// The bulk bar's review menu checks a status only when every selected result has it.@@ -616,7 +624,7 @@ function Inner() {)}{/* The folder row has its place from the first paint: arriving later, it pushed the filters and the cards down. */}- {(tab.id === "all" && !folderId) || (folder && !trash) ? (+ {owner && ((tab.id === "all" && !folderId) || (folder && !trash)) ? (<div className="mb-4">{folders.data ? (<FolderStrip all={allFolders} parent={folder ?? null} steps={filters.steps} onOpen={(f) => go({ folder: f.id })} onMove={(list, f) => void moveTo(list, f.id, f.name)} />@@ -840,26 +848,30 @@ function Inner() {onClick={() => share.publish(selectedGens.filter((g) => g.status === "succeeded"))}/>)}- <DropdownMenu modal={false}>- <DropdownMenuTrigger asChild disabled={!selectedGens.length}>- <button className={BAR} disabled={!selectedGens.length} aria-label="Move to">- <FolderInput className="size-4" /> <span className="hidden sm:inline">Move to</span>- </button>- </DropdownMenuTrigger>- <DropdownMenuContent side="top" align="center" collisionPadding={12}>- <MoveMenuItems folders={folders.data ?? []} current={folderId} onMove={(fid, name) => void moveTo([...selected], fid, name)} onNew={() => setNewFolderFor([...selected])} />- </DropdownMenuContent>- </DropdownMenu>- <BarButton- icon={Trash2}- label="Delete"- destructive- disabled={!selectedGens.length}- onClick={() => {- void actions.trash(selectedGens);- clear();- }}- />+ {owner && (+ <>+ <DropdownMenu modal={false}>+ <DropdownMenuTrigger asChild disabled={!selectedGens.length}>+ <button className={BAR} disabled={!selectedGens.length} aria-label="Move to">+ <FolderInput className="size-4" /> <span className="hidden sm:inline">Move to</span>+ </button>+ </DropdownMenuTrigger>+ <DropdownMenuContent side="top" align="center" collisionPadding={12}>+ <MoveMenuItems folders={folders.data ?? []} current={folderId} onMove={(fid, name) => void moveTo([...selected], fid, name)} onNew={() => setNewFolderFor([...selected])} />+ </DropdownMenuContent>+ </DropdownMenu>+ <BarButton+ icon={Trash2}+ label="Delete"+ destructive+ disabled={!selectedGens.length}+ onClick={() => {+ void actions.trash(selectedGens);+ clear();+ }}+ />+ </>+ )}</>)}<span className="mx-1 h-5 w-px shrink-0 bg-border" />diff --git a/src/lib/api.ts b/src/lib/api.tsindex 025bab96..89f436e7 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -44,7 +44,8 @@ export interface Asset {async function json<T>(res: Response): Promise<T> {const body = (await res.json().catch(() => ({}))) as T & { error?: string };- if (!res.ok) throw responseError(res, body.error ?? `Request failed (${res.status})`);+ // With its status, so a refusal or a missing thing isn't retried (src/app/providers.tsx).+ if (!res.ok) throw responseError(res, Object.assign(new Error(body.error ?? `Request failed (${res.status})`), { status: res.status }));return body;}@@ -1111,10 +1112,25 @@ export async function signOut(): Promise<void> {window.location.reload();}-/** A guest or an account, once known: the studio's library, projects and settings are its owner's, not theirs. */+/**+ * A guest or an account, once known: the studio's library, projects and settings are its owner's, not theirs. False+ * until the page has hydrated: another Suspense boundary may have filled the cache first, and the first render must+ * match the server's HTML.+ */export function useIsVisitor(): boolean {const v = useViewer().data;- return !!v && !v.owner;+ const hydrated = useHydrated();+ return hydrated && !!v && !v.owner;+}++/**+ * The studio's owner, once known (and after hydration, as useIsVisitor): what only the owner can do (Assist's Create+ * and Schedule, the Library's folders, shares and Trash) shows from then on, so a visitor never sees it flash in and out.+ */+export function useIsOwner(): boolean {+ const v = useViewer().data;+ const hydrated = useHydrated();+ return hydrated && !!v?.owner;}/** "Sign up" / "Log in" with a way back here. */diff --git a/src/lib/guest-access.ts b/src/lib/guest-access.tsindex cd211795..5dc15d72 100644--- a/src/lib/guest-access.ts+++ b/src/lib/guest-access.ts@@ -26,6 +26,9 @@ const GUEST_READS = new Set(["/api/status", "/api/models", "/api/search-index",/** Catalogs mixed with the owner's own items: the route leaves the owner's part out for a guest (GUEST_HEADER). */const GUEST_FILTERED = new Set(["/api/moodboards", "/api/palettes", "/api/assist", "/api/assist/skills"]);+/** One skill, its recipe and its download: the route answers a guest for a built-in skill only (404 for the owner's own). */+const GUEST_SKILL = /^\/api\/assist\/skills\/[^/]+(\/recipe|\/download)?$/;+/** The owner's lists ({ items }): a guest gets them empty. */const EMPTY_LISTS = ["/api/generations",@@ -51,14 +54,18 @@ const EMPTY_LISTS = ["/api/ads/creatives","/api/assist/projects","/api/assist/schedules",+ "/api/assist/memory",];+/** The Library's counts with nothing in it (a guest's). */+export const NO_FACETS = { models: [], kinds: {}, total: 0, favorites: 0, failed: 0, trash: 0, pinned: 0, steps: 0, reviews: {} };+const EMPTY: Record<string, unknown> = {...Object.fromEntries(EMPTY_LISTS.map((p) => [p, { items: [] }])),"/api/shares": { items: [], signIn: true },"/api/photodump": { packs: [] },"/api/photodump/packs": { packs: [] },- "/api/generations/facets": { models: [], kinds: {}, total: 0, favorites: 0, failed: 0, trash: 0, pinned: 0, steps: 0, reviews: {} },+ "/api/generations/facets": NO_FACETS,// GPU pre-flight: a guest has no GPU (Connect your GPU), so no board and no chips."/api/gpu/readiness": { connected: false, reason: "guest" },"/api/gpu/badges": { connected: false, models: {}, presets: {} },@@ -80,7 +87,7 @@ export type GuestRead =export function guestRead(pathname: string): GuestRead {if (pathname !== "/api" && !pathname.startsWith("/api/")) return { kind: "pass" };if (GUEST_READS.has(pathname)) return { kind: "pass" };- if (GUEST_FILTERED.has(pathname)) return { kind: "filtered" };+ if (GUEST_FILTERED.has(pathname) || GUEST_SKILL.test(pathname)) return { kind: "filtered" };if (Object.hasOwn(EMPTY, pathname)) return { kind: "empty", body: EMPTY[pathname] };if (pathname === "/api/generations/stream") return { kind: "none" };return { kind: "closed" };@@ -115,7 +122,8 @@ const LIBRARY_CHANGES: [methods: string, path: RegExp][] = [["POST", /^\/api\/folders$/],["PATCH DELETE", /^\/api\/folders\/[^/]+$/],["PATCH DELETE", /^\/api\/generations\/[^/]+$/],- ["POST", /^\/api\/generations\/(bulk|local)$/],+ // (POST /api/generations/bulk goes to the route, which takes an account's likes, pins and reviews of its own runs only.)+ ["POST", /^\/api\/generations\/local$/],["POST", /^\/api\/generations\/[^/]+\/(cancel|finish)$/],["DELETE", /^\/api\/generations\/trash$/],["DELETE", /^\/api\/assets\/[^/]+$/],@@ -147,7 +155,8 @@ export function accountGeneration(method: string, pathname: string): string | unconst step = /^\/api\/generations\/([^/]+)\/(cancel|finish)$/.exec(pathname);if (method === "POST" && step) return step[1];const one = GENERATION.exec(pathname);- return one && (method === "GET" || method === "HEAD" || method === "DELETE") ? one[1] : undefined;+ // PATCH: a like, a pin or a review status (all the route changes).+ return one && (method === "GET" || method === "HEAD" || method === "PATCH" || method === "DELETE") ? one[1] : undefined;}/**@@ -155,9 +164,13 @@ export function accountGeneration(method: string, pathname: string): string | un* the list of its runs, a stored file (the proxy checks whose it is), its GPU.*/export function accountOwnRead(pathname: string): boolean {+ if (ACCOUNT_LISTS.has(pathname)) return true;return pathname === "/api/generations" || pathname === "/api/account/gpu" || GPU_READS.has(pathname);}+/** The Library's counts and its Uploads (its stored files): each route answers an account with its own only. */+const ACCOUNT_LISTS = new Set(["/api/generations/facets", "/api/assets"]);+/** GPU pre-flight reads: each answers for the account's own GPU only (src/server/gpu/target.ts). */const GPU_READS = new Set(["/api/gpu/readiness", "/api/gpu/badges", "/api/gpu/plan"]);@@ -172,9 +185,23 @@ export function accountMayChange(method: string, pathname: string, search: strin// GPU pre-flight: checking its own ComfyUI (reads only; the routes check the target and the request themselves).if ((method === "POST" && pathname === "/api/gpu/check") || (method === "PUT" && pathname === "/api/gpu/inventory")) return true;if (method === "POST" && (pathname === "/api/uploads" || pathname === "/api/media/probe")) return true;+ // Like, pin or review many of its own runs at once (the route checks each is its own, and refuses the rest).+ if (method === "POST" && pathname === "/api/generations/bulk") return true;return isPriceCheck(method, pathname, search);}+/** Assist (chats, skills, memory, projects, schedules): any change to it, which only the owner may make on a public studio. */+export function isAssistChange(method: string, pathname: string): boolean {+ return method !== "GET" && method !== "HEAD" && (pathname === "/api/assist" || pathname.startsWith("/api/assist/"));+}++/**+ * Assist plans with the install's own AI helpers and keeps the owner's chats, memory and projects, so an account gets+ * this one answer to any change there (code "assist-owner"; price checks still go through), with or without its own+ * GPU. A guest's change is a 401, as everywhere. The Assist pages say the same to both (src/components/assist/visitor-note.tsx).+ */+export const ASSIST_OWNER_MESSAGE = "Assist runs on the studio owner's AI, so only the owner can use it here. Fuobe is open source: run it yourself for your own chats, skills, memory and schedules.";+/** A change to the studio's library or projects (refused for an account with LIBRARY_MESSAGE, not "Connect your GPU"). */export function isLibraryChange(method: string, pathname: string): boolean {return LIBRARY_CHANGES.some(([methods, path]) => methods.split(" ").includes(method) && path.test(pathname));diff --git a/src/proxy.ts b/src/proxy.tsindex 137360cd..e2a25f02 100644--- a/src/proxy.ts+++ b/src/proxy.ts@@ -8,12 +8,14 @@ import {accountGeneration,accountMayChange,accountOwnRead,+ ASSIST_OWNER_MESSAGE,CONNECT_GPU_HEADER,CONNECT_GPU_MESSAGE,GUEST_HEADER,GUEST_LIBRARY_MESSAGE,GUEST_RUN_MESSAGE,guestRead,+ isAssistChange,isLibraryChange,isPriceCheck,LIBRARY_MESSAGE,@@ -162,6 +164,9 @@ function guest(request: NextRequest): NextResponse {return NextResponse.json({ error: GUEST_RUN_MESSAGE }, { status: 401, headers: guestHeaders });}+/** Any change to Assist by an account: one answer, which the Assist pages also show (a GPU doesn't change it). */+const assistOwner = () => NextResponse.json({ error: ASSIST_OWNER_MESSAGE, code: "assist-owner" }, { status: 403, headers: { "Cache-Control": "no-store" } });+/*** A read by a guest or an account: pages and catalog reads go through, the owner's lists come back* empty, and the rest of the owner's library is refused (401 for a guest, who can sign up; 403 for an account).@@ -187,14 +192,15 @@ function readAsGuest(request: NextRequest, isAccount: boolean): NextResponse {* (accountGeneration, accountOwnRead: only what it made). Install-wide settings, keys and tokens are* the owner's, and it never runs on the owner's cloud keys or GPU: with its own ComfyUI connected* ("Your GPU") the studios' generations run there, and anything else that would reach a model is- * refused ("Connect your GPU" until it has one).+ * refused ("Connect your GPU" until it has one). Assist is the owner's (isAssistChange): a GPU doesn't change that.*/const notYours = () => NextResponse.json({ error: ACCOUNT_LIBRARY_MESSAGE }, { status: 403, headers: { "Cache-Control": "no-store" } });function account(request: NextRequest, who: Account): NextResponse {const { pathname, search } = request.nextUrl;if (ownerOnly(request.method, pathname)) {- return NextResponse.json({ error: "Only the studio's owner can change settings, keys and tokens." }, { status: 403 });+ const verb = request.method === "GET" || request.method === "HEAD" ? "see" : "change";+ return NextResponse.json({ error: `Only the studio's owner can ${verb} settings, keys and tokens.` }, { status: 403 });}// Its own runs and their files: only what it made.const gen = accountGeneration(request.method, pathname);@@ -204,6 +210,7 @@ function account(request: NextRequest, who: Account): NextResponse {if (request.method === "GET" || request.method === "HEAD") return accountOwnRead(pathname) ? pass(request) : readAsGuest(request, true);if (isPriceCheck(request.method, pathname, search)) return priceCheck(request, `account:${who.id}`);if (accountMayChange(request.method, pathname, search)) return pass(request);+ if (isAssistChange(request.method, pathname)) return assistOwner();if (isLibraryChange(request.method, pathname)) return NextResponse.json({ error: LIBRARY_MESSAGE, code: "library" }, { status: 403 });// A tool its own GPU wouldn't run says so first: "Connect your GPU" only for what a GPU unlocks.if (!ownGpuRun(request.method, pathname)) return NextResponse.json({ error: OWN_GPU_TOOL_MESSAGE, code: "own-gpu-tool" }, { status: 403 });diff --git a/src/server/library.ts b/src/server/library.tsindex be5fcefc..1c2df445 100644--- a/src/server/library.ts+++ b/src/server/library.ts@@ -392,22 +392,24 @@ export interface LibraryFacets {/*** Counts for the owner's Library tabs and filters; helper steps are left out unless `steps` (as the lists do). Accounts'- * runs are theirs, never counted here (public sign-up).+ * runs are theirs, never counted here (public sign-up); with `account`, that account's own runs only (it has no Trash).*/-export function libraryFacets(opts: { steps?: boolean } = {}): LibraryFacets {- const all = "FROM generations g LEFT JOIN generation_trash t ON t.generation_id = g.id WHERE t.generation_id IS NULL AND json_extract(g.request_json, '$.account') IS NULL";+export function libraryFacets(opts: { steps?: boolean; account?: string } = {}): LibraryFacets {+ const whose = opts.account ? "json_extract(g.request_json, '$.account') = ?" : "json_extract(g.request_json, '$.account') IS NULL";+ const args = opts.account ? [opts.account] : [];+ const all = `FROM generations g LEFT JOIN generation_trash t ON t.generation_id = g.id WHERE t.generation_id IS NULL AND ${whose}`;const live = opts.steps ? all : `${all} AND NOT ${HELPER_SQL}`;- const models = db().prepare(`SELECT g.model_id AS id, COUNT(*) AS n ${live} GROUP BY g.model_id ORDER BY n DESC`).all() as { id: string; n: number }[];- const kinds = db().prepare(`SELECT g.kind AS kind, COUNT(*) AS n ${live} GROUP BY g.kind`).all() as { kind: MediaKind; n: number }[];- const reviews = db().prepare(`SELECT g.review AS review, COUNT(*) AS n ${live} AND g.review IS NOT NULL GROUP BY g.review`).all() as { review: string; n: number }[];- const one = (sql: string) => (db().prepare(sql).get() as { n: number }).n;+ const models = db().prepare(`SELECT g.model_id AS id, COUNT(*) AS n ${live} GROUP BY g.model_id ORDER BY n DESC`).all(...args) as { id: string; n: number }[];+ const kinds = db().prepare(`SELECT g.kind AS kind, COUNT(*) AS n ${live} GROUP BY g.kind`).all(...args) as { kind: MediaKind; n: number }[];+ const reviews = db().prepare(`SELECT g.review AS review, COUNT(*) AS n ${live} AND g.review IS NOT NULL GROUP BY g.review`).all(...args) as { review: string; n: number }[];+ const one = (sql: string) => (db().prepare(sql).get(...args) as { n: number }).n;return {models: models.map((m) => ({ id: m.id, name: getModel(m.id)?.name ?? m.id, count: m.n })),kinds: Object.fromEntries(kinds.map((k) => [k.kind, k.n])),total: one(`SELECT COUNT(*) AS n ${live}`),favorites: one(`SELECT COUNT(*) AS n ${live} AND g.favorite = 1`),failed: one(`SELECT COUNT(*) AS n ${live} AND g.status IN ('failed','canceled')`),- trash: trashCount(),+ trash: opts.account ? 0 : trashCount(),pinned: one(`SELECT COUNT(*) AS n ${live} AND g.pinned_at IS NOT NULL`),steps: one(`SELECT COUNT(*) AS n ${all} AND ${HELPER_SQL}`),reviews: Object.fromEntries(reviews.filter((r) => isReviewStatus(r.review)).map((r) => [r.review, r.n])),diff --git a/src/server/storage.ts b/src/server/storage.tsindex 0f9c933e..cce1f5a3 100644--- a/src/server/storage.ts+++ b/src/server/storage.ts@@ -216,10 +216,10 @@ export function getAsset(id: string): Asset | null {}/** Newest first; page with `before` (+ `beforeId`): the last asset of the previous page. Derived renders only when asked for. */-export function listAssets(opts: { source?: Asset["source"]; kind?: MediaKind; limit?: number; before?: number; beforeId?: string }): Asset[] {- // The owner's files: an account's uploads and results are its own (public sign-up).- const where: string[] = ["account_id IS NULL"];- const args: unknown[] = [];+export function listAssets(opts: { source?: Asset["source"]; kind?: MediaKind; limit?: number; before?: number; beforeId?: string; accountId?: string | null }): Asset[] {+ // The owner's files, or with `accountId` that account's own (public sign-up: its uploads and results are its own).+ const where: string[] = [opts.accountId ? "account_id = ?" : "account_id IS NULL"];+ const args: unknown[] = opts.accountId ? [opts.accountId] : [];if (opts.source) {where.push("source = ?");args.push(opts.source);diff --git a/tests/account-gpu.test.ts b/tests/account-gpu.test.tsindex a2a0954b..f2f07a5a 100644--- a/tests/account-gpu.test.ts+++ b/tests/account-gpu.test.ts@@ -129,6 +129,8 @@ describe("an account's own runs", () => {expect(passed(at("/api/generations"))).toBe(true);expect(passed(at("/api/generations/a-run"))).toBe(true);expect(passed(at("/api/generations/a-run", "DELETE"))).toBe(true);+ // A like, a pin or a review status of its own run.+ expect(passed(at("/api/generations/a-run", "PATCH"))).toBe(true);expect(passed(at("/api/generations/a-run/cancel", "POST"))).toBe(true);expect(passed(at("/api/files/outputs/a-run.png"))).toBe(true);for (const [url, method] of [@@ -136,7 +138,7 @@ describe("an account's own runs", () => {["/api/generations/owner-run", "DELETE"],["/api/generations/b-run", "GET"],["/api/generations/b-run/cancel", "POST"],- ["/api/generations/a-run", "PATCH"],+ ["/api/generations/b-run", "PATCH"],["/api/files/outputs/owner.png", "GET"],]) {expect(at(url, method).status, `${method} ${url}`).toBe(403);diff --git a/tests/e2e/guest-prompt.mjs b/tests/e2e/guest-prompt.mjsindex ca227c11..2845241c 100644--- a/tests/e2e/guest-prompt.mjs+++ b/tests/e2e/guest-prompt.mjs@@ -2,8 +2,9 @@// to run this" opens alone (no error toast, no trip to the sign-in page). Its Log in and Sign up free open the sign-in// page with the card closed, Back closes it too, and a wrong password on the sign-in page is the form's own error.// The same in the studios with their own fetch helpers: a guest presses New canvas in Canvas and sends a message in Assist.-// Then an account without its GPU: "Connect your GPU" opens alone, its form inside it, and closes when the page changes;-// alone again on a message in Assist, and none on New canvas, whose refusal ("Free accounts can't save…") is its toast.+// Then an account without its GPU: "Connect your GPU" opens alone, its form inside it, and closes when the page changes.+// None on a message in Assist (it's the owner's: "Assist runs on the studio owner's AI…" is its toast), and none on New+// canvas, whose refusal ("Free accounts can't save…") is its toast.// Usage: node tests/e2e/guest-prompt.mjs [appUrl] [--shots <dir>] (the app with a password and FUOBE_PUBLIC_SIGNUP=1).// Signs up one throwaway account. Exits 1 on a failed check.import fs from "node:fs";@@ -184,15 +185,16 @@ try {s = await seen(page);check("Back closes it", s.cards.length === 0, JSON.stringify(s.cards));- // A message in Assist (its own fetch helper): Connect your GPU again, alone.+ // A message in Assist (its own fetch helper): Assist is the owner's, and a GPU wouldn't change that, so no card.const sent = await sendInAssist(page);- check("the account's message in Assist is refused until it connects a GPU (403)", sent.status() === 403 && sent.headers()["x-fuobe-connect-gpu"] === "1", String(sent.status()));- await page.getByRole("dialog").waitFor();+ check("the account's message in Assist is refused (403, Assist is the owner's)", sent.status() === 403 && !sent.headers()["x-fuobe-connect-gpu"], String(sent.status()));+ await page.locator("[data-sonner-toast][data-type=error]").first().waitFor();await settled(page);s = await seen(page);await shot(page, "8-account-assist-send");- check("Assist: one card opens: Connect your GPU", s.cards.length === 1 && s.cards[0] === GPU_CARD, JSON.stringify(s.cards));- check("Assist: no error toast on top of it", s.errors.length === 0, JSON.stringify(s.errors));+ check("Assist: its own error toast, with no card", s.cards.length === 0 && s.errors.length === 1 && /owner/.test(s.errors[0]), JSON.stringify(s));+ // Gone before New canvas, so its toast is counted alone.+ await page.locator("[data-sonner-toast][data-type=error]").first().waitFor({ state: "detached", timeout: 20_000 });// New canvas: a refusal with no card of its own, so its toast is the one thing shown.const made = await newCanvas(page);diff --git a/tests/public-signup-visitors.test.ts b/tests/public-signup-visitors.test.tsnew file mode 100644index 00000000..bd5c2705--- /dev/null+++ b/tests/public-signup-visitors.test.ts@@ -0,0 +1,212 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import { NextRequest } from "next/server";+// Route handlers call connection(); outside a request scope it would throw.+vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));++/**+ * What a guest and an account (public sign-up) get on a public studio, from the site QA of Assist and the Library:+ * built-in skills open, Assist says once that it's the owner's, and an account's own likes, pins, reviews, counts and+ * uploads are its own.+ */++const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-visitors-"));+process.env.FUOBE_DATA_DIR = dir;+delete process.env.FUOBE_PASSWORD;+delete process.env.FUOBE_ALLOWED_ORIGINS;+process.env.FUOBE_PUBLIC_SIGNUP = "1";+const auth = await import("@/server/auth");+const { proxy } = await import("@/proxy");+const access = await import("@/lib/guest-access");+const { db } = await import("@/server/db");+afterAll(() => {+ delete process.env.FUOBE_PUBLIC_SIGNUP;+ // The database stays open until the worker exits (Windows won't delete it before).+ try {+ fs.rmSync(dir, { recursive: true, force: true });+ } catch {}+});++const passed = (r: Response) => r.headers.get("x-middleware-next") === "1";+const toldGuest = (r: Response) => r.headers.get(`x-middleware-request-${access.GUEST_HEADER}`) === "1";++function req(url: string, init: { method?: string; cookie?: string; headers?: Record<string, string> } = {}) {+ const method = init.method ?? "GET";+ const headers: Record<string, string> = { ...init.headers };+ if (init.cookie) headers.cookie = `${auth.SESSION_COOKIE}=${init.cookie}`;+ return new NextRequest(`http://localhost:3000${url}`, { method, headers, ...(method !== "GET" && method !== "HEAD" && { body: "{}" }) });+}++let account = "";+let accountId = "";+let gpuAccount = "";+let other = "";+let owner = "";+beforeAll(() => {+ auth.setPassword("install password");+ const a = auth.createAccount("[email protected]", "long enough");+ accountId = a.id;+ account = auth.createSession(a.id).value;+ const g = auth.createAccount("[email protected]", "long enough");+ auth.setAccountGpu(g.id, { url: "https://gpu.example" });+ gpuAccount = auth.createSession(g.id).value;+ other = auth.createAccount("[email protected]", "long enough").id;+ owner = auth.createSession().value;+});++describe("a built-in skill opens for a guest and an account", () => {+ it("passes one skill, its recipe and its download to the route, marked as a guest's", () => {+ for (const cookie of [undefined, account]) {+ for (const p of ["/api/assist/skills/product-photoshoot", "/api/assist/skills/product-photoshoot/recipe", "/api/assist/skills/product-photoshoot/download"]) {+ const r = proxy(req(p, { cookie }));+ expect(passed(r), `${p} ${cookie ? "account" : "guest"}`).toBe(true);+ expect(toldGuest(r), p).toBe(true);+ }+ }+ // The owner's request is never marked.+ expect(toldGuest(proxy(req("/api/assist/skills/product-photoshoot", { cookie: owner })))).toBe(false);+ });++ it("answers a guest for a built-in skill, and 404 for the owner's own", async () => {+ const { createSkill } = await import("@/server/skills");+ createSkill({ name: "owners-secret", title: "Owner's secret", description: "d", body: "b" });+ const one = await import("@/app/api/assist/skills/[name]/route");+ const recipe = await import("@/app/api/assist/skills/[name]/recipe/route");+ const download = await import("@/app/api/assist/skills/[name]/download/route");+ const asGuest = (url: string) => new Request(`http://localhost:3000${url}`, { headers: { [access.GUEST_HEADER]: "1" } });+ const ctx = (name: string) => ({ params: Promise.resolve({ name }) });++ const builtin = await one.GET(asGuest("/api/assist/skills/product-photoshoot"), ctx("product-photoshoot"));+ expect(builtin.status).toBe(200);+ expect((await builtin.json()).source).toBe("builtin");+ expect((await one.GET(asGuest("/api/assist/skills/owners-secret"), ctx("owners-secret"))).status).toBe(404);+ expect((await recipe.GET(asGuest("/api/assist/skills/owners-secret/recipe"), ctx("owners-secret"))).status).toBe(404);+ expect((await download.GET(asGuest("/api/assist/skills/owners-secret/download"), ctx("owners-secret"))).status).toBe(404);+ expect((await download.GET(asGuest("/api/assist/skills/product-photoshoot/download"), ctx("product-photoshoot"))).status).toBe(200);+ // The owner still opens their own.+ expect((await one.GET(new Request("http://localhost:3000/api/assist/skills/owners-secret"), ctx("owners-secret"))).status).toBe(200);+ });+});++describe("Assist is the owner's", () => {+ const changes: [string, string][] = [+ ["POST", "/api/assist"],+ ["POST", "/api/assist/t1/messages"],+ ["POST", "/api/assist/t1/approval"],+ ["POST", "/api/assist/skills"],+ ["POST", "/api/assist/skills/upload"],+ ["POST", "/api/assist/skills/draft"],+ ["PATCH", "/api/assist/skills/ad-multiplier"],+ ["POST", "/api/assist/skills/product-photoshoot/run"],+ ["POST", "/api/assist/memory"],+ ["POST", "/api/assist/memory/import"],+ ["POST", "/api/assist/projects"],+ ["POST", "/api/assist/schedules"],+ ];++ it("gives an account, with or without its own GPU, one answer to every change", async () => {+ for (const cookie of [account, gpuAccount]) {+ for (const [method, p] of changes) {+ const r = proxy(req(p, { method, cookie }));+ const who = `${method} ${p} ${cookie === account ? "account" : "gpu account"}`;+ expect(r.status, who).toBe(403);+ // Not "Connect your GPU" (a GPU wouldn't let it use Assist), not the library message.+ expect(r.headers.get(access.CONNECT_GPU_HEADER), who).toBeNull();+ expect(await r.json(), who).toEqual({ error: access.ASSIST_OWNER_MESSAGE, code: "assist-owner" });+ }+ }+ // A guest's change is a 401, as everywhere (the client offers to sign up).+ for (const [method, p] of changes) {+ const r = proxy(req(p, { method }));+ expect(r.status, `${method} ${p}`).toBe(401);+ expect(r.headers.get(access.GUEST_HEADER)).toBe("1");+ }+ });++ it("still prices a skill's run, and lets the owner change everything", () => {+ for (const cookie of [undefined, account]) expect(passed(proxy(req("/api/assist/skills/s1/estimate", { method: "POST", cookie })))).toBe(true);+ for (const [method, p] of changes) expect(passed(proxy(req(p, { method, cookie: owner }))), `${method} ${p}`).toBe(true);+ });++ it("says an owner-only read is the owner's to see", async () => {+ expect((await proxy(req("/api/assist/connectors", { cookie: account })).json()).error).toMatch(/owner can see/);+ expect((await proxy(req("/api/assist/connectors", { method: "POST", cookie: account })).json()).error).toMatch(/owner can change/);+ });+});++describe("the live stream", () => {+ it("answers a visitor with no content (a 404 is a console error on every page)", async () => {+ for (const cookie of [undefined, account]) {+ const r = proxy(req("/api/generations/stream", { cookie }));+ expect(r.status).toBe(204);+ expect(await r.text()).toBe("");+ }+ });+});++describe("an account's own Library", () => {+ const run = (id: string, who: string | null, favorite = 0) =>+ db()+ .prepare(+ "INSERT INTO generations (id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, favorite, created_at, updated_at) VALUES (?, 'image', 'm', 'open', 'comfyui', 'text-to-image', 'image', 'succeeded', ?, '[]', ?, ?, ?)",+ )+ .run(id, JSON.stringify({ feature: "image", modelId: "m", ...(who && { account: who }) }), favorite, Date.now(), Date.now());+ const file = (id: string, who: string | null) =>+ db()+ .prepare("INSERT INTO assets (id, kind, rel_path, content_type, size, source, account_id, created_at) VALUES (?, 'image', ?, 'image/png', 1, 'upload', ?, ?)")+ .run(id, `uploads/${id}.png`, who, Date.now());+ const cookieOf = (value: string) => ({ headers: { cookie: `${auth.SESSION_COOKIE}=${value}` } });++ beforeAll(() => {+ run("own-1", accountId, 1);+ run("own-2", accountId);+ run("owner-1", null, 1);+ run("other-1", other);+ file("up-own", accountId);+ file("up-owner", null);+ });++ it("counts only its own runs, and has no Trash", async () => {+ expect(passed(proxy(req("/api/generations/facets", { cookie: account })))).toBe(true);+ expect(await proxy(req("/api/generations/facets")).json()).toEqual(access.NO_FACETS);+ const { GET } = await import("@/app/api/generations/facets/route");+ const mine = await (await GET(new Request("http://localhost:3000/api/generations/facets", cookieOf(account)))).json();+ expect(mine).toMatchObject({ total: 2, favorites: 1, trash: 0 });+ const owners = await (await GET(new Request("http://localhost:3000/api/generations/facets", cookieOf(owner)))).json();+ expect(owners).toMatchObject({ total: 1, favorites: 1 });+ });++ it("lists its own uploads only", async () => {+ expect(passed(proxy(req("/api/assets?source=upload", { cookie: account })))).toBe(true);+ const { GET } = await import("@/app/api/assets/route");+ const ids = async (cookie?: string) =>+ ((await (await GET(new Request("http://localhost:3000/api/assets?source=upload", cookie ? cookieOf(cookie) : undefined))).json()) as { items: { id: string }[] }).items.map((a) => a.id);+ expect(await ids(account)).toEqual(["up-own"]);+ expect(await ids(owner)).toEqual(["up-owner"]);+ expect(await ids()).toEqual([]);+ });++ it("likes, pins and reviews its own runs at once, and nothing else", async () => {+ expect(passed(proxy(req("/api/generations/bulk", { method: "POST", cookie: account })))).toBe(true);+ const { POST } = await import("@/app/api/generations/bulk/route");+ const bulk = (body: object, cookie?: string) =>+ POST(new Request("http://localhost:3000/api/generations/bulk", { method: "POST", headers: { "content-type": "application/json", ...(cookie && { cookie: `${auth.SESSION_COOKIE}=${cookie}` }) }, body: JSON.stringify(body) }));+ const ok = await bulk({ action: "pin", ids: ["own-1", "own-2"] }, account);+ expect(ok.status).toBe(200);+ expect((await ok.json()).count).toBe(2);+ expect((await bulk({ action: "review", ids: ["own-1"], review: "approved" }, account)).status).toBe(200);+ // Someone else's run, or the owner's: refused, and unchanged.+ expect((await bulk({ action: "favorite", ids: ["own-1", "owner-1"] }, account)).status).toBe(403);+ expect((await bulk({ action: "favorite", ids: ["other-1"] }, account)).status).toBe(403);+ expect((db().prepare("SELECT favorite FROM generations WHERE id = 'other-1'").get() as { favorite: number }).favorite).toBe(0);+ // No folders, Trash or restore for an account.+ const move = await bulk({ action: "move", ids: ["own-1"], folderId: null }, account);+ expect(move.status).toBe(403);+ expect((await move.json()).code).toBe("library");+ expect((await bulk({ action: "trash", ids: ["own-1"] }, account)).status).toBe(403);+ // A guest that reached the route anyway.+ expect((await bulk({ action: "pin", ids: ["owner-1"] })).status).toBe(401);+ });+});diff --git a/tests/public-signup.test.ts b/tests/public-signup.test.tsindex ed279568..a8182420 100644--- a/tests/public-signup.test.ts+++ b/tests/public-signup.test.ts@@ -128,6 +128,8 @@ describe("proxy with public sign-up on", () => {expect(r.status, p).toBe(401);expect(r.headers.get(access.GUEST_HEADER), p).toBe("1");}+ // Assist's memory: none.+ expect(await proxy(req("/api/assist/memory?scope=personal")).json()).toEqual({ items: [] });// Catalogs mixed with the owner's items: the route is told it's a guest.for (const p of ["/api/moodboards", "/api/assist"]) {const r = proxy(req(p));@@ -226,9 +228,6 @@ describe("accounts never run on the owner's keys or GPU", () => {"/api/katana/k1/retry","/api/enhance","/api/brands/b1/chat",- "/api/assist",- "/api/assist/t1/messages",- "/api/assist/t1/approval","/api/faceless/episodes/e1/render","/api/content-factory/claude",// A run route that ignores ?preview=1 isn't a price check.@@ -257,13 +256,15 @@ describe("accounts never run on the owner's keys or GPU", () => {describe("accounts never see or change the owner's library", () => {const families: Record<string, { lists: string[]; records: string[]; changes: [string, string][] }> = {generations: {- // (/api/generations itself goes to the route, which lists only the account's own runs: tests/account-gpu.test.ts.)- lists: ["/api/generations/trash", "/api/generations/facets"],+ // (/api/generations, its facets and its bulk changes go to the routes, which take only the account's own runs:+ // tests/account-gpu.test.ts, tests/public-signup-visitors.test.ts.)+ lists: ["/api/generations/trash"],records: ["/api/generations/g1", "/api/generations/zip?ids=g1"],- changes: [["PATCH", "/api/generations/g1"], ["DELETE", "/api/generations/g1"], ["POST", "/api/generations/bulk"], ["DELETE", "/api/generations/trash"], ["POST", "/api/generations/g1/cancel"]],+ changes: [["PATCH", "/api/generations/g1"], ["DELETE", "/api/generations/g1"], ["DELETE", "/api/generations/trash"], ["POST", "/api/generations/g1/cancel"]],},- // (POST /api/uploads is the account's own: the route checks it, tests/account-uploads.test.ts.)- files: { lists: ["/api/assets"], records: ["/api/files/outputs/a.png", "/api/assets/a1", "/api/uploads"], changes: [["DELETE", "/api/assets/a1"]] },+ // (POST /api/uploads is the account's own: the route checks it, tests/account-uploads.test.ts; so is the list of its+ // files, /api/assets: tests/public-signup-visitors.test.ts.)+ files: { lists: [], records: ["/api/files/outputs/a.png", "/api/assets/a1", "/api/uploads"], changes: [["DELETE", "/api/assets/a1"]] },folders: { lists: ["/api/folders"], records: ["/api/folders/f1", "/api/folders/f1/zip"], changes: [["POST", "/api/folders"], ["PATCH", "/api/folders/f1"], ["DELETE", "/api/folders/f1"]] },shares: { lists: ["/api/shares"], records: ["/api/shares/s1"], changes: [["POST", "/api/shares"], ["PATCH", "/api/shares/s1"], ["DELETE", "/api/shares/s1"]] },layers: { lists: ["/api/layers"], records: ["/api/layers/l1"], changes: [["POST", "/api/layers"], ["PATCH", "/api/layers/l1"], ["DELETE", "/api/layers/l1"], ["POST", "/api/layers/l1/versions"]] },@@ -271,7 +272,11 @@ describe("accounts never see or change the owner's library", () => {canvases: { lists: ["/api/canvases"], records: ["/api/canvases/c1"], changes: [["POST", "/api/canvases"], ["PATCH", "/api/canvases/c1"], ["DELETE", "/api/canvases/c1"], ["POST", "/api/canvases/c1/duplicate"]] },cinema: { lists: ["/api/cinema/projects"], records: ["/api/cinema/projects/p1", "/api/cinema/projects/p1/items"], changes: [["POST", "/api/cinema/projects"], ["PATCH", "/api/cinema/projects/p1"], ["DELETE", "/api/cinema/projects/p1"]] },storyboards: { lists: [], records: ["/api/storyboards"], changes: [["POST", "/api/storyboards"]] },- assist: { lists: ["/api/assist/projects"], records: ["/api/assist/t1", "/api/assist/memory"], changes: [["PATCH", "/api/assist/t1"], ["DELETE", "/api/assist/t1"], ["POST", "/api/assist/projects"]] },+ assist: {+ lists: ["/api/assist/projects", "/api/assist/memory"],+ records: ["/api/assist/t1", "/api/assist/projects/p1"],+ changes: [["PATCH", "/api/assist/t1"], ["DELETE", "/api/assist/t1"], ["POST", "/api/assist/projects"], ["POST", "/api/assist/memory"]],+ },brands: { lists: ["/api/brands", "/api/products"], records: ["/api/brands/b1"], changes: [["POST", "/api/brands"], ["DELETE", "/api/brands/b1"], ["POST", "/api/products"]] },};