Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): never condition on non-guide images when flagged guides are unsendable

[._.]/ Adam Eivyc918f8143278
diff --git a/server/lib/musicVideoConditioning.js b/server/lib/musicVideoConditioning.js
index 39f7b9d02e..e09b327420 100644
--- a/server/lib/musicVideoConditioning.js
+++ b/server/lib/musicVideoConditioning.js
@@ -50,6 +50,8 @@ export function sceneCastVariant(scene) {
// A file a frame render can name as a reference (routes/imageGen.js galleryImageFilenameSchema).
const SENDABLE_REFERENCE_FILE = /^[^/\\]+\.(png|jpe?g|webp)$/i;
+// The catalog media kinds pickGuideMedia treats as images (catalogMediaLibrary.js).
+const CAST_IMAGE_KINDS = new Set(['portrait', 'reference']);
/**
* The Casting guide images (catalogMediaLibrary.pickGuideMedia) for the cast
@@ -64,9 +66,14 @@ export function musicVideoCastGuideReferences(project, scene, castMedia) {
if (!Array.isArray(media)) return [];
const name = (project?.concept?.subjects || []).find((s) => s?.ingredientId === variant.ingredientId)?.name || 'Cast guide';
// Frame renders accept only a png/jpg/jpeg/webp basename (routes/imageGen.js). Filtering before
- // the pick lets the next candidate take an unsendable file's slot.
+ // the pick lets the next candidate take an unsendable file's slot. The guide-vs-fallback choice
+ // reads the member's real guide flags: with guides flagged, only sendable guides qualify (none
+ // left = the automatic set), never the non-guide images pickGuideMedia falls back to.
const sendable = media.filter((m) => typeof m?.mediaKey === 'string' && SENDABLE_REFERENCE_FILE.test(m.mediaKey));
- return pickGuideMedia(sendable, { age: variant.age, era: variant.era, wardrobeId: variant.wardrobeId }, MUSIC_VIDEO_MAX_CONDITIONING_REFERENCES)
+ const flagged = media.some((m) => m && !m.deleted && CAST_IMAGE_KINDS.has(m.kind) && m.library?.guide === true);
+ const candidates = flagged ? sendable.filter((m) => m.library?.guide === true) : sendable;
+ if (!candidates.length) return [];
+ return pickGuideMedia(candidates, { age: variant.age, era: variant.era, wardrobeId: variant.wardrobeId }, MUSIC_VIDEO_MAX_CONDITIONING_REFERENCES)
.map((m) => {
const v = m.library?.variant || {};
const detail = v.label || (Number.isInteger(v.age) ? `age ${v.age}` : v.era || '');
diff --git a/server/lib/musicVideoConditioning.test.js b/server/lib/musicVideoConditioning.test.js
index 6a68976578..b8570b845c 100644
--- a/server/lib/musicVideoConditioning.test.js
+++ b/server/lib/musicVideoConditioning.test.js
@@ -42,6 +42,15 @@ describe('musicVideoConditioningReferences with Casting guides', () => {
.toEqual(['teen.png', 'lead.png', 'set.png']);
});
+ // Uniquely catches unsendable flagged guides letting non-guide images condition the shot.
+ it('uses the automatic set when every flagged guide is unsendable, never the non-guide images', () => {
+ const media = { [CAST_ID]: [guide('hero.avif', 7), { mediaKey: 'stale.png', kind: 'reference', library: { variant: { age: 7 } } }] };
+ expect(ids(musicVideoConditioningReferences(project(authored), { characterVariant: { ingredientId: CAST_ID, age: 7 } }, media)))
+ .toEqual(['lead.png', 'set.png']);
+ const unflagged = { [CAST_ID]: [{ mediaKey: 'face.png', kind: 'portrait', library: {} }] };
+ expect(ids(musicVideoConditioningReferences(project(authored), { characterVariant: { ingredientId: CAST_ID } }, unflagged))[0]).toBe('face.png');
+ });
+
it('is unchanged without a variant or before the cast media loads', () => {
const today = ids(musicVideoConditioningReferences(project(authored), {}));
expect(today).toEqual(['lead.png', 'set.png']);