The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Result panel: action labels truncate in their own button; own-setup badge fits
Adarshcf8db652d371
diff --git a/src/components/own-setup.tsx b/src/components/own-setup.tsxindex 71ceeeda..d6544734 100644--- a/src/components/own-setup.tsx+++ b/src/components/own-setup.tsx@@ -17,9 +17,9 @@ import { cn } from "@/lib/utils";/*** The label: a small chip in the studios' badge style (the pickers' "Open source" and "Reads boxes" chips). `short`- * uses the short words on a phone. Fixed height, so it never moves the row it sits in.+ * uses the short words on a phone ("always": everywhere). Fixed height, so it never moves the row it sits in.*/-export function OwnSetupChip({ setup, short = true, className }: { setup: OwnSetup | string | null | undefined; short?: boolean; className?: string }) {+export function OwnSetupChip({ setup, short = true, className }: { setup: OwnSetup | string | null | undefined; short?: boolean | "always"; className?: string }) {const o = typeof setup === "string" ? ownSetupOnly(setup) : setup;if (!o) return null;const Icon = o.need === "key" ? KeyRound : Cpu;@@ -34,7 +34,9 @@ export function OwnSetupChip({ setup, short = true, className }: { setup: OwnSet)}><Icon className="size-2.5! shrink-0" aria-hidden />- {short ? (+ {short === "always" ? (+ <span className="truncate">{ownSetupShort(o)}</span>+ ) : short ? (<><span className="truncate sm:hidden">{ownSetupShort(o)}</span><span className="truncate max-sm:hidden">{label}</span>diff --git a/src/components/studio/result-actions.tsx b/src/components/studio/result-actions.tsxindex a6e18ced..a09240d0 100644--- a/src/components/studio/result-actions.tsx+++ b/src/components/studio/result-actions.tsx@@ -78,7 +78,7 @@ import { useShare } from "@/components/share/share-provider";import { useSkillBuilder } from "@/components/skills/skill-builder-provider";import { Popover, PopoverAnchor, PopoverContent } from "@/components/ui/popover";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";-import { useCreateGeneration, useEngineMode, useGenerationActions, useIsAccount, useLikelyVisitor, useSaveElement, useStatus } from "@/lib/api";+import { useCreateGeneration, useEngineMode, useGenerationActions, useIsAccount, useIsOwner, useLikelyVisitor, useSaveElement, useStatus } from "@/lib/api";import { askDeleteForGood } from "@/components/studio/delete-for-good";import { placeholdersOn } from "@/lib/demo-mode";import { ELEMENT_KINDS, type ElementKind } from "@/lib/catalog/elements";@@ -546,6 +546,7 @@ export function ActionMenu({defaultOpen?: boolean;}) {const actions = useGenerationActions();+ const owner = useIsOwner();const destructive = list.filter((a) => a.destructive);const rest = list.filter((a) => !a.destructive);// Focus goes back to ⋯ when the menu closes, except when it hands over to the Save-as-element popover.@@ -578,7 +579,7 @@ export function ActionMenu({<DropdownMenuItem key={a.id} asChild><Link href={a.href} prefetch={false}><Icon /> {a.label}- <OwnSetupChip setup={a.ownSetup} className="ml-auto" />+ {!owner && <OwnSetupChip setup={a.ownSetup} className="ml-auto" />}</Link></DropdownMenuItem>);@@ -594,7 +595,7 @@ export function ActionMenu({}}><Icon className={cn(a.id === "favorite" && g.favorite && "fill-current")} /> {a.id === "save-character" ? "Save as element…" : a.label}- <OwnSetupChip setup={a.ownSetup} className="ml-auto" />+ {!owner && <OwnSetupChip setup={a.ownSetup} className="ml-auto" />}</DropdownMenuItem>);};diff --git a/src/components/studio/viewer.tsx b/src/components/studio/viewer.tsxindex e2878e18..f4a74a54 100644--- a/src/components/studio/viewer.tsx+++ b/src/components/studio/viewer.tsx@@ -13,7 +13,7 @@ import { formatCost, timeAgo } from "@/lib/format";import { PRESETS as GRADE_PRESETS } from "@/lib/grade";import { trashDaysLeft, userTitle } from "@/lib/library";import { editOnlyFormat, isLayered, layerInfo, outputActions, type OutputAction } from "@/lib/output-actions";-import { useEngineMode, useIsAccount, useLikelyVisitor, usePlaceName, useStatus } from "@/lib/api";+import { useEngineMode, useIsAccount, useIsOwner, useLikelyVisitor, usePlaceName, useStatus } from "@/lib/api";import { knownPlace } from "@/lib/place-name";import { placeholdersOn } from "@/lib/demo-mode";import { cn } from "@/lib/utils";@@ -22,7 +22,7 @@ import { CompareSlider } from "./compare-slider";import { MadeNote } from "./made-note";import { shownSettings } from "@/lib/catalog/made";import { ACTION_ICONS, downloadUrl, SaveElementForm, useActionRunner } from "./result-actions";-import { OwnSetupChip } from "@/components/own-setup";+import { OwnSetupChip, OwnSetupMark } from "@/components/own-setup";import { LayersStack, ModelViewer, TextReader, VideoFileCard } from "./result-media";import { ReviewSelect } from "@/components/library/review";import { PlaceholderChip } from "@/components/demo-mode";@@ -200,6 +200,7 @@ export function Viewer({const visitor = useLikelyVisitor();const placeholders = placeholdersOn(useStatus().data?.demoMode);const account = useIsAccount();+ const owner = useIsOwner();const list = useMemo(() => outputActions(g, index, { reuse: !!onReuse, compare: !!source, inViewer: true, engineMode, visitor, placeholders, account }), [g, index, onReuse, source, engineMode, visitor, placeholders, account]);// Read the latest values from the key handler without re-subscribing on every render.@@ -260,15 +261,27 @@ export function Viewer({const Icon = ACTION_ICONS[a.id];const label = a.id === "favorite" ? (g.favorite ? "Favorited" : "Favorite") : a.id === "save-character" ? "Save as element" : a.label;const icon = <Icon className={cn(a.id === "favorite" && g.favorite && "fill-current text-highlight")} />;- const cls = cn(a.destructive && "text-destructive hover:text-destructive", opts.className);+ // The label truncates inside its own button, so a long one never spills into the next column.+ const text = (+ <span className="min-w-0 truncate" title={label}>+ {label}+ </span>+ );+ const cls = cn("min-w-0", a.destructive && "text-destructive hover:text-destructive", opts.className);const variant = a.destructive ? "ghost" : (opts.variant ?? "secondary");- // An action that runs on the visitor's own setup (src/lib/own-setup.ts) says what it needs beside its name.- const setup = <OwnSetupChip setup={a.ownSetup} />;+ // An action that runs on the visitor's own setup (src/lib/own-setup.ts) says what it needs beside its name: its icon+ // in a narrow cell, the short words where the cell has room. The owner runs it as any other, so no mark.+ const setup = a.ownSetup && !owner && (+ <>+ <OwnSetupMark setup={a.ownSetup} className="@min-[34rem]/actions:hidden" />+ <OwnSetupChip setup={a.ownSetup} short="always" className="min-w-0 shrink @max-[34rem]/actions:hidden" />+ </>+ );if (a.href && a.download !== undefined) {return (<Button key={a.id} asChild variant={variant} size="sm" className={cls}><a href={a.href} download={a.download} onClick={opts.onDone}>- {icon} {label}+ {icon} {text}</a></Button>);@@ -277,7 +290,7 @@ export function Viewer({return (<Button key={a.id} asChild variant={variant} size="sm" className={cls}><Link href={a.href} prefetch={false}>- {icon} {label}+ {icon} {text}{setup}</Link></Button>@@ -288,7 +301,7 @@ export function Viewer({<Popover key={a.id} open={saving} onOpenChange={setSaving}><PopoverTrigger asChild><Button variant={variant} size="sm" className={cls}>- {icon} {label}+ {icon} {text}</Button></PopoverTrigger><PopoverContent align="end" collisionPadding={12} className="w-72">@@ -309,7 +322,7 @@ export function Viewer({opts.onDone?.();}}>- {icon} {label}+ {icon} {text}{setup}</Button>);@@ -447,7 +460,7 @@ export function Viewer({/>)}</div>- <div className="grid grid-cols-2 gap-2 border-t p-3">+ <div className="@container/actions grid grid-cols-2 gap-2 border-t p-3">{primary && actionButton(primary, { variant: "default" })}{bar.map((a) => actionButton(a))}{menu.filter((a) => !a.destructive && a.id !== "compare").map((a) => actionButton(a))}@@ -498,7 +511,7 @@ export function Viewer({<div className="space-y-4 overflow-y-auto px-4">{/* The next steps first: on a phone this sheet is where they are. */}{!layered && <NextSteps g={g} index={index} variant="list" max={5} onNavigate={onClose} />}- <div className="grid grid-cols-2 gap-2">+ <div className="@container/actions grid grid-cols-2 gap-2">{source && (<Button variant="secondary" size="sm" aria-pressed={comparing} onClick={() => (setComparing((v) => !v), setDrawer(false))}><Columns2 /> {comparing ? "Hide original" : "Compare"}diff --git a/tests/result-actions-layout.test.ts b/tests/result-actions-layout.test.tsnew file mode 100644index 00000000..355aab9d--- /dev/null+++ b/tests/result-actions-layout.test.ts@@ -0,0 +1,52 @@+import fs from "node:fs";+import path from "node:path";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";++/*+ * The result panel's action grid: a long label truncates inside its own button, and an action that runs on the visitor's+ * own setup shows its mark (an icon with its words as tooltip) in a narrow cell and the short words where there is room,+ * never the long label that pushed the button out of its column. The owner sees no mark.+ */++vi.mock("server-only", () => ({}));++const { OwnSetupChip, OwnSetupMark } = await import("@/components/own-setup");+const { ownSetupLabel, ownSetupOnly, ownSetupShort } = await import("@/lib/own-setup");++const source = (f: string) => fs.readFileSync(path.join(process.cwd(), f), "utf8");++describe("the own-setup chip in the result panel", () => {+ it("short=always says only the short words, at every width", () => {+ const o = ownSetupOnly("video-tools:restore")!;+ const html = renderToStaticMarkup(createElement(OwnSetupChip, { setup: o, short: "always" }));+ expect(html).toContain(ownSetupShort(o));+ expect(html).not.toContain(`>${ownSetupLabel(o)}<`);+ expect(html).not.toContain("sm:hidden");+ });++ it("the mark keeps the full words for a tooltip and a screen reader", () => {+ const o = ownSetupOnly("regenerate:upscale")!;+ const html = renderToStaticMarkup(createElement(OwnSetupMark, { setup: o }));+ expect(html).toContain(`title="${ownSetupLabel(o)}"`);+ expect(html).toContain("sr-only");+ });+});++describe("the result panel's action buttons", () => {+ const viewer = source("src/components/studio/viewer.tsx");++ it("truncate their label inside their own cell", () => {+ expect(viewer).toMatch(/className="min-w-0 truncate" title=\{label\}/);+ expect(viewer).toMatch(/const cls = cn\("min-w-0"/);+ expect(viewer).not.toMatch(/\{icon\} \{label\}/);+ });++ it("show the short chip only where the grid has room, the mark elsewhere, and nothing to the owner", () => {+ expect(viewer.match(/@container\/actions grid grid-cols-2/g)).toHaveLength(2);+ expect(viewer).toMatch(/a\.ownSetup && !owner &&/);+ expect(viewer).toMatch(/<OwnSetupMark setup=\{a\.ownSetup\} className="@min-\[34rem\]\/actions:hidden" \/>/);+ expect(viewer).toMatch(/<OwnSetupChip setup=\{a\.ownSetup\} short="always" className="min-w-0 shrink @max-\[34rem\]\/actions:hidden" \/>/);+ });+});