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

fix: keep guides from other casting tabs accessible

[._.]/ Adam Eivy606db7c29efd
diff --git a/client/src/components/catalog/CatalogReferenceLibrary.jsx b/client/src/components/catalog/CatalogReferenceLibrary.jsx
index a6bfe14318..b27808b1f6 100644
--- a/client/src/components/catalog/CatalogReferenceLibrary.jsx
+++ b/client/src/components/catalog/CatalogReferenceLibrary.jsx
@@ -10,10 +10,10 @@ const LIBRARY_KINDS = new Set(['portrait', 'reference', 'video']);
const eraFor = (m) => m.library?.variant?.era
|| (Number.isInteger(m.library?.variant?.age) ? (m.library.variant.age < 13 ? 'child' : m.library.variant.age < 20 ? 'teen' : m.library.variant.age < 65 ? 'adult' : 'elder') : '');
-export default function CatalogReferenceLibrary({ ingredientId, media = [], forms = [], readOnly = false, onChanged, guideMedia = media, missingMedia = new Set(), onSetPortrait, onDetach }) {
+export default function CatalogReferenceLibrary({ ingredientId, media = [], forms = [], readOnly = false, onChanged, referenceMedia = media, missingMedia = new Set(), onSetPortrait, onDetach }) {
const id = useId();
const [armedDetach, setArmedDetach] = useState(null);
- const [filter, setFilter] = useState({ form: '', age: '', era: '', tag: '', guides: false });
+ const [filter, setFilter] = useState({ form: '', age: '', era: '', tag: '', guides: false, allMedia: false });
const [error, setError] = useState('');
const [busyKey, setBusyKey] = useState('');
const [boardId, setBoardId] = useState('');
@@ -21,11 +21,13 @@ export default function CatalogReferenceLibrary({ ingredientId, media = [], form
const rows = useMemo(() => media.filter((m) => !m.deleted && LIBRARY_KINDS.has(m.kind)), [media]);
// Sheets and looks in other tabs still consume the character-wide guide limit.
- const guideCount = guideMedia.filter((m) => !m.deleted && LIBRARY_KINDS.has(m.kind) && m.library?.guide === true).length;
+ const guideCount = media.filter((m) => !m.deleted && LIBRARY_KINDS.has(m.kind) && m.library?.guide === true).length;
const ages = [...new Set(rows.map((m) => m.library?.variant?.age).filter(Number.isInteger))].sort((a, b) => a - b);
const tags = [...new Set(rows.flatMap((m) => m.library?.tags || []))].sort();
const formKey = (m) => m.library?.variant?.formId || 'canonical';
- const visible = rows.filter((m) => (!filter.form || formKey(m) === filter.form)
+ const referenceKeys = new Set(referenceMedia.map((m) => `${m.kind}:${m.mediaKey}`));
+ const visible = rows.filter((m) => (filter.allMedia || referenceKeys.has(`${m.kind}:${m.mediaKey}`))
+ && (!filter.form || formKey(m) === filter.form)
&& (filter.age === '' || m.library?.variant?.age === Number(filter.age))
&& (!filter.era || eraFor(m) === filter.era)
&& (!filter.tag || (m.library?.tags || []).includes(filter.tag))
@@ -71,9 +73,17 @@ export default function CatalogReferenceLibrary({ ingredientId, media = [], form
<section aria-label="Reference library" className="min-w-0 space-y-3">
<header className="flex flex-wrap items-center justify-between gap-2 text-sm">
<h3 className="font-semibold">Reference library</h3>
- <span data-testid="guide-count" className="text-gray-400">{formatCount(guideCount)}/{MAX_CAST_GUIDES} render guides</span>
+ <span data-testid="guide-count" className="text-gray-400">{formatCount(guideCount)}/{MAX_CAST_GUIDES} render guides (all media)</span>
</header>
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,9rem),1fr))] items-end gap-2 text-xs">
+ {referenceMedia !== media && (
+ <label htmlFor={`${id}-scope`} className="min-w-0 space-y-1"><span>Media scope</span>
+ <select id={`${id}-scope`} value={filter.allMedia ? 'all' : 'references'} onChange={(e) => setFilter({ ...filter, allMedia: e.target.value === 'all' })} className={fieldClass}>
+ <option value="references">References</option>
+ <option value="all">All character media</option>
+ </select>
+ </label>
+ )}
{forms.length > 0 && (
<label htmlFor={`${id}-form`} className="min-w-0 space-y-1"><span>Age or look</span>
<select id={`${id}-form`} aria-label="Filter by age or look" value={filter.form} onChange={(e) => setFilter({ ...filter, form: e.target.value })} className={fieldClass}>
diff --git a/client/src/components/catalog/CatalogReferenceLibrary.test.jsx b/client/src/components/catalog/CatalogReferenceLibrary.test.jsx
index 51aefa1af0..39070b132d 100644
--- a/client/src/components/catalog/CatalogReferenceLibrary.test.jsx
+++ b/client/src/components/catalog/CatalogReferenceLibrary.test.jsx
@@ -94,8 +94,8 @@ describe('CatalogReferenceLibrary', () => {
it('preserves per-attachment read-only provenance and counts guides outside this tab', () => {
render(<CatalogReferenceLibrary ingredientId="cat-chr-1"
- media={[{ ...media[0], readOnly: true }, media[1]]}
- guideMedia={[...media, ...[1, 2, 3].map((n) => ({ kind: 'reference', mediaKey: `sheet-${n}.png`, library: { guide: true } }))]} />);
+ referenceMedia={media.slice(0, 2)}
+ media={[{ ...media[0], readOnly: true }, ...media.slice(1), ...[1, 2, 3].map((n) => ({ kind: 'reference', mediaKey: `sheet-${n}.png`, library: { guide: true } }))]} />);
expect(within(screen.getAllByTestId('library-row')[0]).queryByText('Edit reference details')).toBeNull();
expect(screen.getByRole('button', { name: /make guide/i })).toBeDisabled();
expect(screen.getByTestId('guide-count')).toHaveTextContent('4/4');
diff --git a/client/src/pages/CatalogIngredient.jsx b/client/src/pages/CatalogIngredient.jsx
index a45f66f373..80f453ff6c 100644
--- a/client/src/pages/CatalogIngredient.jsx
+++ b/client/src/pages/CatalogIngredient.jsx
@@ -886,7 +886,7 @@ function IngredientEditor() {
{(activeTab === 'profile' ? !tabs : activeTab === 'references' || activeTab === 'images') && (
<MediaPanel
readOnly={identityReadOnly}
- referenceLibrary={record.type === 'character' ? { ingredientId: record.id, forms: formsOf(record.payload), guideMedia: media, onChanged: refreshMedia } : null}
+ referenceLibrary={record.type === 'character' ? { ingredientId: record.id, forms: formsOf(record.payload), media: media.map(protectMedia), onChanged: refreshMedia } : null}
media={(tabs ? media.filter(isReferenceTabRow) : media).map(protectMedia)}
canonImageRefs={[payload.primaryImageRef, ...(Array.isArray(payload.imageRefs) ? payload.imageRefs : [])].filter((ref) =>
!media.some((m) => (m.kind === 'portrait' || m.kind === 'reference') && m.mediaKey === ref))}
@@ -1588,7 +1588,7 @@ function MediaPanel({ readOnly = false, referenceLibrary = null, media, canonIma
: 'Drag a gallery image or a file here to attach it (image, audio, or video).'}
</div>}
- {referenceLibrary && <CatalogReferenceLibrary {...referenceLibrary} media={list} readOnly={readOnly}
+ {referenceLibrary && <CatalogReferenceLibrary {...referenceLibrary} referenceMedia={list} readOnly={readOnly}
missingMedia={missingMedia} onSetPortrait={onSetPortrait} onDetach={onDetach} />}
{!referenceLibrary && portrait && (
diff --git a/client/src/pages/CatalogIngredient.test.jsx b/client/src/pages/CatalogIngredient.test.jsx
index a0ee4f06ac..39065d4b21 100644
--- a/client/src/pages/CatalogIngredient.test.jsx
+++ b/client/src/pages/CatalogIngredient.test.jsx
@@ -1057,6 +1057,10 @@ describe('CatalogIngredient — tabbed library record pages', () => {
expect(screen.queryByAltText('Winter reference')).not.toBeInTheDocument();
expect(screen.getByAltText('Studio portrait')).toBeInTheDocument();
expect(screen.queryByAltText('Sheet in its own tab')).not.toBeInTheDocument();
+ fireEvent.change(within(library).getByLabelText('Filter by age'), { target: { value: '' } });
+ fireEvent.change(within(library).getByLabelText('Media scope'), { target: { value: 'all' } });
+ expect(screen.getByAltText('Sheet in its own tab')).toBeInTheDocument();
+ expect(within(screen.getByRole('group', { name: 'reference details for sheet.png' })).getByRole('button', { name: 'Guide' })).toBeEnabled();
});
it('keeps archive-only reference media visible on References without using it as a profile cover', async () => {