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): open the new collection on create instead of nudging the filter row

[._.]/ Adam Eivy4183b20b144d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index feb2331668..3e250914e5 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -7,7 +7,7 @@
## Media Gen
- **The favourite star on an image or video card is now reachable by keyboard.** The star sat inside the card's own click-to-preview button. A button nested in another button is invalid HTML with no defined behaviour, and here it left the star unreachable by keyboard and out of the tab order. The star and the badges are now siblings of the preview target rather than children of it, so the star is focusable and clicking it still favourites without also opening the preview. Three more controls with the same defect were fixed alongside it: the Plan/Execute/Verify button on a GSD phase row, the Dashboard link on a Chief-of-Staff GSD project card, and the tag filters on a SongBook entry — each was mouse-only, and each needed a click-suppressing workaround that is no longer necessary.
-- **[issue-3283] Media Collections can now be searched, sorted, and stripped of empty auto-created buckets.** Every Creative Director project and render bucket files itself away as a collection the moment it is created, so the grid filled with empty cards that all read as the same clipped `Creative Director: …` text — the trailing project name and date that told them apart were exactly what got cut off. The page now has a search box, a Recently updated / Name / Item count sort, and a "Hide empty" toggle that is on by default (with a "N empty hidden — Show" link when you want them back); collections that actually hold something, plus any you named yourself, sort ahead of the auto-generated empties; and the shared `Creative Director` prefix moved into a small badge above each title so the distinguishing tail stays readable. Your filters live in the URL, so a filtered view is shareable and survives going back from a collection.
+- **[issue-3283] Media Collections can now be searched, sorted, and stripped of empty auto-created buckets.** Every Creative Director project and render bucket files itself away as a collection the moment it is created, so the grid filled with empty cards that all read as the same clipped `Creative Director: …` text — the trailing project name and date that told them apart were exactly what got cut off. The page now has a search box, a Recently updated / Name / Item count sort, and a "Hide empty" toggle that is on by default (with a "N empty hidden — Show" link when you want them back); collections that actually hold something, plus any you named yourself, sort ahead of the auto-generated empties; and the shared `Creative Director` prefix moved into a small badge above each title so the distinguishing tail stays readable. Your filters live in the URL, so a filtered view is shareable and survives going back from a collection, and creating a collection now opens it — a brand-new bucket is empty by definition, so the filter row would otherwise swallow the thing you just made.
- **A collection whose cover image is missing now shows the syncing placeholder instead of a broken image.** Collection covers were plain `<img>` tags, so a cover pointing at a pruned video thumbnail — or at a federated collection whose files haven't been pulled yet — left the browser's broken-image icon on the card. Covers now use the same component as the rest of the media UI: they fall back to a "Syncing" tile and swap in the real image the moment the file arrives from a peer.
## Documentation
diff --git a/client/src/pages/MediaCollections.jsx b/client/src/pages/MediaCollections.jsx
index 3b7fcc4d2e..9c533df6e5 100644
--- a/client/src/pages/MediaCollections.jsx
+++ b/client/src/pages/MediaCollections.jsx
@@ -102,12 +102,13 @@ export default function MediaCollections() {
setCollections((prev) => [...prev, created]);
setName('');
toast.success(`Created "${created.name}"`);
- // A new collection is always empty, so with "Hide empty" on (the default)
- // it would be filtered straight back out and the create would read as
- // broken. Reveal the empties so the thing the user just made is visible.
- // (Referenced before its `const` in source order, but only ever called
- // from an event handler — well after the component body has run.)
- if (hideEmpty) updateParams({ empty: '1' });
+ // Open the new collection instead of dropping the user back on the grid.
+ // A new collection is always empty, so any filter state that hides
+ // empties — or an active search it doesn't match — would swallow it and
+ // make the create read as broken. Navigating is the one feedback that
+ // holds regardless of the filter row, and an empty bucket exists to be
+ // filled anyway.
+ navigate(`/media/collections/${encodeURIComponent(created.id)}`);
}
};
@@ -273,15 +274,22 @@ export default function MediaCollections() {
{loading ? (
<div className="text-gray-500 text-sm">Loading…</div>
- ) : enriched.length === 0 ? (
- <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>
) : (
<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 && (
+ <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>
+ )}
{/* One notice for both the populated and the emptied-out grid, so the
"Show" escape hatch has a single implementation. */}
- {hiddenEmptyCount > 0 && (
+ {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">
@@ -289,7 +297,7 @@ export default function MediaCollections() {
</button>
</div>
)}
- {visible.length === 0 ? (
+ {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
@@ -299,7 +307,7 @@ export default function MediaCollections() {
? 'No collections match that search.'
: 'Every collection here is empty — use Show above to see them.'}
</div>
- ) : (
+ ) : visible.length === 0 ? null : (
<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 a84cc27972..a48653f458 100644
--- a/client/src/pages/MediaCollections.test.jsx
+++ b/client/src/pages/MediaCollections.test.jsx
@@ -42,11 +42,14 @@ vi.mock('../hooks/useSyncIntegrity', () => ({
}));
// ── Mock buildUnsortedCollection ─────────────────────────────────────────────
+// Read at call time (inside the factory's returned function), so a test can
+// empty it to simulate a fresh install with no media at all.
+let mockUnsortedItems = [{ kind: 'image', ref: 'loose.png', addedAt: '2024-01-02' }];
vi.mock('../lib/unsorted', () => ({
buildUnsortedCollection: () => ({
id: '__unsorted__',
name: 'Unsorted',
- items: [{ kind: 'image', ref: 'loose.png', addedAt: '2024-01-02' }],
+ items: mockUnsortedItems,
synthetic: true,
}),
}));
@@ -62,6 +65,7 @@ function RouteProbe() {
return (
<>
<div data-testid="search-string">{location.search}</div>
+ <div data-testid="pathname">{location.pathname}</div>
<button type="button" onClick={() => navigate('/media/collections?q=alpha')}>external nav</button>
</>
);
@@ -77,7 +81,12 @@ function renderPage(entry = '/media/collections') {
}
describe('MediaCollections', () => {
- beforeEach(() => { vi.clearAllMocks(); });
+ beforeEach(() => {
+ vi.clearAllMocks();
+ // clearAllMocks resets calls, not implementations — restore the shared
+ // fixture so a test that emptied it can't leak into the next one.
+ mockUnsortedItems = [{ kind: 'image', ref: 'loose.png', addedAt: '2024-01-02' }];
+ });
it('renders non-empty collection names after loading', async () => {
renderPage();
@@ -199,17 +208,43 @@ describe('MediaCollections', () => {
expect(screen.queryByText(/No collections match that search/)).not.toBeInTheDocument();
});
- it('reveals the empties after creating a collection so the new one is visible', async () => {
+ it('opens the new collection after creating it, even under an active search', async () => {
const { createMediaCollection } = await import('../services/api');
- createMediaCollection.mockResolvedValue({ id: 'col-4', name: 'Fresh Bucket', items: [] });
+ createMediaCollection.mockResolvedValueOnce({ id: 'col-4', name: 'Fresh Bucket', items: [] });
const user = userEvent.setup();
- renderPage();
+ // `?q=alpha` is the hostile case: a brand-new collection is always empty
+ // AND doesn't match the search, so any grid-local feedback would be
+ // swallowed and the create would look like it failed.
+ renderPage('/media/collections?q=alpha');
await waitFor(() => screen.getByText('Alpha'));
await user.type(screen.getByLabelText('New collection name'), 'Fresh Bucket');
await user.click(screen.getByRole('button', { name: /create/i }));
- // A brand-new collection is always empty; without the reveal it would be
- // filtered straight back out and the create would look like it failed.
- expect(await screen.findByText('Fresh Bucket')).toBeInTheDocument();
+ await waitFor(() => expect(screen.getByTestId('pathname')).toHaveTextContent('/media/collections/col-4'));
+ });
+
+ it('preserves sibling URL params when one filter changes', async () => {
+ const user = userEvent.setup();
+ renderPage('/media/collections?q=beta&sort=name&empty=1');
+ await waitFor(() => screen.getByText('Beta'));
+ await user.selectOptions(screen.getByLabelText('Sort collections'), 'count');
+ await waitFor(() => expect(screen.getByTestId('search-string')).toHaveTextContent('sort=count'));
+ // A params merge built from a stale/blank snapshot would silently drop the
+ // search and the empty toggle the user set moments earlier.
+ expect(screen.getByTestId('search-string')).toHaveTextContent('q=beta');
+ expect(screen.getByTestId('search-string')).toHaveTextContent('empty=1');
+ });
+
+ it('shows the onboarding copy on a fresh install, not a hidden-empties notice', async () => {
+ const { listMediaCollections } = await import('../services/api');
+ listMediaCollections.mockResolvedValueOnce([]);
+ mockUnsortedItems = [];
+ renderPage();
+ expect(await screen.findByText(/No collections yet/)).toBeInTheDocument();
+ // The synthetic "Unsorted" entry is always prepended, so a gate on the
+ // enriched list would never fire this copy — and would instead tell a new
+ // user that 1 empty collection they never made is hidden.
+ expect(screen.queryByText(/empty collection/)).not.toBeInTheDocument();
+ expect(screen.queryByText(/Every collection here is empty/)).not.toBeInTheDocument();
});
it('offers the three sort options', async () => {