Skip to content

The agent that grows with you

feat(desktop): tier filter keeps plugins grouped; every chip on reads as All

Austin Pickett36400de0e8b2
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
index 962acf9db20..cfc967ad373 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
@@ -258,8 +258,11 @@ const detailRelated = (entries: CatalogEntry[], selected: CatalogEntry | undefin
selected && shown ? relatedEntries(entries, selected, RELATED_COUNT) : []
/** Discovery shelves show only while browsing everything. */
-const isDiscoverView = (facets: CatalogFacets, query: string) =>
- !facets.sources.length && !facets.categories.length && !facets.tags.length && !query && !facets.installedOnly
+/** 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. */
+const isDiscoverView = (facets: CatalogFacets, query: string, kind: CatalogKind) =>
+ (kind === 'plugins' || !facets.sources.length) && !facets.categories.length && !facets.tags.length && !query && !facets.installedOnly
function CatalogLoadState({ error, onRetry }: { error: Error | null; onRetry: () => void }) {
const { t } = useI18n()
@@ -362,7 +365,7 @@ export const CatalogBrowser = memo(function CatalogBrowser({
const visible = isSuperseded ? entries.filter(entry => !isSuperseded(entry)) : entries
const filtered = sortCatalog(filterCatalog(visible, facets, deferredQuery, isInstalled, kind), sort, kind)
- const discover = isDiscoverView(facets, deferredQuery)
+ const discover = isDiscoverView(facets, deferredQuery, kind)
const pageOrder = filtered
const selected = visible.find(entry => entry.id === selectedId) ?? filtered[0]
@@ -488,7 +491,7 @@ export const CatalogBrowser = memo(function CatalogBrowser({
key={`${filterKey}:${sort}:${deferredQuery}:${facets.installedOnly}`}
>
{discover ? (
- <CatalogDiscovery actions={actions} card={card} entries={filtered} kind={kind} onCategory={filters.chooseCategory} />
+ <CatalogDiscovery actions={actions} card={card} entries={filtered} kind={kind} narrowed={facets.sources.length > 0} 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.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
index 3775a4f9a12..77b6f0dfe11 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-discovery.tsx
@@ -30,12 +30,14 @@ 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 }: {
+export function CatalogDiscovery({ entries, kind, card, onCategory, actions, narrowed }: {
entries: CatalogEntry[]
kind: CatalogKind
card: (entry: CatalogEntry, index: number, variant: CatalogCardVariant, placement?: React.CSSProperties) => ReactNode
onCategory: (category: string) => void
actions?: ReactNode
+ /** A tier filter is on: the shelves show only those tiers, so no hero pick. */
+ narrowed?: boolean
}) {
const { t } = useI18n()
const [categoryLimit, setCategoryLimit] = useState(CATEGORY_PAGE)
@@ -43,7 +45,7 @@ export function CatalogDiscovery({ entries, kind, card, onCategory, actions }: {
const title = kind === 'plugins' ? t.skills.tabPlugins : t.skills.tabSkills
// Same pick as the website: curated ranks from the feed, rotated weekly.
- const featured = pickFeatured(entries, entry => ({
+ const featured = narrowed ? undefined : pickFeatured(entries, entry => ({
featured: entry.featured,
official: kind === 'plugins' ? pluginTier(entry) === 'official' : isOfficialSkillSource(entry.source),
pictured: Boolean(entry.imageUrl),
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.test.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.test.tsx
new file mode 100644
index 00000000000..65d77be4033
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.test.tsx
@@ -0,0 +1,46 @@
+import { fireEvent, render, screen } from '@testing-library/react'
+import { describe, expect, it, vi } from 'vitest'
+
+import { CatalogFilterBar } from './catalog-filter-bar'
+import { EMPTY_FACETS } from './catalog-query'
+
+const renderBar = (sources: string[], onSource = vi.fn()) => {
+ render(
+ <CatalogFilterBar
+ actions={null}
+ categories={[]}
+ facets={{ ...EMPTY_FACETS, sources }}
+ kind="plugins"
+ onCategory={vi.fn()}
+ onClear={vi.fn()}
+ onInstalled={vi.fn()}
+ onSource={onSource}
+ onTag={vi.fn()}
+ resultCount={0}
+ sortControl={null}
+ sources={['official', 'verified', 'community']}
+ tags={[]}
+ />
+ )
+ fireEvent.click(screen.getByRole('button', { name: /^tier$/i }))
+
+ return onSource
+}
+
+describe('tier chips', () => {
+ it('collapses to All when the last unselected tier is picked', () => {
+ const onSource = renderBar(['official', 'verified'])
+
+ fireEvent.click(screen.getByRole('button', { name: 'Community' }))
+ expect(onSource).toHaveBeenCalledWith(null)
+ })
+
+ it('toggles a tier normally while others stay unselected', () => {
+ const onSource = renderBar(['official'])
+
+ fireEvent.click(screen.getByRole('button', { name: 'Verified' }))
+ expect(onSource).toHaveBeenCalledWith('verified')
+ fireEvent.click(screen.getByRole('button', { name: 'Official' }))
+ expect(onSource).toHaveBeenCalledWith('official')
+ })
+})
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.tsx
index 22646cb1b46..8bdc3bd419a 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-filter-bar.tsx
@@ -46,7 +46,12 @@ export function CatalogFilterBar(props: CatalogFilterBarProps) {
: props.sources.map(value => ({ value, label: tierLabel(value) ?? catalogLabel(value) }))
const selected = props.facets[mode]
- const onSelect = mode === 'categories' ? props.onCategory : props.onSource
+ const select = mode === 'categories' ? props.onCategory : props.onSource
+
+ // Picking the last unselected chip means every value is on: that is "All".
+ const onSelect = (value: string | null) =>
+ select(value !== null && !selected.includes(value) && rows.every(row => row.value === value || selected.includes(row.value)) ? null : value)
+
const visible = rows.filter((row, index) => index < VISIBLE_CHIPS || selected.includes(row.value))
const overflow = rows.filter(row => !visible.includes(row))
const activeCount = props.facets.categories.length + props.facets.sources.length + props.facets.tags.length