From 8a99ee2686ecfa3e632e67ae2631e77ff6664b5d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 14:17:26 +0000 Subject: [PATCH] Clear references leaves the pinned references alone Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Tw9fjYBYFyV8YG5YDfYPRb --- app/ui/features/media/hub.test.js | 4 ++-- app/ui/features/media/index.js | 2 +- app/ui/shell/edits.js | 8 +++----- app/ui/shell/tests/edits.test.js | 8 ++++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/ui/features/media/hub.test.js b/app/ui/features/media/hub.test.js index e4290a1f..38a1653e 100644 --- a/app/ui/features/media/hub.test.js +++ b/app/ui/features/media/hub.test.js @@ -40,7 +40,7 @@ test("the selected scene's references are marked on their tiles, and the menu ta const flag = (n) => [...named(n).querySelectorAll(".cx-cell-flag")].map((x) => x.textContent).join(); assert.deepEqual([flag("dog.png"), flag("cat.png"), flag("owl.png")], ["R1", "R2", "📌R3"]); const clear = [...host.querySelectorAll("button")].find((b) => b.textContent.startsWith("Clear references")); - assert.ok(clear && !clear.hidden && /\(3\)/.test(clear.textContent), "counts every picture used in any scene, pinned ones too"); + assert.ok(clear && !clear.hidden && /\(2\)/.test(clear.textContent), "counts every picture in any scene's own list; pins are not counted"); document.querySelectorAll(".cx-popover").forEach((n) => n.remove()); named("dog.png").dispatchEvent(new window.MouseEvent("contextmenu", { bubbles: true, cancelable: true })); const stop = [...document.querySelectorAll(".cx-menu-item")].find((b) => b.textContent.includes("Stop using as a reference")); @@ -48,7 +48,7 @@ test("the selected scene's references are marked on their tiles, and the menu ta stop.click(); assert.deepEqual(set, [["s1", "references", ["m1"]]]); clear.click(); - assert.deepEqual([doc.scenes.map((x) => x.references), doc.fixed_references], [[[], []], {}], "one click takes them off every scene and unpins"); + assert.deepEqual([doc.scenes.map((x) => x.references), doc.fixed_references], [[[], []], { m3: 3 }], "one click empties every scene's list; the pin stays"); }); test("a changed pin repaints the slot numbers on the tiles even when the list of references is the same", async () => { diff --git a/app/ui/features/media/index.js b/app/ui/features/media/index.js index 96c2ae54..c3d9dd17 100644 --- a/app/ui/features/media/index.js +++ b/app/ui/features/media/index.js @@ -149,7 +149,7 @@ export default { } }); const controls = { sort, view: view, cols: tileSize }; bulk.node.hidden = true; - const clearRefs = c.button.sm({ label: "Clear references", tone: "ghost", title: "Stop using every reference picture in every scene, pinned ones too", onClick: () => p.edit(clearReferences) }); + const clearRefs = c.button.sm({ label: "Clear references", tone: "ghost", title: "Stop using every reference picture in every scene (pinned ones stay)", onClick: () => p.edit(clearReferences) }); host.append(c.toolbar.default({ items: [c.text.sm({ text: "Media" })], trailing: [clearRefs, selectBtn, bulk] }).node, drop.node, note.node, seg("Show", FILTERS, "filter").node, sort.node, view.node, tileSize.node, shelf.node); diff --git a/app/ui/shell/edits.js b/app/ui/shell/edits.js index b4419924..02af0c60 100644 --- a/app/ui/shell/edits.js +++ b/app/ui/shell/edits.js @@ -18,17 +18,15 @@ export function addScene(p, sourceType = "carry") { return sc; } -/** Every picture used as a reference anywhere in the project: each scene's own and the pinned ones (which go to every scene). */ +/** Every picture in any scene's own reference list. The pinned ones (project.fixed_references) are a separate setting and are not counted. */ export function allReferences(p) { - return new Set([...Object.keys(p.fixed_references || {}), ...(p.scenes || []).flatMap((s) => s.references || [])]); + return new Set((p.scenes || []).flatMap((s) => s.references || [])); } -/** Stop using any reference picture in the whole project: every scene's list and the pins. -> how many pictures were in use (0: nothing changed). */ +/** Empty every scene's own reference list; the pins stay. -> how many pictures were in use (0: nothing changed). */ export function clearReferences(p) { const n = allReferences(p).size; - if (!n) return 0; for (const s of p.scenes || []) if ((s.references || []).length) s.references = []; - p.fixed_references = {}; return n; } diff --git a/app/ui/shell/tests/edits.test.js b/app/ui/shell/tests/edits.test.js index 7d06f942..7cc70c62 100644 --- a/app/ui/shell/tests/edits.test.js +++ b/app/ui/shell/tests/edits.test.js @@ -87,10 +87,10 @@ test("removing the first cut of a unit hands its takes to the clip that becomes assert.deepEqual(Object.keys(p.scene_variants), ["b"]); }); -test("clearReferences empties every scene and the pins, and says how many pictures were in use", async () => { +test("clearReferences empties every scene's own list, keeps the pins, and says how many pictures were in use", async () => { const { clearReferences, allReferences } = await import("../edits.js"); const p = { fixed_references: { a: 1 }, scenes: [{ id: "x", references: ["b", "c"] }, { id: "y", references: ["b"] }, { id: "z" }] }; - assert.equal(allReferences(p).size, 3); - assert.equal(clearReferences(p), 3); - assert.deepEqual([p.scenes.map((s) => s.references || []), p.fixed_references, clearReferences(p)], [[[], [], []], {}, 0]); + assert.equal(allReferences(p).size, 2); + assert.equal(clearReferences(p), 2); + assert.deepEqual([p.scenes.map((s) => s.references || []), p.fixed_references, clearReferences(p)], [[[], [], []], { a: 1 }, 0]); });