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.

Cinema: a built-in palette's fixed name reaches an install seeded before

Adarsh1ae82e2375f3
diff --git a/src/server/palettes.ts b/src/server/palettes.ts
index f13e2d91..55df946c 100644
--- a/src/server/palettes.ts
+++ b/src/server/palettes.ts
@@ -89,13 +89,18 @@ declare global {
var __fuobePalettesSeeded: boolean | undefined;
}
-/** Seed (or top up) the built-in palettes; cheap after the first call in a process. */
+/**
+ * Seed (or top up) the built-in palettes; cheap after the first call in a process. A built-in can't be renamed, so
+ * its name follows the catalog: a name fixed there ("Crimson Vigil") reaches an install seeded before the fix.
+ */
function ensureBuiltins(): void {
if (globalThis.__fuobePalettesSeeded) return;
const now = Date.now();
const insert = db().prepare(
- `INSERT OR IGNORE INTO palettes (id, name, colors_json, background, slug, source, thumb_url, position, created_at, updated_at)
- VALUES (@id, @name, @colors_json, @background, @slug, 'builtin', NULL, @position, @now, @now)`,
+ `INSERT INTO palettes (id, name, colors_json, background, slug, source, thumb_url, position, created_at, updated_at)
+ VALUES (@id, @name, @colors_json, @background, @slug, 'builtin', NULL, @position, @now, @now)
+ ON CONFLICT(id) DO UPDATE SET name = excluded.name, updated_at = excluded.updated_at
+ WHERE palettes.source = 'builtin' AND palettes.name <> excluded.name`,
);
db().transaction(() => {
builtinPalettes().forEach((p, i) => insert.run({ id: p.id, name: p.name, colors_json: JSON.stringify(p.colors), background: p.background, slug: p.slug, position: i, now }));
diff --git a/tests/image-studios-api.test.ts b/tests/image-studios-api.test.ts
index 128ee899..972be8a6 100644
--- a/tests/image-studios-api.test.ts
+++ b/tests/image-studios-api.test.ts
@@ -78,6 +78,13 @@ describe("palettes", () => {
expect(body.caps.native["ideogram-3"]).toEqual({ max: 12 });
});
+ it("gives a built-in palette its catalog name on an install seeded before the name was fixed", () => {
+ db().prepare("UPDATE palettes SET name = 'Crimson Vigi' WHERE id = 'builtin-crimson-vigi'").run();
+ globalThis.__fuobePalettesSeeded = false;
+ expect(palettes.getPalette("builtin-crimson-vigi")?.name).toBe("Crimson Vigil");
+ expect(palettes.listPalettes().filter((p) => p.source === "builtin")).toHaveLength(50);
+ });
+
it("saves, renames and deletes your palettes; built-ins stay", async () => {
const bad = await palettesRoute.POST(json("POST", { name: "x", colors: ["#zzzzzz"] }));
expect(bad.status).toBe(400);