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): answer a failed search as a failed search on a fresh install

[._.]/ Adam Eivydd8c6e510b4a
diff --git a/client/src/pages/MediaCollections.jsx b/client/src/pages/MediaCollections.jsx
index 9c533df6e5..896c83eff7 100644
--- a/client/src/pages/MediaCollections.jsx
+++ b/client/src/pages/MediaCollections.jsx
@@ -276,38 +276,43 @@ export default function MediaCollections() {
<div className="text-gray-500 text-sm">Loading…</div>
) : (
<div className="space-y-2">
- {/* First run. Gated on the REAL collections, not `enriched` — the
- synthetic "Unsorted" entry is always prepended, so `enriched` is
- never empty and an `enriched.length === 0` gate would leave a
- fresh install staring at "1 empty collection hidden" with no copy
- telling it where collections come from. The grid below still
- renders alongside this when Unsorted has media in it. */}
- {collections.length === 0 && (
+ {/* Precedence chain, not independent gates. First run wins only when
+ no search is active — gated on the REAL collections, since the
+ synthetic "Unsorted" entry is always prepended and an
+ `enriched.length === 0` test would never fire. Otherwise the
+ hidden-empties notice and the empty-result panel render TOGETHER,
+ so the panel's "use Show above" can never point at a link that
+ isn't on screen. The grid is independent of both — a fresh install
+ with loose media shows the onboarding copy AND its Unsorted card. */}
+ {collections.length === 0 && !query ? (
<div className="text-gray-500 text-sm bg-port-card border border-port-border rounded-lg p-6 text-center">
No collections yet. Create one above, or use the folder icon on any image/video card to start a new collection.
</div>
+ ) : (
+ <>
+ {hiddenEmptyCount > 0 && (
+ <div className="text-xs text-gray-500">
+ {hiddenEmptyCount} empty {hiddenEmptyCount === 1 ? 'collection' : 'collections'} hidden.{' '}
+ <button type="button" onClick={() => updateParams({ empty: '1' })} className="text-port-accent hover:underline">
+ Show
+ </button>
+ </div>
+ )}
+ {visible.length === 0 && (
+ <div className="text-gray-500 text-sm bg-port-card border border-port-border rounded-lg p-6 text-center">
+ {/* "No match" is only true when the search itself came up
+ empty. When it matched rows that "Hide empty" then
+ removed, saying that would contradict the "N empty hidden
+ — Show" line above and send the user hunting for a
+ collection that does exist. */}
+ {matching.length === 0
+ ? 'No collections match that search.'
+ : 'Every collection here is empty — use Show above to see them.'}
+ </div>
+ )}
+ </>
)}
- {/* One notice for both the populated and the emptied-out grid, so the
- "Show" escape hatch has a single implementation. */}
- {collections.length > 0 && hiddenEmptyCount > 0 && (
- <div className="text-xs text-gray-500">
- {hiddenEmptyCount} empty {hiddenEmptyCount === 1 ? 'collection' : 'collections'} hidden.{' '}
- <button type="button" onClick={() => updateParams({ empty: '1' })} className="text-port-accent hover:underline">
- Show
- </button>
- </div>
- )}
- {collections.length > 0 && visible.length === 0 ? (
- <div className="text-gray-500 text-sm bg-port-card border border-port-border rounded-lg p-6 text-center">
- {/* "No match" is only true when the search itself came up empty.
- When it matched rows that "Hide empty" then removed, saying
- that would contradict the "N empty hidden — Show" line above
- and send the user hunting for a collection that does exist. */}
- {matching.length === 0
- ? 'No collections match that search.'
- : 'Every collection here is empty — use Show above to see them.'}
- </div>
- ) : visible.length === 0 ? null : (
+ {visible.length > 0 && (
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3">
{visible.map((c) => (
<div
diff --git a/client/src/pages/MediaCollections.test.jsx b/client/src/pages/MediaCollections.test.jsx
index a48653f458..66b830b71e 100644
--- a/client/src/pages/MediaCollections.test.jsx
+++ b/client/src/pages/MediaCollections.test.jsx
@@ -247,6 +247,17 @@ describe('MediaCollections', () => {
expect(screen.queryByText(/Every collection here is empty/)).not.toBeInTheDocument();
});
+ it('reports a failed search as a failed search, not as a fresh install', async () => {
+ const { listMediaCollections } = await import('../services/api');
+ listMediaCollections.mockResolvedValueOnce([]);
+ // Loose media but no collections yet — the exact population the onboarding
+ // copy is for. With a query active, that copy would answer the search with
+ // "No collections yet" and give no sign a filter was even applied.
+ renderPage('/media/collections?q=zzzz');
+ expect(await screen.findByText(/No collections match that search/)).toBeInTheDocument();
+ expect(screen.queryByText(/No collections yet/)).not.toBeInTheDocument();
+ });
+
it('offers the three sort options', async () => {
renderPage();
await waitFor(() => screen.getByText('Alpha'));