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.

Library, keys, Kinetic and ads: controls that look active act or say why

Adarsh6711e68baea8
diff --git a/src/components/ads/ad-editor.tsx b/src/components/ads/ad-editor.tsx
index 313ae21c..9346d268 100644
--- a/src/components/ads/ad-editor.tsx
+++ b/src/components/ads/ad-editor.tsx
@@ -155,7 +155,12 @@ export function AdEditor({
</div>
{brand?.logo && (
<label className="flex items-center justify-between gap-2 text-[13px]">
- Show logo <Switch checked={logo} onCheckedChange={setLogo} aria-label="Show logo" />
+ {/* Only this dialog's downloads read it: the grid's downloads always draw the brand's logo. */}
+ <span>
+ Show logo
+ <span className="block text-[11px] text-muted-foreground">In the downloads made here</span>
+ </span>
+ <Switch checked={logo} onCheckedChange={setLogo} aria-label="Show logo in the downloads made here" />
</label>
)}
{changed && (
diff --git a/src/components/keys/use-key-info.ts b/src/components/keys/use-key-info.ts
index fd2bb611..c6607754 100644
--- a/src/components/keys/use-key-info.ts
+++ b/src/components/keys/use-key-info.ts
@@ -2,6 +2,7 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useEffect, useState } from "react";
+import { toast } from "sonner";
import { KEY_INFO_REFRESH_GAP_MS, KEY_INFO_URL, type KeyInfoAnswer } from "@/lib/key-info";
/*
@@ -57,7 +58,8 @@ export function useRefreshKeyInfo(detail = false) {
if (detail) qc.setQueryData(keyInfoKey(false), data);
else void qc.invalidateQueries({ queryKey: keyInfoKey(true), exact: true });
} catch {
- // What was shown stays: the next look asks again.
+ // What was shown stays (the next look asks again), and the press is answered: the figures on show are the earlier ones.
+ toast.error("Couldn't refresh the balance just now. The figures shown are from the last check: try again in a moment.");
} finally {
setBusy(false);
}
diff --git a/src/components/kinetic/editor.tsx b/src/components/kinetic/editor.tsx
index ac3376e1..dc3949a7 100644
--- a/src/components/kinetic/editor.tsx
+++ b/src/components/kinetic/editor.tsx
@@ -368,7 +368,19 @@ export function Editor({ editor, doc, entry, onBack, onScene, missing }: { edito
</>
)}
- <ExportSheet open={sheet === "export"} onClose={() => setSheet(null)} side={side} doc={doc} entry={entry} editor={editor} jobs={jobs} blocked={blocked} mp4={mp4} onSave={(k) => void save(k)} />
+ <ExportSheet
+ open={sheet === "export"}
+ onClose={() => setSheet(null)}
+ side={side}
+ doc={doc}
+ entry={entry}
+ editor={editor}
+ jobs={jobs}
+ blocked={blocked ?? (!plan && scene && inputs.ready ? "This scene can't be drawn with these settings: undo the last change, then save." : null)}
+ waiting={plan ? null : "Getting the scene ready…"}
+ mp4={mp4}
+ onSave={(k) => void save(k)}
+ />
<VersionsSheet open={sheet === "versions"} onClose={() => setSheet(null)} side={side} jobs={jobs} onSaveVersion={() => save("version")} onRestore={restore} dirty={key !== versionKey} />
<GroupSheet open={!!group && (!desk || large)} onClose={() => setGroup(null)} groupId={group} doc={doc} editor={editor} side={side} planWith={planWith} />
</div>
diff --git a/src/components/kinetic/export-sheet.tsx b/src/components/kinetic/export-sheet.tsx
index 8b529833..96c4d563 100644
--- a/src/components/kinetic/export-sheet.tsx
+++ b/src/components/kinetic/export-sheet.tsx
@@ -70,6 +70,7 @@ export function ExportSheet({
editor,
jobs,
blocked,
+ waiting,
mp4,
onSave,
}: {
@@ -82,6 +83,8 @@ export function ExportSheet({
jobs: KineticJobs;
/** Why nothing can save yet (words that don't fit, MP4 that can't be made here), or null. */
blocked: string | null;
+ /** Why saving waits a moment (the scene is still getting ready), or null: the buttons wait and say so. */
+ waiting?: string | null;
/** Whether this browser makes an MP4 at this size (null while it checks). */
mp4: boolean | null;
onSave: (kind: JobKind) => void;
@@ -100,7 +103,7 @@ export function ExportSheet({
<button
type="button"
onClick={() => onSave(kind)}
- disabled={!!blocked || (kind === "clip" && r.export.format === "mp4" && mp4 === false && !jobs.guest) || (!!jobs.job && !mine)}
+ disabled={!!blocked || !!waiting || (kind === "clip" && r.export.format === "mp4" && mp4 === false && !jobs.guest) || (!!jobs.job && !mine)}
data-kinetic-save={kind}
className={cn("flex h-12 w-full min-w-0 items-center gap-2 rounded-xl px-4 text-[14px] font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", kind === "clip" ? "bg-primary text-primary-foreground hover:opacity-90" : "bg-secondary hover:bg-accent")}
>
@@ -176,7 +179,7 @@ export function ExportSheet({
</p>
</div>
<div className="sticky bottom-0 min-w-0 space-y-2 border-t bg-popover px-4 pt-3">
- {blocked && <p className="text-[12px] text-destructive">{blocked}</p>}
+ {blocked ? <p className="text-[12px] text-destructive">{blocked}</p> : waiting && <p className="text-[12px] text-muted-foreground">{waiting}</p>}
{out("clip", "Save clip", Clapperboard)}
<div className="grid grid-cols-1 gap-2 min-[420px]:grid-cols-2">
{out("frame", "Save frame", ImageIcon)}
diff --git a/src/components/library-view.tsx b/src/components/library-view.tsx
index 930aab00..6e77254e 100644
--- a/src/components/library-view.tsx
+++ b/src/components/library-view.tsx
@@ -44,7 +44,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import { BULK_MAX, signInHref, useCreateGeneration, useFolders, useGenerationActions, useIsAccount, useIsGuest, useIsOwner, useIsVisitor, useLibrary, useLibraryFacets, useShares, useStatus, useUploads, type Asset, type FeedFilter } from "@/lib/api";
import type { Generation, MediaKind, ReviewStatus } from "@/lib/catalog/types";
import { keyCombo, useModKey } from "@/lib/keys";
-import { buildEntries, folderAndDescendants, reviewInfo, splitByDate, toggleAll, TRASH_DAYS, type LibraryEntry } from "@/lib/library";
+import { buildEntries, folderAndDescendants, reviewInfo, splitByDate, stacksOffReason, toggleAll, TRASH_DAYS, type LibraryEntry } from "@/lib/library";
import { isLayered, shownOutputs } from "@/lib/output-actions";
import { isExpired } from "@/lib/share";
import { StarterSection, useStarters } from "@/components/starters/starter-section";
@@ -642,7 +642,7 @@ function Inner({ starters: given }: { starters: StarterCardData[] }) {
<CheckSquare className="size-3.5" /> <span className="hidden sm:inline">{selecting ? "Done" : "Select"}</span>
</button>
)}
- <ViewOptions prefs={prefs} onChange={setPrefs} />
+ <ViewOptions prefs={prefs} onChange={setPrefs} noStacks={stacksOffReason(tab.id)} />
</div>
</div>
diff --git a/src/components/library/asset-card.tsx b/src/components/library/asset-card.tsx
index 38999ea4..4a2ea27f 100644
--- a/src/components/library/asset-card.tsx
+++ b/src/components/library/asset-card.tsx
@@ -7,7 +7,7 @@ import { TileActions, useCanHover, type RunnerOptions } from "@/components/studi
import { LayersStack, MediaThumb, SmallThumb } from "@/components/studio/result-media";
import { OPERATION_LABELS, type Generation } from "@/lib/catalog/types";
import { elapsed, timeAgo } from "@/lib/format";
-import { coverOf, trashDaysLeft, userTitle, type LibraryEntry } from "@/lib/library";
+import { cardStateWords, coverOf, trashDaysLeft, userTitle, type LibraryEntry } from "@/lib/library";
import { isLayered, shownOutputs } from "@/lib/output-actions";
import { cn } from "@/lib/utils";
import { PlaceholderChip } from "@/components/demo-mode";
@@ -150,6 +150,8 @@ export const AssetCard = memo(function AssetCard({
const done = g.status === "succeeded" && g.outputs.length > 0;
const ratio = cardRatio(entry, layout);
+ // A run that is still going, failed or was stopped has nothing to open yet: its card shows why, with no pointer or hover.
+ const acts = selecting || !!stack || done;
const activate = (shift: boolean) => {
if (selecting) api.toggle(entry.key, ids, shift);
else if (stack) api.expand(entry.key);
@@ -160,7 +162,7 @@ export const AssetCard = memo(function AssetCard({
const target = (
<button
type="button"
- aria-label={stack ? `${title} — ${stack.label}` : selecting ? `Select “${title}”` : done ? `Open “${title}”` : title}
+ aria-label={stack ? `${title} — ${stack.label}` : selecting ? `Select “${title}”` : done ? `Open “${title}”` : `${title} — ${cardStateWords(g.status)}`}
aria-pressed={selecting ? selected : undefined}
aria-expanded={stack && !selecting ? !!expanded : undefined}
onClick={(e) => {
@@ -252,7 +254,7 @@ export const AssetCard = memo(function AssetCard({
return (
<div
{...common}
- className={cn("group/card relative flex min-h-16 cursor-pointer items-center gap-3 rounded-xl px-2 py-2 hover:bg-accent", selected && "bg-brand-faint hover:bg-brand-faint-hover")}
+ className={cn("group/card relative flex min-h-16 items-center gap-3 rounded-xl px-2 py-2", acts && "cursor-pointer hover:bg-accent", selected && "bg-brand-faint hover:bg-brand-faint-hover")}
>
{target}
<div className="relative size-14 shrink-0 overflow-hidden rounded-lg bg-muted">
@@ -321,7 +323,8 @@ export const AssetCard = memo(function AssetCard({
<div
{...common}
className={cn(
- "@container relative w-full cursor-pointer overflow-hidden rounded-xl bg-muted transition-[box-shadow]",
+ "@container relative w-full overflow-hidden rounded-xl bg-muted transition-[box-shadow]",
+ acts && "cursor-pointer",
!selecting && done && !stack && "cursor-zoom-in",
selected && "ring-3 ring-primary",
expanded && "ring-2 ring-border-strong",
diff --git a/src/components/library/view-options.tsx b/src/components/library/view-options.tsx
index 1ec458dc..96eb8704 100644
--- a/src/components/library/view-options.tsx
+++ b/src/components/library/view-options.tsx
@@ -82,7 +82,16 @@ function Segmented<T extends string>({ value, options, onChange, label }: { valu
);
}
-export function ViewOptions({ prefs, onChange }: { prefs: ViewPrefs; onChange: (patch: Partial<ViewPrefs>) => void }) {
+export function ViewOptions({
+ prefs,
+ onChange,
+ noStacks,
+}: {
+ prefs: ViewPrefs;
+ onChange: (patch: Partial<ViewPrefs>) => void;
+ /** Why batches aren't stacked on this tab (Trash, Uploads): the switch says so, and is off, instead of flipping for nothing. */
+ noStacks?: string;
+}) {
return (
<Popover>
<PopoverTrigger asChild>
@@ -129,12 +138,12 @@ export function ViewOptions({ prefs, onChange }: { prefs: ViewPrefs; onChange: (
Split by date
<Switch checked={prefs.splitByDate} onCheckedChange={(splitByDate) => onChange({ splitByDate })} />
</label>
- <label className="flex items-center justify-between gap-3 text-[13px]">
- <span>
+ <label className={cn("flex items-center justify-between gap-3 text-[13px]", noStacks && "cursor-not-allowed")}>
+ <span className={cn(noStacks && "text-muted-foreground")}>
Stack batches
- <span className="block text-[12px] text-muted-foreground">Storyboards, films and takes as one card</span>
+ <span className="block text-[12px] text-muted-foreground">{noStacks ?? "Storyboards, films and takes as one card"}</span>
</span>
- <Switch checked={prefs.stacks} onCheckedChange={(stacks) => onChange({ stacks })} />
+ <Switch checked={!noStacks && prefs.stacks} disabled={!!noStacks} onCheckedChange={(stacks) => onChange({ stacks })} />
</label>
</PopoverContent>
</Popover>
diff --git a/src/components/nav/create-menu.tsx b/src/components/nav/create-menu.tsx
index 8ff6db8d..79c8a51d 100644
--- a/src/components/nav/create-menu.tsx
+++ b/src/components/nav/create-menu.tsx
@@ -4,7 +4,6 @@ import { Plus } from "lucide-react";
import { usePathname } from "next/navigation";
import { useId } from "react";
import { IntentLink } from "@/components/intent-link";
-import { Kbd } from "@/components/ui/kbd";
import { navActive, NEW_CREATION_HREF } from "@/lib/nav";
import { area } from "@/lib/nav-areas";
import { CREATE_COLUMNS, entry, visibleTo, type NavEntry, type ViewerKind } from "@/lib/nav-model";
@@ -90,9 +89,6 @@ export function CreateList({ variant, onNavigate }: { variant: "menu" | "sheet";
<IntentLink href={NEW_CREATION_HREF} eager data-col={0} data-row={columns[0]?.entries.length ?? 0} className={cn(CARD_ROW, MENU_ROW_1, "font-medium")}>
<Plus aria-hidden className="size-4 text-brand-text" />
New creation
- <Kbd aria-hidden className="ml-auto [@media(hover:none)]:hidden">
- ↵
- </Kbd>
</IntentLink>
</>
);
diff --git a/src/lib/library.ts b/src/lib/library.ts
index f784d388..021fefcc 100644
--- a/src/lib/library.ts
+++ b/src/lib/library.ts
@@ -504,3 +504,16 @@ export function toggleAll(selected: ReadonlySet<string>, ids: readonly string[])
}
return next;
}
+
+/**
+ * What a card without anything to open is, in words (the card's label for screen readers): a run still going, failed or
+ * stopped shows its state on the card, and has no pointer or hover that would promise an action.
+ */
+export function cardStateWords(status: Generation["status"]): string {
+ return status === "queued" ? "queued" : status === "running" ? "still generating" : status === "failed" ? "failed" : status === "canceled" ? "stopped" : "nothing to open";
+}
+
+/** Why the "Stack batches" view setting doesn't apply on a Library tab (Trash, Uploads), or undefined where it does. */
+export function stacksOffReason(tab: string): string | undefined {
+ return tab === "trash" ? "Trash lists every run on its own" : tab === "uploads" ? "Uploads lists every file on its own" : undefined;
+}
diff --git a/tests/inert-controls.test.ts b/tests/inert-controls.test.ts
new file mode 100644
index 00000000..69111d1d
--- /dev/null
+++ b/tests/inert-controls.test.ts
@@ -0,0 +1,48 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+import { cardStateWords, stacksOffReason } from "@/lib/library";
+
+/**
+ * Controls that look like they act must act, or say why they can't: a Library card with nothing to open, a view setting
+ * a tab doesn't use, a Refresh that failed, a key cap no key is bound to.
+ */
+const src = (p: string) => readFileSync(p, "utf8").replace(/\r\n/g, "\n");
+
+describe("Library cards and view settings", () => {
+ it("names the state of a card that has nothing to open", () => {
+ expect(cardStateWords("queued")).toBe("queued");
+ expect(cardStateWords("running")).toBe("still generating");
+ expect(cardStateWords("failed")).toBe("failed");
+ expect(cardStateWords("canceled")).toBe("stopped");
+ });
+
+ it("gives no pointer or hover to a card that can't open, select or expand", () => {
+ const card = src("src/components/library/asset-card.tsx");
+ expect(card).toContain("const acts = selecting || !!stack || done;");
+ expect(card).toContain('acts && "cursor-pointer hover:bg-accent"');
+ expect(card).not.toMatch(/"group\/card relative flex min-h-16 cursor-pointer/);
+ });
+
+ it("says why Stack batches doesn't apply in Trash and Uploads", () => {
+ expect(stacksOffReason("trash")).toMatch(/Trash/);
+ expect(stacksOffReason("uploads")).toMatch(/Uploads/);
+ expect(stacksOffReason("all")).toBeUndefined();
+ expect(src("src/components/library-view.tsx")).toContain("noStacks={stacksOffReason(tab.id)}");
+ });
+});
+
+describe("buttons that answer every press", () => {
+ it("a failed balance Refresh says so", () => {
+ expect(src("src/components/keys/use-key-info.ts")).toMatch(/catch \{[^}]*toast\.error\("Couldn't refresh the balance/);
+ });
+
+ it("New creation shows no Enter key cap that nothing is bound to", () => {
+ expect(src("src/components/nav/create-menu.tsx")).not.toContain("↵");
+ });
+
+ it("the Kinetic export buttons wait, with words, while the scene isn't ready", () => {
+ const sheet = src("src/components/kinetic/export-sheet.tsx");
+ expect(sheet).toContain("disabled={!!blocked || !!waiting ||");
+ expect(src("src/components/kinetic/editor.tsx")).toContain('waiting={plan ? null : "Getting the scene ready…"}');
+ });
+});