Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Studios menu, phone sheet, /studios and search list what each studio holds inside

Adarsh6cc78fbf1f37
diff --git a/src/components/areas/area-islands.tsx b/src/components/areas/area-islands.tsx
index 4a8ec383..859a9800 100644
--- a/src/components/areas/area-islands.tsx
+++ b/src/components/areas/area-islands.tsx
@@ -11,7 +11,7 @@ import { onAttr, reducedMotion, TAB_PILL, TabRow } from "@/components/ui/tab-row
import { glideTo } from "@/lib/glide-scroll";
import { area, type AreaId } from "@/lib/nav-areas";
import { navIcon } from "@/lib/nav-icons";
-import { entry, visibleTo, type NavEntry } from "@/lib/nav-model";
+import { entry, subLabel, visibleTo, type NavEntry } from "@/lib/nav-model";
import { cn } from "@/lib/utils";
/*
@@ -238,6 +238,15 @@ const pillOf = (e: NavEntry, tap = true) => {
);
};
+/** A studio's feature as a pill in its row on /studios: its tab's name, no icon (the row names the studio). */
+const subPillOf = (e: NavEntry) => (
+ <li key={e.id}>
+ <IntentLink href={e.href} className={cn(PILL, PILL_TAP)}>
+ {subLabel(e)}
+ </IntentLink>
+ </li>
+);
+
/**
* "Jump back in": the last four pages of this area this browser opened, newest first, for someone signed in. Nothing for
* a guest, while hydrating, when storage is blocked, or before anything here was opened. It sits under the first
@@ -265,9 +274,27 @@ export function JumpBackIn({ ids }: { ids: string[] }) {
);
}
-/** The owner's own pills in a section's row (a mode only the owner sees), added once the viewer is known. */
-export function OwnerPills({ ids }: { ids: string[] }) {
+/** The owner's own pills in a section's row (a mode only the owner sees), added once the viewer is known. `sub`: a studio's feature row. */
+export function OwnerPills({ ids, sub }: { ids: string[]; sub?: boolean }) {
const kind = useViewerKind();
if (kind !== "owner") return null;
- return <>{ids.map(entry).filter((e): e is NavEntry => !!e && visibleTo(e, kind)).map((e) => pillOf(e))}</>;
+ const list = ids.map(entry).filter((e): e is NavEntry => !!e && visibleTo(e, kind));
+ return <>{list.map((e) => (sub ? subPillOf(e) : pillOf(e)))}</>;
+}
+
+/** A studio's feature row on /studios that only the owner has (Cinema Studio's Blockout), added once the viewer is known. */
+export function OwnerSubRow({ parent, ids }: { parent: string; ids: string[] }) {
+ const kind = useViewerKind();
+ const p = entry(parent);
+ if (kind !== "owner" || !p) return null;
+ const list = ids.map(entry).filter((e): e is NavEntry => !!e && visibleTo(e, kind));
+ if (!list.length) return null;
+ return (
+ <li className="flex flex-col gap-1.5 sm:flex-row sm:items-start sm:gap-4">
+ <p className="shrink-0 pt-1.5 text-[13px] leading-5 font-medium sm:w-40">{p.label}</p>
+ <ul aria-label={`In ${p.label}`} className="flex flex-wrap gap-x-1.5 gap-y-3">
+ {list.map(subPillOf)}
+ </ul>
+ </li>
+ );
}
diff --git a/src/components/areas/area-page.tsx b/src/components/areas/area-page.tsx
index 908aa640..6a8468f0 100644
--- a/src/components/areas/area-page.tsx
+++ b/src/components/areas/area-page.tsx
@@ -8,7 +8,7 @@ import { AREAS, area, type AreaId } from "@/lib/nav-areas";
import { navIcon } from "@/lib/nav-icons";
import { entry, type NavEntry } from "@/lib/nav-model";
import { cn } from "@/lib/utils";
-import { AreaSearch, AreaTabs, JumpBackIn, OwnerPills, type AreaTab } from "./area-islands";
+import { AreaSearch, AreaTabs, JumpBackIn, OwnerPills, OwnerSubRow, type AreaTab } from "./area-islands";
/*
* An area page: everything one of the bar's menus holds, as Home shows its studios (src/components/home/home-sections.tsx,
@@ -102,12 +102,58 @@ export function AreaSections({ sections }: { sections: AreaShowcase["sections"]
grid
after={s.ownerPills.length > 0 ? <OwnerPills ids={s.ownerPills.map((p) => p.id)} /> : undefined}
/>
+ <StudioFeatures section={s.id} subs={s.subs} />
</div>
{i === 0 && <JumpBackIn ids={ids} />}
</div>
));
}
+/** A studio's row of features: its name, then its tabs and modes as pills that wrap (44 px to tap). */
+export const SUB_ROW = "flex flex-col gap-1.5 sm:flex-row sm:items-start sm:gap-4";
+export const SUB_ROW_NAME = "shrink-0 pt-1.5 text-[13px] leading-5 font-medium sm:w-40";
+export const SUB_PILL = cn(PILL, PILL_TAP);
+
+/**
+ * What a section's studios hold inside (their tabs and modes), a row per studio under its cards and pills, so each is
+ * one tap from here: "Marketing Studio (Click to Ad) (Ad Multiplier)". The owner's own features come with the island.
+ */
+function StudioFeatures({ section, subs }: { section: string; subs: AreaShowcase["sections"][number]["subs"] }) {
+ const shown = subs.filter((g) => g.pills.length > 0);
+ if (!shown.length) return null;
+ const titleId = `${section}-inside`;
+ return (
+ <div className="mt-6" data-studio-features={section}>
+ <h3 id={titleId} className="mb-2 font-sans text-[13px] text-muted-foreground">
+ Inside these studios
+ </h3>
+ <ul aria-labelledby={titleId} className="flex flex-col gap-2.5">
+ {subs.map((g) =>
+ g.pills.length > 0 ? (
+ <li key={g.parent.id} className={SUB_ROW}>
+ <p id={`${section}-inside-${g.parent.id}`} className={SUB_ROW_NAME}>
+ {g.parent.label}
+ </p>
+ <ul aria-labelledby={`${section}-inside-${g.parent.id}`} className="flex flex-wrap gap-x-1.5 gap-y-3">
+ {g.pills.map((p) => (
+ <li key={p.id}>
+ <IntentLink href={p.href} className={SUB_PILL}>
+ {p.label}
+ </IntentLink>
+ </li>
+ ))}
+ {g.ownerIds.length > 0 && <OwnerPills ids={g.ownerIds} sub />}
+ </ul>
+ </li>
+ ) : (
+ <OwnerSubRow key={g.parent.id} parent={g.parent.id} ids={g.ownerIds} />
+ ),
+ )}
+ </ul>
+ </div>
+ );
+}
+
/** The pills at the end of an area page: the other areas, then Canvas and Assist. */
export function MoreInFuobe({ current }: { current: AreaId }) {
const others = AREAS.filter((a) => a.id !== current).map((a) => entry(a.entryId));
diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsx
index 1f14a8fc..55753fbe 100644
--- a/src/components/fashion/character-sheet.tsx
+++ b/src/components/fashion/character-sheet.tsx
@@ -28,6 +28,7 @@ import { cn } from "@/lib/utils";
import { onAttr, TAB_PILL, TabRow } from "@/components/ui/tab-row";
import { toastError } from "@/lib/refusals";
import { SheetExample } from "@/components/empty-examples";
+import { linkTab, TabFromLink } from "@/components/nav/tab-from-link";
type Mode = "reference" | "cast" | "describe";
const MODES: [Mode, string][] = [
@@ -35,6 +36,8 @@ const MODES: [Mode, string][] = [
["cast", "Build from scratch"],
["describe", "From a description"],
];
+/** The tabs a link can open (?mode=reference|cast|describe: the bar's menus, search). */
+const MODE_IDS: readonly Mode[] = MODES.map(([id]) => id);
const fmt = (f: CastFieldData, v: string | number) => (f.format ? f.format.replace("{v}", String(v)) : String(v));
@@ -232,6 +235,7 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
<Suspense fallback={null}>
<HandoffImage onImage={takeHandoff} />
</Suspense>
+ <TabFromLink param="mode" ids={MODE_IDS} onTab={setMode} />
<PageHeader title="Character Sheet" description="Build your AI avatar: a consistent character for your videos, from a reference or defined from scratch.">
<EngineSwitch value={engine} onChange={setEngine} selfHostedOnly />
</PageHeader>
@@ -240,7 +244,17 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
<section className="min-w-0 space-y-4">
<TabRow role="tablist" aria-label="How to build it" follow>
{MODES.map(([id, label]) => (
- <button key={id} role="tab" aria-selected={mode === id} onClick={() => setMode(id)} className={TAB_PILL} {...onAttr(mode === id)}>
+ <button
+ key={id}
+ role="tab"
+ aria-selected={mode === id}
+ onClick={() => {
+ setMode(id);
+ linkTab("mode", id);
+ }}
+ className={TAB_PILL}
+ {...onAttr(mode === id)}
+ >
{label}
</button>
))}
diff --git a/src/components/nav/mega-canvas-owner.tsx b/src/components/nav/mega-canvas-owner.tsx
index 76ac897b..0cde55d4 100644
--- a/src/components/nav/mega-canvas-owner.tsx
+++ b/src/components/nav/mega-canvas-owner.tsx
@@ -6,6 +6,7 @@ import { useState, type ReactNode } from "react";
import { IntentLink } from "@/components/intent-link";
import { useCanvasActions, useCanvases } from "@/components/canvas/use-canvas";
import { timeAgo } from "@/lib/format";
+import { entry } from "@/lib/nav-model";
import { toastError } from "@/lib/refusals";
/** How many of the owner's boards the Canvas menu lists, the newest edited first. */
@@ -54,6 +55,8 @@ export default function CanvasOwnerStart({ col, labelledBy, fallback }: { col: n
const boards = useCanvases();
const { busy, start } = useNewBoard();
const recent = [...(boards.data ?? [])].sort((a, b) => (b.editedAt ?? b.updatedAt) - (a.editedAt ?? a.updatedAt)).slice(0, RECENT_BOARDS);
+ // Canvas' own section of skills drawn as boards (/canvas?tab=skills), last in the column.
+ const skills = entry("canvas-skills");
return (
<ul aria-labelledby={labelledBy} className="flex flex-col gap-2">
<li>
@@ -109,6 +112,20 @@ export default function CanvasOwnerStart({ col, labelledBy, fallback }: { col: n
) : (
fallback && <li>{fallback}</li>
)}
+ {skills && !boards.isPending && (
+ <li>
+ <IntentLink
+ href={skills.href}
+ data-col={col}
+ data-row={recent.length ? recent.length + 2 : 2}
+ title={skills.what}
+ className="nav-row group/all -mx-2 inline-flex h-10 items-center gap-1 self-start rounded-[10px] px-2 text-[13px] font-medium text-brand-text"
+ >
+ {skills.label}
+ <ArrowRight aria-hidden className="size-3.5 motion-safe:transition-transform group-hover/all:translate-x-0.5" />
+ </IntentLink>
+ </li>
+ )}
</ul>
);
}
diff --git a/src/components/nav/mega-launcher.tsx b/src/components/nav/mega-launcher.tsx
index 2b96f93e..a99087d5 100644
--- a/src/components/nav/mega-launcher.tsx
+++ b/src/components/nav/mega-launcher.tsx
@@ -3,7 +3,7 @@
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
import { IntentLink } from "@/components/intent-link";
import { MEGA_AREAS, megaMove, megaPanelId, TILE_COLS, type MegaId } from "@/lib/mega-menus";
-import { launcherActive, studioCount } from "@/lib/nav-model";
+import { launcherActive, studioCount, subActive } from "@/lib/nav-model";
import { isPlainClick } from "@/lib/use-tapped-tab";
import { cn } from "@/lib/utils";
import { BAR_CHEVRON, BAR_LABEL, BAR_SPLIT, BarChevron, useHoverIntent } from "./bar-split";
@@ -48,9 +48,9 @@ export const LAUNCHER_PANEL =
/** The routes a menu's links lead to that load ahead when it opens (each row also loads on hover: IntentLink). */
const WARM: Record<MegaId, NavPanel> = { studios: "studios", apps: "more", motions: "more", canvas: "more" };
-/** The item of a menu the open page is (aria-current): a studio, an app, a preset, a ready board. */
+/** The item of a menu the open page is (aria-current): a studio or one of its features, an app, a preset, a ready board. */
export function megaCurrent(id: MegaId, pathname: string, search = ""): string | undefined {
- if (id === "studios") return launcherActive(pathname);
+ if (id === "studios") return subActive(pathname, search) ?? launcherActive(pathname);
if (id === "apps") return /^\/apps\/([^/]+)$/.exec(pathname)?.[1];
if (id === "motions") return pathname === "/video" ? (new URLSearchParams(search).get("preset") ?? undefined) : undefined;
return /^\/canvas\/start\/([^/]+)$/.exec(pathname)?.[1];
diff --git a/src/components/nav/mega-panel.tsx b/src/components/nav/mega-panel.tsx
index a358efef..61a7c10c 100644
--- a/src/components/nav/mega-panel.tsx
+++ b/src/components/nav/mega-panel.tsx
@@ -92,6 +92,41 @@ function Row({ e, col, row, current, now, className }: { e: MegaItem; col: numbe
);
}
+/** A studio's links hide on a window shorter than they need (the panel never scrolls inside). */
+const SUBS_FROM: Record<800 | 880 | 960, string> = { 800: "[@media(max-height:799.98px)]:hidden", 880: "[@media(max-height:879.98px)]:hidden", 960: "[@media(max-height:959.98px)]:hidden" };
+
+/**
+ * What a studio holds inside (its tabs and modes), as links under its card or row: names only, smaller and quieter
+ * than the rows, hung from a hairline under the studio. `row`: the first link's place for the arrow keys (they go
+ * down from the studio through its links to the next row). `current`: the open page's feature.
+ */
+function SubLinks({ e, col, row, current, className }: { e: MegaItem; col: number; row: number; current?: string; className?: string }) {
+ if (!e.subs?.length) return null;
+ return (
+ <ul aria-label={`In ${e.label}`} data-subs={e.id} className={cn("mt-0.5 mb-1 ml-[17px] flex flex-col border-l border-border pl-1 max-[1439.98px]:ml-1.5", e.subsFrom && SUBS_FROM[e.subsFrom], className)}>
+ {e.subs.map((s, i) => (
+ <li key={s.id} className={s.from && SUBS_FROM[s.from]}>
+ <IntentLink
+ href={s.href}
+ data-col={col}
+ data-row={row + i}
+ data-sub=""
+ aria-current={current === s.id ? "page" : undefined}
+ title={s.line}
+ className={cn(
+ "nav-row nav-mark-start group/sub flex min-h-7 items-center gap-1 rounded-[8px] px-2 text-[12.5px] leading-4 [@media(pointer:coarse)]:min-h-11",
+ s.more ? "font-medium text-brand-text" : "text-muted-foreground hover:text-foreground aria-[current=page]:font-semibold aria-[current=page]:text-foreground",
+ )}
+ >
+ <span className="truncate">{s.label}</span>
+ {s.more && <ArrowRight aria-hidden className="size-3 shrink-0 motion-safe:transition-transform group-hover/sub:translate-x-0.5" />}
+ </IntentLink>
+ </li>
+ ))}
+ </ul>
+ );
+}
+
/**
* A ready board as a 16:9 tile: its peak frame (the finished scene), its name and one line. The first row's pictures
* load with the panel; a later row's when it shows (lazy: a row hidden by the window's height never fetches its own).
@@ -214,6 +249,13 @@ export function MegaColumns({ model, current, now, kind }: { model: MegaModel; c
</div>
);
}
+ // Places for the arrow keys, top to bottom: the lead (0), its links, then each row and its links.
+ let next = 1 + (c.lead?.subs?.length ?? 0);
+ const at = c.rows.map((e) => {
+ const r = next;
+ next += 1 + (e.subs?.length ?? 0);
+ return r;
+ });
return (
<div key={c.id} data-group={c.id} className={cn("flex min-w-0 flex-col gap-2", place)}>
{label}
@@ -221,11 +263,13 @@ export function MegaColumns({ model, current, now, kind }: { model: MegaModel; c
{c.lead && (
<li className="pb-1.5">
<LeadCard e={c.lead} col={col} current={current === c.lead.id} now={now} />
+ <SubLinks e={c.lead} col={col} row={1} current={current} className="mt-1.5" />
</li>
)}
{c.rows.map((e, ri) => (
<li key={e.id} className={capped ? ROW_HIDE(ri, families) : undefined}>
- <Row e={e} col={col} row={ri + 1} current={current === e.id} now={now} />
+ <Row e={e} col={col} row={at[ri]} current={current === e.id} now={now} />
+ <SubLinks e={e} col={col} row={at[ri] + 1} current={current} />
</li>
))}
</ul>
diff --git a/src/components/nav/studios-sheet.tsx b/src/components/nav/studios-sheet.tsx
index 7022c747..736a88ec 100644
--- a/src/components/nav/studios-sheet.tsx
+++ b/src/components/nav/studios-sheet.tsx
@@ -8,7 +8,7 @@ import { useNavUi, useViewerKind } from "@/components/nav/nav-ui";
import { IntentLink } from "@/components/intent-link";
import { onAttr, TAB_PILL, TabRow, useSwapFade } from "@/components/ui/tab-row";
import { MEGA_AREAS, type MegaId, type MegaItem, type MegaModel } from "@/lib/mega-menus";
-import { isNew } from "@/lib/nav-model";
+import { isNew, studioSubs, subLabel, subParent, type ViewerKind } from "@/lib/nav-model";
import { cn } from "@/lib/utils";
import { megaCurrent } from "./mega-launcher";
import { useMegaMenu, warmMenu } from "./mega-data";
@@ -48,6 +48,36 @@ function Tile({ entry, current }: { entry: MegaItem; current: boolean }) {
);
}
+/**
+ * What the group's studios hold inside (their tabs and modes, every one a viewer may run): under the tiles, a small
+ * heading per studio and its features as 44 px pills that wrap. Only for one group (All stays one screen of tiles).
+ */
+function SheetSubs({ items, kind, current }: { items: MegaItem[]; kind: ViewerKind | undefined; current?: string }) {
+ const groups = items.map((e) => ({ e, subs: studioSubs(e.id, kind, "sheet") })).filter((g) => g.subs.length > 0);
+ if (!groups.length) return null;
+ return (
+ <div data-sheet-subs className="flex flex-col gap-3 border-t pt-3 pb-3">
+ {groups.map(({ e, subs }) => (
+ <section key={e.id} aria-labelledby={`sheet-subs-${e.id}`}>
+ <p id={`sheet-subs-${e.id}`} className="text-[11px] leading-4 font-semibold tracking-[.08em] text-brand-text uppercase">
+ {e.label}
+ </p>
+ {/* 36 px pills whose touch area reaches 4 px past each edge (44 px): rows 8 px apart, so no two overlap. */}
+ <ul aria-labelledby={`sheet-subs-${e.id}`} className="mt-2 flex flex-wrap gap-x-1.5 gap-y-2">
+ {subs.map((s) => (
+ <li key={s.id}>
+ <IntentLink href={s.href} aria-current={current === s.id ? "page" : undefined} {...onAttr(current === s.id)} title={s.what} className={cn(TAB_PILL, "px-3.5 text-[13px]")}>
+ {subLabel(s)}
+ </IntentLink>
+ </li>
+ ))}
+ </ul>
+ </section>
+ ))}
+ </div>
+ );
+}
+
/** A grid's closing tile: the family's (or a part of it's) whole set. */
function SeeAllTile({ href, label, name }: { href: string; label: string; name: string }) {
return (
@@ -142,6 +172,8 @@ export function StudiosSheet({ family = "studios", group: initial, onSearch }: {
useEffect(() => warmMenu(family), [family]);
// The query too: moving from one preset to another (/video?preset=…) keeps the path.
const current = megaCurrent(family, pathname, useSearchParams()?.toString() ?? "");
+ // On a studio's feature (Genjutsu's Restyle, Ads Studio), that studio's tile is the one marked.
+ const currentTile = family === "studios" && current ? (subParent(current) ?? current) : current;
const area = MEGA_AREAS[family];
// Canvas: its "Start here" column is the desktop's; on a phone the boards are the grid.
const columns = model?.columns.filter((c) => !(family === "canvas" && c.id === "start")) ?? [];
@@ -219,13 +251,16 @@ export function StudiosSheet({ family = "studios", group: initial, onSearch }: {
</ul>
</>
) : (
- <ul aria-label={group ? columns.find((c) => c.id === group)?.label : area.panel} className="grid grid-cols-5 gap-x-1 pb-1">
- {items.map((e) => (
- <Tile key={e.id} entry={e} current={e.id === current} />
- ))}
- {seeAll && family !== "studios" && <SeeAllTile {...seeAll} />}
- {family === "studios" && <SeeAllTile href={area.href} label="See all" name="See all studios" />}
- </ul>
+ <>
+ <ul aria-label={group ? columns.find((c) => c.id === group)?.label : area.panel} className="grid grid-cols-5 gap-x-1 pb-1">
+ {items.map((e) => (
+ <Tile key={e.id} entry={e} current={e.id === currentTile} />
+ ))}
+ {seeAll && family !== "studios" && <SeeAllTile {...seeAll} />}
+ {family === "studios" && <SeeAllTile href={area.href} label="See all" name="See all studios" />}
+ </ul>
+ {family === "studios" && group && <SheetSubs items={items} kind={kind} current={current} />}
+ </>
)}
</div>
</>
diff --git a/src/components/nav/tab-from-link.tsx b/src/components/nav/tab-from-link.tsx
new file mode 100644
index 00000000..746ba32e
--- /dev/null
+++ b/src/components/nav/tab-from-link.tsx
@@ -0,0 +1,37 @@
+"use client";
+
+import { useSearchParams } from "next/navigation";
+import { Suspense, useEffect } from "react";
+
+/*
+ * A studio tab that a link can open: the bar's menus, the phone's Studios sheet and search link a studio's tabs by a
+ * query (/character-sheet?mode=cast, /photodump?tab=instadump). The tab follows the address on load and whenever a link
+ * changes it; picking a tab writes it back (linkTab), so the address can be shared and a link to another tab still
+ * switches it.
+ */
+
+function ReadTab<T extends string>({ param, ids, onTab }: { param: string; ids: readonly T[]; onTab: (id: T) => void }) {
+ const value = useSearchParams().get(param);
+ useEffect(() => {
+ if (value && (ids as readonly string[]).includes(value)) onTab(value as T);
+ }, [value, ids, onTab]);
+ return null;
+}
+
+/** Opens the tab the address names (`?<param>=<id>`, one of `ids`). Under its own Suspense: it reads the URL. */
+export function TabFromLink<T extends string>(props: { param: string; ids: readonly T[]; onTab: (id: T) => void }) {
+ return (
+ <Suspense fallback={null}>
+ <ReadTab {...props} />
+ </Suspense>
+ );
+}
+
+/** Puts a picked tab in the address (`?<param>=<id>`) without a new history entry or a navigation. */
+export function linkTab(param: string, id: string): void {
+ if (typeof window === "undefined") return;
+ const url = new URL(window.location.href);
+ if (url.searchParams.get(param) === id) return;
+ url.searchParams.set(param, id);
+ window.history.replaceState(null, "", url);
+}
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index 28fbf023..f59fa6f8 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -2,7 +2,7 @@
import { ArrowLeft, ArrowRight, History, Library, Loader2, Plus, RotateCcw, Search, Trash2, X } from "lucide-react";
import Link from "next/link";
-import { useMemo, useRef, useState } from "react";
+import { useCallback, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { PageHeader, PageShell } from "@/components/page-shell";
import { SelfHostNote } from "@/components/self-host-note";
@@ -19,6 +19,7 @@ import type { Generation } from "@/lib/catalog/types";
import { timeAgo } from "@/lib/format";
import { cn } from "@/lib/utils";
import { onAttr, TAB_PILL, TabRow } from "@/components/ui/tab-row";
+import { linkTab, TabFromLink } from "@/components/nav/tab-from-link";
import { toastError } from "@/lib/refusals";
import { PackCover } from "./covers";
import { useRun, useRunPreview, usePackActions, useUserPacks } from "./hooks";
@@ -44,6 +45,9 @@ const TABS = [
["instadump", "From a selfie"],
["mine", "My packs"],
] as const;
+type PackTab = (typeof TABS)[number][0];
+/** The tabs a link can open (?tab=instadump: the bar's menus, search). */
+const TAB_IDS: readonly PackTab[] = TABS.map(([id]) => id);
const ratioOf = (a: string) => {
const [w, h] = a.split(":").map(Number);
return w && h ? w / h : 3 / 4;
@@ -159,7 +163,12 @@ export function PhotodumpView() {
const isOwner = useIsOwner();
const [step, setStep] = useState(0);
const [reached, setReached] = useState(0);
- const [tab, setTab] = useState<(typeof TABS)[number][0]>("all");
+ const [tab, setTab] = useState<PackTab>("all");
+ // A link to a tab (the bar's menus, search) shows that tab's packs: back to the first step.
+ const tabFromLink = useCallback((id: PackTab) => {
+ setTab(id);
+ setStep(0);
+ }, []);
const [q, setQ] = useState("");
const [packId, setPackId] = useState<string>();
const [subjectMode, setSubjectMode] = useState<"selfie" | "character">("selfie");
@@ -226,6 +235,7 @@ export function PhotodumpView() {
return (
<PageShell wide>
+ <TabFromLink param="tab" ids={TAB_IDS} onTab={tabFromLink} />
<PageHeader title="Photodump" description="A whole set of photos of you in one go, from one selfie or a saved character, in a pack of styles.">
<EngineSwitch value={engine} onChange={setEngine} selfHostedOnly />
</PageHeader>
@@ -239,7 +249,17 @@ export function PhotodumpView() {
<div className="flex flex-wrap items-center gap-3">
<TabRow role="tablist" aria-label="Packs" follow className="max-w-full">
{TABS.map(([id, label]) => (
- <button key={id} role="tab" aria-selected={tab === id} onClick={() => setTab(id)} className={TAB_PILL} {...onAttr(tab === id)}>
+ <button
+ key={id}
+ role="tab"
+ aria-selected={tab === id}
+ onClick={() => {
+ setTab(id);
+ linkTab("tab", id);
+ }}
+ className={TAB_PILL}
+ {...onAttr(tab === id)}
+ >
{label}
</button>
))}
diff --git a/src/lib/area-showcase.ts b/src/lib/area-showcase.ts
index eb53ac93..74a18dcc 100644
--- a/src/lib/area-showcase.ts
+++ b/src/lib/area-showcase.ts
@@ -8,7 +8,7 @@ import { cacheLife } from "next/cache";
import { EFFECTS, MOTIONS } from "@/lib/catalog";
import { HOME_EFFECTS, HOME_MOTIONS, HOME_STUDIOS, homeCard, homeShowcase, presetHref, type HomeFacts } from "@/lib/home-showcase";
import { areaCount, areaSections, rankCards, type AreaId } from "@/lib/nav-areas";
-import { entry, NAV_ENTRIES, visibleTo, type NavEntry } from "@/lib/nav-model";
+import { entry, NAV_ENTRIES, subLabel, visibleTo, type NavEntry } from "@/lib/nav-model";
import type { PresetCardData } from "@/lib/preset-cards";
import { featuredAll, featuredBand } from "@/lib/preset-featured";
@@ -42,6 +42,11 @@ export interface AreaShowcaseSection {
pills: AreaPill[];
/** Added for the studio's owner only, by a client island (OwnerPills), so the server's HTML never holds them. */
ownerPills: AreaPill[];
+ /**
+ * What the section's studios hold inside, a row per studio: its features everyone sees, and the ids of the owner's
+ * own (added by OwnerPills). A studio with only the owner's has no pills and its row is the owner's alone.
+ */
+ subs: { parent: AreaPill; pills: AreaPill[]; ownerIds: string[] }[];
}
const DRAWN: Record<string, AreaDrawn> = { "live-edit": "live" };
@@ -53,6 +58,8 @@ function lineOf(e: NavEntry, facts: HomeFacts): string {
}
const pill = (e: NavEntry): AreaPill => ({ id: e.id, href: e.href, label: e.label, icon: e.icon });
+/** A feature as a pill under its studio: its tab's name. */
+const subPill = (e: NavEntry): AreaPill => ({ ...pill(e), label: subLabel(e) });
/**
* A card's cover: Home's for a page Home has a card for (so a studio looks the same in both places), unless another
@@ -103,6 +110,13 @@ export async function areaShowcase(id: AreaId) {
};
});
const entries = (ids: string[]) => ids.map(entry).filter((e): e is NavEntry => !!e);
+ const guestSubs = s.subs ?? [];
+ const subs = (owner.find((o) => o.id === s.id)?.subs ?? []).flatMap((o) => {
+ const parent = entry(o.parent);
+ if (!parent) return [];
+ const everyone = guestSubs.find((g) => g.parent === o.parent)?.ids ?? [];
+ return [{ parent: pill(parent), pills: entries(everyone).map(subPill), ownerIds: o.ids.filter((x) => !everyone.includes(x)) }];
+ });
return {
id: s.id,
title: s.title,
@@ -113,6 +127,7 @@ export async function areaShowcase(id: AreaId) {
ownerPills: entries(ownerOnly)
.filter((e) => visibleTo(e, "owner"))
.map(pill),
+ subs,
};
});
return { count: areaCount(id, undefined), sections };
diff --git a/src/lib/mega-menus.ts b/src/lib/mega-menus.ts
index 7f69fce1..6862138a 100644
--- a/src/lib/mega-menus.ts
+++ b/src/lib/mega-menus.ts
@@ -6,7 +6,7 @@
*/
import type { CoverFraming } from "./cover-framing";
import { area } from "./nav-areas";
-import { launcherColumns, studioCount, type NavEntry, type NavIconName, type ViewerKind } from "./nav-model";
+import { entriesFor, launcherColumns, studioCount, studioSubs, STUDIO_SUBS, subLabel, subParent, type NavEntry, type NavIconName, type ViewerKind } from "./nav-model";
export type MegaId = "studios" | "apps" | "motions" | "canvas";
@@ -45,6 +45,22 @@ export interface MegaItem {
short?: string;
/** ISO date: a "New" badge until then. */
newUntil?: string;
+ /** What it holds inside (a studio's tabs and modes): links under it (Studios). */
+ subs?: MegaSub[];
+ /** The window height its links need (800, 880 or 960 px): below it they hide, so the panel never scrolls. */
+ subsFrom?: 800 | 880 | 960;
+}
+
+/** A feature inside a studio, as a link under it: its tab's name, its line as the link's title. */
+export interface MegaSub {
+ id: string;
+ href: string;
+ label: string;
+ line?: string;
+ /** "See all N": the studio's page, where every one of its features is a tab. */
+ more?: true;
+ /** The window height this one link needs, when it is more than its studio's other links do (the owner's own). */
+ from?: 880 | 960;
}
export interface MegaColumn {
@@ -142,7 +158,35 @@ const studioItem = (e: NavEntry): MegaItem => ({
...(e.newUntil && { newUntil: e.newUntil }),
});
-/** Studios as a menu: the launcher's columns (launcherColumns) for who is looking, as the bar has always shown them. */
+/** A studio's features as the menu links them under it (STUDIO_SUBS), then "See all N" when it lists only some. */
+export function megaSubs(parent: NavEntry, kind: ViewerKind | undefined): MegaSub[] {
+ const shown = studioSubs(parent.id, kind, "menu");
+ if (!shown.length) return [];
+ const ownerTall = STUDIO_SUBS[parent.id]?.ownerTall;
+ const subs: MegaSub[] = shown.map((e) => ({
+ id: e.id,
+ href: e.href,
+ label: subLabel(e),
+ line: e.what,
+ ...(ownerTall && e.visibility?.length === 1 && e.visibility[0] === "owner" && { from: ownerTall }),
+ }));
+ // Every tab the studio's page shows this viewer (Audio's rows in the Sound column count too).
+ const all = Math.max(studioSubs(parent.id, kind, "list").length, entriesFor(kind).filter((e) => e.kind === "tool" && e.parent === parent.id).length);
+ if (all > shown.length) subs.push({ id: `${parent.id}-all`, href: parent.href, label: `See all ${all}`, line: `Every tool in ${parent.label}`, more: true });
+ return subs;
+}
+
+const withSubs = (e: NavEntry, kind: ViewerKind | undefined): MegaItem => {
+ const subs = megaSubs(e, kind);
+ const from = STUDIO_SUBS[e.id]?.tall;
+ return { ...studioItem(e), ...(subs.length > 0 && { subs, ...(from && { subsFrom: from }) }) };
+};
+
+/**
+ * Studios as a menu: the launcher's columns (launcherColumns) for who is looking, each studio with what it holds inside
+ * as links under it (megaSubs). A studio that is a tab of another's suite (Ads Studio, in Marketing Studio's) is one of
+ * those links instead of a row of its own.
+ */
export function studiosMenu(kind: ViewerKind | undefined): MegaModel {
const n = studioCount();
return {
@@ -150,7 +194,13 @@ export function studiosMenu(kind: ViewerKind | undefined): MegaModel {
count: n,
countLine: `${n} studios, grouped by what you want to make`,
seeAll: { href: MEGA_AREAS.studios.href, name: "See all studios" },
- columns: launcherColumns(kind).map((c) => ({ id: c.group.id, label: c.group.label, chip: c.group.chip, lead: studioItem(c.lead), rows: c.rest.map(studioItem) })),
+ columns: launcherColumns(kind).map((c) => ({
+ id: c.group.id,
+ label: c.group.label,
+ chip: c.group.chip,
+ lead: withSubs(c.lead, kind),
+ rows: c.rest.filter((e) => !subParent(e.id)).map((e) => withSubs(e, kind)),
+ })),
};
}
diff --git a/src/lib/nav-areas.ts b/src/lib/nav-areas.ts
index c0b48e5b..2a50817e 100644
--- a/src/lib/nav-areas.ts
+++ b/src/lib/nav-areas.ts
@@ -14,6 +14,7 @@ import {
LAUNCHER_GROUPS,
launcherEntries,
NAV_ENTRIES,
+ studioSubs,
visibleTo,
type LauncherGroupId,
type NavEntry,
@@ -35,6 +36,8 @@ export interface AreaSection {
cards: string[];
/** NavEntry ids drawn as pills under the cards. */
chips: string[];
+ /** What the section's studios hold inside (their tabs and modes): a row of pills per studio, under the rest. */
+ subs?: { parent: string; ids: string[] }[];
}
export interface Area {
@@ -157,8 +160,8 @@ function createSections(): AreaSection[] {
const CREATE_CARDS: ReadonlySet<string> = new Set(createSections().flatMap((s) => s.cards));
/**
- * /studios' sections: one per launcher group, its studios as cards, then the ones whose card is on /create, their
- * tools and Apps (a page of its own) as pills.
+ * /studios' sections: one per launcher group, its studios as cards, then the ones whose card is on /create and Apps (a
+ * page of its own) as pills, then what each studio holds inside (STUDIO_SUBS: its tabs and modes) as a row of its own.
*/
function studioSections(kind: ViewerKind | undefined): AreaSection[] {
return LAUNCHER_GROUPS.map((g) => {
@@ -169,7 +172,8 @@ function studioSections(kind: ViewerKind | undefined): AreaSection[] {
title: g.label,
...GROUP_COPY[g.id],
cards: studios.filter((id) => !CREATE_CARDS.has(id)),
- chips: [...studios.filter((id) => CREATE_CARDS.has(id)), ...toolsOf(studios), ...all.filter((id) => id === "apps")],
+ chips: [...studios.filter((id) => CREATE_CARDS.has(id)), ...all.filter((id) => id === "apps")],
+ subs: studios.map((parent) => ({ parent, ids: studioSubs(parent, kind).map((e) => e.id) })).filter((s) => s.ids.length > 0),
};
});
}
@@ -198,7 +202,13 @@ export function areaSections(id: AreaId, kind: ViewerKind | undefined, order: (i
.map(entry)
.filter(seen)
.filter((e, i, list) => !cardHrefs.has(e.href) && list.findIndex((x) => x.href === e.href) === i);
- return { ...s, cards: cards.map((e) => e.id), chips: chips.map((e) => e.id) };
+ // A studio's features, less any that is a card or a pill of its own here (Ads Studio is a studio too).
+ const listed = new Set([...cards, ...chips].map((e) => e.href));
+ const subs = (s.subs ?? [])
+ .filter((x) => seen(entry(x.parent)))
+ .map((x) => ({ parent: x.parent, ids: x.ids.map(entry).filter(seen).filter((e) => !listed.has(e.href)).map((e) => e.id) }))
+ .filter((x) => x.ids.length > 0);
+ return { ...s, cards: cards.map((e) => e.id), chips: chips.map((e) => e.id), ...(s.subs && { subs }) };
})
.filter((s) => s.cards.length || s.chips.length);
}
diff --git a/src/lib/nav-model.ts b/src/lib/nav-model.ts
index e22459ef..f872015e 100644
--- a/src/lib/nav-model.ts
+++ b/src/lib/nav-model.ts
@@ -55,6 +55,11 @@ export interface NavEntry {
eager?: true;
/** A tool's studio id ("audio" for audio-clean): search shows "Audio › Clean up voice". */
parent?: string;
+ /**
+ * A tool's name on its studio's own tab, where its label says more for search ("Upscale video" is the Upscale tab
+ * "Video"): the links under its studio show this one.
+ */
+ tab?: string;
}
export interface LauncherGroup {
@@ -273,6 +278,7 @@ const HUB_TOOLS: NavEntry[] = HUB_ORDER.flatMap((hub) =>
id,
href: modeHref(hub, m.id),
label: copy?.label ?? m.label,
+ ...(copy?.label && copy.label !== m.label && { tab: m.label }),
what: copy?.what ?? m.label,
kind: "tool",
goals: [],
@@ -288,15 +294,70 @@ const HUB_TOOLS: NavEntry[] = HUB_ORDER.flatMap((hub) =>
}),
);
-/** Pages inside a studio that people look for by name. */
+/** Pages inside a studio that people look for by name (labels as the studio's own tabs say them). */
const SUB_TOOLS: NavEntry[] = [
- { id: "marketing-click-to-ad", href: "/marketing/click-to-ad", label: "Click to ad", what: "From a product link to an ad", kind: "tool", goals: [], keywords: "product link url to ad shop page amazon", icon: "Megaphone", parent: "marketing" },
- { id: "ads-multiplier", href: "/ads/multiplier", label: "Ad multiplier", what: "One ad in many versions", kind: "tool", goals: [], keywords: "variations versions sizes multiply", icon: "Target", parent: "ads" },
+ { id: "marketing-click-to-ad", href: "/marketing/click-to-ad", label: "Click to Ad", what: "From a product link to an ad", kind: "tool", goals: [], keywords: "product link url to ad shop page amazon", icon: "Megaphone", parent: "marketing" },
+ // A tab of Marketing Studio's suite (Marketing Studio · Click to Ad · Ads Studio · Ad Multiplier), so its studio is that one.
+ { id: "ads-multiplier", href: "/ads/multiplier", label: "Ad Multiplier", what: "One ad in many versions", kind: "tool", goals: [], keywords: "variations versions sizes multiply ads studio", icon: "Target", parent: "marketing" },
{ id: "assist-skills", href: "/assist/skills", label: "Skills", what: "Reusable recipes", kind: "tool", goals: [], keywords: "skill recipe playbook automation", icon: "MessageCircle", parent: "assist" },
// An app with a page of its own that Create lists: a tool of Apps, so the bar marks Apps on its page.
{ id: "any-angle", href: "/apps/app-any-angle", label: "Any Angle", what: "See it from any angle", kind: "tool", goals: [], keywords: "angle rotate turn view camera viewpoint orbit 3d", cover: "app-any-angle", icon: "Rotate3d", parent: "apps" },
];
+/** A feature inside a studio: one of its tabs or modes, opened by its own link. */
+const feature = (parent: string, icon: NavIconName, id: string, href: string, label: string, what: string, keywords: string, visibility?: readonly ViewerKind[]): NavEntry => ({
+ id: `${parent}-${id}`,
+ href,
+ label,
+ what,
+ kind: "tool",
+ goals: [],
+ keywords,
+ icon,
+ parent,
+ ...(visibility && { visibility }),
+});
+
+/**
+ * The modes and tabs inside the studios that have no page of their own, each opened by its link (?mode=, ?tab=):
+ * Genjutsu (src/lib/catalog/genjutsu.ts), Character Sheet, Image to 3D (src/lib/av/model3d.ts), Photodump, Cinema
+ * Studio, Canvas and Assist. Labels are the studio's own (a test holds them to it).
+ */
+const STUDIO_FEATURES: NavEntry[] = [
+ ...(
+ [
+ ["motion", "Motion transfer", "Your character, moving as filmed", "motion transfer move copy movement dance performance replace person"],
+ ["character", "Character swap", "Your character takes over a part", "character swap replace person face actor recast one part"],
+ ["swap", "Object swap", "Swap a thing or an outfit", "object swap replace thing product outfit clothes"],
+ ["restyle", "Restyle", "A new look on every frame", "restyle style look anime clay painting filter"],
+ ["insert", "Insert", "Add something to the shot", "insert add object put into clip place"],
+ ] as const
+ ).map(([id, label, what, kw]) => feature("genjutsu", "WandSparkles", id, `/genjutsu?mode=${id}`, label, what, kw)),
+ feature("genjutsu", "WandSparkles", "picture", "/genjutsu?mode=picture", "From picture", "Your picture's setting, moving", "from picture photo setting animate motion", OWNER),
+ feature("genjutsu", "WandSparkles", "finish", "/genjutsu?mode=finish", "Finish", "Fix faces and colours", "finish fix faces colours colors", OWNER),
+ ...(
+ [
+ ["reference", "From Reference", "A sheet from your photos", "reference photo upload face sheet"],
+ ["cast", "Build from scratch", "Pick every trait yourself", "build scratch cast traits face body"],
+ ["describe", "From a description", "A sheet from a few words", "describe description words text prompt"],
+ ] as const
+ ).map(([id, label, what, kw]) => feature("character-sheet", "UserRoundCog", id, `/character-sheet?mode=${id}`, label, what, kw)),
+ ...(
+ [
+ ["image", "From an image", "One photo to a 3D model", "photo picture image to 3d glb"],
+ ["multi", "From several images", "Photos from 2 to 4 sides", "multi view several photos sides 3d"],
+ ["text", "From text", "Describe one object", "text to 3d describe words"],
+ ["objects", "Pick an object", "One object out of a photo", "segment pick object out of photo 3d"],
+ ["splat", "Splat", "A soft, photoreal 3D capture", "gaussian splat capture photoreal"],
+ ] as const
+ ).map(([id, label, what, kw]) => feature("image-to-3d", "Box", id, `/image-to-3d?mode=${id}`, label, what, kw)),
+ feature("photodump", "Camera", "instadump", "/photodump?tab=instadump", "From a selfie", "A photo pack from one selfie", "instadump selfie one photo pack instagram"),
+ feature("cinema", "Clapperboard", "blockout", "/cinema?blockout=1", "Blockout", "Block a scene out in 3D", "blockout block out 3d layout previs scene", OWNER),
+ feature("canvas", "Network", "skills", "/canvas?tab=skills", "Skills as canvases", "Assist's skills, drawn as boards", "skills recipes boards assist canvas", OWNER),
+ feature("assist", "MessageCircle", "memory", "/assist/memory", "Memory", "What Assist remembers", "memory remember facts notes", OWNER),
+ feature("assist", "MessageCircle", "scheduled", "/assist/scheduled", "Scheduled", "Tasks that run on a schedule", "scheduled schedule recurring tasks", OWNER),
+];
+
/** The pages that show everything one of the bar's menus holds (src/lib/nav-areas.ts lays them out). */
const AREA_PAGES: NavEntry[] = [
{ id: "area-create", href: "/create", label: "All of Create", what: "Every way to make or edit", kind: "area", goals: [], keywords: "create make edit tools all overview", icon: "Sparkles" },
@@ -397,7 +458,7 @@ const ACTIONS: NavEntry[] = [
{ id: "login", href: "/login", label: "Log in", what: "Back to your account", kind: "action", goals: [], keywords: "log in login sign in account", icon: "LogIn", visibility: GUEST },
];
-export const NAV_ENTRIES: readonly NavEntry[] = [...PAGES, ...STUDIOS, ...HUB_TOOLS, ...SUB_TOOLS, ...AREA_PAGES, ...SETTINGS, ...ACCOUNT_SETTINGS, ...ACTIONS].map((e) =>
+export const NAV_ENTRIES: readonly NavEntry[] = [...PAGES, ...STUDIOS, ...HUB_TOOLS, ...SUB_TOOLS, ...STUDIO_FEATURES, ...AREA_PAGES, ...SETTINGS, ...ACCOUNT_SETTINGS, ...ACTIONS].map((e) =>
CARD_LINES[e.id] ? { ...e, line: CARD_LINES[e.id] } : e,
);
@@ -608,6 +669,101 @@ export function launcherActive(pathname: string): string | undefined {
return best?.id;
}
+/**
+ * What each studio holds inside (its tabs and modes), as the bar lists it under the studio: links under its card or row
+ * in the Studios menu, pills under a group's tiles in the phone's Studios sheet, and a row of pills in its section of
+ * /studios. Search finds every one of them on its own ("Genjutsu › Restyle").
+ * - `ids`: NavEntry ids in the studio's own order (a viewer sees those visibleTo them).
+ * - `menu`: how many the Studios menu lists (it never scrolls): these first (`pick`), then "See all N" to the studio
+ * (so not the one its own link opens). Omitted: all of them. 0: none (its column has no room): the sheet, /studios
+ * and search carry them.
+ * - `tall`: the menu shows them only on a window this tall (800, 880 or 960 px), where its column has the room.
+ * Ads Studio is a tab of Marketing Studio's suite: it lives under Marketing Studio, not as a row of its own.
+ */
+export interface StudioSubs {
+ ids: readonly string[];
+ menu?: number;
+ pick?: readonly string[];
+ tall?: 800 | 880 | 960;
+ /** The owner's own features in the list (Genjutsu's From picture and Finish) show from this height. */
+ ownerTall?: 880 | 960;
+}
+
+const hubTools = (hub: HubKind, skip: readonly string[] = []) => HUB_MODES[hub].map((m) => `${hub}-${m.id}`).filter((id) => !skip.includes(id));
+
+export const STUDIO_SUBS: Readonly<Record<string, StudioSubs>> = {
+ marketing: { ids: ["marketing-click-to-ad", "ads", "ads-multiplier"] },
+ genjutsu: { ids: ["genjutsu-motion", "genjutsu-character", "genjutsu-swap", "genjutsu-restyle", "genjutsu-insert", "genjutsu-picture", "genjutsu-finish"], tall: 800, ownerTall: 880 },
+ // The modes that aren't rows of the Sound column already.
+ audio: { ids: hubTools("audio", SOUND_COLUMN), menu: 3 },
+ upscale: { ids: hubTools("upscale") },
+ "video-tools": { ids: hubTools("video-tools"), menu: 3, pick: ["video-tools-relight", "video-tools-captions", "video-tools-remove-object"], tall: 880 },
+ photodump: { ids: ["photodump-instadump"] },
+ "image-to-3d": { ids: ["image-to-3d-image", "image-to-3d-multi", "image-to-3d-text", "image-to-3d-objects", "image-to-3d-splat"], menu: 3, tall: 800 },
+ "character-sheet": { ids: ["character-sheet-reference", "character-sheet-cast", "character-sheet-describe"], menu: 0 },
+ cinema: { ids: ["cinema-blockout"], menu: 0 },
+ canvas: { ids: ["canvas-skills"] },
+ assist: { ids: ["assist-skills", "assist-memory", "assist-scheduled"] },
+};
+
+/**
+ * Features a guest or an account may open but not run here (their pages say so up front, docs/public-signup.md): the
+ * menus and the phone sheet link them for the owner only. Search and /studios still list them.
+ */
+export const OWNER_RUNS: ReadonlySet<string> = new Set([
+ "audio-split",
+ "video-tools-remove-dialogue",
+ ...STUDIO_SUBS["image-to-3d"].ids,
+ ...STUDIO_SUBS["character-sheet"].ids,
+ ...STUDIO_SUBS.photodump.ids,
+]);
+
+/** The studio a feature lives under in the menus (Ads Studio under Marketing Studio). */
+const SUB_PARENT = new Map(Object.entries(STUDIO_SUBS).flatMap(([parent, s]) => s.ids.map((id) => [id, parent] as const)));
+export const subParent = (id: string): string | undefined => SUB_PARENT.get(id);
+
+/** A studio's features as this viewer sees them: all (`list`, for /studios and search), or as the menus and sheets link them. */
+export function studioSubs(parent: string, kind: ViewerKind | undefined, place: "list" | "sheet" | "menu" = "list"): NavEntry[] {
+ const spec = STUDIO_SUBS[parent];
+ if (!spec) return [];
+ const all = spec.ids.map((id) => byId.get(id)).filter((e): e is NavEntry => !!e && visibleTo(e, kind));
+ if (place === "list") return all;
+ const linked = all.filter((e) => kind === "owner" || !OWNER_RUNS.has(e.id));
+ if (place === "sheet") return linked;
+ if (spec.menu === 0) return [];
+ if (spec.menu === undefined || spec.menu >= linked.length) return linked;
+ // A cut list ends on "See all", the studio's own page: the feature that page opens on is left to it.
+ const home = byId.get(parent)?.href;
+ const pick = spec.pick ?? [];
+ const rest = linked.filter((e) => e.href !== home);
+ const ordered = [...rest.filter((e) => pick.includes(e.id)).sort((a, b) => pick.indexOf(a.id) - pick.indexOf(b.id)), ...rest.filter((e) => !pick.includes(e.id))];
+ return ordered.slice(0, spec.menu);
+}
+
+/** A sub-link's name: its studio's own tab name ("Video" under Upscale), else its label. */
+export const subLabel = (e: Pick<NavEntry, "label" | "tab">) => e.tab ?? e.label;
+
+/**
+ * The studio feature a page is (for aria-current on its link under its studio): the one whose link the path and query
+ * match, the longest such link winning. None when the feature's link is its studio's own (/upscale is Upscale, and its
+ * "Image" tab is that same page), so the studio stays the one marked.
+ */
+export function subActive(pathname: string, search: string | URLSearchParams = ""): string | undefined {
+ const q = typeof search === "string" ? new URLSearchParams(search) : search;
+ let best: NavEntry | undefined;
+ for (const [id, parent] of SUB_PARENT) {
+ const e = byId.get(id);
+ const p = byId.get(parent);
+ if (!e || !p || e.href === p.href) continue;
+ const [path, query] = e.href.split("?");
+ if (path !== pathname) continue;
+ const want = new URLSearchParams(query ?? "");
+ if ([...want].some(([k, v]) => q.get(k) !== v)) continue;
+ if (!best || e.href.length > best.href.length) best = e;
+ }
+ return best?.id;
+}
+
/** How many studios there are (Apps is not one): for copy such as "28 studios". */
export function studioCount(): number {
return NAV_ENTRIES.filter((e) => e.group && e.kind === "studio").length;
diff --git a/tests/e2e/nav-hubs.mjs b/tests/e2e/nav-hubs.mjs
index 8e37a143..ab912369 100644
--- a/tests/e2e/nav-hubs.mjs
+++ b/tests/e2e/nav-hubs.mjs
@@ -285,8 +285,8 @@ try {
if (tab === "Studios") {
const tiles = sheet.locator("ul").first().getByRole("link");
const seen = await tiles.evaluateAll((els) => els.map((el) => el.getBoundingClientRect()).map((r) => r.top >= 0 && r.bottom <= innerHeight));
- // 33 studio tiles and the See all tile that ends the grid.
- check(seen.length === 34 && seen.every(Boolean), "phone Studios sheet: all 33 tiles and See all fit 390x844", `${seen.filter(Boolean).length}/${seen.length}`);
+ // 32 studio tiles (Ads Studio is under Marketing Studio, in the Sell group) and the See all tile that ends the grid.
+ check(seen.length === 33 && seen.every(Boolean), "phone Studios sheet: all 32 tiles and See all fit 390x844", `${seen.filter(Boolean).length}/${seen.length}`);
check((await sheet.getByRole("button", { name: "Search everything" }).count()) === 1, "phone Studios sheet: Search everything is an icon button");
if (shots) await p.screenshot({ path: path.join(shots, "phone-studios-sheet-390.png") });
}
diff --git a/tests/e2e/nav-subfeatures.mjs b/tests/e2e/nav-subfeatures.mjs
new file mode 100644
index 00000000..4549f9fd
--- /dev/null
+++ b/tests/e2e/nav-subfeatures.mjs
@@ -0,0 +1,480 @@
+// What each studio holds inside (its tabs and modes) in the top nav, in a real browser, for a guest, an account and the
+// owner: the links under their studio in the Studios menu (fit, keys, focus, current page, deep links that open the right
+// tab), the phone's Studios sheet pills, /studios' "Inside these studios" rows, search, and the owner's Canvas column.
+// Usage: node tests/e2e/nav-subfeatures.mjs [appUrl] [shotsDir]
+// E2E_BROWSER=webkit or firefox runs it there. E2E_OWNER_PASSWORD: the studio's password, when it has one. Account
+// checks need public sign-up (a throwaway qa account, deleted at the end).
+// Exits 1 if any check fails; shots (1440 and 1280 menus, 390 sheets and /studios, light and dark) go to shotsDir.
+import fs from "node:fs";
+import path from "node:path";
+import { ENGINE, launch, openRoute, PHONE } from "./_browser.mjs";
+
+const args = process.argv.slice(2).filter((a) => !a.startsWith("--"));
+const app = (args[0] ?? "http://localhost:3000").replace(/\/$/, "");
+const shots = args[1];
+if (shots) fs.mkdirSync(shots, { recursive: true });
+const failures = [];
+const check = (ok, what, detail = "") => {
+ console.log(`${ok ? "✓" : "✗"} ${what}${!ok && detail ? ` (${detail})` : ""}`);
+ if (!ok) failures.push(what);
+};
+const shot = async (page, name, opts = {}) => shots && (await page.screenshot({ path: path.join(shots, `${name}.png`), ...opts }));
+const publicSignup = !!(await fetch(`${app}/api/auth/me`).then((r) => r.json()).catch(() => null))?.publicSignup;
+
+/** Features a visitor never gets a menu or sheet link to: the owner's own, and pages that say "isn't available here". */
+const OWNER_SUBS = ["From picture", "Blockout", "Split soundtrack", "Remove dialogue", "From an image", "From several images", "From a selfie", "From Reference", "Skills as canvases"];
+
+const browser = await launch();
+const accounts = [];
+let accountState;
+async function account() {
+ if (!accountState) {
+ const ctx = await browser.newContext();
+ const email = `qa-navsub-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}@example.com`;
+ const password = `Qa-${Math.random().toString(36).slice(2)}-${Date.now()}`;
+ const res = await ctx.request.post(`${app}/api/auth/signup`, { data: { email, password } });
+ if (!res.ok()) throw new Error(`sign-up answered ${res.status()}`);
+ accounts.push({ ctx, password });
+ accountState = await ctx.storageState();
+ }
+ return accountState;
+}
+async function as(who, device = { viewport: { width: 1440, height: 900 } }, extra = {}) {
+ const ctx = await browser.newContext({ ...device, ...extra });
+ ctx.errors = [];
+ if (who === "owner" && process.env.E2E_OWNER_PASSWORD) await ctx.request.post(`${app}/api/auth/login`, { data: { password: process.env.E2E_OWNER_PASSWORD } });
+ if (who === "account") await ctx.addCookies((await account()).cookies);
+ const me = (await (await ctx.request.get(`${app}/api/auth/me`)).json().catch(() => null)) ?? {};
+ if (who === "owner" && !me.owner) throw new Error("couldn't sign in as the owner (set E2E_OWNER_PASSWORD)");
+ return ctx;
+}
+async function page(ctx) {
+ const p = await ctx.newPage();
+ const noise = (t) => /Failed to load resource/.test(t) || (/_rsc=/.test(t) && /due to access control checks/.test(t));
+ p.on("pageerror", (e) => !noise(e.message) && ctx.errors.push(`uncaught: ${e.message.split("\n")[0]}`));
+ p.on("console", (m) => m.type() === "error" && !noise(m.text()) && ctx.errors.push(m.text().slice(0, 200)));
+ return p;
+}
+const bar = (p) => p.locator("[data-top-bar]");
+const panel = (p) => p.locator("#studios-launcher");
+const focused = (p) =>
+ p.evaluate(() => {
+ const a = document.activeElement;
+ return { text: a?.textContent?.trim() ?? "", sub: a?.hasAttribute("data-sub") ?? false, col: a?.getAttribute("data-col"), row: a?.getAttribute("data-row") };
+ });
+const waitUrl = (p, test) => p.waitForURL((u) => test(new URL(u)), { timeout: 20_000 }).then(() => true, () => false);
+/** Whether a page's tab (or a mode picked as a radio, Image to 3D's) by this name is the selected one. */
+const selectedTab = async (p, name) => {
+ const tab = p.getByRole("tab", { name, exact: true }).or(p.getByRole("radio", { name, exact: true })).first();
+ try {
+ await tab.waitFor({ timeout: 15_000 });
+ await p.waitForTimeout(200);
+ return (await tab.getAttribute("aria-selected")) === "true" || (await tab.getAttribute("aria-checked")) === "true";
+ } catch {
+ return false;
+ }
+};
+/** Opens search from the bar's own button (the / key belongs to a focused field when there is one). */
+async function openSearch(p) {
+ await p.keyboard.press("Escape").catch(() => {});
+ const input = p.locator("[cmdk-input]").or(p.getByPlaceholder("What do you want to make?")).first();
+ // The bar's search button, else its / key (a click can land while the page is still settling).
+ await p.locator('[data-top-bar] button[aria-keyshortcuts^="/"]').first().click({ timeout: 5_000 }).catch(() => p.keyboard.press("/"));
+ if (!(await input.isVisible().catch(() => false))) await input.waitFor({ timeout: 3_000 }).catch(() => p.keyboard.press("/"));
+ await input.waitFor({ timeout: 10_000 });
+ return input;
+}
+
+async function openStudios(p) {
+ const chev = bar(p).getByRole("button", { name: "Studios menu", exact: true });
+ await chev.click();
+ // A click that met a menu the resting mouse had just opened closes it: open it again from the keyboard.
+ if (!(await panel(p).waitFor({ state: "visible", timeout: 2_000 }).then(() => true, () => false))) {
+ await chev.focus();
+ await p.keyboard.press("Enter");
+ }
+ await panel(p).waitFor({ state: "visible" });
+ await panel(p).locator('[data-col="0"][data-row="0"]').first().waitFor({ timeout: 10_000 });
+ await p.waitForFunction(() => [...document.querySelectorAll("#studios-launcher img")].filter((i) => i.checkVisibility()).every((i) => i.complete), null, { timeout: 10_000 }).catch(() => {});
+ await p.waitForTimeout(250);
+}
+
+/** The Studios panel as it shows: fit, and each studio's links that show. */
+const measure = (p) =>
+ panel(p).evaluate((el) => {
+ const links = [...el.querySelectorAll("[data-col]")].filter((a) => a.checkVisibility());
+ const subs = {};
+ for (const ul of el.querySelectorAll("[data-subs]")) {
+ if (!ul.checkVisibility()) continue;
+ subs[ul.getAttribute("data-subs")] = [...ul.querySelectorAll("a")].filter((a) => a.checkVisibility()).map((a) => ({ label: a.textContent.trim(), h: a.getBoundingClientRect().height }));
+ }
+ return {
+ inner: el.scrollHeight - el.clientHeight,
+ offscreen: links.filter((a) => {
+ const r = a.getBoundingClientRect();
+ return r.bottom > innerHeight + 0.5 || r.right > innerWidth + 0.5 || r.top < 0;
+ }).length,
+ links: links.length,
+ subs,
+ text: el.innerText,
+ };
+ });
+
+try {
+ // 1. The Studios menu: each viewer, each size: everything on screen, the studios' links where their column has room.
+ for (const who of ["guest", "owner", ...(publicSignup ? ["account"] : [])]) {
+ for (const size of [
+ { width: 1280, height: 720 },
+ { width: 1366, height: 768 },
+ { width: 1280, height: 800 },
+ { width: 1440, height: 900 },
+ { width: 1920, height: 1080 },
+ ]) {
+ const label = `${who} ${size.width}x${size.height}`;
+ const ctx = await as(who, { viewport: size });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await openStudios(p);
+ const r = await measure(p);
+ const names = (id) => (r.subs[id] ?? []).map((s) => s.label);
+ check(r.inner <= 1 && r.offscreen === 0, `${label}: every studio and link on screen, no scrolling inside`, `inner ${r.inner}, ${r.offscreen}/${r.links} off`);
+ check(names("marketing").join(" · ") === "Click to Ad · Ads Studio · Ad Multiplier", `${label}: Marketing Studio lists Click to Ad · Ads Studio · Ad Multiplier`, names("marketing").join(" · "));
+ check(names("upscale").join(" · ") === "Image · Video · FPS Boost · SDR to HDR · Export", `${label}: Upscale lists its five tabs`, names("upscale").join(" · "));
+ if (size.height >= 800) {
+ const gen = names("genjutsu");
+ // The owner's own two modes from 880 px (People is the tallest column then).
+ const want = ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert", ...(who === "owner" && size.height >= 880 ? ["From picture", "Finish"] : [])];
+ check(want.every((w) => gen.includes(w)) && gen.length === want.length, `${label}: Genjutsu lists its modes`, gen.join(" · "));
+ if (size.height >= 880) check(/^See all \d+$/.test(names("video-tools").at(-1) ?? ""), `${label}: Video tools lists a few, then See all`, names("video-tools").join(" · "));
+ else check(!r.subs["video-tools"], `${label}: Video tools keeps its row only (its links from 880 px)`);
+ } else {
+ check(!r.subs.genjutsu && !r.subs["video-tools"], `${label}: full columns keep their rows only (Genjutsu and Video tools links from 800 px)`, Object.keys(r.subs).join(","));
+ }
+ check((await panel(p).locator('[data-group="sell"] > ul > li > a[href="/ads"]').count()) === 0, `${label}: Ads Studio is under Marketing Studio, not a row of its own`);
+ const allSubs = Object.values(r.subs).flat();
+ check(allSubs.every((s) => s.h >= 27.5), `${label}: every link at least 28 px tall`, allSubs.filter((s) => s.h < 27.5).map((s) => `${s.label} ${s.h}`).join(", "));
+ if (who !== "owner") {
+ const said = OWNER_SUBS.filter((w) => allSubs.some((s) => s.label === w));
+ check(said.length === 0, `${label}: no link a visitor can't use`, said.join(", "));
+ } else if (size.height >= 800) {
+ check(names("image-to-3d").length === 4, `${label}: the owner's Image to 3D modes, then See all`, names("image-to-3d").join(" · "));
+ }
+ if (shots && who !== "account" && [1280, 1440].includes(size.width)) await shot(p, `studios-${size.width}-${who}-light`);
+ await p.keyboard.press("Escape");
+ check(ctx.errors.length === 0, `${label}: no console errors`, ctx.errors.join(" | "));
+ await ctx.close();
+ }
+ }
+
+ // 1b. Dark, and a touch screen at desktop width (44 px links), and reduced motion (no transitions on the links).
+ if (shots) {
+ for (const who of ["guest", "owner"]) {
+ const ctx = await as(who, { viewport: { width: 1440, height: 900 } }, { colorScheme: "dark" });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await openStudios(p);
+ await shot(p, `studios-1440-${who}-dark`);
+ await ctx.close();
+ }
+ }
+ {
+ const ctx = await as("guest", { viewport: { width: 1366, height: 1024 }, hasTouch: true, isMobile: false });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ const coarse = await p.evaluate(() => matchMedia("(pointer: coarse)").matches);
+ if (coarse) {
+ await openStudios(p);
+ const r = await measure(p);
+ const small = Object.values(r.subs).flat().filter((s) => s.h < 43.5);
+ check(small.length === 0, "touch screen at 1366x1024: every link 44 px tall", small.map((s) => `${s.label} ${s.h}`).join(", "));
+ check(r.inner <= 1 && r.offscreen === 0, "touch screen at 1366x1024: still no scrolling inside", `inner ${r.inner}, off ${r.offscreen}`);
+ } else console.log(" touch screen: this engine doesn't report (pointer: coarse) here, skipped");
+ await ctx.close();
+ }
+ {
+ const ctx = await as("guest", { viewport: { width: 1440, height: 900 } }, { reducedMotion: "reduce" });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await openStudios(p);
+ const t = await panel(p).locator("[data-sub]").first().evaluate((a) => getComputedStyle(a).transitionDuration);
+ check(t.split(",").every((d) => parseFloat(d) === 0), "reduced motion: the links don't animate", t);
+ await ctx.close();
+ }
+
+ // 2. Keys, focus and links (guest 1440x900).
+ {
+ const ctx = await as("guest");
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ const chev = bar(p).getByRole("button", { name: "Studios menu", exact: true });
+ await chev.focus();
+ await p.keyboard.press("Enter");
+ await panel(p).waitFor({ state: "visible" });
+ await p.waitForFunction(() => document.activeElement?.closest("[data-mega-panel]"), null, { timeout: 10_000 }).catch(() => {});
+ await p.keyboard.press("ArrowRight");
+ await p.keyboard.press("ArrowRight");
+ check((await focused(p)).text.startsWith("Marketing Studio"), "keys: Right, Right reaches Marketing Studio", (await focused(p)).text);
+ await p.keyboard.press("ArrowDown");
+ let f = await focused(p);
+ check(f.sub && f.text === "Click to Ad", "keys: Down from a studio goes to its first link", JSON.stringify(f));
+ await p.keyboard.press("ArrowDown");
+ await p.keyboard.press("ArrowDown");
+ f = await focused(p);
+ check(f.sub && f.text === "Ad Multiplier", "keys: Down walks its links", JSON.stringify(f));
+ await p.keyboard.press("ArrowDown");
+ f = await focused(p);
+ check(!f.sub && f.text.startsWith("Mixed Media"), "keys: Down from its last link goes on to the next studio", JSON.stringify(f));
+ await p.keyboard.press("ArrowUp");
+ check((await focused(p)).text === "Ad Multiplier", "keys: Up comes back to the link");
+ await p.keyboard.press("ArrowRight");
+ f = await focused(p);
+ check(f.col === "3", "keys: Right from a link goes to the next column", JSON.stringify(f));
+ await p.keyboard.press("Escape");
+ await p.waitForTimeout(200);
+ check(await chev.evaluate((b) => b === document.activeElement), "keys: Esc from a link closes the menu and focus goes back to the chevron");
+ // Tab order: a studio, then its links, then the next studio.
+ await chev.focus();
+ await p.keyboard.press("Enter");
+ await p.waitForFunction(() => document.activeElement?.closest("[data-mega-panel]"), null, { timeout: 10_000 }).catch(() => {});
+ await panel(p).locator('[data-group="sell"] a[data-row="0"]').focus();
+ // Safari's engine leaves links out of Tab order unless the person turns it on: the arrow keys are its way in.
+ if (ENGINE === "webkit") await p.keyboard.press("ArrowDown");
+ else await p.keyboard.press("Tab");
+ check((await focused(p)).text === "Click to Ad", "Tab goes from a studio to its first link");
+ // Enter on a link opens its page.
+ await p.keyboard.press("Enter");
+ check(await waitUrl(p, (u) => u.pathname === "/marketing/click-to-ad"), "Enter on Click to Ad opens /marketing/click-to-ad", p.url());
+ check(!(await panel(p).isVisible()), "the menu closes when a link is followed");
+ await p.waitForTimeout(800);
+ // On a studio's feature, its link is the one marked.
+ await openRoute(p, `${app}/ads/multiplier`, { settleMs: 300 });
+ await openStudios(p);
+ check((await panel(p).locator('a[data-sub][href="/ads/multiplier"]').getAttribute("aria-current")) === "page", "on Ad Multiplier its link is marked as the page");
+ check((await panel(p).locator('[aria-current="page"]').count()) === 1, "and nothing else is");
+ // Every link resolves (those the window hides too).
+ const hrefs = [...new Set(await panel(p).locator("a[data-sub]").evaluateAll((as_) => as_.map((a) => a.getAttribute("href"))))];
+ const bad = [];
+ for (const h of hrefs) {
+ const res = await ctx.request.get(app + h, { maxRedirects: 0 }).catch(() => null);
+ if (!res || res.status() >= 400) bad.push(`${h} ${res?.status()}`);
+ }
+ check(hrefs.length >= 15 && bad.length === 0, `all ${hrefs.length} studio links resolve`, bad.join(", "));
+ await p.keyboard.press("Escape");
+ check(ctx.errors.length === 0, "keys and links: no console errors", ctx.errors.join(" | "));
+ await ctx.close();
+ }
+
+ // 3. Deep links open the right tab, from the menu, from the address, and on the same page.
+ {
+ const ctx = await as("guest");
+ const p = await page(ctx);
+ for (const [href, tab] of [
+ ["/genjutsu?mode=restyle", "Restyle"],
+ ["/genjutsu?mode=character", "Character swap"],
+ ["/character-sheet?mode=cast", "Build from scratch"],
+ ["/character-sheet?mode=describe", "From a description"],
+ ["/photodump?tab=instadump", "From a selfie"],
+ ["/image-to-3d?mode=text", "From text"],
+ ]) {
+ await openRoute(p, app + href, { settleMs: 600 });
+ check(await selectedTab(p, tab), `${href} opens on its "${tab}" tab`);
+ }
+ // From the menu, then another of the same studio's links while on it (same page, new query).
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await openStudios(p);
+ await panel(p).locator('a[data-sub][href="/genjutsu?mode=swap"]').click();
+ check(await waitUrl(p, (u) => u.pathname === "/genjutsu" && u.searchParams.get("mode") === "swap"), "menu: Object swap opens Genjutsu", p.url());
+ check(await selectedTab(p, "Object swap"), "on its Object swap tab");
+ await p.waitForTimeout(500);
+ await openStudios(p);
+ check((await panel(p).locator('a[data-sub][href="/genjutsu?mode=swap"]').getAttribute("aria-current")) === "page", "menu: Object swap is marked as the page");
+ await panel(p).locator('a[data-sub][href="/genjutsu?mode=insert"]').click();
+ check(await waitUrl(p, (u) => u.searchParams.get("mode") === "insert"), "menu: Insert while on Genjutsu", p.url());
+ await p.waitForTimeout(400);
+ check(await selectedTab(p, "Insert"), "switches the open studio to its Insert tab");
+ // A tab picked on the page goes in the address, so a link to another still switches it.
+ await openRoute(p, `${app}/character-sheet?mode=cast`, { settleMs: 600 });
+ await p.getByRole("tab", { name: "From a description", exact: true }).click();
+ check(await waitUrl(p, (u) => u.searchParams.get("mode") === "describe"), "Character Sheet: a picked tab goes in the address", p.url());
+ // The search finds Build from scratch: a link to another tab of the open page switches it.
+ await (await openSearch(p)).fill("build from scratch");
+ await p.waitForTimeout(500);
+ await p.keyboard.press("Enter");
+ check(await waitUrl(p, (u) => u.searchParams.get("mode") === "cast"), "Character Sheet: a link to another tab while on it", p.url());
+ await p.waitForTimeout(400);
+ check(await selectedTab(p, "Build from scratch"), "switches it to that tab");
+ await openRoute(p, `${app}/photodump`, { settleMs: 600 });
+ await p.getByRole("tab", { name: "From a selfie", exact: true }).click();
+ check(await waitUrl(p, (u) => u.searchParams.get("tab") === "instadump"), "Photodump: a picked tab goes in the address", p.url());
+ check(ctx.errors.length === 0, "deep links: no console errors", ctx.errors.join(" | "));
+ await ctx.close();
+ }
+
+ // 4. Phone: the Studios sheet's groups list their studios' features as 44 px pills; All stays one screen.
+ for (const who of ["guest", "owner", ...(publicSignup ? ["account"] : [])]) {
+ for (const scheme of who === "account" ? ["light"] : ["light", "dark"]) {
+ const label = `phone ${who} ${scheme}`;
+ const ctx = await as(who, PHONE, { colorScheme: scheme });
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await p.locator("[data-phone-tabs]").getByRole("button", { name: "Studios" }).tap();
+ const sheet = p.locator("#phone-sheet");
+ await sheet.waitFor({ state: "visible" });
+ const body = sheet.locator('[data-sheet-family="studios"]');
+ await body.locator("a[href]").first().waitFor({ timeout: 10_000 });
+ check((await body.locator("[data-sheet-subs]").count()) === 0, `${label}: All shows tiles only`);
+ const chip = (name) => sheet.locator('[role="group"][aria-label="Show the studios for one goal"]').getByRole("button", { name, exact: true });
+ for (const [g, studio, want] of [
+ ["Sell", "Marketing Studio", ["Click to Ad", "Ads Studio", "Ad Multiplier"]],
+ ["People", "Genjutsu", ["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]],
+ ["Film", "Video tools", ["Remove background", "Relight", "Captions"]],
+ ["Finish", "Upscale", ["Image", "Video", "FPS Boost", "SDR to HDR", "Export"]],
+ ]) {
+ await chip(g).tap();
+ await p.waitForTimeout(350);
+ const subs = body.locator("[data-sheet-subs]");
+ const r = await subs.evaluate((el, name) => {
+ const sec = [...el.querySelectorAll("section")].find((s) => s.querySelector("p")?.textContent?.trim().toLowerCase() === name.toLowerCase());
+ const pills = sec ? [...sec.querySelectorAll("a")] : [];
+ return {
+ labels: pills.map((a) => a.textContent.trim()),
+ // The pill and its touch area past it (::after on a touch screen: 44 px).
+ small: pills
+ .map((a) => {
+ const after = getComputedStyle(a, "::after");
+ const reach = after.content !== "none" && after.position === "absolute" ? Math.max(0, -parseFloat(after.top) || 0) + Math.max(0, -parseFloat(after.bottom) || 0) : 0;
+ return [a.textContent.trim(), a.getBoundingClientRect().height + reach];
+ })
+ .filter(([, h]) => h < 43.5)
+ .map(([t, h]) => `${t} ${h}`),
+ all: el.innerText,
+ sideways: document.documentElement.scrollWidth - document.documentElement.clientWidth,
+ wide: [...el.querySelectorAll("a")].filter((a) => a.getBoundingClientRect().right > innerWidth + 0.5).length,
+ };
+ }, studio);
+ check(want.every((w) => r.labels.includes(w)), `${label} ${g}: ${studio}'s features as pills`, r.labels.join(" · "));
+ check(r.small.length === 0, `${label} ${g}: pills 44 px tall`, r.small.join(", "));
+ check(r.sideways <= 0 && r.wide === 0, `${label} ${g}: no sideways scroll`, `${r.sideways}px, ${r.wide} past the edge`);
+ if (who !== "owner") {
+ const said = OWNER_SUBS.filter((w) => r.all.split("\n").some((l) => l.trim() === w));
+ check(said.length === 0, `${label} ${g}: no pill a visitor can't use`, said.join(", "));
+ }
+ if (shots && who !== "account" && (g === "Sell" || g === "People")) await shot(p, `phone-sheet-${g.toLowerCase()}-${who}-${scheme}`);
+ }
+ if (who === "owner") {
+ await chip("Film").tap();
+ await p.waitForTimeout(300);
+ check((await body.locator("[data-sheet-subs]").innerText()).includes("Blockout"), `${label}: the owner's Cinema Studio Blockout in Film`);
+ }
+ // A pill opens its feature on the right tab.
+ await chip("People").tap();
+ await p.waitForTimeout(300);
+ await body.locator("[data-sheet-subs]").getByRole("link", { name: "Restyle", exact: true }).tap();
+ check(await waitUrl(p, (u) => u.pathname === "/genjutsu" && u.searchParams.get("mode") === "restyle"), `${label}: Restyle opens Genjutsu`, p.url());
+ check(await selectedTab(p, "Restyle"), `${label}: on its Restyle tab`);
+ check(ctx.errors.length === 0, `${label}: no console errors`, ctx.errors.join(" | "));
+ await ctx.close();
+ }
+ }
+
+ // 5. /studios: each section's "Inside these studios" rows.
+ for (const who of ["guest", "owner"]) {
+ for (const device of [{ viewport: { width: 1440, height: 900 } }, PHONE]) {
+ const w = device.viewport.width;
+ const label = `/studios ${who} ${w}`;
+ const ctx = await as(who, device);
+ const p = await page(ctx);
+ await openRoute(p, `${app}/studios`, { settleMs: 1200 });
+ const sell = p.locator('[data-studio-features="sell"]');
+ const text = await sell.innerText().catch(() => "");
+ check(["Marketing Studio", "Click to Ad", "Ad Multiplier"].every((x) => text.includes(x)), `${label}: Sell lists Marketing Studio's Click to Ad and Ad Multiplier`, text.replace(/\n/g, " · "));
+ const people = await p.locator('[data-studio-features="people"]').innerText().catch(() => "");
+ check(["Genjutsu", "Restyle", "Character Sheet", "Build from scratch"].every((x) => people.includes(x)), `${label}: People lists Genjutsu's and Character Sheet's`, people.replace(/\n/g, " · "));
+ // The owner's own rows come once the viewer is known.
+ if (who === "owner") await p.waitForFunction(() => document.querySelector('[data-studio-features="film"]')?.textContent?.includes("Blockout"), null, { timeout: 10_000 }).catch(() => {});
+ const film = await p.locator('[data-studio-features="film"]').innerText().catch(() => "");
+ check(film.includes("Blockout") === (who === "owner"), `${label}: Cinema Studio's Blockout for the owner only`);
+ const all = await p.locator("[data-studio-features]").allInnerTexts();
+ if (who !== "owner") check(!all.join("\n").includes("From picture"), `${label}: no owner-only mode`);
+ const r = await p.evaluate(() => ({
+ sideways: document.documentElement.scrollWidth - document.documentElement.clientWidth,
+ small: [...document.querySelectorAll("[data-studio-features] a")].filter((a) => {
+ const after = getComputedStyle(a, "::after");
+ const h = a.getBoundingClientRect().height + (after.content !== "none" ? Math.max(0, -parseFloat(after.top) - parseFloat(after.bottom)) : 0);
+ return h < 43.5;
+ }).length,
+ }));
+ check(r.sideways <= 0, `${label}: no sideways scroll`, `${r.sideways}px`);
+ check(r.small === 0, `${label}: pills 44 px to tap`, `${r.small} smaller`);
+ if (shots && who === "guest") {
+ await sell.scrollIntoViewIfNeeded();
+ await p.waitForTimeout(300);
+ await shot(p, `studios-page-sell-${w}-${who}`);
+ }
+ const hrefs = await p.locator("[data-studio-features] a").evaluateAll((as_) => as_.map((a) => a.getAttribute("href")));
+ const bad = [];
+ for (const h of new Set(hrefs)) {
+ const res = await ctx.request.get(app + h, { maxRedirects: 0 }).catch(() => null);
+ if (!res || res.status() >= 400) bad.push(`${h} ${res?.status()}`);
+ }
+ check(bad.length === 0, `${label}: all ${hrefs.length} feature links resolve`, bad.join(", "));
+ check(ctx.errors.length === 0, `${label}: no console errors`, ctx.errors.join(" | "));
+ await ctx.close();
+ }
+ }
+
+ // 6. Search: a feature by its name, under its studio; the owner's own for the owner only.
+ for (const who of ["guest", "owner"]) {
+ const ctx = await as(who);
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 500 });
+ const ask = async (q) => {
+ const input = await openSearch(p);
+ await input.fill(q);
+ await p.waitForTimeout(500);
+ return p.locator("[cmdk-item]").evaluateAll((els) => els.map((e) => e.textContent.replace(/\s+/g, " ").trim()));
+ };
+ const restyle = await ask("restyle");
+ check(/Restyle/.test(restyle[0] ?? "") && /Genjutsu/.test(restyle[0] ?? ""), `search (${who}): "restyle" finds Genjutsu › Restyle first`, restyle.slice(0, 3).join(" | "));
+ const cta = await ask("click to ad");
+ check(/Click to Ad/.test(cta[0] ?? ""), `search (${who}): "click to ad" finds Click to Ad first`, cta.slice(0, 3).join(" | "));
+ const blockout = await ask("blockout");
+ check(blockout.some((t) => /^Blockout|Blockout Cinema|Cinema Studio.*Blockout|Blockout.*Cinema/.test(t)) === (who === "owner"), `search (${who}): Blockout ${who === "owner" ? "found" : "not found"}`, blockout.slice(0, 3).join(" | "));
+ if (who === "guest") {
+ await ask("restyle");
+ await p.keyboard.press("Enter");
+ check(await waitUrl(p, (u) => u.pathname === "/genjutsu" && u.searchParams.get("mode") === "restyle"), "search: Enter on Restyle opens Genjutsu on it", p.url());
+ if (shots) {
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await ask("genjutsu");
+ await shot(p, "search-genjutsu-1440-guest");
+ }
+ }
+ await ctx.close();
+ }
+
+ // 7. Canvas: the owner's column links Skills as canvases; a visitor's menu doesn't.
+ for (const who of ["guest", "owner"]) {
+ const ctx = await as(who);
+ const p = await page(ctx);
+ await openRoute(p, `${app}/image`, { settleMs: 300 });
+ await bar(p).getByRole("button", { name: "Canvas menu", exact: true }).click();
+ const cp = p.locator("#canvas-launcher");
+ await cp.waitFor({ state: "visible" });
+ await cp.locator('[data-col="0"][data-row="0"]').first().waitFor({ timeout: 10_000 });
+ await p.waitForTimeout(1500);
+ const n = await cp.locator('a[href="/canvas?tab=skills"]').count();
+ check(n === (who === "owner" ? 1 : 0), `Canvas menu (${who}): Skills as canvases ${who === "owner" ? "linked" : "not linked"}`, String(n));
+ const fit = await cp.evaluate((el) => el.scrollHeight - el.clientHeight);
+ check(fit <= 1, `Canvas menu (${who}): no scrolling inside`, String(fit));
+ if (shots && who === "owner") await shot(p, "canvas-1440-owner");
+ await ctx.close();
+ }
+} catch (e) {
+ check(false, "run", e.stack ?? String(e));
+} finally {
+ for (const { ctx, password } of accounts) await ctx.request.delete(`${app}/api/auth/me`, { data: { password } }).catch(() => {});
+ await browser.close();
+}
+console.log(failures.length ? `\n${failures.length} failed` : "\nall passed");
+process.exit(failures.length ? 1 : 0);
diff --git a/tests/e2e/nav.mjs b/tests/e2e/nav.mjs
index 9f376cd1..d64ca0bd 100644
--- a/tests/e2e/nav.mjs
+++ b/tests/e2e/nav.mjs
@@ -171,10 +171,17 @@ try {
await p.setViewportSize({ width: w, height: h });
await trigger.click();
await panel.waitFor({ state: "visible" });
- const links = panel.locator("a[data-col]");
+ // The studios and Apps (Ads Studio is a link under Marketing Studio), then See all; and each studio's links that show.
+ const links = panel.locator("a[data-col]:not([data-sub])");
const seen = [...(await inView(links)), ...(await inView(panel.getByRole("link", { name: "See all studios", exact: true })))];
+ const subs = await panel.locator("a[data-sub]").evaluateAll((as_) =>
+ as_.filter((a) => a.checkVisibility()).map((a) => {
+ const r = a.getBoundingClientRect();
+ return r.top >= 0 && r.bottom <= innerHeight + 0.5;
+ }),
+ );
const scrolls = await panel.evaluate((el) => el.scrollHeight > el.clientHeight + 1);
- check(seen.length === 34 && seen.every(Boolean) && !scrolls, `launcher at ${w}x${h}: all 33 studios and See all on screen, no scrolling`, `${seen.filter(Boolean).length}/${seen.length}`);
+ check(seen.length === 33 && seen.every(Boolean) && subs.every(Boolean) && !scrolls, `launcher at ${w}x${h}: all 32 studios, their links and See all on screen, no scrolling`, `${seen.filter(Boolean).length}/${seen.length}, links ${subs.filter(Boolean).length}/${subs.length}`);
await p.keyboard.press("Escape");
}
await p.setViewportSize(DESKTOP.viewport);
@@ -294,9 +301,9 @@ try {
await p.waitForTimeout(350);
const tiles = sheet.locator("ul").first().getByRole("link");
const seen = await inView(tiles);
- // 33 tiles and the closing See all.
- if (size.height >= 844) check(seen.length === 34 && seen.every(Boolean), `${label}: the Studios sheet shows all 33 and See all without scrolling`, `${seen.filter(Boolean).length}/${seen.length}`);
- else check(seen.length === 34, `${label}: the Studios sheet lists all 33 and See all (it scrolls inside at this height)`, String(seen.length));
+ // 32 tiles (Ads Studio is under Marketing Studio, in the Sell group) and the closing See all.
+ if (size.height >= 844) check(seen.length === 33 && seen.every(Boolean), `${label}: the Studios sheet shows all 32 and See all without scrolling`, `${seen.filter(Boolean).length}/${seen.length}`);
+ else check(seen.length === 33, `${label}: the Studios sheet lists all 32 and See all (it scrolls inside at this height)`, String(seen.length));
await sheet.getByRole("button", { name: /^Film/ }).tap();
check((await sheet.locator("ul").first().getByRole("link").count()) === 9, `${label}: the Film chip shows 8 and See all`);
if (size.height >= 844) await shot(p, "phone-studios-sheet-film-390");
diff --git a/tests/mega-menus.test.ts b/tests/mega-menus.test.ts
index 38c6eec5..4ca0170a 100644
--- a/tests/mega-menus.test.ts
+++ b/tests/mega-menus.test.ts
@@ -10,7 +10,7 @@ import { keyPlaces } from "@/components/nav/mega-panel";
import { CANVAS_INTRO } from "@/lib/canvas-template-cards";
import { MENU_LINES } from "@/lib/menu-lines";
import type { Preset } from "@/lib/catalog/types";
-import { launcherColumns } from "@/lib/nav-model";
+import { launcherColumns, subParent } from "@/lib/nav-model";
import { featuredAll } from "@/lib/preset-featured";
import { PRESET_COVERS } from "@/lib/preset-covers.generated";
import { templateCover } from "@/lib/template-covers";
@@ -158,10 +158,20 @@ describe("the menus' size", () => {
});
describe("Studios as a menu", () => {
- it("is the launcher's columns as they were", () => {
+ it("is the launcher's columns, a studio that is a tab of another's suite under that one", () => {
for (const kind of [undefined, "guest", "account", "owner"] as const) {
const m: MegaModel = studiosMenu(kind);
- expect(m.columns.map((c) => [c.id, c.lead?.id, ...c.rows.map((r) => r.id)])).toEqual(launcherColumns(kind).map((c) => [c.group.id, c.lead.id, ...c.rest.map((e) => e.id)]));
+ expect(m.columns.map((c) => [c.id, c.lead?.id, ...c.rows.map((r) => r.id)])).toEqual(
+ launcherColumns(kind).map((c) => [c.group.id, c.lead.id, ...c.rest.filter((e) => !subParent(e.id)).map((e) => e.id)]),
+ );
+ const marketing = m.columns.find((c) => c.id === "sell")!.lead!;
+ expect(marketing.subs!.map((s) => [s.id, s.href])).toEqual([
+ ["marketing-click-to-ad", "/marketing/click-to-ad"],
+ ["ads", "/ads"],
+ ["ads-multiplier", "/ads/multiplier"],
+ ]);
+ // A studio's features stay out of the phone's "All" (megaItems: leads and rows).
+ expect(megaItems(m).some((e) => e.id === "ads" || e.id.startsWith("genjutsu-"))).toBe(false);
}
});
});
diff --git a/tests/nav-areas.test.ts b/tests/nav-areas.test.ts
index be1ce152..1ddf0af7 100644
--- a/tests/nav-areas.test.ts
+++ b/tests/nav-areas.test.ts
@@ -29,7 +29,7 @@ const { categoryFrom, skippedInAll } = await import("@/lib/gallery-category");
const KINDS = [undefined, "guest", "account", "owner"] as const;
/** Words no visitor reads about the site itself. */
const STATUS = /\b(beta|unverified|not checked|coming soon|demo|placeholder|experimental|wip)\b/i;
-const ids = (id: "create" | "studios", kind?: (typeof KINDS)[number]) => areaSections(id, kind).flatMap((s) => [...s.cards, ...s.chips]);
+const ids = (id: "create" | "studios", kind?: (typeof KINDS)[number]) => areaSections(id, kind).flatMap((s) => [...s.cards, ...s.chips, ...(s.subs ?? []).flatMap((x) => x.ids)]);
describe("what each area lists", () => {
it("names only entries of the navigation model, each once per page, and only what the viewer may see", () => {
@@ -120,16 +120,28 @@ describe("/studios", () => {
for (const kind of KINDS) expect(areaCount("studios", kind)).toBe(studioCount());
});
- it("lists a studio's own tools under it, never a pill that repeats a card", () => {
+ it("lists what each studio holds inside in a row of its own, never a pill that repeats a card or a pill", () => {
const sections = areaSections("studios", "guest");
- const film = sections.find((s) => s.id === "film")!;
- expect(film.chips).toContain("video-tools-captions");
- expect(film.chips).not.toContain("video-tools-matte"); // Video tools' first mode is the studio's own page
- expect(sections.find((s) => s.id === "sell")!.chips).toEqual(expect.arrayContaining(["marketing-click-to-ad", "ads-multiplier"]));
+ const subsOf = (section: string, parent: string) => sections.find((s) => s.id === section)!.subs!.find((x) => x.parent === parent)?.ids ?? [];
+ expect(subsOf("film", "video-tools")).toContain("video-tools-captions");
+ expect(subsOf("film", "video-tools")).not.toContain("video-tools-matte"); // Video tools' first mode is the studio's own page
+ // Ads Studio is a studio with a card or pill of its own here: Marketing Studio's row has the other two.
+ expect(subsOf("sell", "marketing")).toEqual(["marketing-click-to-ad", "ads-multiplier"]);
+ expect(subsOf("people", "genjutsu")).toEqual(["genjutsu-motion", "genjutsu-character", "genjutsu-swap", "genjutsu-restyle", "genjutsu-insert"]);
+ expect(subsOf("people", "character-sheet")).toEqual(["character-sheet-reference", "character-sheet-cast", "character-sheet-describe"]);
+ expect(subsOf("sound", "audio")).not.toContain("audio-music"); // a card of its own
for (const s of sections) {
- const hrefs = new Set(s.cards.map((c) => entry(c)!.href));
- for (const c of s.chips) expect(hrefs.has(entry(c)!.href), `${s.id}: ${c}`).toBe(false);
+ // A tool is a pill of the section only when it is in the bar's menu itself (the Sound column's modes).
+ expect(s.chips.filter((c) => entry(c)!.kind === "tool" && !entry(c)!.group), s.id).toEqual([]);
+ const hrefs = new Set([...s.cards, ...s.chips].map((c) => entry(c)!.href));
+ for (const c of s.chips) expect(s.cards.map((x) => entry(x)!.href), `${s.id}: ${c}`).not.toContain(entry(c)!.href);
+ for (const x of s.subs ?? []) for (const c of x.ids) expect(hrefs.has(entry(c)!.href), `${s.id}: ${c}`).toBe(false);
}
+ // The owner's own (Genjutsu's From picture, Cinema Studio's Blockout) are theirs alone.
+ const owner = areaSections("studios", "owner");
+ expect(owner.find((s) => s.id === "people")!.subs!.find((x) => x.parent === "genjutsu")!.ids).toContain("genjutsu-picture");
+ expect(owner.find((s) => s.id === "film")!.subs!.find((x) => x.parent === "cinema")!.ids).toEqual(["cinema-blockout"]);
+ expect(subsOf("film", "cinema")).toEqual([]);
});
});
diff --git a/tests/nav-bar.test.ts b/tests/nav-bar.test.ts
index bb10e97d..95b1b4c1 100644
--- a/tests/nav-bar.test.ts
+++ b/tests/nav-bar.test.ts
@@ -41,6 +41,7 @@ const { COVER_SIZES, CoverThumb } = await import("@/components/nav/cover-thumb")
const { NavUiProvider } = await import("@/components/nav/nav-ui");
const { navCovers } = await import("@/lib/nav-covers");
const { entriesFor, entry, launcherColumns, NAV_ENTRIES, studioCount } = await import("@/lib/nav-model");
+const { studiosMenu } = await import("@/lib/mega-menus");
const covers = navCovers();
const Nav = NavUiProvider as (p: { covers: typeof covers; children?: ReactNode }) => ReactNode;
@@ -142,25 +143,49 @@ describe("which bar item holds the page", () => {
describe("the launcher's columns", () => {
const html = render(createElement(LauncherColumns, { kind: undefined, now: Date.parse("2026-11-02") }));
- it("shows every studio, Apps and the Sound column, 8/6/6/6/5/3, each column's lead first", () => {
- const links = hrefs(html);
- expect(links).toHaveLength(34);
- expect(new Set(links).size).toBe(34);
+ it("shows every studio, Apps and the Sound column, 8/6/5/6/5/3 (Ads Studio under Marketing Studio), each column's lead first", () => {
+ const main = anchors(html).filter((a) => !a.tag.includes("data-sub"));
+ expect(main).toHaveLength(33);
+ expect(new Set(main.map((a) => a.href)).size).toBe(33);
expect(launcherColumns(undefined).map((c) => 1 + c.rest.length)).toEqual([8, 6, 6, 6, 5, 3]);
+ expect(studiosMenu(undefined).columns.map((c) => 1 + c.rows.length)).toEqual([8, 6, 5, 6, 5, 3]);
expect(launcherColumns(undefined).map((c) => c.lead.id)).toEqual(["cinema", "shorts", "marketing", "fashion-factory", "audio", "upscale"]);
expect(html).toContain("grid-cols-6");
- for (const [i, c] of launcherColumns(undefined).entries()) {
- const at = (href: string) => anchors(html).find((a) => a.href === href)?.tag ?? "";
- expect(at(c.lead.href)).toContain(`data-col="${i}" data-row="0"`);
- c.rest.forEach((e, r) => expect(at(e.href), e.id).toContain(`data-col="${i}" data-row="${r + 1}"`));
+ // The arrow keys' places: the lead, its features, then each row and its features, top to bottom.
+ for (const [i, c] of studiosMenu(undefined).columns.entries()) {
+ const at = (href: string, sub: boolean) => anchors(html).find((a) => a.href === href && a.tag.includes(`data-col="${i}"`) && a.tag.includes("data-sub") === sub)?.tag ?? "";
+ let r = 0;
+ for (const e of [c.lead!, ...c.rows]) {
+ expect(at(e.href, false), e.id).toContain(`data-col="${i}" data-row="${r++}"`);
+ for (const s of e.subs ?? []) expect(at(s.href, true), s.id).toContain(`data-col="${i}" data-row="${r++}"`);
+ }
}
expect(studioCount()).toBe(29);
});
+ it("lists what a studio holds inside under it, by the names of its own tabs", () => {
+ const subs = (id: string) =>
+ studiosMenu(undefined)
+ .columns.flatMap((c) => [c.lead!, ...c.rows])
+ .find((e) => e.id === id)
+ ?.subs?.map((s) => s.label);
+ expect(subs("marketing")).toEqual(["Click to Ad", "Ads Studio", "Ad Multiplier"]);
+ expect(subs("genjutsu")).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]);
+ expect(subs("upscale")).toEqual(["Image", "Video", "FPS Boost", "SDR to HDR", "Export"]);
+ expect(subs("audio")).toEqual(["Dialogue", "Voice change", "Design a voice", "See all 13"]);
+ expect(subs("video-tools")).toEqual(["Relight", "Captions", "Remove object", "See all 10"]);
+ for (const w of ["Click to Ad", "Ads Studio", "Ad Multiplier", "Motion transfer", "FPS Boost"]) expect(words(html)).toContain(w);
+ // Under a hairline, quieter than a row, with no picture and no line of their own.
+ const sub = anchors(html).find((a) => a.tag.includes("data-sub"))!.tag;
+ expect(sub).toContain("text-[12.5px]");
+ expect(sub).toContain("min-h-7");
+ expect(sub).toContain("[@media(pointer:coarse)]:min-h-11");
+ });
+
it("labels the groups, and every link has its studio's real cover in a box of fixed size", () => {
for (const label of ["Film &amp; video", "Social &amp; shorts", "Sell &amp; advertise", "People &amp; fashion", ">Sound<", "Finish &amp; convert"]) expect(html).toContain(label);
for (const c of launcherColumns(undefined)) {
- for (const e of [c.lead, ...c.rest]) {
+ for (const e of [c.lead, ...c.rest].filter((x) => x.id !== "ads")) {
const cover = covers[e.cover!];
expect(cover, e.id).toBeDefined();
// The lead card shows the 320 px copy (and the poster by its srcset); a row the 96 px one.
@@ -169,9 +194,9 @@ describe("the launcher's columns", () => {
// The lead's 4:3 card picks the poster on sharp screens.
expect(html).toContain(`${covers[c.lead.cover!].poster} 512w`);
}
- // The six lead cards load as the panel warms; a row's picture when the row shows (lazy).
+ // The six lead cards load as the panel warms; a row's picture when the row shows (lazy). A studio's features have none.
expect(count(html, 'loading="eager"')).toBe(6);
- expect(count(html, 'alt=""')).toBe(34);
+ expect(count(html, 'alt=""')).toBe(33);
});
it("marks the open page's studio, and nothing else", () => {
diff --git a/tests/nav-subfeatures.test.ts b/tests/nav-subfeatures.test.ts
new file mode 100644
index 00000000..f56a4cd0
--- /dev/null
+++ b/tests/nav-subfeatures.test.ts
@@ -0,0 +1,217 @@
+import fs from "node:fs";
+import path from "node:path";
+import { describe, expect, it } from "vitest";
+import { MODEL3D_MODES } from "@/lib/av/model3d";
+import { GENJUTSU_MODES } from "@/lib/catalog/genjutsu";
+import { HUB_MODES, type HubKind } from "@/lib/hubs";
+import { megaSubs, studiosMenu } from "@/lib/mega-menus";
+import { megaCurrent } from "@/components/nav/mega-launcher";
+import { areaSections } from "@/lib/nav-areas";
+import {
+ entriesFor,
+ entry,
+ launcherEntries,
+ NAV_ENTRIES,
+ OWNER_RUNS,
+ STUDIO_SUBS,
+ studioSubs,
+ subActive,
+ subLabel,
+ subParent,
+ visibleTo,
+ type ViewerKind,
+} from "@/lib/nav-model";
+import { navSearchEntries, searchNav } from "@/lib/nav-search";
+
+/*
+ * What each studio holds inside (its tabs and modes) in the top nav: the catalogue (STUDIO_SUBS) and the links the
+ * Studios menu, the phone's Studios sheet, /studios and search make of it. Every link opens a real page on the right
+ * tab, by the studio's own name for it, and what is the owner's stays the owner's.
+ */
+
+const root = path.join(__dirname, "..");
+const read = (file: string) => fs.readFileSync(path.join(root, file), "utf8");
+const KINDS = [undefined, "guest", "account", "owner"] as const;
+const VISITORS = [undefined, "guest", "account"] as const;
+const subs = () => Object.entries(STUDIO_SUBS).flatMap(([parent, s]) => s.ids.map((id) => ({ parent, id, e: entry(id)! })));
+
+/** The page file a path is served by (a folder of its own, else a dynamic [segment] folder beside it). */
+function pageFile(pathname: string): string | undefined {
+ const parts = pathname.split("/").filter(Boolean);
+ let dir = path.join(root, "src/app/(studio)");
+ for (const p of parts) {
+ const own = path.join(dir, p);
+ if (fs.existsSync(own)) {
+ dir = own;
+ continue;
+ }
+ const dynamic = fs.readdirSync(dir).find((d) => /^\[[^.]+\]$/.test(d));
+ if (!dynamic) return undefined;
+ dir = path.join(dir, dynamic);
+ }
+ const file = path.join(dir, "page.tsx");
+ return fs.existsSync(file) ? file : undefined;
+}
+
+describe("the catalogue of studio features", () => {
+ it("names only entries of the navigation model, each under one studio, a tool of it (Ads Studio is a studio of Marketing's suite)", () => {
+ const seen = new Set<string>();
+ for (const { parent, id, e } of subs()) {
+ expect(e, id).toBeDefined();
+ expect(entry(parent), parent).toBeDefined();
+ expect(seen.has(id), id).toBe(false);
+ seen.add(id);
+ if (id === "ads") expect(e.kind).toBe("studio");
+ else expect([e.kind, e.parent], id).toEqual(["tool", parent]);
+ }
+ expect(subParent("ads")).toBe("marketing");
+ expect(entry("ads-multiplier")!.parent).toBe("marketing");
+ });
+
+ it("links every feature to a page that exists", () => {
+ for (const { id, e } of subs()) {
+ const [pathname] = e.href.split("?");
+ expect(pageFile(pathname), `${id}: ${e.href}`).toBeDefined();
+ }
+ // A hub mode's [mode] page knows the mode.
+ for (const { e } of subs().filter((s) => s.parent in HUB_MODES)) {
+ const [, hub, mode] = e.href.split("/");
+ if (mode) expect(HUB_MODES[hub as HubKind].some((m) => m.id === mode), e.href).toBe(true);
+ }
+ });
+
+ it("opens the right tab: every ?mode= and ?tab= is one the studio's page reads", () => {
+ const query = (id: string) => new URLSearchParams(entry(id)!.href.split("?")[1] ?? "");
+ for (const id of STUDIO_SUBS.genjutsu.ids) expect(GENJUTSU_MODES.map((m) => m.id), id).toContain(query(id).get("mode"));
+ expect(read("src/components/genjutsu/genjutsu-studio.tsx")).toMatch(/fresh\("mode"\)/);
+ for (const id of STUDIO_SUBS["image-to-3d"].ids) expect(MODEL3D_MODES.map((m) => m.id), id).toContain(query(id).get("mode"));
+ expect(read("src/components/model3d/model3d-studio.tsx")).toMatch(/params\.get\("mode"\)/);
+ const sheet = read("src/components/fashion/character-sheet.tsx");
+ expect(sheet).toContain('<TabFromLink param="mode" ids={MODE_IDS}');
+ for (const id of STUDIO_SUBS["character-sheet"].ids) expect(sheet, id).toContain(`["${query(id).get("mode")}", "${entry(id)!.label}"]`);
+ const dump = read("src/components/photodump/photodump-view.tsx");
+ expect(dump).toContain('<TabFromLink param="tab" ids={TAB_IDS}');
+ expect(dump).toContain(`["${query("photodump-instadump").get("tab")}", "From a selfie"]`);
+ expect(read("src/components/canvas/canvas-list.tsx")).toContain('params.get("tab") === "skills"');
+ expect(read("src/components/cinema/projects-view.tsx")).toContain('useSearchParams().get("blockout") === "1"');
+ });
+
+ it("calls every feature by its studio's own name for it", () => {
+ for (const m of GENJUTSU_MODES) expect(entry(`genjutsu-${m.id}`)?.label, m.id).toBe(m.label);
+ for (const m of MODEL3D_MODES) expect(entry(`image-to-3d-${m.id}`)?.label, m.id).toBe(m.label);
+ for (const hub of Object.keys(HUB_MODES) as HubKind[]) for (const m of HUB_MODES[hub]) expect(subLabel(entry(`${hub}-${m.id}`)!), m.id).toBe(m.label);
+ const suite = read("src/components/marketing/shell.tsx");
+ for (const id of STUDIO_SUBS.marketing.ids) expect(suite, id).toContain(`href: "${entry(id)!.href}", label: "${entry(id)!.label}"`);
+ const rail = read("src/components/assist/shell.tsx");
+ for (const id of STUDIO_SUBS.assist.ids) expect(rail, id).toContain(`href="${entry(id)!.href}" icon={`);
+ for (const id of STUDIO_SUBS.assist.ids) expect(rail, id).toContain(`label="${entry(id)!.label}"`);
+ expect(read("src/components/canvas/canvas-list.tsx")).toContain(entry("canvas-skills")!.label);
+ expect(read("src/components/cinema/blockout-panel.tsx")).toContain(`>${entry("cinema-blockout")!.label}<`);
+ });
+});
+
+describe("who sees a studio's features", () => {
+ it("keeps the owner's own modes the owner's, in every place", () => {
+ for (const id of ["genjutsu-picture", "genjutsu-finish", "cinema-blockout", "canvas-skills", "assist-memory", "assist-scheduled", "audio-song", "video-tools-restore"]) {
+ expect(entry(id)!.visibility, id).toEqual(["owner"]);
+ for (const kind of VISITORS) expect(entriesFor(kind).some((e) => e.id === id), `${kind}: ${id}`).toBe(false);
+ }
+ for (const kind of VISITORS) {
+ for (const parent of Object.keys(STUDIO_SUBS)) {
+ for (const place of ["list", "sheet", "menu"] as const) for (const e of studioSubs(parent, kind, place)) expect(visibleTo(e, kind), `${kind} ${place}: ${e.id}`).toBe(true);
+ }
+ const menu = studiosMenu(kind).columns.flatMap((c) => [c.lead!, ...c.rows]).flatMap((e) => e.subs ?? []);
+ for (const s of menu.filter((x) => !x.more)) expect(entry(s.id)!.visibility ?? [], `${kind}: ${s.id}`).not.toEqual(["owner"]);
+ const hub = areaSections("studios", kind).flatMap((s) => (s.subs ?? []).flatMap((x) => x.ids));
+ for (const id of hub) expect(visibleTo(entry(id)!, kind), `${kind}: ${id}`).toBe(true);
+ }
+ });
+
+ it("links a feature a visitor may open but not run here (its page says so) in the menus and sheets for the owner only", () => {
+ for (const id of OWNER_RUNS) {
+ for (const kind of VISITORS) {
+ const parent = subParent(id)!;
+ expect(studioSubs(parent, kind, "sheet").some((e) => e.id === id), `${kind}: ${id}`).toBe(false);
+ expect(studioSubs(parent, kind, "menu").some((e) => e.id === id), `${kind}: ${id}`).toBe(false);
+ }
+ }
+ expect(studioSubs("audio", "owner", "sheet").map((e) => e.id)).toContain("audio-split");
+ expect(studioSubs("image-to-3d", "owner", "menu").length).toBe(3);
+ expect(studioSubs("image-to-3d", "guest", "menu")).toEqual([]);
+ // Search still finds them, as before.
+ expect(entriesFor("guest").some((e) => e.id === "audio-split")).toBe(true);
+ });
+
+ it("lists in the menu only as many as its column has room for, then See all to the studio's page", () => {
+ for (const kind of KINDS) {
+ for (const e of launcherEntries(kind)) {
+ const spec = STUDIO_SUBS[e.id];
+ const list = megaSubs(e, kind);
+ if (!spec || spec.menu === 0) {
+ expect(list, e.id).toEqual([]);
+ continue;
+ }
+ const more = list.filter((s) => s.more);
+ expect(more.length, e.id).toBeLessThanOrEqual(1);
+ if (more.length) {
+ expect(list.at(-1)!.more, e.id).toBe(true);
+ expect(more[0].href, e.id).toBe(e.href);
+ expect(more[0].label, e.id).toMatch(/^See all \d+$/);
+ // The studio's own page is "See all", not one of the links before it.
+ expect(list.slice(0, -1).some((s) => s.href === e.href), e.id).toBe(false);
+ }
+ if (spec.menu !== undefined) expect(list.filter((s) => !s.more).length, e.id).toBeLessThanOrEqual(spec.menu);
+ }
+ }
+ });
+});
+
+describe("finding a studio's features", () => {
+ const find = (kind: ViewerKind | undefined, q: string) => searchNav(q, navSearchEntries(entriesFor(kind)));
+
+ it("finds each by name, shown under its studio", () => {
+ const top = (q: string) => find("guest", q).best[0];
+ expect(top("restyle")).toMatchObject({ id: "genjutsu-restyle", hint: "Genjutsu" });
+ expect(top("click to ad")).toMatchObject({ id: "marketing-click-to-ad", hint: "Marketing Studio" });
+ expect(top("ad multiplier")).toMatchObject({ id: "ads-multiplier", hint: "Marketing Studio" });
+ expect(top("from a selfie")).toMatchObject({ id: "photodump-instadump", hint: "Photodump" });
+ expect(top("build from scratch")).toMatchObject({ id: "character-sheet-cast", hint: "Character Sheet" });
+ expect(top("motion transfer")).toMatchObject({ id: "genjutsu-motion", href: "/genjutsu?mode=motion" });
+ });
+
+ it("finds the owner's own only for the owner", () => {
+ const hits = (kind: ViewerKind | undefined, q: string) => {
+ const r = find(kind, q);
+ return [...r.best, ...r.groups.flatMap((g) => g.hits)].map((h) => h.id);
+ };
+ expect(hits("owner", "blockout")).toContain("cinema-blockout");
+ expect(hits("owner", "skills as canvases")).toContain("canvas-skills");
+ expect(hits("owner", "scheduled")).toContain("assist-scheduled");
+ for (const kind of VISITORS) {
+ expect(hits(kind, "blockout"), String(kind)).not.toContain("cinema-blockout");
+ expect(hits(kind, "skills as canvases"), String(kind)).not.toContain("canvas-skills");
+ expect(hits(kind, "assist memory"), String(kind)).not.toContain("assist-memory");
+ }
+ });
+});
+
+describe("the open feature", () => {
+ it("is the feature whose link the page's path and query match, and its studio where they are one page", () => {
+ expect(subActive("/genjutsu", "mode=restyle")).toBe("genjutsu-restyle");
+ expect(subActive("/genjutsu", "mode=restyle&video=x")).toBe("genjutsu-restyle");
+ expect(subActive("/genjutsu", "")).toBeUndefined();
+ expect(subActive("/ads/multiplier")).toBe("ads-multiplier");
+ expect(subActive("/ads")).toBe("ads");
+ expect(subActive("/audio/dialogue")).toBe("audio-dialogue");
+ expect(subActive("/upscale")).toBeUndefined(); // Upscale's Image tab is Upscale's own page
+ expect(megaCurrent("studios", "/upscale")).toBe("upscale");
+ expect(megaCurrent("studios", "/marketing/click-to-ad")).toBe("marketing-click-to-ad");
+ expect(megaCurrent("studios", "/genjutsu", "mode=insert")).toBe("genjutsu-insert");
+ expect(megaCurrent("studios", "/genjutsu")).toBe("genjutsu");
+ });
+
+ it("names every feature once in the whole model", () => {
+ const ids = NAV_ENTRIES.map((e) => e.id);
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+});
diff --git a/tests/phone-nav.test.ts b/tests/phone-nav.test.ts
index dbc1493c..bdac06d0 100644
--- a/tests/phone-nav.test.ts
+++ b/tests/phone-nav.test.ts
@@ -22,7 +22,10 @@ import { PhoneTabs } from "@/components/nav/phone-tabs";
import { StudiosSheet } from "@/components/nav/studios-sheet";
import { PhoneBar } from "@/components/phone-bar";
import { navCovers } from "@/lib/nav-covers";
-import { activeEntry, LAUNCHER_GROUPS, launcherEntries, studioCount } from "@/lib/nav-model";
+import { activeEntry, LAUNCHER_GROUPS, launcherEntries as allLauncherEntries, studioCount, subParent, type LauncherGroupId, type ViewerKind } from "@/lib/nav-model";
+
+/** The studios as tiles: every launcher entry but one that is a tab of another's suite (Ads Studio, under Marketing Studio). */
+const launcherEntries = (kind: ViewerKind | undefined, group?: LauncherGroupId) => allLauncherEntries(kind, group).filter((e) => !subParent(e.id));
/*
* The phone's navigation (below md): the tab bar (Home, Create, Studios, Library, You), the Studios sheet with every
@@ -186,13 +189,20 @@ describe("the tab bar", () => {
describe("the Studios sheet", () => {
const sheet = (props: { group?: (typeof LAUNCHER_GROUPS)[number]["id"] } = {}) => createElement(StudiosSheet, { ...props, onSearch: () => {} });
- // The grid ends on a See all tile (/studios): the family's whole set.
- const tiles = (html: string) => hrefs(html).filter((h) => h !== "/" && h !== "/library" && h !== "/studios");
-
- it("shows every studio, Apps and the Sound modes (34 tiles, 29 studios), in launcher order, each with a real cover", () => {
+ // The grid ends on a See all tile (/studios): the family's whole set. A studio's features are pills under it.
+ const tiles = (html: string) =>
+ [...html.matchAll(/<a [^>]*href="([^"]*)"[^>]*>/g)]
+ .filter((m) => !m[0].includes("tab-pill"))
+ .map((m) => m[1].replaceAll("&amp;", "&"))
+ .filter((h) => h !== "/" && h !== "/library" && h !== "/studios");
+ const pills = (html: string) => [...html.matchAll(/<a [^>]*class="tab-pill[^>]*>([^<]*)</g)].map((m) => m[1]);
+
+ it("shows every studio, Apps and the Sound modes (33 tiles, 29 studios), in launcher order, each with a real cover", () => {
const html = at("/", () => sheet());
const all = launcherEntries(undefined);
- expect(all).toHaveLength(34);
+ expect(all).toHaveLength(33);
+ // All is one screen of tiles: a studio's features show under one group only.
+ expect(pills(html)).toEqual([]);
expect(studioCount()).toBe(29);
expect(tiles(html)).toEqual(all.map((e) => e.href));
for (const e of all) {
@@ -227,7 +237,7 @@ describe("the Studios sheet", () => {
});
it("starts on the group it was opened for", () => {
- const sizes = { film: 8, social: 6, sell: 6, people: 6, sound: 5, finish: 3 } as const;
+ const sizes = { film: 8, social: 6, sell: 5, people: 6, sound: 5, finish: 3 } as const;
for (const g of LAUNCHER_GROUPS) {
const html = at("/", () => sheet({ group: g.id }));
expect(tiles(html), g.id).toEqual(launcherEntries(undefined, g.id).map((e) => e.href));
@@ -236,6 +246,29 @@ describe("the Studios sheet", () => {
}
});
+ it("lists what a group's studios hold inside as pills under the tiles, by their tabs' names, as a visitor may run them", () => {
+ const sell = at("/", () => sheet({ group: "sell" }));
+ expect(pills(sell)).toEqual(["Click to Ad", "Ads Studio", "Ad Multiplier"]);
+ expect(words(sell)).toContain("Marketing Studio");
+ const people = at("/", () => sheet({ group: "people" }));
+ expect(pills(people)).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert"]);
+ // Pages that say "isn't available here" to a visitor, and the owner's own modes, aren't linked for them.
+ for (const w of ["From a selfie", "From Reference", "From picture", "Split soundtrack", "Remove dialogue", "From an image", "Blockout"]) {
+ for (const g of LAUNCHER_GROUPS) expect(pills(at("/", () => sheet({ group: g.id }))), `${g.id}: ${w}`).not.toContain(w);
+ }
+ const finish = at("/", () => sheet({ group: "finish" }));
+ expect(pills(finish)).toEqual(["Image", "Video", "FPS Boost", "SDR to HDR", "Export"]);
+ // Each pill links its feature (a route, or its studio with ?mode= / ?tab=).
+ expect(hrefs(sell)).toEqual(expect.arrayContaining(["/marketing/click-to-ad", "/ads", "/ads/multiplier"]));
+ expect(hrefs(people)).toEqual(expect.arrayContaining(["/genjutsu?mode=motion", "/genjutsu?mode=insert"]));
+ });
+
+ it("marks a studio's feature you are on, and its studio's tile", () => {
+ const html = at("/ads/multiplier", () => sheet({ group: "sell" }));
+ expect(tagWith(html, 'href="/ads/multiplier"')).toContain('aria-current="page"');
+ expect(tagWith(html, 'href="/marketing"')).toContain('aria-current="page"');
+ });
+
it("marks the studio you are in", () => {
const html = at("/cinema/abc", () => sheet());
expect(tagWith(html, 'href="/cinema"')).toContain('aria-current="page"');