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: keep the mood-board picker out of the collection auto-empty bucketing (#3312)
[._.]/ Adam Eivyd787cc1c15c5
diff --git a/client/src/components/media/CollectionPickerShell.jsx b/client/src/components/media/CollectionPickerShell.jsxindex 9254c89c3a..8f8852bf92 100644--- a/client/src/components/media/CollectionPickerShell.jsx+++ b/client/src/components/media/CollectionPickerShell.jsx@@ -30,7 +30,9 @@ import { applyCollectionView } from '../../lib/mediaCollectionList.js';// collection API so the two collection pickers need no extra wiring, but mood-// board (or any future `{ id, name, items }`-shaped) pickers pass their own// loader/creator + nouns. The record shape the shell assumes is minimal:-// `{ id, name }` plus whatever `renderItem` reads.+// `{ id, name }` plus whatever `renderItem` reads. `orderItems` is injectable+// for the same reason — the default is the media-collection search/ordering+// view, which is domain-specific and must be overridden alongside the loader.//// `excludeId` is a single-item allow-list filter so BulkTargetPicker can hide// the current collection from its move/copy target list.@@ -39,6 +41,22 @@ const DEFAULT_MENU_WIDTH = 260;const MENU_GAP = 6;const SEARCH_THRESHOLD = 6;+// Default row search + ordering: the same view the /media/collections grid uses+// (#3283), so the picker and the grid agree on what a query matches and what+// order rows land in — auto-generated empties sink to the bottom instead of+// burying the real collections in the raw list order (#3312).+//+// "Hide empty" is deliberately NOT applied: filing an item INTO an empty+// collection is the picker's main job, so the empties are ordered last, never+// removed. The AND-token matcher replaces the old single-substring filter — it's+// a strict superset (every token of a query is itself a substring of that+// query), so nothing that matched before stops matching, and multi-word queries+// now match in any order, which matters once the shared "Creative Director: "+// prefix lives in a badge and users type only the tail.+//+// Module-scope so the default prop value is referentially stable across renders.+const orderCollectionRows = (records, query) => applyCollectionView(records, { query });+export default function CollectionPickerShell({anchorRef,open = true,@@ -65,6 +83,11 @@ export default function CollectionPickerShell({// `{ id, name, ... }`; `createItem({ name })` resolves to the created record.loadItems = listMediaCollections,createItem = createMediaCollection,+ // `(records, query) => records` — filters AND orders the rows. Defaults to the+ // media-collection view; a non-collection data source (mood boards) must pass+ // its own, since the default's "auto-generated" bucketing is collection+ // provenance and would misread a board that merely looks like one.+ orderItems = orderCollectionRows,searchPlaceholder = 'Search collections…',}) {const [collectionsState, setCollectionsState] = useState(collectionsProp ?? null);@@ -121,23 +144,11 @@ export default function CollectionPickerShell({return () => { cancelled = true; };}, [open, collectionsProp, loadItems]);- // Search + ordering come from the same helper the /media/collections grid uses- // (#3283), so the picker and the grid agree on what a query matches and what- // order rows land in — auto-generated empties sink to the bottom instead of- // burying the real collections in the raw list order (#3312).- //- // "Hide empty" is deliberately NOT applied here: filing an item INTO an empty- // collection is the picker's main job, so the empties are ordered last, never- // removed. The AND-token matcher replaces the old single-substring filter —- // it's a strict superset (every token of a query is itself a substring of that- // query), so nothing that matched before stops matching, and multi-word- // queries now match in any order, which matters once the shared- // "Creative Director: " prefix lives in a badge and users type only the tail.const filtered = useMemo(() => {if (!collectionsState) return null;const base = excludeId ? collectionsState.filter((c) => c.id !== excludeId) : collectionsState;- return applyCollectionView(base, { query });- }, [collectionsState, query, excludeId]);+ return orderItems(base, query);+ }, [collectionsState, query, excludeId, orderItems]);// Close on outside-click / Escape — placement and scroll/resize reflow are// owned by usePopoverPosition; this effect only handles dismissal.diff --git a/client/src/components/media/PinToMoodBoardMenu.jsx b/client/src/components/media/PinToMoodBoardMenu.jsxindex 8dbf34fc87..2db5b6d228 100644--- a/client/src/components/media/PinToMoodBoardMenu.jsx+++ b/client/src/components/media/PinToMoodBoardMenu.jsx@@ -2,6 +2,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';import { LayoutGrid, Check } from 'lucide-react';import toast from '../ui/Toast';import CollectionPickerShell from './CollectionPickerShell';+import { tokenizeQuery, matchHaystack } from '../../lib/mediaSearch.js';import {listMoodBoards,createMoodBoard,@@ -38,6 +39,21 @@ const SIZES = {// rejects anything else, so we must not send a non-media key as `mediaKey`.const isValidMediaKey = (key) => /^(image|video):[^:]+$/.test(key || '');+// Row search for the board list. The shell's default (#3312) is the media-+// COLLECTION view, whose bucket ordering sinks auto-generated empties — that+// classification reads collection provenance a board record simply doesn't+// carry, so a user's empty board that happened to be named "Universe: Refs"+// would be demoted for looking like an auto-created collection. Boards keep the+// server's `updatedAt DESC` order and only get the shared AND-token filter over+// name + description.+const filterBoards = (boards, query) => {+ const tokens = tokenizeQuery(query);+ if (tokens.length === 0) return boards;+ return boards.filter((b) => (+ matchHaystack(`${b?.name || ''} ${b?.description || ''}`.toLowerCase(), tokens)+ ));+};+// Find the board item this asset is pinned as — by mediaKey when we have a real// one, else by the imageUrl we pinned it under.const findPinned = (board, { mediaKey, imageUrl }) =>@@ -178,6 +194,7 @@ export default function PinToMoodBoardMenu({ item, size = 'sm' }) {onCreated={handleCreated}loadItems={listMoodBoards}createItem={createMoodBoard}+ orderItems={filterBoards}/></>);diff --git a/client/src/components/media/PinToMoodBoardMenu.test.jsx b/client/src/components/media/PinToMoodBoardMenu.test.jsxindex fe6545db73..6ccac3ce92 100644--- a/client/src/components/media/PinToMoodBoardMenu.test.jsx+++ b/client/src/components/media/PinToMoodBoardMenu.test.jsx@@ -121,6 +121,23 @@ describe('PinToMoodBoardMenu', () => {expect(api.removeMoodBoardItem).toHaveBeenCalledWith('b1', 'mbi-7', { silent: true });});+ it('keeps the server board order — collection auto-empty bucketing must not apply (#3312)', async () => {+ // A board a user named like an auto-created collection. The shell's default+ // ordering would classify it as an auto-generated empty and sink it; boards+ // inject their own filter and keep `updatedAt DESC` from the server.+ api.listMoodBoards.mockResolvedValue([+ { id: 'b0', name: 'Universe: Refs', items: [], updatedAt: '2026-01-09T00:00:00Z' },+ { id: 'b1', name: 'Palettes', items: [{ id: 'mbi-1', type: 'image' }], updatedAt: '2026-01-08T00:00:00Z' },+ ]);++ render(<PinToMoodBoardMenu item={imageItem} />);+ fireEvent.click(screen.getByTitle('Pin to mood board'));+ await screen.findByRole('menuitemcheckbox', { name: /Palettes/ });++ expect(screen.getAllByRole('menuitemcheckbox').map((el) => el.textContent.trim()))+ .toEqual(['Universe: Refs', 'Palettes']);+ });+it('renders nothing when there is no valid media-key and no renderable thumbnail', () => {const { container } = render(<PinToMoodBoardMenu item={{ kind: 'image', key: 'noun:x.png', previewUrl: 'blob:abc' }} />,