Skip to content

The agent that grows with you

feat(desktop): several picked categories show as one shelf each

Austin Pickett68de2c251db0
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
index cfc967ad373..569a6515b19 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
@@ -258,11 +258,12 @@ const detailRelated = (entries: CatalogEntry[], selected: CatalogEntry | undefin
selected && shown ? relatedEntries(entries, selected, RELATED_COUNT) : []
/** Discovery shelves show only while browsing everything. */
-/** Shelves (not a flat grid) while nothing narrows the catalog — or, for
- * plugins, while only tiers do: Official / Verified stay their own shelves
- * and Community keeps its category shelves. */
+/** Shelves (not a flat grid) while nothing narrows the catalog, and also
+ * while only tiers (plugins) or several categories do: Official / Verified
+ * stay their own shelves, Community and multi-category picks keep their
+ * category shelves. One category is a drill-in, so it stays a flat grid. */
const isDiscoverView = (facets: CatalogFacets, query: string, kind: CatalogKind) =>
- (kind === 'plugins' || !facets.sources.length) && !facets.categories.length && !facets.tags.length && !query && !facets.installedOnly
+ (kind === 'plugins' || !facets.sources.length) && facets.categories.length !== 1 && !facets.tags.length && !query && !facets.installedOnly
function CatalogLoadState({ error, onRetry }: { error: Error | null; onRetry: () => void }) {
const { t } = useI18n()
@@ -491,7 +492,7 @@ export const CatalogBrowser = memo(function CatalogBrowser({
key={`${filterKey}:${sort}:${deferredQuery}:${facets.installedOnly}`}
>
{discover ? (
- <CatalogDiscovery actions={actions} card={card} entries={filtered} kind={kind} narrowed={facets.sources.length > 0} onCategory={filters.chooseCategory} />
+ <CatalogDiscovery actions={actions} byCategory={facets.categories.length > 1} card={card} entries={filtered} kind={kind} narrowed={facets.sources.length > 0 || facets.categories.length > 1} onCategory={filters.chooseCategory} />
) : (
<CatalogFilteredCards card={card} entries={filtered.slice(0, limit)} more={filtered.length > limit} onMore={() => setLimit(value => value + PAGE_SIZE)} />
)}
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-discovery.test.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.test.tsx
new file mode 100644
index 00000000000..b5278e688c0
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.test.tsx
@@ -0,0 +1,36 @@
+import { render } from '@testing-library/react'
+import { describe, expect, it } from 'vitest'
+
+import type { CatalogEntry } from './catalog-data'
+import { CatalogDiscovery } from './catalog-discovery'
+
+const entry = (name: string, category: string, source = 'community') =>
+ ({ id: name, name, source, category, categoryLabel: category, tags: [], search: name, stars: 1, imageUrl: null }) as unknown as CatalogEntry
+
+const sections = (container: HTMLElement) =>
+ [...container.querySelectorAll('[data-catalog-section]')].map(node => node.getAttribute('data-catalog-section')).filter(id => id !== 'developer')
+
+const renderDiscovery = (entries: CatalogEntry[], byCategory: boolean) =>
+ render(
+ <CatalogDiscovery
+ byCategory={byCategory}
+ card={item => <article key={item.id}>{item.name}</article>}
+ entries={entries}
+ kind="plugins"
+ narrowed={byCategory}
+ onCategory={() => {}}
+ />
+ ).container
+
+describe('multi-category discovery', () => {
+ const picked = [entry('m1', 'memory'), entry('t1', 'tools'), entry('o1', 'tools', 'official'), entry('o2', 'memory', 'official')]
+
+ it('gives every picked category its own shelf, small ones included, with no tier shelves', () => {
+ expect(sections(renderDiscovery(picked, true)).sort()).toEqual(['memory', 'tools'])
+ })
+
+ it('keeps the default page folding small categories and splitting tiers', () => {
+ // One official becomes the hero pick; the other keeps the Official shelf.
+ expect(sections(renderDiscovery(picked, false))).toEqual(['featured', 'official', 'more'])
+ })
+})
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
index 77b6f0dfe11..e9ad495ec51 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
@@ -30,7 +30,7 @@ const CATEGORY_PAGE = 8
/** Rows of the mixed "More to explore" shelf shown at first, and per "Show more". */
const LOOSE_ROWS_PAGE = 3
-export function CatalogDiscovery({ entries, kind, card, onCategory, actions, narrowed }: {
+export function CatalogDiscovery({ entries, kind, card, onCategory, actions, narrowed, byCategory }: {
entries: CatalogEntry[]
kind: CatalogKind
card: (entry: CatalogEntry, index: number, variant: CatalogCardVariant, placement?: React.CSSProperties) => ReactNode
@@ -38,6 +38,8 @@ export function CatalogDiscovery({ entries, kind, card, onCategory, actions, nar
actions?: ReactNode
/** A tier filter is on: the shelves show only those tiers, so no hero pick. */
narrowed?: boolean
+ /** Several categories picked: one shelf per category, tiers and small-shelf folding off. */
+ byCategory?: boolean
}) {
const { t } = useI18n()
const [categoryLimit, setCategoryLimit] = useState(CATEGORY_PAGE)
@@ -54,8 +56,8 @@ export function CatalogDiscovery({ entries, kind, card, onCategory, actions, nar
}))
const others = entries.filter(entry => entry !== featured)
- const tiered = kind === 'plugins' ? PLUGIN_TIERS.map(tier => ({ tier, ...t.catalog.tiers[tier], items: others.filter(entry => pluginTier(entry) === tier) })).filter(({ items }) => items.length) : []
- const remaining = kind === 'plugins' ? others.filter(entry => pluginTier(entry) === 'community') : others
+ const tiered = kind === 'plugins' && !byCategory ? PLUGIN_TIERS.map(tier => ({ tier, ...t.catalog.tiers[tier], items: others.filter(entry => pluginTier(entry) === tier) })).filter(({ items }) => items.length) : []
+ const remaining = kind === 'plugins' && !byCategory ? others.filter(entry => pluginTier(entry) === 'community') : others
// Plugins with an unlisted category land in `general`, as in every other plugin grouping.
const sections: [string, string, CatalogEntry[]][] = (
@@ -66,8 +68,10 @@ export function CatalogDiscovery({ entries, kind, card, onCategory, actions, nar
// A category too small to fill a row reads as a stray full-width strip; those
// fold into one mixed shelf at the end instead.
- const shelves = sections.filter(([, , items]) => items.length >= MIN_SHELF)
- const loose = sections.filter(([, , items]) => items.length < MIN_SHELF).flatMap(([, , items]) => items)
+ // (A category the user picked always gets its own shelf, however small.)
+ const minShelf = byCategory ? 1 : MIN_SHELF
+ const shelves = sections.filter(([, , items]) => items.length >= minShelf)
+ const loose = sections.filter(([, , items]) => items.length < minShelf).flatMap(([, , items]) => items)
const bento = (items: CatalogEntry[], rows?: number, flip = false) => (
<div className="catalog-bento" data-catalog-hover-group>