Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Scope variant badges to Fast/Max per flow

Abi Rajaa8254b964720
diff --git a/frontend/src/components/variants/Variants.tsx b/frontend/src/components/variants/Variants.tsx
index d63fb0d6..6212611e 100644
--- a/frontend/src/components/variants/Variants.tsx
+++ b/frontend/src/components/variants/Variants.tsx
@@ -14,11 +14,8 @@ const IFRAME_HEIGHT = 550;
// Color-coded badge shown in the corner of each variant thumbnail.
const BADGE_TONE: Record<VariantLabelTone, string> = {
- flash: "bg-sky-500/90 text-white",
+ fast: "bg-sky-500/90 text-white",
max: "bg-amber-500/90 text-white",
- pro: "bg-violet-500/90 text-white",
- code: "bg-emerald-500/90 text-white",
- neutral: "bg-zinc-700/90 text-white",
};
interface VariantThumbnailProps {
@@ -80,11 +77,14 @@ function VariantThumbnail({ code, isSelected }: VariantThumbnailProps) {
}
function Variants() {
- const { head, commits, updateSelectedVariantIndex } = useProjectStore();
+ const { head, commits, updateSelectedVariantIndex, inputMode } =
+ useProjectStore();
const commit = head ? commits[head] : null;
const variants = commit?.variants || [];
const selectedVariantIndex = commit?.selectedVariantIndex || 0;
+ const generationType: "create" | "update" =
+ commit?.type === "ai_create" ? "create" : "update";
const handleVariantClick = (index: number) => {
if (index === selectedVariantIndex || !head) return;
@@ -130,7 +130,10 @@ function Variants() {
if (variant.status === "complete") statusColor = "bg-green-500";
else if (variant.status === "error" || variant.status === "cancelled") statusColor = "bg-red-500";
- const label = getVariantLabel(variant.model);
+ const label = getVariantLabel(variant.model, {
+ inputMode,
+ generationType,
+ });
return (
<div
diff --git a/frontend/src/lib/models.test.ts b/frontend/src/lib/models.test.ts
new file mode 100644
index 00000000..84101383
--- /dev/null
+++ b/frontend/src/lib/models.test.ts
@@ -0,0 +1,50 @@
+import { CodeGenerationModel, getVariantLabel } from "./models";
+
+const FLASH_MIN = CodeGenerationModel.GEMINI_3_FLASH_PREVIEW_MINIMAL;
+const PRO_HIGH = CodeGenerationModel.GEMINI_3_1_PRO_PREVIEW_HIGH;
+const CODEX_HIGH = CodeGenerationModel.GPT_5_2_CODEX_HIGH;
+const PRO_LOW = CodeGenerationModel.GEMINI_3_1_PRO_PREVIEW_LOW;
+
+describe("getVariantLabel", () => {
+ test("image/create: Flash-minimal -> Fast, Pro-high -> Max", () => {
+ const ctx = { inputMode: "image" as const, generationType: "create" as const };
+ expect(getVariantLabel(FLASH_MIN, ctx)).toEqual({ text: "Fast", tone: "fast" });
+ expect(getVariantLabel(PRO_HIGH, ctx)).toEqual({ text: "Max", tone: "max" });
+ // The other image/create models stay unlabelled.
+ expect(getVariantLabel(CODEX_HIGH, ctx)).toBeNull();
+ expect(
+ getVariantLabel(CodeGenerationModel.GEMINI_3_FLASH_PREVIEW_HIGH, ctx)
+ ).toBeNull();
+ });
+
+ test("text/create: Flash-minimal -> Fast; Pro-low has no Max", () => {
+ const ctx = { inputMode: "text" as const, generationType: "create" as const };
+ expect(getVariantLabel(FLASH_MIN, ctx)).toEqual({ text: "Fast", tone: "fast" });
+ expect(getVariantLabel(PRO_LOW, ctx)).toBeNull();
+ });
+
+ test("image/update: no labels (Flash-minimal reused but unlabelled)", () => {
+ const ctx = { inputMode: "image" as const, generationType: "update" as const };
+ expect(getVariantLabel(FLASH_MIN, ctx)).toBeNull();
+ expect(getVariantLabel(PRO_HIGH, ctx)).toBeNull();
+ });
+
+ test("text/update: no labels", () => {
+ const ctx = { inputMode: "text" as const, generationType: "update" as const };
+ expect(getVariantLabel(FLASH_MIN, ctx)).toBeNull();
+ });
+
+ test("video/create and video/update: Fast and Max", () => {
+ for (const generationType of ["create", "update"] as const) {
+ const ctx = { inputMode: "video" as const, generationType };
+ expect(getVariantLabel(FLASH_MIN, ctx)).toEqual({ text: "Fast", tone: "fast" });
+ expect(getVariantLabel(PRO_HIGH, ctx)).toEqual({ text: "Max", tone: "max" });
+ }
+ });
+
+ test("no model -> null", () => {
+ expect(
+ getVariantLabel(undefined, { inputMode: "image", generationType: "create" })
+ ).toBeNull();
+ });
+});
diff --git a/frontend/src/lib/models.ts b/frontend/src/lib/models.ts
index f4f82c35..6367e9ca 100644
--- a/frontend/src/lib/models.ts
+++ b/frontend/src/lib/models.ts
@@ -29,38 +29,35 @@ export enum CodeGenerationModel {
GEMINI_3_5_FLASH_MINIMAL = "gemini-3.5-flash (minimal thinking)",
}
-export type VariantLabelTone = "flash" | "max" | "pro" | "code" | "neutral";
+export type VariantLabelTone = "fast" | "max";
export interface VariantLabel {
text: string;
tone: VariantLabelTone;
}
-// Short, friendly badge shown on each variant tile, derived from the model.
-// Anchors requested by product: Gemini 3 Flash (minimal) -> "Flash",
-// Gemini 3.1 Pro (high) -> "Max".
+export interface VariantLabelContext {
+ inputMode: "image" | "video" | "text";
+ generationType: "create" | "update";
+}
+
+// Per-model badge text. Only these two models are labelled.
const VARIANT_LABELS: Partial<Record<CodeGenerationModel, VariantLabel>> = {
- [CodeGenerationModel.GEMINI_3_FLASH_PREVIEW_MINIMAL]: { text: "Flash", tone: "flash" },
- [CodeGenerationModel.GEMINI_3_FLASH_PREVIEW_HIGH]: { text: "Flash+", tone: "flash" },
+ [CodeGenerationModel.GEMINI_3_FLASH_PREVIEW_MINIMAL]: { text: "Fast", tone: "fast" },
[CodeGenerationModel.GEMINI_3_1_PRO_PREVIEW_HIGH]: { text: "Max", tone: "max" },
- [CodeGenerationModel.GEMINI_3_1_PRO_PREVIEW_MEDIUM]: { text: "Pro", tone: "pro" },
- [CodeGenerationModel.GEMINI_3_1_PRO_PREVIEW_LOW]: { text: "Pro", tone: "pro" },
- [CodeGenerationModel.GPT_5_2_CODEX_HIGH]: { text: "Codex", tone: "code" },
};
-export function getVariantLabel(model?: string): VariantLabel | null {
+// Badges are only shown on create flows and on any video flow. In particular
+// image/text update runs reuse Flash-minimal but should stay unlabelled.
+export function getVariantLabel(
+ model: string | undefined,
+ context: VariantLabelContext
+): VariantLabel | null {
if (!model) return null;
- const exact = VARIANT_LABELS[model as CodeGenerationModel];
- if (exact) return exact;
- // Family fallback so any model still gets a sensible badge.
- if (model.includes("gemini-3.1-pro")) return { text: "Pro", tone: "pro" };
- if (model.includes("flash")) return { text: "Flash", tone: "flash" };
- if (model.includes("codex")) return { text: "Codex", tone: "code" };
- if (model.includes("gpt")) return { text: "GPT", tone: "code" };
- if (model.includes("opus")) return { text: "Opus", tone: "max" };
- if (model.includes("sonnet")) return { text: "Sonnet", tone: "pro" };
- if (model.includes("fable")) return { text: "Fable", tone: "max" };
- return null;
+ const showLabels =
+ context.generationType === "create" || context.inputMode === "video";
+ if (!showLabels) return null;
+ return VARIANT_LABELS[model as CodeGenerationModel] ?? null;
}
// Will generate a static error if a model in the enum above is not in the descriptions