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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: drop non-string sidecar metadata from the picker's filter options instead of throwing (review round 2)
[._.]/ Adam Eivy481ca1a1343b
diff --git a/client/src/components/imageGen/GalleryImagePicker.jsx b/client/src/components/imageGen/GalleryImagePicker.jsxindex 09a29b161b..a37b407b5b 100644--- a/client/src/components/imageGen/GalleryImagePicker.jsx+++ b/client/src/components/imageGen/GalleryImagePicker.jsx@@ -45,6 +45,11 @@ const KIND_PREFIX = 'kind:';// `item.key` — so membership is a set lookup, not a filename comparison.const membershipKey = (it) => `${it?.kind}:${it?.ref}`;const byLabel = (a, b) => a.label.localeCompare(b.label);+// Image sidecars are unvalidated JSON on disk and arrive from peers, so a+// non-string `entryCategory` / `universeName` is representable. Everything+// downstream here calls string methods (humanizeCategory, localeCompare), so a+// bad value drops the option rather than throwing during render.+const asText = (value) => (typeof value === 'string' && value.trim() ? value : null);export default function GalleryImagePicker({ open, onClose, onSelect, allowUpload = false }) {const [items, setItems] = useState([]);@@ -105,10 +110,13 @@ export default function GalleryImagePicker({ open, onClose, onSelect, allowUploaconst universeOptions = useMemo(() => {const present = new Map();for (const it of items) {- if (it.universeId && !present.has(it.universeId)) present.set(it.universeId, it.universeName || it.universeId);+ const id = asText(it.universeId);+ if (id && !present.has(id)) present.set(id, asText(it.universeName) || id);}for (const u of universes) {- if (u?.id && u.name && present.has(u.id)) present.set(u.id, u.name);+ const id = asText(u?.id);+ const name = asText(u?.name);+ if (id && name && present.has(id)) present.set(id, name);}return [...present.entries()].map(([id, label]) => ({ value: `${UNI_PREFIX}${id}`, label }))@@ -120,16 +128,18 @@ export default function GalleryImagePicker({ open, onClose, onSelect, allowUploa// Same "must match something" rule as universes. A collection also holds video// refs, which this image-only picker can never surface.const collectionOptions = useMemo(() => collections- .filter((c) => Array.isArray(c?.items) && c.items.some((it) => galleryKeys.has(membershipKey(it))))- .map((c) => ({ value: `${COL_PREFIX}${c.id}`, label: c.name || c.id }))+ .filter((c) => asText(c?.id) && Array.isArray(c?.items) && c.items.some((it) => galleryKeys.has(membershipKey(it))))+ .map((c) => ({ value: `${COL_PREFIX}${c.id}`, label: asText(c.name) || c.id })).sort(byLabel), [collections, galleryKeys]);const [categoryOptions, kindOptions] = useMemo(() => {const categories = new Set();const kinds = new Set();for (const it of items) {- if (it.entryCategory) categories.add(it.entryCategory);- if (it.entryKind) kinds.add(it.entryKind);+ const category = asText(it.entryCategory);+ const kind = asText(it.entryKind);+ if (category) categories.add(category);+ if (kind) kinds.add(kind);}const toOptions = (values, prefix) => [...values].map((value) => ({ value: `${prefix}${value}`, label: humanizeCategory(value) }))diff --git a/client/src/components/imageGen/GalleryImagePicker.test.jsx b/client/src/components/imageGen/GalleryImagePicker.test.jsxindex 2c03c3112c..422fb41d7b 100644--- a/client/src/components/imageGen/GalleryImagePicker.test.jsx+++ b/client/src/components/imageGen/GalleryImagePicker.test.jsx@@ -240,6 +240,27 @@ describe('GalleryImagePicker', () => {expect(listUniverses).toHaveBeenCalledWith({ silent: true });});+ it('skips malformed sidecar metadata instead of throwing while building options', async () => {+ listImageGallery.mockResolvedValue([+ // Sidecars are unvalidated JSON on disk and arrive from peers.+ { filename: 'bad.png', path: '/data/images/bad.png', prompt: 'bad metadata', entryCategory: 1, entryKind: {}, universeId: 7, universeName: 42 },+ { filename: 'ok.png', path: '/data/images/ok.png', prompt: 'good metadata', entryCategory: 'places', universeId: 'uni-a', universeName: 'Second Universe' },+ ]);+ listMediaCollections.mockResolvedValue([{ id: 'col-1', name: 5, items: [{ kind: 'image', ref: 'ok.png' }] }]);+ listUniverses.mockResolvedValue([{ id: 'uni-a', name: 99 }]);+ render(<GalleryImagePicker open onClose={vi.fn()} onSelect={vi.fn()} />);+ await screen.findByAltText('bad metadata');++ expect(screen.getByRole('option', { name: 'Places' })).toBeTruthy();+ // The non-string universe/collection names fall back to their ids, not to a throw.+ await waitFor(() => expect(screen.getByRole('option', { name: 'col-1' })).toBeTruthy());+ expect(screen.getByRole('option', { name: 'Second Universe' })).toBeTruthy();++ fireEvent.change(typeSelect(), { target: { value: 'cat:places' } });+ await waitFor(() => expect(screen.queryByAltText('bad metadata')).toBeNull());+ expect(screen.getByAltText('good metadata')).toBeTruthy();+ });+it('does not render the filter selects when nothing is filterable', async () => {listImageGallery.mockResolvedValue([{ filename: 'plain.png', path: '/data/images/plain.png', prompt: 'plain' }]);listMediaCollections.mockResolvedValue([]);