Skip to content

The agent that grows with you

refactor(desktop): split catalog components under the complexity target

Austin Pickettceb2a5543a3a
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
index 92a1508f158..5cc39393caf 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx
@@ -27,14 +27,13 @@ import { CatalogListRow } from './catalog-list-row'
import { CATALOG_POINTER_ENABLED, trackCatalogPointer } from './catalog-pointer'
import {
catalogCategories,
+ type CatalogFacets,
type CatalogSort,
catalogSortOptions,
catalogSources,
catalogTags,
filterCatalog,
- relatedEntries,
- sortCatalog
-} from './catalog-query'
+ relatedEntries, sortCatalog } from './catalog-query'
import { $catalogCardView } from './store'
import { useCatalogFilters } from './use-catalog-filters'
@@ -106,6 +105,197 @@ function mergeInstalled(
return [...catalog, ...remaining.values()]
}
+function CatalogEntryInstall({
+ entry,
+ installed,
+ installedPending,
+ installing,
+ kind,
+ onInstall
+}: {
+ entry: CatalogEntry
+ installed: boolean
+ installedPending: boolean
+ installing: boolean
+ kind: CatalogKind
+ onInstall: () => void
+}) {
+ return (
+ <CatalogInstallSwitch
+ disabled={installedPending || installed || (kind === 'skills' && !entry.installIdentifier)}
+ installed={installed}
+ installing={installing}
+ name={entry.name}
+ onInstall={onInstall}
+ />
+ )
+}
+
+function CatalogSortSelect({
+ entries,
+ kind,
+ value,
+ onChange
+}: {
+ entries: CatalogEntry[]
+ kind: CatalogKind
+ value: CatalogSort
+ onChange: (value: CatalogSort) => void
+}) {
+ const { t } = useI18n()
+ const c = t.catalog
+
+ const sortLabels: Record<CatalogSort, string> = {
+ discover: c.featured,
+ stars: c.mostStarred,
+ newest: c.newest,
+ updated: c.recentlyUpdated,
+ name: c.alphabetical
+ }
+
+ return (
+ <Select onValueChange={next => onChange(next as CatalogSort)} value={value}>
+ <SelectTrigger aria-label={c.sortBy} className="w-full" size="sm">
+ <SelectValue placeholder={c.sortBy} />
+ </SelectTrigger>
+ <SelectContent>
+ {catalogSortOptions(entries, kind, sortLabels).map(({ value: option, label }) => (
+ <SelectItem key={option} value={option}>
+ {label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )
+}
+
+/** Search owns the header; kind-specific setup actions and the view toggle share the end slot. */
+function CatalogSearchHeader({
+ actions,
+ cardView,
+ hints,
+ kind,
+ query,
+ onQueryChange,
+ onToggleView
+}: {
+ actions: ReactNode
+ cardView: boolean
+ hints: CatalogBrowserProps['searchHints']
+ kind: CatalogKind
+ query: CatalogBrowserProps['query']
+ onQueryChange: CatalogBrowserProps['onQueryChange']
+ onToggleView: () => void
+}) {
+ const { t } = useI18n()
+ const c = t.catalog
+ const viewToggleLabel = cardView ? c.listView : c.cardView
+
+ return (
+ <header className="catalog-search-header shrink-0" data-catalog-header>
+ <CapabilitySearch
+ actions={
+ <>
+ {actions}
+ <Tip label={viewToggleLabel}>
+ <Button aria-label={viewToggleLabel} onClick={onToggleView} size="icon-xs" variant="ghost">
+ <Codicon name={cardView ? 'list-unordered' : 'extensions'} />
+ </Button>
+ </Tip>
+ </>
+ }
+ hints={hints}
+ onChange={value => onQueryChange?.(value)}
+ placeholder={kind === 'plugins' ? c.searchPlugins : c.searchSkills}
+ scope={kind === 'plugins' ? t.skills.tabPlugins : t.skills.tabSkills}
+ value={query ?? ''}
+ />
+ </header>
+ )
+}
+
+function CatalogMoreButton({ onMore }: { onMore: () => void }) {
+ const { t } = useI18n()
+
+ return (
+ <Button onClick={onMore} size="sm" variant="text">
+ {t.catalog.more}
+ </Button>
+ )
+}
+
+function CatalogFilteredCards({
+ entries,
+ card,
+ more,
+ onMore
+}: {
+ entries: CatalogEntry[]
+ card: (entry: CatalogEntry, accentIndex: number) => ReactNode
+ more: boolean
+ onMore: () => void
+}) {
+ const cards = entries.map((entry, index) => card(entry, index))
+
+ return (
+ <div className="catalog-filtered-results pt-(--capabilities-gap-lead) pb-2">
+ {CATALOG_MASONRY ? (
+ <Masonry data-catalog-hover-group>{cards}</Masonry>
+ ) : (
+ <div className="catalog-grid" data-catalog-hover-group>
+ {cards}
+ </div>
+ )}
+ {more && <CatalogMoreButton onMore={onMore} />}
+ </div>
+ )
+}
+
+/** Related picks are only worth computing while a detail is on screen. */
+const detailRelated = (entries: CatalogEntry[], selected: CatalogEntry | undefined, shown: boolean) =>
+ selected && shown ? relatedEntries(entries, selected, 3) : []
+
+/** 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
+
+function CatalogLoadState({ error, onRetry }: { error: Error | null; onRetry: () => void }) {
+ const { t } = useI18n()
+ const c = t.catalog
+
+ if (!error) {
+ return <PageLoader label={t.skills.loading} />
+ }
+
+ return (
+ <div className="grid h-full place-items-center p-5">
+ <ErrorState description={error.message} title={c.loadFailed}>
+ <Button onClick={onRetry} size="sm" variant="secondary">
+ {c.retry}
+ </Button>
+ </ErrorState>
+ </div>
+ )
+}
+
+function CatalogNoResults({ onClear }: { onClear: () => void }) {
+ const { t } = useI18n()
+ const c = t.catalog
+
+ return (
+ <PanelEmpty
+ action={
+ <Button onClick={onClear} size="sm" variant="secondary">
+ {c.clearFilters}
+ </Button>
+ }
+ description={c.tryAnother}
+ icon="search"
+ title={c.noResults}
+ />
+ )
+}
+
// Props take no destructuring defaults: React Compiler 1.0 skips components that have them.
export const CatalogBrowser = memo(function CatalogBrowser({
kind,
@@ -170,11 +360,11 @@ export const CatalogBrowser = memo(function CatalogBrowser({
const visible = isSuperseded ? entries.filter(entry => !isSuperseded(entry)) : entries
const filtered = sortCatalog(filterCatalog(visible, facets, deferredQuery, isInstalled), sort, kind)
- const discover = !facets.sources.length && !facets.categories.length && !facets.tags.length && !deferredQuery && !facets.installedOnly
+ const discover = isDiscoverView(facets, deferredQuery)
const pageOrder = filtered
const selected = visible.find(entry => entry.id === selectedId) ?? filtered[0]
- const related = selected && (!cardView || detailOpen) ? relatedEntries(filtered, selected, 3) : []
+ const related = detailRelated(filtered, selected, !cardView || detailOpen)
const searchFor = (value: string) => {
onQueryChange?.(value)
@@ -192,21 +382,14 @@ export const CatalogBrowser = memo(function CatalogBrowser({
}
// Installed entries get the owner's on/off switch; the rest install one-way.
- const entryAction = (entry: CatalogEntry) => {
- const custom = renderInstalledAction?.(entry)
-
- if (custom) {
- return custom
- }
-
- const installed = isInstalled(entry)
-
- return (
- <CatalogInstallSwitch
- disabled={Boolean(installedPending) || installed || (kind === 'skills' && !entry.installIdentifier)}
- installed={installed}
+ const entryAction = (entry: CatalogEntry) =>
+ renderInstalledAction?.(entry) || (
+ <CatalogEntryInstall
+ entry={entry}
+ installed={isInstalled(entry)}
+ installedPending={Boolean(installedPending)}
installing={isInstalling?.(entry) ?? false}
- name={entry.name}
+ kind={kind}
onInstall={() => {
if (kind === 'plugins') {
setDetailOpen(false)
@@ -216,7 +399,6 @@ export const CatalogBrowser = memo(function CatalogBrowser({
}}
/>
)
- }
const card = (entry: CatalogEntry, accentIndex: number, variant: CatalogCardVariant = 'default', placement?: React.CSSProperties) => (
<CatalogCard
@@ -248,30 +430,8 @@ export const CatalogBrowser = memo(function CatalogBrowser({
/>
) : null
- const sortLabels: Record<CatalogSort, string> = {
- discover: c.featured,
- stars: c.mostStarred,
- newest: c.newest,
- updated: c.recentlyUpdated,
- name: c.alphabetical
- }
+ const sortControl = <CatalogSortSelect entries={visible} kind={kind} onChange={filters.setSort} value={sort} />
- const sortControl = (
- <Select onValueChange={value => filters.setSort(value as CatalogSort)} value={sort}>
- <SelectTrigger aria-label={c.sortBy} className="w-full" size="sm">
- <SelectValue placeholder={c.sortBy} />
- </SelectTrigger>
- <SelectContent>
- {catalogSortOptions(visible, kind, sortLabels).map(({ value, label }) => (
- <SelectItem key={value} value={value}>
- {label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- )
-
- const viewToggleLabel = cardView ? c.listView : c.cardView
const filterKey = [facets.sources, facets.categories, facets.tags].map(list => list.join(',')).join(':')
return (
@@ -279,34 +439,18 @@ export const CatalogBrowser = memo(function CatalogBrowser({
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
<div className="flex min-h-0 min-w-0 flex-1 flex-col" data-catalog-results>
{/* Search owns the header; kind-specific setup actions and the view toggle share the end slot. */}
- <header
- className="catalog-search-header shrink-0"
- data-catalog-header
- >
- <CapabilitySearch
- actions={<>
- {headerActions}
- <Tip label={viewToggleLabel}>
- <Button
- aria-label={viewToggleLabel}
- onClick={() => {
- setDetailOpen(false)
- $catalogCardView.set(!cardView)
- }}
- size="icon-xs"
- variant="ghost"
- >
- <Codicon name={cardView ? 'list-unordered' : 'extensions'} />
- </Button>
- </Tip>
- </>}
- hints={searchHints}
- onChange={value => onQueryChange?.(value)}
- placeholder={kind === 'plugins' ? c.searchPlugins : c.searchSkills}
- scope={kind === 'plugins' ? t.skills.tabPlugins : t.skills.tabSkills}
- value={query ?? ''}
- />
- </header>
+ <CatalogSearchHeader
+ actions={headerActions}
+ cardView={cardView}
+ hints={searchHints}
+ kind={kind}
+ onQueryChange={onQueryChange}
+ onToggleView={() => {
+ setDetailOpen(false)
+ $catalogCardView.set(!cardView)
+ }}
+ query={query}
+ />
<CatalogFilterBar
actions={actions}
categories={catalogCategories(visible)}
@@ -328,27 +472,10 @@ export const CatalogBrowser = memo(function CatalogBrowser({
</CatalogAlert>
)}
<div className="min-h-0 flex-1">
- {isPending && !entries.length ? (
- <PageLoader label={t.skills.loading} />
- ) : error && !entries.length ? (
- <div className="grid h-full place-items-center p-5">
- <ErrorState description={error.message} title={c.loadFailed}>
- <Button onClick={() => void refetch()} size="sm" variant="secondary">
- {c.retry}
- </Button>
- </ErrorState>
- </div>
+ {!entries.length && (isPending || error) ? (
+ <CatalogLoadState error={error} onRetry={() => void refetch()} />
) : !selected ? (
- <PanelEmpty
- action={
- <Button onClick={clearFilters} size="sm" variant="secondary">
- {c.clearFilters}
- </Button>
- }
- description={c.tryAnother}
- icon="search"
- title={c.noResults}
- />
+ <CatalogNoResults onClear={clearFilters} />
) : cardView ? (
<>
<div className="flex h-full min-h-0 flex-col" data-catalog-cards={kind}>
@@ -360,20 +487,7 @@ export const CatalogBrowser = memo(function CatalogBrowser({
{discover ? (
<CatalogDiscovery actions={actions} card={card} entries={filtered} kind={kind} onCategory={filters.chooseCategory} />
) : (
- <div className="catalog-filtered-results pt-(--capabilities-gap-lead) pb-2">
- {CATALOG_MASONRY ? (
- <Masonry data-catalog-hover-group>{filtered.slice(0, limit).map((entry, index) => card(entry, index))}</Masonry>
- ) : (
- <div className="catalog-grid" data-catalog-hover-group>
- {filtered.slice(0, limit).map((entry, index) => card(entry, index))}
- </div>
- )}
- {filtered.length > limit && (
- <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">
- {c.more}
- </Button>
- )}
- </div>
+ <CatalogFilteredCards card={card} entries={filtered.slice(0, limit)} more={filtered.length > limit} onMore={() => setLimit(value => value + PAGE_SIZE)} />
)}
</div>
</div>
@@ -407,11 +521,7 @@ export const CatalogBrowser = memo(function CatalogBrowser({
selected={entry.id === selected.id}
/>
))}
- {filtered.length > limit && (
- <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">
- {c.more}
- </Button>
- )}
+ {filtered.length > limit && <CatalogMoreButton onMore={() => setLimit(value => value + PAGE_SIZE)} />}
</ListColumn>
<DetailColumn footer={c.snapshotHint}>
<div className="sm:hidden">
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx
index cc9b3dfe730..68b3fe90b34 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx
@@ -74,6 +74,24 @@ interface CatalogCardProps {
style?: CSSProperties
}
+const isEditorialArt = (entry: CatalogEntry) => Boolean(entry.imageUrl?.includes('official-art'))
+
+/** Compact and showcase cards only show first-party editorial art; the hero paints its own. */
+const showsCardImage = (entry: CatalogEntry, variant: CatalogCardVariant) =>
+ variant !== 'hero' && Boolean(entry.imageUrl) && ((variant !== 'compact' && variant !== 'showcase') || isEditorialArt(entry))
+
+function CatalogCardFooter({ entry, action, hero }: { entry: CatalogEntry; action: ReactNode; hero: boolean }) {
+ return (
+ <div className="catalog-card-footer">
+ <CatalogHeaderMeta entry={entry} />
+ <span className="flex shrink-0 items-center gap-3">
+ <CatalogRating entry={entry} />
+ {hero && <span className="catalog-hero-action relative shrink-0">{action}</span>}
+ </span>
+ </div>
+ )
+}
+
export function CatalogCard({ entry, action, accentIndex, onOpen, onCategory, onTag, onSearch, variant = 'default', style }: CatalogCardProps) {
return (
<article
@@ -82,12 +100,12 @@ export function CatalogCard({ entry, action, accentIndex, onOpen, onCategory, on
CARD_ACCENTS[accentIndex % CARD_ACCENTS.length]
)}
data-catalog-card
- data-catalog-editorial-art={(variant !== 'hero' && entry.imageUrl?.includes("official-art")) || undefined}
+ data-catalog-editorial-art={(variant !== 'hero' && isEditorialArt(entry)) || undefined}
data-catalog-variant={variant}
data-entry-id={entry.id}
style={style}
>
- {variant !== 'hero' && entry.imageUrl && ((variant !== 'compact' && variant !== 'showcase') || entry.imageUrl.includes('official-art')) && <CatalogImage className="catalog-card-image aspect-[2/1]" key={entry.imageUrl} src={entry.imageUrl} />}
+ {showsCardImage(entry, variant) && <CatalogImage className="catalog-card-image aspect-[2/1]" key={entry.imageUrl!} src={entry.imageUrl!} />}
{variant !== 'default' && <div className="catalog-card-topline">
<span className="min-w-0 truncate" title={entry.author || catalogLabel(entry.source)}>{entry.author || catalogLabel(entry.source)}</span>
{variant !== 'hero' && <span className="relative shrink-0">{action}</span>}
@@ -131,15 +149,7 @@ export function CatalogCard({ entry, action, accentIndex, onOpen, onCategory, on
onTag={onTag}
/>
</div>}
- {variant !== 'default' && (
- <div className="catalog-card-footer">
- <CatalogHeaderMeta entry={entry} />
- <span className="flex shrink-0 items-center gap-3">
- <CatalogRating entry={entry} />
- {variant === 'hero' && <span className="catalog-hero-action relative shrink-0">{action}</span>}
- </span>
- </div>
- )}
+ {variant !== 'default' && <CatalogCardFooter action={action} entry={entry} hero={variant === 'hero'} />}
{variant === 'default' && <div className="catalog-card-dates mt-auto px-3 pb-3">
<CatalogDates entry={entry} />
</div>}
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts b/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
index 8bb5f7a68b2..724266a1176 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
@@ -78,6 +78,110 @@ function webUrl(value: unknown): string | null {
export const catalogLabel = (value: string) =>
value.includes('.') ? value : value.replace(/[-_]+/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
+const isoDate = (value: unknown) => (Number.isFinite(Date.parse(text(value))) ? text(value) : undefined)
+
+/** Where an entry points: install id, source/docs links, artwork. */
+function catalogLinks(kind: CatalogKind, row: any, rawName: string, source: string) {
+ return {
+ installIdentifier:
+ kind === 'skills'
+ ? skillCatalogInstallIdentifier({
+ name: rawName,
+ source,
+ identifier: text(row.identifier),
+ installIdentifier: text(row.installIdentifier)
+ })
+ : null,
+ sourceUrl: webUrl(row.repo || row.sourceUrl),
+ docsUrl:
+ webUrl(row.docsUrl) || (text(row.docsPath) ? `${DOCS_ORIGIN}/docs/user-guide/skills/${text(row.docsPath)}` : null),
+ imageUrl: curationOwnsArtwork(kind, row) ? officialCatalogArtwork(kind, row) : catalogImageUrl(row.image),
+ screenshots:
+ kind === 'plugins'
+ ? strings(row.screenshots)
+ .map(catalogImageUrl)
+ .filter((url): url is string => url !== null)
+ : []
+ }
+}
+
+/** Ranking signals: dates, stars, curated rank. */
+function catalogSignals(kind: CatalogKind, row: any) {
+ return {
+ addedAt: isoDate(row.addedAt),
+ updatedAt: isoDate(row.updatedAt),
+ stars: typeof row.stars === 'number' && Number.isFinite(row.stars) ? row.stars : null,
+ featured: typeof row.featured === 'number' && row.featured > 0 ? row.featured : curatedFeaturedRank(kind, row)
+ }
+}
+
+function catalogEntry(kind: CatalogKind, row: any): CatalogEntry {
+ const rawName = text(row.name)
+ // Registry rows occasionally carry a stray front-matter delimiter ("---")
+ // as their name; show the slug instead of a blank title.
+ const name = /[\p{L}\p{N}]/u.test(rawName) ? rawName : text(row.identifier) || rawName
+ const source = text(kind === 'plugins' ? row.tier : row.source)
+ const identifier = text(row.identifier) || rawName
+ const caps = row.capabilities ?? {}
+ const category = text(row.category) || 'uncategorized'
+ const categoryLabel = text(row.categoryLabel) || category
+ const tags = strings(row.tags)
+ const tools = strings(caps.providesTools)
+ const hooks = strings(caps.providesHooks)
+ const middleware = strings(caps.providesMiddleware)
+ const commands = strings(row.commands)
+ const platforms = strings(row.platforms)
+ const requirements = strings(kind === 'plugins' ? caps.requiresEnv : row.envVars)
+ const author = text(row.maintainer ?? row.author)
+ const description = text(row.description)
+
+ return {
+ id: `${source}:${identifier}`,
+ name,
+ description,
+ overview: text(row.overview),
+ category,
+ categoryLabel,
+ source,
+ author,
+ identifier,
+ repo: text(row.repo),
+ sha: text(row.sha),
+ subdir: text(row.subdir),
+ version: text(row.version),
+ requiresHermes: text(row.requiresHermes),
+ tags,
+ tools,
+ hooks,
+ middleware,
+ commands,
+ license: text(row.license) || undefined,
+ platforms,
+ requirements,
+ ...catalogLinks(kind, row, rawName, source),
+ ...catalogSignals(kind, row),
+ search: [
+ name,
+ description,
+ text(row.overview),
+ author,
+ category,
+ categoryLabel,
+ source,
+ ...tags,
+ ...tools,
+ ...hooks,
+ ...platforms,
+ ...requirements,
+ ...commands,
+ ...middleware
+ ]
+ .filter(Boolean)
+ .join(' ')
+ .toLowerCase()
+ }
+}
+
export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {
if (!Array.isArray(data)) {
throw new Error('Invalid catalog response')
@@ -86,97 +190,11 @@ export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {
const entries = new Map<string, CatalogEntry>()
for (const row of data) {
- if (!row || typeof row !== 'object' || !text(row.name)) {
- continue
- }
+ if (row && typeof row === 'object' && text(row.name)) {
+ const entry = catalogEntry(kind, row)
- const rawName = text(row.name)
- // Registry rows occasionally carry a stray front-matter delimiter ("---")
- // as their name; show the slug instead of a blank title.
- const name = /[\p{L}\p{N}]/u.test(rawName) ? rawName : text(row.identifier) || rawName
- const source = text(kind === 'plugins' ? row.tier : row.source)
- const identifier = text(row.identifier) || rawName
- const id = `${source}:${identifier}`
- const caps = row.capabilities ?? {}
- const category = text(row.category) || 'uncategorized'
- const categoryLabel = text(row.categoryLabel) || category
- const tags = strings(row.tags)
- const tools = strings(caps.providesTools)
- const hooks = strings(caps.providesHooks)
- const middleware = strings(caps.providesMiddleware)
- const commands = strings(row.commands)
- const platforms = strings(row.platforms)
- const requirements = strings(kind === 'plugins' ? caps.requiresEnv : row.envVars)
- const author = text(row.maintainer ?? row.author)
- const description = text(row.description)
-
- entries.set(id, {
- id,
- name,
- description,
- overview: text(row.overview),
- category,
- categoryLabel,
- source,
- author,
- identifier,
- installIdentifier:
- kind === 'skills'
- ? skillCatalogInstallIdentifier({
- name: rawName,
- source,
- identifier: text(row.identifier),
- installIdentifier: text(row.installIdentifier)
- })
- : null,
- repo: text(row.repo),
- sha: text(row.sha),
- subdir: text(row.subdir),
- version: text(row.version),
- requiresHermes: text(row.requiresHermes),
- tags,
- tools,
- hooks,
- middleware,
- commands,
- license: text(row.license) || undefined,
- platforms,
- requirements,
- sourceUrl: webUrl(row.repo || row.sourceUrl),
- docsUrl:
- webUrl(row.docsUrl) ||
- (text(row.docsPath) ? `${DOCS_ORIGIN}/docs/user-guide/skills/${text(row.docsPath)}` : null),
- imageUrl: curationOwnsArtwork(kind, row) ? officialCatalogArtwork(kind, row) : catalogImageUrl(row.image),
- screenshots:
- kind === 'plugins'
- ? strings(row.screenshots)
- .map(catalogImageUrl)
- .filter((url): url is string => url !== null)
- : [],
- addedAt: Number.isFinite(Date.parse(text(row.addedAt))) ? text(row.addedAt) : undefined,
- updatedAt: Number.isFinite(Date.parse(text(row.updatedAt))) ? text(row.updatedAt) : undefined,
- stars: typeof row.stars === 'number' && Number.isFinite(row.stars) ? row.stars : null,
- featured: typeof row.featured === 'number' && row.featured > 0 ? row.featured : curatedFeaturedRank(kind, row),
- search: [
- name,
- description,
- text(row.overview),
- author,
- category,
- categoryLabel,
- source,
- ...tags,
- ...tools,
- ...hooks,
- ...platforms,
- ...requirements,
- ...commands,
- ...middleware
- ]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- })
+ entries.set(entry.id, entry)
+ }
}
return [...entries.values()]
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx
index de23212e9da..d014cdecda9 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx
@@ -29,6 +29,36 @@ interface CatalogDetailProps {
dialog: boolean
}
+/** Title, author line and outbound links at the top of the inspector. */
+function CatalogDetailHeader({ entry, action, dialog }: { entry: CatalogEntry; action: ReactNode; dialog?: boolean }) {
+ const { t } = useI18n()
+ const c = t.catalog
+ const Title = dialog ? DialogTitle : 'h3'
+
+ return (
+ <header className="space-y-3">
+ <div className="flex min-w-0 items-start gap-3">
+ <div className="min-w-0 flex-1">
+ <div className={cn('flex min-w-0 items-center gap-2', dialog && !entry.imageUrl && 'pr-7')}>
+ <Title className="min-w-0 flex-1 break-words text-lg font-semibold tracking-tight">{entry.name}</Title>
+ {action && <span className="shrink-0">{action}</span>}
+ </div>
+ <div className="mt-1 flex min-w-0 items-center gap-2 text-xs text-(--ui-text-tertiary)">
+ <span className="min-w-0 truncate">{entry.author || catalogLabel(entry.source)}</span>
+ <CatalogHeaderMeta entry={entry} />
+ </div>
+ </div>
+ </div>
+ {(entry.sourceUrl || entry.docsUrl) && (
+ <div className="flex flex-wrap gap-3 text-xs">
+ {entry.sourceUrl && <ExternalLink href={entry.sourceUrl}>{c.repository}</ExternalLink>}
+ {entry.docsUrl && <ExternalLink href={entry.docsUrl}>{c.documentation}</ExternalLink>}
+ </div>
+ )}
+ </header>
+ )
+}
+
/** The shared catalog inspector used by both Skills and Plugins. No destructuring
* defaults: React Compiler 1.0 bails on this component with them. */
export function CatalogDetail({
@@ -46,7 +76,6 @@ export function CatalogDetail({
const { t } = useI18n()
const c = t.catalog
const root = useRef<HTMLDivElement>(null)
- const Title = dialog ? DialogTitle : 'h3'
// In the modal the body (this root's parent) is the scroller; a new entry starts at its top.
useLayoutEffect(() => {
@@ -73,26 +102,7 @@ export function CatalogDetail({
src={entry.imageUrl}
/>
)}
- <header className="space-y-3">
- <div className="flex min-w-0 items-start gap-3">
- <div className="min-w-0 flex-1">
- <div className={cn('flex min-w-0 items-center gap-2', dialog && !entry.imageUrl && 'pr-7')}>
- <Title className="min-w-0 flex-1 break-words text-lg font-semibold tracking-tight">{entry.name}</Title>
- {action && <span className="shrink-0">{action}</span>}
- </div>
- <div className="mt-1 flex min-w-0 items-center gap-2 text-xs text-(--ui-text-tertiary)">
- <span className="min-w-0 truncate">{entry.author || catalogLabel(entry.source)}</span>
- <CatalogHeaderMeta entry={entry} />
- </div>
- </div>
- </div>
- {(entry.sourceUrl || entry.docsUrl) && (
- <div className="flex flex-wrap gap-3 text-xs">
- {entry.sourceUrl && <ExternalLink href={entry.sourceUrl}>{c.repository}</ExternalLink>}
- {entry.docsUrl && <ExternalLink href={entry.docsUrl}>{c.documentation}</ExternalLink>}
- </div>
- )}
- </header>
+ <CatalogDetailHeader action={action} dialog={dialog} entry={entry} />
<p className="whitespace-pre-wrap break-words text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-secondary)">
{entry.description}