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 (codex r3): albums honor universe/series filters; stop album retry loop (#1762)

[._.]/ Adam Eivy23dfef7903e8
diff --git a/client/src/components/catalog/CatalogAlbum.jsx b/client/src/components/catalog/CatalogAlbum.jsx
index 3530807460..13bf9a5bbb 100644
--- a/client/src/components/catalog/CatalogAlbum.jsx
+++ b/client/src/components/catalog/CatalogAlbum.jsx
@@ -36,6 +36,10 @@ export default function CatalogAlbum({
const [loading, setLoading] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
const [error, setError] = useState('');
+ // `attempted` gates the auto-load so a FAILED first load (which leaves items
+ // null + loading false) doesn't make the expand effect retry in a tight loop.
+ // Reset by Retry; a remount (filter/data change) starts fresh.
+ const [attempted, setAttempted] = useState(false);
const fetchPage = useCallback(async (offset) => {
const list = await loadPage(offset).catch((err) => {
@@ -48,13 +52,21 @@ export default function CatalogAlbum({
}, [loadPage, pageSize]);
const ensureLoaded = useCallback(async () => {
- if (items !== null || loading) return;
+ if (items !== null || loading || attempted) return;
+ setAttempted(true);
setLoading(true);
setError('');
const list = await fetchPage(0);
setLoading(false);
if (list) setItems(list);
- }, [items, loading, fetchPage]);
+ }, [items, loading, attempted, fetchPage]);
+
+ // Retry after a failed load: clear the attempt gate + error so the expand
+ // effect re-runs ensureLoaded.
+ const retry = () => {
+ setError('');
+ setAttempted(false);
+ };
// Load the first time the album is expanded — covers both an explicit toggle
// and a `defaultExpanded` album that mounts already open (the pinned Raw album).
@@ -110,7 +122,16 @@ export default function CatalogAlbum({
<Loader2 size={14} className="animate-spin" /> Loading…
</div>
) : error ? (
- <div className="text-sm text-port-error py-3">{error}</div>
+ <div className="flex items-center gap-3 py-3">
+ <span className="text-sm text-port-error">{error}</span>
+ <button
+ type="button"
+ onClick={retry}
+ className="text-xs px-2 py-1 rounded border border-port-border text-gray-300 hover:text-white"
+ >
+ Retry
+ </button>
+ </div>
) : (items && items.length > 0) ? (
<>
<ul className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
diff --git a/client/src/pages/Catalog.jsx b/client/src/pages/Catalog.jsx
index 0a0a4f9e40..111b1610da 100644
--- a/client/src/pages/Catalog.jsx
+++ b/client/src/pages/Catalog.jsx
@@ -733,11 +733,13 @@ export default function Catalog() {
{view === 'albums' ? (
<AlbumsView
- // Remount on a mutation OR a filter change so the lazy album loads
- // re-run against fresh data and honor the active type/tag/q filters.
- key={`${dataVersion}|${selectedType}|${selectedTag}|${q}`}
+ // Remount on a mutation OR any filter change so the lazy album loads
+ // re-run against fresh data and honor the active filters.
+ key={`${dataVersion}|${selectedType}|${selectedTag}|${q}|${selectedUniverse}|${selectedSeries}`}
facets={facets}
filters={{ type: selectedType || undefined, tag: selectedTag || undefined, q: q || undefined }}
+ selectedUniverse={selectedUniverse}
+ selectedSeries={selectedSeries}
cardProps={cardProps}
onConfirmDelete={albumDelete}
/>
@@ -906,11 +908,11 @@ export default function Catalog() {
// under a `key={dataVersion}` so a mutation remounts it and the lazy loads
// re-run against fresh data. A universe album rolls up its series' members
// server-side (decision #1), so a series-only ingredient still has a home here.
-function AlbumsView({ facets, filters = {}, cardProps, onConfirmDelete }) {
+function AlbumsView({ facets, filters = {}, selectedUniverse = '', selectedSeries = '', cardProps, onConfirmDelete }) {
if (!facets) {
return <div className="text-gray-500 text-sm">Loading albums…</div>;
}
- const { universes = [], unlinkedCount = 0, orphanedCount = 0 } = facets;
+ const { universes = [], series = [], unlinkedCount = 0, orphanedCount = 0 } = facets;
const albumProps = { ...cardProps, onConfirmDelete, pageSize: PAGE_SIZE };
// One page fetcher per album view — paginated so albums never reintroduce the
// old silent cap. `extra` carries the album selector (unlinked / orphaned / a
@@ -919,6 +921,42 @@ function AlbumsView({ facets, filters = {}, cardProps, onConfirmDelete }) {
const pageLoader = (extra) => (offset) =>
listCatalogIngredients({ ...filters, ...extra, limit: PAGE_SIZE, offset, silent: true })
.then((d) => (Array.isArray(d?.items) ? d.items : []));
+
+ // A selected universe/series scopes the Albums view to that one album (the
+ // grid's ref filter, surfaced as a single open album) so the dropdowns drive
+ // albums the same way they drive the grid. Series wins over universe (more
+ // specific), mirroring the grid's buildListParams.
+ if (selectedSeries) {
+ const ser = series.find((s) => s.refId === selectedSeries);
+ return (
+ <div className="space-y-3">
+ <CatalogAlbum
+ title={ser?.name || 'Series'}
+ subtitle="filtered to the selected series"
+ count={ser?.count ?? 0}
+ defaultExpanded
+ loadPage={pageLoader({ refKind: 'series', refId: selectedSeries })}
+ {...albumProps}
+ />
+ </div>
+ );
+ }
+ if (selectedUniverse) {
+ const uni = universes.find((u) => u.refId === selectedUniverse);
+ return (
+ <div className="space-y-3">
+ <CatalogAlbum
+ title={uni?.name || 'Universe'}
+ subtitle="filtered to the selected universe"
+ count={uni?.count ?? 0}
+ defaultExpanded
+ loadPage={pageLoader({ refKind: 'universe', refId: selectedUniverse })}
+ {...albumProps}
+ />
+ </div>
+ );
+ }
+
const noAlbums = universes.length === 0 && unlinkedCount === 0 && orphanedCount === 0;
if (noAlbums) {
return (
diff --git a/client/src/pages/Catalog.test.jsx b/client/src/pages/Catalog.test.jsx
index 0cec029d13..b11dcc57d5 100644
--- a/client/src/pages/Catalog.test.jsx
+++ b/client/src/pages/Catalog.test.jsx
@@ -410,6 +410,35 @@ describe('Catalog page', () => {
expect(toast.success).toHaveBeenCalledWith(expect.stringMatching(/Added 2 ingredients to Echo Saints/i));
});
+ it('scopes the Albums view to a single album when a universe is selected', async () => {
+ renderCatalog();
+ await waitFor(() => expect(screen.getByText('Echo Saint')).toBeTruthy());
+ fireEvent.click(screen.getByRole('button', { name: /^Albums$/i }));
+ await waitFor(() => expect(screen.getByText('Unsorted / Raw')).toBeTruthy());
+
+ fireEvent.change(screen.getByLabelText(/^Universe$/i), { target: { value: 'u-1' } });
+ // Raw/Orphaned/other albums collapse to just the selected universe's album.
+ await waitFor(() => expect(screen.queryByText('Unsorted / Raw')).toBeNull());
+ expect(screen.getByText('Echo Saints')).toBeTruthy();
+ });
+
+ it('shows an inline error + Retry (no retry loop) when an album load fails', async () => {
+ listCatalogIngredients.mockImplementation((params = {}) => {
+ if (params.unlinked) return Promise.reject(new Error('boom'));
+ return Promise.resolve({ items: sample, nextOffset: sample.length });
+ });
+ renderCatalog();
+ await waitFor(() => expect(screen.getByText('Echo Saint')).toBeTruthy());
+ fireEvent.click(screen.getByRole('button', { name: /^Albums$/i }));
+
+ // The default-expanded Raw album fails → inline error + Retry, not a loop.
+ expect(await screen.findByRole('button', { name: /^Retry$/i })).toBeTruthy();
+ const unlinkedCalls = () => listCatalogIngredients.mock.calls.filter(([p]) => p?.unlinked).length;
+ const before = unlinkedCalls();
+ await new Promise((r) => setTimeout(r, 50));
+ expect(unlinkedCalls()).toBe(before); // bounded — no tight retry loop
+ });
+
it('lists empty (link-less) universes in the Add-to menu so they can be seeded', async () => {
// A brand-new universe with zero catalog links is absent from /facets but
// must still be a valid placement target.