The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(catalog): browse-only catalog with clickable cards, category reels, and plugin enable/disable switches
brooklyn!78e2bcfaa973
diff --git a/apps/desktop/src/app/capabilities/catalog/capability-tabs.tsx b/apps/desktop/src/app/capabilities/catalog/capability-tabs.tsxdeleted file mode 100644index d227a7797a3..00000000000--- a/apps/desktop/src/app/capabilities/catalog/capability-tabs.tsx+++ /dev/null@@ -1,33 +0,0 @@-import type { ReactNode } from 'react'--import { TextTab } from '@/components/ui/text-tab'-import { useI18n } from '@/i18n'--export type CapabilityView = 'installed' | 'browse'--interface CapabilityTabsProps {- value: CapabilityView- onChange: (value: CapabilityView) => void- actions?: ReactNode-}--/** Shared Installed / Browse navigation for Skills and Plugins. */-export function CapabilityTabs({ value, onChange, actions }: CapabilityTabsProps) {- const { t } = useI18n()-- return (- <div className="flex shrink-0 items-center gap-4 px-3 py-1" data-capability-tabs>- <TextTab- active={value === 'installed'}- aria-pressed={value === 'installed'}- onClick={() => onChange('installed')}- >- {t.catalog.installed}- </TextTab>- <TextTab active={value === 'browse'} aria-pressed={value === 'browse'} onClick={() => onChange('browse')}>- {t.catalog.browse}- </TextTab>- {actions && <div className="-my-0.5 -mr-2 ml-auto flex h-6 items-center gap-2">{actions}</div>}- </div>- )-}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-alert.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-alert.tsxnew file mode 100644index 00000000000..ac7ad928269--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-alert.tsx@@ -0,0 +1,31 @@+import type { ReactNode } from 'react'++import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'+import { Button } from '@/components/ui/button'+import { Codicon } from '@/components/ui/codicon'++/** A load failure above the catalog results that keeps what's already shown. */+export function CatalogAlert({+ title,+ children,+ retryLabel,+ onRetry+}: {+ title: string+ children?: ReactNode+ retryLabel: string+ onRetry: () => void+}) {+ return (+ <Alert className="mx-3 w-auto shrink-0" variant="warning">+ <Codicon name="warning" />+ <AlertTitle>{title}</AlertTitle>+ <AlertDescription>+ {children}+ <Button onClick={onRetry} size="xs" variant="text">+ {retryLabel}+ </Button>+ </AlertDescription>+ </Alert>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-browser.test.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-browser.test.tsxindex f2bed3c2381..efdc090e075 100644--- a/apps/desktop/src/app/capabilities/catalog/catalog-browser.test.tsx+++ b/apps/desktop/src/app/capabilities/catalog/catalog-browser.test.tsx@@ -30,8 +30,8 @@ function setup(kind: CatalogKind) {installIdentifier: `official/${name}`,source: 'official',tier: 'official',- category: 'research',- description: `${name} research workflow`,+ category: name === 'alpha' ? 'memory' : 'voice',+ description: `${name} workflow`,repo: `https://github.com/example/${name}`,sourceUrl: `https://github.com/example/${name}`,docsUrl: `https://example.com/${name}`@@ -62,27 +62,25 @@ function setup(kind: CatalogKind) {return { entries, onInstall, ...render(<Harness />) }}+const card = (name: string) =>+ screen.getAllByRole('article').find(article => within(article).queryByRole('button', { name }))!+describe.each(['skills', 'plugins'] as const)('%s catalog layouts', kind => {- it('defaults to cards with icon-only layout controls and whole-card hover', () => {+ it('defaults to cards, with installed entries already switched on', () => {const { container } = setup(kind)- const cards = screen.getAllByRole('article')- const cardView = screen.getByRole('button', { name: 'Card view', pressed: true })-- expect(cards).toHaveLength(2)- expect(cardView.textContent).toBe('')- expect(cardView.querySelector('.codicon-extensions')).not.toBeNull()- expect(screen.getByRole('button', { name: 'List view' }).querySelector('.codicon-list-unordered')).not.toBeNull()- expect(cards[0].classList.contains('row-hover')).toBe(true)- expect(within(cards[0]).getByRole('button', { name: 'alpha' }).classList.contains('row-hover')).toBe(false)++ expect(screen.getAllByRole('article')).toHaveLength(2)expect(container.querySelector('[data-catalog-list]')).toBeNull()- expect(within(cards[1]).getByRole<HTMLButtonElement>('button', { name: 'Installed' }).disabled).toBe(true)+ expect(screen.getByRole('button', { name: 'List view' })).toBeTruthy()+ expect(+ within(card('beta')).getByRole<HTMLButtonElement>('switch', { name: 'Added beta' }).getAttribute('aria-checked')+ ).toBe('true')})- it('offers installation directly on a card without opening its details', () => {+ it('installs from the card switch without opening its details', () => {const { entries, onInstall } = setup(kind)- const card = screen.getAllByRole('article')[0]- fireEvent.click(within(card).getByRole('button', { name: 'Install' }))+ fireEvent.click(within(card('alpha')).getByRole('switch', { name: 'Add alpha' }))expect(onInstall).toHaveBeenCalledExactlyOnceWith(entries[0])expect(screen.queryByRole('dialog')).toBeNull()@@ -93,10 +91,9 @@ describe.each(['skills', 'plugins'] as const)('%s catalog layouts', kind => {fireEvent.click(screen.getByRole('button', { name: 'alpha' }))const dialog = screen.getByRole('dialog', { name: 'alpha' })- expect(within(dialog).getByRole('heading', { name: 'alpha' })).toBeTruthy()expect(within(dialog).getByRole('link', { name: 'Repository' }).getAttribute('href')).toBe(entries[0].sourceUrl)expect(within(dialog).getByRole('link', { name: 'Documentation' }).getAttribute('href')).toBe(entries[0].docsUrl)- fireEvent.click(within(dialog).getByRole('button', { name: 'Install' }))+ fireEvent.click(within(dialog).getByRole('switch', { name: 'Add alpha' }))expect(onInstall).toHaveBeenCalledExactlyOnceWith(entries[0])if (kind === 'plugins') {@@ -111,24 +108,23 @@ describe.each(['skills', 'plugins'] as const)('%s catalog layouts', kind => {it('preserves the parent search and filter when switching to list and back', async () => {const { container } = setup(kind)const search = screen.getByRole<HTMLInputElement>('textbox', { name: 'Search catalog' })- fireEvent.change(search, { target: { value: 'alpha' } })+ fireEvent.change(search, { target: { value: 'workflow' } })+ fireEvent.click(screen.getByRole('button', { name: /^Memory/, pressed: false }))await waitFor(() => expect(screen.getAllByRole('article')).toHaveLength(1))- fireEvent.click(screen.getByRole('combobox', { name: 'Category' }))- fireEvent.click(screen.getByRole('option', { name: 'Research' }))+fireEvent.click(screen.getByRole('button', { name: 'List view' }))expect(container.querySelector(`[data-catalog-list="${kind}"]`)).not.toBeNull()expect(screen.queryByRole('article')).toBeNull()expect(screen.getByRole('heading', { name: 'alpha' })).toBeTruthy()- expect(screen.getByRole('combobox', { name: 'Category' }).textContent).toContain('Research')+ expect(screen.queryByRole('heading', { name: 'beta' })).toBeNull()+ expect(screen.getByRole('button', { name: /^Memory/, pressed: true })).toBeTruthy()expect(screen.getByRole('textbox', { name: 'Search catalog' })).toBe(search)- expect(search.value).toBe('alpha')- expect(screen.getByRole('status').textContent).toBe('1 result')+ expect(search.value).toBe('workflow')fireEvent.click(screen.getByRole('button', { name: 'Card view' }))expect(screen.getAllByRole('article')).toHaveLength(1)- expect(screen.getByRole('textbox', { name: 'Search catalog' })).toBe(search)- expect(screen.getByRole('combobox', { name: 'Category' }).textContent).toContain('Research')+ expect(screen.getByRole('button', { name: /^Memory/, pressed: true })).toBeTruthy()expect(screen.queryByRole('dialog')).toBeNull()})})@@ -140,7 +136,6 @@ it('shares the saved layout choice when moving between Skills and Plugins', () =cleanup()const { container } = setup('plugins')- expect(screen.getByRole('button', { name: 'List view', pressed: true })).toBeTruthy()expect(container.querySelector('[data-catalog-list="plugins"]')).not.toBeNull()fireEvent.click(screen.getByRole('button', { name: 'Card view' }))expect($catalogCardView.get()).toBe(true)diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsxindex 02eac5e0688..14009de5a11 100644--- a/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx+++ b/apps/desktop/src/app/capabilities/catalog/catalog-browser.tsx@@ -1,467 +1,459 @@+import { groupCatalogPlugins, PLUGIN_CATEGORIES } from '@hermes/shared'import { useStore } from '@nanostores/react'-import { memo, type ReactNode, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'+import { memo, type ReactNode, useDeferredValue, useEffect, useRef, useState } from 'react'import { PageLoader } from '@/components/page-loader'-import { ActionStatus } from '@/components/ui/action-status'-import { Badge } from '@/components/ui/badge'import { Button } from '@/components/ui/button'-import { Codicon, codiconIcon } from '@/components/ui/codicon'-import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'+import { Codicon } from '@/components/ui/codicon'import { ErrorState } from '@/components/ui/error-state'-import { RowButton } from '@/components/ui/row-button'-import { SegmentedControl } from '@/components/ui/segmented-control'+import { Masonry } from '@/components/ui/masonry'+import { Reel } from '@/components/ui/reel'+import { SearchField } from '@/components/ui/search-field'import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'+import { Tip } from '@/components/ui/tooltip'import { useI18n } from '@/i18n'-import { ExternalLink } from '@/lib/external-link'import { cn } from '@/lib/utils'-import { DetailColumn, ListColumn, ListStrip, ListStripLabel, MasterDetail, ToolChip } from '../../master-detail'+import { DetailColumn, ListColumn, MasterDetail } from '../../master-detail'import { PanelEmpty } from '../../overlays/panel'-import { prettyName } from '../../settings/helpers'-import type { CapabilityView } from './capability-tabs'+import { CatalogAlert } from './catalog-alert'+import { CatalogCard } from './catalog-card'import { type CatalogEntry, type CatalogKind, useCatalog } from './catalog-data'+import { CatalogDetail } from './catalog-detail'+import { CatalogDetailDialog } from './catalog-detail-dialog'+import { CatalogFilters } from './catalog-filters'+import { CatalogInstallSwitch } from './catalog-install-switch'+import { CatalogListRow } from './catalog-list-row'+import { CATALOG_POINTER_ENABLED, trackCatalogPointer } from './catalog-pointer'+import {+ catalogCategories,+ type CatalogSort,+ catalogSortOptions,+ catalogSources,+ catalogTags,+ filterCatalog,+ relatedEntries,+ sortCatalog+} from './catalog-query'import { $catalogCardView } from './store'+import { useCatalogFilters } from './use-catalog-filters'interface CatalogBrowserProps {kind: CatalogKindquery?: stringonQueryChange?: (value: string) => void- view?: CapabilityViewisInstalled: (entry: CatalogEntry) => booleanonInstall: (entry: CatalogEntry) => voidisInstalling?: (entry: CatalogEntry) => booleaninstalledEntries?: CatalogEntry[]+ matchInstalled?: (entry: CatalogEntry) => CatalogEntry | undefined+ actions?: ReactNode+ headerActions?: ReactNode+ installedPending?: boolean+ notice?: ReactNoderenderInstalledDetail?: (entry: CatalogEntry) => ReactNode+ renderInstalledAction?: (entry: CatalogEntry) => ReactNodeselectedEntryId?: string | null- onSelectEntry?: (id: string | null) => void}const PAGE_SIZE = 60-const ListViewIcon = codiconIcon('list-unordered')-const CardViewIcon = codiconIcon('extensions')+// The skills hub carries ~10k distinct tags; the rail is for browsing, search covers the tail.+const TAG_LIMIT = 16+// Discovery shelves preview a category; "See all" opens the full list. Every+// rendered card is restyled whenever a modal locks the page.+const SHELF_SIZE = 6+/** On: masonry lanes. Off: fallback grid whose rows share one height (`.catalog-grid`). */+const CATALOG_MASONRY = true+/** Merge the public feed with installed rows: a catalog entry that matches an+ * installed one takes the installed id (so selection and install state line+ * up); installed rows with no catalog match are appended. */+function mergeInstalled(+ data: CatalogEntry[],+ installedEntries: CatalogEntry[],+ matchInstalled?: (entry: CatalogEntry) => CatalogEntry | undefined+) {+ const remaining = new Map(installedEntries.map(entry => [entry.id, entry]))+ const seen = new Set<string>()++ const catalog = data.flatMap(entry => {+ const installed = matchInstalled?.(entry)++ if (!installed) {+ return [entry]+ }+ remaining.delete(installed.id)++ if (seen.has(installed.id)) {+ return []+ }+ seen.add(installed.id)++ return [+ {+ ...entry,+ id: installed.id,+ version: installed.version || entry.version,+ search: `${entry.search} ${installed.search}`+ }+ ]+ })++ return [...catalog, ...remaining.values()]+}++// Props take no destructuring defaults: React Compiler 1.0 skips components that have them.export const CatalogBrowser = memo(function CatalogBrowser({kind,isInstalled,onInstall,isInstalling,installedEntries,+ matchInstalled,+ actions,+ headerActions,+ installedPending,+ notice,renderInstalledDetail,+ renderInstalledAction,selectedEntryId,- onSelectEntry,- view = 'browse',- query = '',+ query,onQueryChange}: CatalogBrowserProps) {const { t } = useI18n()const c = t.catalogconst cardView = useStore($catalogCardView)- const { data, isPending, error, refetch } = useCatalog(kind, view === 'browse')- const deferredQuery = useDeferredValue(query.trim().toLowerCase())- const [source, setSource] = useState('all')- const [category, setCategory] = useState('all')- const [localSelectedId, setLocalSelectedId] = useState<string | null>(null)- const selectedId = selectedEntryId === undefined ? localSelectedId : selectedEntryId-- const setSelectedId = (id: string | null) => {- setLocalSelectedId(id)- onSelectEntry?.(id)- }-+ const { data, isPending, error, refetch } = useCatalog(kind)+ const deferredQuery = useDeferredValue((query ?? '').trim().toLowerCase())+ const [selectedId, setSelectedId] = useState<string | null>(selectedEntryId ?? null)const [detailOpen, setDetailOpen] = useState(false)- const selectedCardRef = useRef<HTMLButtonElement | null>(null)const [limit, setLimit] = useState(PAGE_SIZE)- const entries = useMemo(() => {- return view === 'installed' ? (installedEntries ?? []) : (data ?? [])- }, [data, installedEntries, view])-- const sources = useMemo(() => [...new Set(entries.map(entry => entry.source))], [entries])-- const categories = useMemo(() => {- const values = new Map<string, string>()-- for (const entry of entries) {- if (source === 'all' || entry.source === source) {- values.set(entry.category, entry.categoryLabel)- }- }-- return [...values].sort((a, b) => a[1].localeCompare(b[1]))- }, [entries, source])-- const filtered = useMemo(- () =>- entries.filter(- entry =>- (view === 'installed' || source === 'all' || entry.source === source) &&- (view === 'installed' || category === 'all' || entry.category === category) &&- (!deferredQuery || entry.search.includes(deferredQuery))- ),- [entries, source, category, deferredQuery, view]- )-- const selected = filtered.find(entry => entry.id === selectedId) ?? filtered[0]- const installedDetail = selected ? renderInstalledDetail?.(selected) : null-const resetSelection = () => {setLimit(PAGE_SIZE)setSelectedId(null)setDetailOpen(false)}+ const filters = useCatalogFilters(kind, resetSelection)+ const { facets, sort } = filters++ // Clearing the query only widens results, and a deep link clears it while selecting its target.useEffect(() => {setLimit(PAGE_SIZE)- setLocalSelectedId(null)- setDetailOpen(Boolean(selectedEntryId))- }, [deferredQuery, selectedEntryId])++ if (deferredQuery) {+ setSelectedId(null)+ }+ }, [deferredQuery])++ // A deep link asks to open one entry; selection stays local afterwards.+ useEffect(() => {+ if (!selectedEntryId) {+ return+ }+ setSelectedId(selectedEntryId)+ setDetailOpen(true)+ }, [selectedEntryId])++ const root = useRef<HTMLDivElement>(null)+ useEffect(() => (CATALOG_POINTER_ENABLED && root.current ? trackCatalogPointer(root.current) : undefined), [])++ const entries = mergeInstalled(data ?? [], installedEntries ?? [], matchInstalled)+ const filtered = sortCatalog(filterCatalog(entries, facets, deferredQuery, isInstalled), sort, kind)+ const discover =+ kind === 'plugins' && !facets.categories.length && !facets.tags.length && !deferredQuery && !facets.installedOnly+ const sections =+ discover && cardView+ ? groupCatalogPlugins(filtered).map(([key, items]) => ({ key, ...PLUGIN_CATEGORIES[key], entries: items }))+ : []+ const pageOrder = sections.length ? sections.flatMap(section => section.entries) : filtered++ const selected = entries.find(entry => entry.id === selectedId) ?? filtered[0]+ const related = selected && (!cardView || detailOpen) ? relatedEntries(filtered, selected, 3) : []++ const searchFor = (value: string) => {+ onQueryChange?.(value)+ resetSelection()+ }const clearFilters = () => {onQueryChange?.('')- setSource('all')- setCategory('all')- resetSelection()+ filters.clear()}- const installButton = (entry: CatalogEntry) => {+ const openEntry = (entry: CatalogEntry) => {+ setSelectedId(entry.id)+ setDetailOpen(true)+ }++ // 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)- const installing = isInstalling?.(entry) ?? falsereturn (- <Button- disabled={installed || installing || (kind === 'skills' && !entry.installIdentifier)}- onClick={() => {+ <CatalogInstallSwitch+ disabled={Boolean(installedPending) || installed || (kind === 'skills' && !entry.installIdentifier)}+ installed={installed}+ installing={isInstalling?.(entry) ?? false}+ name={entry.name}+ onInstall={() => {if (kind === 'plugins') {setDetailOpen(false)}-onInstall(entry)}}- size="sm"- variant={installed ? 'secondary' : 'default'}- >- <ActionStatus- busy={t.skills.hub.installing}- done={c.installed}- idle={t.skills.hub.install}- idleIcon={<Codicon name="cloud-download" />}- state={installed ? 'done' : installing ? 'saving' : 'idle'}- />- </Button>+ />)}- const metadata = selected- ? ([- [c.author, selected.author],- [c.source, prettyName(selected.source)],- [c.category, prettyName(selected.categoryLabel)],- [c.version, selected.version],- [c.platforms, selected.platforms.join(', ')],- [c.requires, selected.requiresHermes ? `Hermes ${selected.requiresHermes}` : ''],- [c.pinned, selected.sha ? <code title={selected.sha}>{selected.sha.slice(0, 8)}</code> : '']- ] as [string, ReactNode][])- : []-- const DetailTitle = view === 'browse' && cardView ? DialogTitle : 'h3'+ const card = (entry: CatalogEntry, accentIndex: number) => (+ <CatalogCard+ accentIndex={accentIndex}+ action={entryAction(entry)}+ entry={entry}+ key={entry.id}+ onCategory={filters.chooseCategory}+ onOpen={openEntry}+ onSearch={searchFor}+ onTag={filters.toggleTag}+ />+ )const details = selected ? (- <>- <header className="space-y-3">- {selected.imageUrl && (- <img- alt=""- className="block aspect-[2/1] w-full rounded-md border border-(--ui-border) object-cover"- decoding="async"- loading="lazy"- onError={e => {- e.currentTarget.style.display = 'none'- }}- referrerPolicy="no-referrer"- src={selected.imageUrl}- />- )}- <div className="flex items-start gap-3">- <Codicon- className="mt-1 shrink-0 text-(--ui-text-tertiary)"- name={kind === 'plugins' ? 'extensions' : 'book'}- size="1.5rem"- />- <div className="min-w-0">- <DetailTitle className="break-words text-lg font-semibold tracking-tight">{selected.name}</DetailTitle>- <p className="mt-1 text-xs text-(--ui-text-tertiary)">{selected.author || prettyName(selected.source)}</p>- </div>- </div>- <div className="flex flex-wrap items-center gap-2">- {installButton(selected)}- <Badge variant="muted">{prettyName(selected.source)}</Badge>- {selected.stars !== null && (- <span className="text-xs text-(--ui-text-tertiary)">☆ {selected.stars.toLocaleString()}</span>- )}- </div>- </header>- <section className="space-y-2">- <h4 className="text-xs font-medium">{c.about}</h4>- <p className="whitespace-pre-wrap break-words text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-secondary)">- {selected.description}- </p>- {selected.overview && selected.overview !== selected.description && (- <p className="whitespace-pre-wrap break-words text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-tertiary)">- {selected.overview}- </p>- )}- </section>- <dl className="space-y-2 text-[length:var(--conversation-caption-font-size)]">- {metadata- .filter(([, value]) => Boolean(value))- .map(([label, value]) => (- <div className="grid grid-cols-[6rem_minmax(0,1fr)] gap-3" key={label}>- <dt className="text-(--ui-text-tertiary)">{label}</dt>- <dd className="m-0 break-words">{value}</dd>- </div>- ))}- </dl>- {[- [c.tools, selected.tools],- [c.hooks, selected.hooks],- [c.requires, selected.requirements]- ].map(- ([label, values]) =>- (values as string[]).length > 0 && (- <section className="space-y-2" key={label as string}>- <h4 className="text-xs font-medium">{label as string}</h4>- <div className="flex flex-wrap gap-1">- {(values as string[]).map(value => (- <ToolChip key={value}>{value}</ToolChip>- ))}- </div>- </section>- )- )}- <div className="flex flex-wrap gap-3 text-xs">- {selected.sourceUrl && <ExternalLink href={selected.sourceUrl}>{c.repository}</ExternalLink>}- {selected.docsUrl && <ExternalLink href={selected.docsUrl}>{c.documentation}</ExternalLink>}- </div>- <p className="text-[0.65rem] leading-relaxed text-(--ui-text-quaternary)">{c.installHint}</p>- </>+ <CatalogDetail+ action={entryAction(selected)}+ dialog={cardView}+ entry={selected}+ kind={kind}+ management={renderInstalledDetail?.(selected)}+ onCategory={filters.chooseCategory}+ onRelated={entry => setSelectedId(entry.id)}+ onSearch={searchFor}+ onTag={filters.toggleTag}+ related={related}+ />) : null+ const sortLabels: Record<CatalogSort, string> = {+ discover: c.featured,+ stars: c.mostStarred,+ newest: c.newest,+ updated: c.recentlyUpdated,+ name: c.alphabetical+ }++ 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(entries, 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 (- <div className="flex h-full min-h-0 min-w-0 flex-col" data-catalog={kind}>- {view === 'browse' && (- <div className="flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2">- <div className="flex min-w-0 flex-wrap items-center gap-2">- <div className="w-36">- <Select- onValueChange={value => {- setSource(value)- setCategory('all')- resetSelection()- }}- value={source}- >- <SelectTrigger aria-label={c.source}>- <SelectValue placeholder={c.allSources} />- </SelectTrigger>- <SelectContent>- <SelectItem value="all">{c.allSources}</SelectItem>- {sources.map(value => (- <SelectItem key={value} value={value}>- {prettyName(value)}- </SelectItem>- ))}- </SelectContent>- </Select>- </div>- <div className="w-40">- <Select- onValueChange={value => {- setCategory(value)- resetSelection()- }}- value={category}- >- <SelectTrigger aria-label={c.category}>- <SelectValue placeholder={c.allCategories} />- </SelectTrigger>- <SelectContent>- <SelectItem value="all">{c.allCategories}</SelectItem>- {categories.map(([value, label]) => (- <SelectItem key={value} value={value || 'uncategorized'}>- {prettyName(label)}- </SelectItem>- ))}- </SelectContent>- </Select>+ <div className="@container/catalog flex h-full min-h-0 min-w-0" data-catalog={kind} ref={root}>+ <div className="flex min-h-0 min-w-0 flex-1 flex-col @[48rem]/catalog:flex-row">+ <CatalogFilters+ categories={catalogCategories(entries, kind)}+ className="max-h-52 shrink-0 gap-0 pt-3 @[48rem]/catalog:max-h-none @[48rem]/catalog:w-48"+ facets={facets}+ onCategory={filters.toggleCategory}+ onClear={clearFilters}+ onInstalled={filters.toggleInstalled}+ onSource={filters.toggleSource}+ onTag={filters.toggleTag}+ resultCount={filtered.length}+ sidebarActions={actions && <div className="flex flex-wrap items-center gap-1.5">{actions}</div>}+ sortControl={sortControl}+ sources={catalogSources(entries)}+ tags={catalogTags(entries, facets.tags, TAG_LIMIT)}+ />+ <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="grid shrink-0 grid-cols-1 items-center gap-2 px-3 pb-1 pt-3 @[48rem]/catalog:grid-cols-[minmax(0,1fr)_auto] @[48rem]/catalog:gap-4"+ data-catalog-header+ >+ <SearchField+ containerClassName="w-full min-w-0"+ onChange={value => onQueryChange?.(value)}+ placeholder={kind === 'plugins' ? c.searchPlugins : c.searchSkills}+ value={query ?? ''}+ variant="box"+ />+ <div+ className="flex min-w-0 flex-wrap items-center justify-end gap-3 justify-self-end"+ data-catalog-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></div>- </div>- <SegmentedControl- className="ml-auto shrink-0"- iconOnly- onChange={layout => {- setDetailOpen(false)- $catalogCardView.set(layout === 'cards')- }}- options={[- { id: 'list', label: c.listView, icon: ListViewIcon },- { id: 'cards', label: c.cardView, icon: CardViewIcon }- ]}- value={cardView ? 'cards' : 'list'}- />- </div>- )}- <div className="min-h-0 flex-1">- {isPending && view === 'browse' && !entries.length ? (- <PageLoader label={t.skills.loading} />- ) : view === 'browse' && 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>- ) : !selected ? (- <PanelEmpty- action={- <Button onClick={clearFilters} size="sm" variant="secondary">- {c.clearFilters}- </Button>- }- description={c.tryAnother}- icon="search"- title={c.noResults}- />- ) : view === 'browse' && cardView ? (- <>- <div className="flex h-full min-h-0 flex-col px-3 pb-3" data-catalog-cards={kind}>- <ListStrip left={<ListStripLabel>{c.results(filtered.length)}</ListStripLabel>} />- <div- className="min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]"- key={`${source}:${category}:${deferredQuery}`}- >- <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,17rem),1fr))] gap-3 py-2">- {filtered.slice(0, limit).map(entry => (- <article- className="row-hover flex min-w-0 flex-col overflow-hidden rounded-lg border border-(--ui-stroke-tertiary) bg-(--ui-chat-bubble-background)"- data-catalog-card- key={entry.id}- >- <RowButton- aria-haspopup="dialog"- aria-label={entry.name}- className="flex min-w-0 flex-1 cursor-pointer flex-col gap-3 p-4 text-left focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2"- onClick={event => {- selectedCardRef.current = event.currentTarget- setSelectedId(entry.id)- setDetailOpen(true)- }}- >- <span className="flex w-full items-center gap-2 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">- <Codicon name={kind === 'plugins' ? 'extensions' : 'book'} size="1.25rem" />- <span className="min-w-0 flex-1 truncate">{prettyName(entry.source)}</span>- {entry.stars !== null && <span className="shrink-0">☆ {entry.stars.toLocaleString()}</span>}- </span>- <span className="line-clamp-2 break-words text-[length:var(--conversation-text-font-size)] font-semibold leading-snug">- {entry.name}- </span>- <span className="line-clamp-3 text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-secondary)">- {entry.description}- </span>- <span className="mt-auto w-full truncate pt-1 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">- {entry.author || prettyName(entry.source)}- </span>- </RowButton>- <div className="flex flex-wrap items-center justify-between gap-2 px-4 pb-4">- <Badge variant="muted">{prettyName(entry.categoryLabel)}</Badge>- {installButton(entry)}- </div>- </article>- ))}- </div>- {filtered.length > limit && (- <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">- {c.more}+ </header>+ {notice}+ {error && entries.length > 0 && (+ <CatalogAlert onRetry={() => void refetch()} retryLabel={c.retry} title={c.loadFailed}>+ {error.message}+ </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>- </div>- <Dialog onOpenChange={setDetailOpen} open={detailOpen}>- <DialogContent- aria-describedby={undefined}- bodyClassName="gap-5"- className="max-w-2xl"- onCloseAutoFocus={event => {- event.preventDefault()- selectedCardRef.current?.focus()- }}- >- {details}- </DialogContent>- </Dialog>- </>- ) : (- <div- className={cn('h-full min-h-0', detailOpen ? '[&_aside]:max-sm:hidden' : '[&_main]:max-sm:hidden')}- data-catalog-list={kind}- >- <MasterDetail resizeId="capabilities-split" split="wide">- <ListColumn- header={<ListStrip left={<ListStripLabel>{c.results(filtered.length)}</ListStripLabel>} />}- key={`${source}:${category}:${deferredQuery}`}- >- {filtered.slice(0, limit).map(entry => (- <RowButton- aria-pressed={entry.id === selected.id}- className={cn(- 'row-hover flex w-full min-w-0 items-start gap-3 rounded-md px-2 py-2 text-left',- entry.id === selected.id && 'bg-(--ui-row-active-background)'- )}- key={entry.id}- onClick={() => {- setSelectedId(entry.id)- setDetailOpen(true)- }}- >- <Codicon- className="mt-0.5 shrink-0 text-(--ui-text-tertiary)"- name={kind === 'plugins' ? 'extensions' : 'book'}- size="1.1rem"- />- <span className="min-w-0 flex-1">- <span className="flex items-center gap-2">- <span className="truncate text-[0.78rem] font-medium">{entry.name}</span>- {isInstalled(entry) && <Codicon className="shrink-0 text-(--ui-text-tertiary)" name="check" />}- </span>- <span className="mt-1 line-clamp-2 text-[length:var(--conversation-caption-font-size)] leading-(--conversation-caption-line-height) text-(--ui-text-tertiary)">- {entry.description}- </span>- <span className="mt-1.5 flex items-center gap-2 text-[0.65rem] text-(--ui-text-quaternary)">- <span className="truncate">{entry.author || prettyName(entry.source)}</span>- {entry.stars !== null && <span className="shrink-0">☆ {entry.stars.toLocaleString()}</span>}- </span>- </span>- </RowButton>- ))}- {filtered.length > limit && (- <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">- {c.more}- </Button>- )}- </ListColumn>- <DetailColumn footer={c.snapshotHint}>- <div className="sm:hidden">- <Button onClick={() => setDetailOpen(false)} size="sm" variant="text">- <Codicon name="arrow-left" />- {c.back}+ ) : !selected ? (+ <PanelEmpty+ action={+ <Button onClick={clearFilters} size="sm" variant="secondary">+ {c.clearFilters}</Button>+ }+ description={c.tryAnother}+ icon="search"+ title={c.noResults}+ />+ ) : cardView ? (+ <>+ <div className="flex h-full min-h-0 flex-col px-3 pb-3" data-catalog-cards={kind}>+ <div+ className="min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]"+ data-catalog-scroll+ key={`${filterKey}:${sort}:${deferredQuery}:${facets.installedOnly}`}+ >+ {discover ? (+ <div className="space-y-7 py-3">+ {sections.map((section, sectionIndex) => (+ <section className="space-y-3" data-catalog-section={section.key} key={section.key}>+ <header className="flex items-center justify-between gap-3">+ <h3 className="flex items-baseline gap-2 text-sm font-semibold">+ <Button+ className="text-sm font-semibold text-(--ui-text-primary)"+ onClick={() => filters.chooseCategory(section.key)}+ size="inline"+ variant="text"+ >+ {section.label}+ </Button>+ <span className="text-xs font-normal text-(--ui-text-tertiary)">+ {section.entries.length.toLocaleString()}+ </span>+ </h3>+ <Button onClick={() => filters.chooseCategory(section.key)} size="inline" variant="text">+ {c.seeAll}+ <Codicon name="arrow-right" />+ </Button>+ </header>+ <p className="text-xs text-(--ui-text-tertiary)">{section.blurb}</p>+ <Reel className="*:w-68" data-catalog-hover-group>+ {section.entries+ .slice(0, SHELF_SIZE)+ .map((entry, index) => card(entry, sectionIndex * SHELF_SIZE + index))}+ </Reel>+ </section>+ ))}+ </div>+ ) : (+ <div className="py-2">+ {CATALOG_MASONRY ? (+ <Masonry data-catalog-hover-group>{filtered.slice(0, limit).map(card)}</Masonry>+ ) : (+ <div className="catalog-grid" data-catalog-hover-group>+ {filtered.slice(0, limit).map(card)}+ </div>+ )}+ {filtered.length > limit && (+ <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">+ {c.more}+ </Button>+ )}+ </div>+ )}+ </div></div>- {installedDetail || details}- </DetailColumn>- </MasterDetail>+ <CatalogDetailDialog+ onOpenChange={setDetailOpen}+ onSelect={setSelectedId}+ open={detailOpen}+ order={pageOrder}+ selectedId={selected.id}+ >+ {details}+ </CatalogDetailDialog>+ </>+ ) : (+ <div+ className={cn('h-full min-h-0', detailOpen ? '[&_aside]:max-sm:hidden' : '[&_main]:max-sm:hidden')}+ data-catalog-list={kind}+ >+ <MasterDetail resizeId="capabilities-split" split="wide">+ <ListColumn key={`${filterKey}:${deferredQuery}`}>+ {filtered.slice(0, limit).map(entry => (+ <CatalogListRow+ entry={entry}+ installed={isInstalled(entry)}+ key={entry.id}+ kind={kind}+ onCategory={filters.chooseCategory}+ onOpen={openEntry}+ onSearch={searchFor}+ onTag={filters.toggleTag}+ selected={entry.id === selected.id}+ />+ ))}+ {filtered.length > limit && (+ <Button onClick={() => setLimit(value => value + PAGE_SIZE)} size="sm" variant="text">+ {c.more}+ </Button>+ )}+ </ListColumn>+ <DetailColumn footer={c.snapshotHint}>+ <div className="sm:hidden">+ <Button onClick={() => setDetailOpen(false)} size="sm" variant="text">+ <Codicon name="arrow-left" />+ {c.back}+ </Button>+ </div>+ {details}+ </DetailColumn>+ </MasterDetail>+ </div>+ )}</div>- )}+ </div></div></div>)diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-card.tsxnew file mode 100644index 00000000000..a551b15b027--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-card.tsx@@ -0,0 +1,127 @@+import './catalog.css'++import { type ReactNode, useState } from 'react'++import { RowButton } from '@/components/ui/row-button'+import { cn } from '@/lib/utils'++import { type CatalogEntry, catalogLabel } from './catalog-data'+import { CatalogDates, CatalogHeaderMeta, CatalogMetadata } from './catalog-metadata'++export function catalogIcon(category: string) {+ const icons: Record<string, string> = {+ desktop: 'layout',+ tools: 'tools',+ memory: 'database',+ platform: 'plug',+ models: 'hubot',+ web: 'globe',+ automation: 'run-all',+ voice: 'mic',+ 'software-development': 'code',+ 'autonomous-ai-agents': 'hubot',+ productivity: 'checklist',+ creative: 'paintcan',+ research: 'beaker',+ science: 'beaker',+ security: 'shield',+ media: 'play',+ apple: 'device-desktop'+ }++ return icons[category] ?? 'extensions'+}++export function CatalogImage({ src, className }: { src: string; className?: string }) {+ const [failed, setFailed] = useState(false)++ return failed ? null : (+ <img+ alt=""+ className={cn('block w-full object-contain', className)}+ decoding="async"+ loading="lazy"+ onError={() => setFailed(true)}+ referrerPolicy="no-referrer"+ src={src}+ />+ )+}++// Shared classes, not per-card inline custom properties: identical declarations+// let the style engine reuse computed styles across cards. catalog.css paints them.+const CARD_ACCENTS = [+ '[--catalog-accent:var(--ui-blue)]',+ '[--catalog-accent:var(--ui-orange)]',+ '[--catalog-accent:var(--ui-purple)]',+ '[--catalog-accent:var(--ui-green)]',+ '[--catalog-accent:var(--ui-red)]',+ '[--catalog-accent:var(--ui-cyan)]',+ '[--catalog-accent:var(--ui-yellow)]'+]++interface CatalogCardProps {+ entry: CatalogEntry+ action: ReactNode+ accentIndex: number+ onOpen: (entry: CatalogEntry) => void+ onCategory: (category: string) => void+ onTag: (tag: string) => void+ onSearch: (value: string) => void+}++export function CatalogCard({ entry, action, accentIndex, onOpen, onCategory, onTag, onSearch }: CatalogCardProps) {+ return (+ <article+ className={cn(+ 'group relative flex min-w-0 flex-col overflow-hidden rounded-lg border',+ CARD_ACCENTS[accentIndex % CARD_ACCENTS.length]+ )}+ data-catalog-card+ data-entry-id={entry.id}+ >+ {entry.imageUrl && <CatalogImage className="aspect-[2/1]" key={entry.imageUrl} src={entry.imageUrl} />}+ <div className="flex min-h-0 w-full flex-1 flex-col gap-2 p-3">+ <div className="flex min-w-0 items-center gap-2.5">+ {/* Its ::after stretches over the whole card, so any empty spot opens the+ detail; real controls sit above it (`relative`). One focus stop per card. */}+ <RowButton+ aria-haspopup="dialog"+ aria-label={entry.name}+ className="min-w-0 flex-1 cursor-pointer text-left font-semibold leading-snug after:absolute after:inset-0 after:rounded-[inherit] focus-visible:outline-none focus-visible:after:outline-2 focus-visible:after:outline-primary focus-visible:after:-outline-offset-2"+ onClick={() => onOpen(entry)}+ >+ <span className="line-clamp-2 min-w-0 break-words text-lg">{entry.name}</span>+ </RowButton>+ {action && (+ <span className="relative shrink-0 opacity-[.66] transition-opacity group-hover:opacity-100 group-focus-within:opacity-100">+ {action}+ </span>+ )}+ </div>+ {/* In a fixed-height grid cell the description is what gives way. */}+ <div className="flex min-h-0 min-w-0 flex-col gap-2">+ <span className="flex w-full items-center gap-2 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">+ <span className="min-w-0 flex-1 truncate">{entry.author || catalogLabel(entry.source)}</span>+ <CatalogHeaderMeta entry={entry} />+ </span>+ <span className="line-clamp-4 min-h-0 text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-secondary)">+ {entry.description}+ </span>+ </div>+ </div>+ <div className="px-3 pb-3 [&_button]:relative">+ <CatalogMetadata+ entry={entry}+ onCategory={onCategory}+ onOpen={() => onOpen(entry)}+ onSearch={onSearch}+ onTag={onTag}+ />+ </div>+ <div className="mt-auto px-3 pb-3">+ <CatalogDates entry={entry} />+ </div>+ </article>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts b/apps/desktop/src/app/capabilities/catalog/catalog-data.tsindex 56a10d091ba..1b3cc968b68 100644--- a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts+++ b/apps/desktop/src/app/capabilities/catalog/catalog-data.ts@@ -1,5 +1,7 @@import { skillCatalogInstallIdentifier } from '@hermes/shared'-import { useQuery } from '@tanstack/react-query'+import { queryOptions, useQuery } from '@tanstack/react-query'++import { queryClient } from '@/lib/query-client'export type CatalogKind = 'skills' | 'plugins'@@ -24,10 +26,16 @@ export interface CatalogEntry {requirements: string[]tools: string[]hooks: string[]+ middleware?: string[]+ commands?: string[]+ license?: stringsourceUrl: string | nulldocsUrl: string | null- /** GitHub-hosted banner for plugin entries; the only third-party fetch the browser makes. */+ /** Catalog-provided media, restricted to the same GitHub hosts as the website. */imageUrl: string | null+ screenshots?: string[]+ addedAt?: string+ updatedAt?: stringstars: number | nullsearch: string}@@ -41,30 +49,31 @@ const strings = (value: unknown): string[] => (Array.isArray(value) ? value.filtconst IMAGE_HOSTS = new Set(['raw.githubusercontent.com', 'github.com'])+// URL.parse, not `new URL` in try/catch: most skill rows carry no repo or docs+// URL, and 200k thrown TypeErrors cost ~0.7s of main thread per catalog load.+const parseUrl = (value: unknown) => URL.parse(text(value))+/** Mirrors scripts/validate_plugin_catalog.py: https on a GitHub host, else no image. */export function catalogImageUrl(value: unknown): string | null {- try {- const url = new URL(text(value))- const host = url.hostname.toLowerCase()-- return url.protocol === 'https:' && (IMAGE_HOSTS.has(host) || host.endsWith('.githubusercontent.com'))- ? url.href- : null- } catch {- return null- }+ const url = parseUrl(value)+ const host = url?.hostname.toLowerCase() ?? ''++ return url?.protocol === 'https:' && (IMAGE_HOSTS.has(host) || host.endsWith('.githubusercontent.com'))+ ? url.href+ : null}function webUrl(value: unknown): string | null {- try {- const url = new URL(text(value))+ const url = parseUrl(value)- return url.protocol === 'https:' || url.protocol === 'http:' ? url.href : null- } catch {- return null- }+ return url?.protocol === 'https:' || url?.protocol === 'http:' ? url.href : null}+/** Display form of a source or category id: domains stay verbatim (`browse.sh`),+ * slugs read as words (`software-development` → `Software Development`). */+export const catalogLabel = (value: string) =>+ value.includes('.') ? value : value.replace(/[-_]+/g, ' ').replace(/\b\w/g, c => c.toUpperCase())+export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {if (!Array.isArray(data)) {throw new Error('Invalid catalog response')@@ -83,9 +92,14 @@ export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {const id = `${source}:${identifier}`const caps = row.capabilities ?? {}const category = text(row.category) || 'uncategorized'+ const categoryLabel = text(row.categoryLabel) || categoryconst 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)@@ -95,7 +109,7 @@ export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {description,overview: text(row.overview),category,- categoryLabel: text(row.categoryLabel) || category,+ categoryLabel,source,author,identifier,@@ -116,15 +130,41 @@ export function parseCatalog(kind: CatalogKind, data: unknown): CatalogEntry[] {tags,tools,hooks,- platforms: strings(row.platforms),- requirements: strings(kind === 'plugins' ? caps.requiresEnv : row.envVars),+ 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: kind === 'plugins' ? catalogImageUrl(row.image) : null,+ 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,- search: [name, description, author, category, row.categoryLabel, source, ...tags, ...tools, ...hooks]+ search: [+ name,+ description,+ text(row.overview),+ author,+ category,+ categoryLabel,+ source,+ ...tags,+ ...tools,+ ...hooks,+ ...platforms,+ ...requirements,+ ...commands,+ ...middleware+ ].filter(Boolean).join(' ').toLowerCase()@@ -149,19 +189,33 @@ export async function fetchCatalog(kind: CatalogKind): Promise<CatalogEntry[]> {return parseCatalog(kind, await response.json())}-export function useCatalog(kind: CatalogKind, enabled = true) {- return useQuery({+const catalogQuery = (kind: CatalogKind) =>+ queryOptions({queryKey: ['public-catalog', kind],- // Re-enabling a mounted query retries errors even with retryOnMount off.- // Keep failures parked until the user explicitly chooses Try again.- enabled: query => enabled && query.state.status !== 'error',queryFn: () => fetchCatalog(kind),staleTime: 30 * 60_000,- gcTime: Infinity,+ // The skills snapshot parses to ~100k rows; release it once the page has+ // been left long enough that a revisit is a fresh browse anyway.+ gcTime: 30 * 60_000,refetchOnWindowFocus: false,refetchOnReconnect: false,refetchOnMount: false,retryOnMount: false,retry: false})++export function useCatalog(kind: CatalogKind) {+ return useQuery({+ ...catalogQuery(kind),+ // A failed catalog stays parked across remounts (tab switches) until the+ // user explicitly chooses Try again.+ enabled: query => query.state.status !== 'error'+ })+}++/** Warm a catalog while the browser is idle so switching tabs doesn't pay the fetch + parse. */+export function prefetchCatalogWhenIdle(kind: CatalogKind) {+ const id = requestIdleCallback(() => void queryClient.prefetchQuery(catalogQuery(kind)), { timeout: 5_000 })++ return () => cancelIdleCallback(id)}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-detail-dialog.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-detail-dialog.tsxnew file mode 100644index 00000000000..0ce46b73ae2--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-detail-dialog.tsx@@ -0,0 +1,93 @@+import type { ReactNode } from 'react'++import { Button } from '@/components/ui/button'+import { Codicon } from '@/components/ui/codicon'+import { Dialog, DialogContent } from '@/components/ui/dialog'+import { useI18n } from '@/i18n'++import type { CatalogEntry } from './catalog-data'++interface CatalogDetailDialogProps {+ open: boolean+ onOpenChange: (open: boolean) => void+ /** On-screen order to page through; wraps at both ends. */+ order: CatalogEntry[]+ selectedId: string+ onSelect: (id: string) => void+ children: ReactNode+}++const EDITABLE = 'input, textarea, [contenteditable="true"]'++export function CatalogDetailDialog({+ open,+ onOpenChange,+ order,+ selectedId,+ onSelect,+ children+}: CatalogDetailDialogProps) {+ const { t } = useI18n()+ const pageable = order.length > 1++ const step = (delta: number) => {+ if (!pageable) {+ return+ }+ const index = order.findIndex(entry => entry.id === selectedId)+ onSelect(order[(index + delta + order.length) % order.length].id)+ }++ const pager = (delta: -1 | 1) => (+ <Button+ aria-label={delta < 0 ? t.ui.pagination.previous : t.ui.pagination.next}+ className={+ delta < 0+ ? 'absolute -left-14 top-1/2 -translate-y-1/2 max-sm:left-2'+ : 'absolute -right-14 top-1/2 -translate-y-1/2 max-sm:right-2'+ }+ onClick={() => step(delta)}+ size="icon-lg"+ variant="ghost"+ >+ <Codicon name={delta < 0 ? 'chevron-left' : 'chevron-right'} />+ </Button>+ )++ return (+ <Dialog onOpenChange={onOpenChange} open={open}>+ <DialogContent+ aria-describedby={undefined}+ bodyClassName="gap-5"+ chrome={+ pageable && (+ <>+ {pager(-1)}+ {pager(1)}+ </>+ )+ }+ className="max-w-2xl"+ // Focus returns to the card of the entry the user paged to, when it's rendered.+ onCloseAutoFocus={event => {+ event.preventDefault()+ document+ .querySelector<HTMLElement>(`[data-entry-id="${CSS.escape(selectedId)}"] [aria-haspopup="dialog"]`)+ ?.focus({ preventScroll: true })+ }}+ onKeyDown={event => {+ if (+ (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') ||+ (event.target as HTMLElement).closest(EDITABLE)+ ) {+ return+ }+ event.preventDefault()+ step(event.key === 'ArrowLeft' ? -1 : 1)+ }}+ >+ {children}+ </DialogContent>+ </Dialog>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsxnew file mode 100644index 00000000000..7bb27a9163f--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-detail.tsx@@ -0,0 +1,196 @@+import { type ReactNode, useLayoutEffect, useRef } from 'react'++import { ZoomableImage } from '@/components/chat/zoomable-image'+import { Badge } from '@/components/ui/badge'+import { Button } from '@/components/ui/button'+import { Codicon } from '@/components/ui/codicon'+import { DialogTitle } from '@/components/ui/dialog'+import { Reel } from '@/components/ui/reel'+import { RowButton } from '@/components/ui/row-button'+import { useI18n } from '@/i18n'+import { ExternalLink } from '@/lib/external-link'+import { cn } from '@/lib/utils'++import { catalogIcon, CatalogImage } from './catalog-card'+import { type CatalogEntry, type CatalogKind, catalogLabel } from './catalog-data'+import { CatalogDates, CatalogHeaderMeta, CatalogMetadata } from './catalog-metadata'++interface CatalogDetailProps {+ entry: CatalogEntry+ kind: CatalogKind+ action?: ReactNode+ management?: ReactNode+ related: CatalogEntry[]+ onCategory?: (category: string) => void+ onTag?: (tag: string) => void+ onSearch?: (value: string) => void+ onRelated?: (entry: CatalogEntry) => void+ /** Inside the modal: the hero bleeds to the edges and paging scrolls back to the top. */+ dialog: boolean+}++/** 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({+ entry,+ kind,+ action,+ management,+ related,+ onCategory,+ onTag,+ onSearch,+ onRelated,+ dialog+}: CatalogDetailProps) {+ 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(() => {+ if (dialog) {+ root.current?.parentElement?.scrollTo({ top: 0 })+ }+ }, [dialog, entry.id])++ const metadata = [+ [c.platforms, entry.platforms.join(', ')],+ [c.requires, entry.requiresHermes ? `Hermes ${entry.requiresHermes}` : ''],+ [c.pinned, entry.sha ? <code>{entry.sha.slice(0, 8)}</code> : '']+ ] as [string, ReactNode][]++ return (+ <div className="min-w-0 space-y-5" data-catalog-detail={kind} ref={root}>+ {entry.imageUrl && (+ <CatalogImage+ className={cn(+ 'aspect-[2/1] object-cover',+ dialog ? '-mx-4 -mt-4 w-[calc(100%+2rem)] max-w-none rounded-t-xl' : 'w-full rounded-md'+ )}+ key={entry.imageUrl}+ 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>++ <p className="whitespace-pre-wrap break-words text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-secondary)">+ {entry.description}+ </p>+ {entry.overview && entry.overview !== entry.description && (+ <p className="whitespace-pre-wrap break-words text-[length:var(--conversation-caption-font-size)] leading-relaxed text-(--ui-text-tertiary)">+ {entry.overview}+ </p>+ )}++ <div className="space-y-3">+ <CatalogMetadata entry={entry} limit={Infinity} onCategory={onCategory} onSearch={onSearch} onTag={onTag} />+ <CatalogDates entry={entry} />+ <dl className="grid grid-cols-[max-content_minmax(0,1fr)] gap-x-4 gap-y-2 text-[length:var(--conversation-caption-font-size)]">+ {metadata+ .filter(([, value]) => Boolean(value))+ .map(([label, value]) => (+ <div className="contents" key={label}>+ <dt className="whitespace-nowrap text-(--ui-text-tertiary)">{label}</dt>+ <dd className="m-0 break-words">{value}</dd>+ </div>+ ))}+ </dl>+ </div>++ {management}++ {Boolean(entry.screenshots?.length) && (+ <section className="space-y-2">+ <h4 className="text-xs font-medium">{c.screenshots}</h4>+ <Reel className={cn(dialog && '-mx-4 scroll-px-4 px-4')}>+ {entry.screenshots?.map((url, index) => (+ <ZoomableImage+ alt={`${c.screenshots} — ${entry.name} ${index + 1}`}+ className="h-56 w-auto max-w-none cursor-zoom-in rounded-lg border border-(--ui-stroke-tertiary)"+ decoding="async"+ key={url}+ loading="lazy"+ referrerPolicy="no-referrer"+ slot="catalog-screenshot"+ src={url}+ />+ ))}+ </Reel>+ </section>+ )}++ {[+ [c.tools, entry.tools],+ [c.hooks, entry.hooks],+ [c.middleware, entry.middleware ?? []],+ [c.requires, entry.requirements]+ ].map(([label, values]) =>+ (values as string[]).length > 0 ? (+ <section className="space-y-2" key={label as string}>+ <h4 className="text-xs font-medium">{label as string}</h4>+ <div className="flex flex-wrap gap-1">+ {(values as string[]).map(value =>+ onSearch ? (+ <Button key={value} onClick={() => onSearch(value)} size="xs" variant="ghost">+ {value}+ </Button>+ ) : (+ <Badge key={value} variant="muted">+ {value}+ </Badge>+ )+ )}+ </div>+ </section>+ ) : null+ )}++ <p className="text-[0.65rem] leading-relaxed text-(--ui-text-quaternary)">{c.installHint}</p>++ {related.length > 0 && (+ <section className="space-y-2">+ <h4 className="text-xs font-medium">{c.related}</h4>+ <div className="grid grid-cols-3 gap-2">+ {related.map(item => (+ <RowButton+ className="row-hover flex min-w-0 flex-col gap-1 overflow-hidden rounded-md text-left"+ key={item.id}+ onClick={() => onRelated?.(item)}+ >+ {item.imageUrl ? (+ <CatalogImage className="aspect-[2/1] w-full rounded-t-md object-contain" src={item.imageUrl} />+ ) : (+ <span className="flex aspect-[2/1] w-full items-center justify-center bg-(--ui-bg-quaternary) text-(--ui-text-tertiary)">+ <Codicon name={catalogIcon(item.category)} size="1.25rem" />+ </span>+ )}+ <span className="w-full truncate px-2 pb-2 text-xs font-medium">{item.name}</span>+ </RowButton>+ ))}+ </div>+ </section>+ )}+ </div>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-filters.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-filters.tsxnew file mode 100644index 00000000000..c94db8607ff--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-filters.tsx@@ -0,0 +1,141 @@+import type { ReactNode } from 'react'++import { SidebarDateDivider, SidebarSectionMeta } from '@/app/chat/sidebar/chrome'+import { OverlayNavItem, OverlaySidebar } from '@/app/overlays/overlay-split-layout'+import { SidebarPanelLabel } from '@/app/shell/sidebar-label'+import { Button } from '@/components/ui/button'+import { CheckboxMark } from '@/components/ui/checkbox'+import { useI18n } from '@/i18n'++import { catalogLabel } from './catalog-data'+import type { CatalogFacets } from './catalog-query'++export interface FacetRow {+ value: string+ label: string+ count?: number+}++interface CatalogFiltersProps {+ sources: string[]+ categories: ReadonlyArray<readonly [string, { label: string; count: number }]>+ tags: FacetRow[]+ facets: CatalogFacets+ /** `null` clears the facet. */+ onSource: (value: string | null) => void+ onCategory: (value: string | null) => void+ onTag: (value: string | null) => void+ onInstalled: () => void+ onClear: () => void+ resultCount: number+ sidebarActions?: ReactNode+ sortControl?: ReactNode+ className?: string+}++function FacetItem({ row, active, onClick }: { row: FacetRow; active: boolean; onClick: () => void }) {+ return (+ <OverlayNavItem+ active={active}+ current={false}+ label={row.label}+ leading={<CheckboxMark checked={active} />}+ nested+ onClick={onClick}+ pressed={active}+ trailing={+ row.count !== undefined ? <SidebarSectionMeta>{row.count.toLocaleString()}</SidebarSectionMeta> : undefined+ }+ />+ )+}++/** Multi-select group: rows toggle, the optional "All" row clears. */+function Facet({+ label,+ all,+ beforeRows,+ rows,+ active,+ onSelect+}: {+ label: string+ all?: string+ beforeRows?: ReactNode+ rows: FacetRow[]+ active: string[]+ onSelect: (value: string | null) => void+}) {+ if (!all && !rows.length) {+ return null+ }++ return (+ <>+ <SidebarDateDivider label={label} />+ {all && <FacetItem active={!active.length} onClick={() => onSelect(null)} row={{ value: 'all', label: all }} />}+ {beforeRows}+ {rows.map(row => (+ <FacetItem active={active.includes(row.value)} key={row.value} onClick={() => onSelect(row.value)} row={row} />+ ))}+ </>+ )+}++export function CatalogFilters({+ sources,+ categories,+ tags,+ facets,+ onSource,+ onCategory,+ onTag,+ onInstalled,+ onClear,+ resultCount,+ sidebarActions,+ sortControl,+ className+}: CatalogFiltersProps) {+ const { t } = useI18n()+ const c = t.catalog+ const filtered = facets.sources.length + facets.categories.length + facets.tags.length > 0 || facets.installedOnly++ return (+ <OverlaySidebar className={className}>+ <div className="flex h-7 shrink-0 items-center gap-2 pb-1">+ <SidebarPanelLabel meta={resultCount.toLocaleString()}>{c.discover}</SidebarPanelLabel>+ {filtered && (+ <Button aria-label={c.clearFilters} className="ml-auto" onClick={onClear} size="inline" variant="text">+ {t.common.clear}+ </Button>+ )}+ </div>++ <div className="pb-2">{sortControl}</div>+ <Facet+ active={facets.sources}+ all={c.allSources}+ beforeRows={+ <FacetItem+ active={facets.installedOnly}+ onClick={onInstalled}+ row={{ value: 'installed', label: c.installed }}+ />+ }+ label={c.source}+ onSelect={onSource}+ rows={sources.map(value => ({ value, label: catalogLabel(value) }))}+ />+ <Facet+ active={facets.categories}+ all={c.allCategories}+ label={c.category}+ onSelect={onCategory}+ rows={categories.map(([value, { label, count }]) => ({ value, label: catalogLabel(label), count }))}+ />+ <Facet active={facets.tags} label={c.tags} onSelect={onTag} rows={tags} />+ {sidebarActions}+ </OverlaySidebar>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-install-switch.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-install-switch.tsxnew file mode 100644index 00000000000..157332d90f9--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-install-switch.tsx@@ -0,0 +1,35 @@+import { Switch } from '@/components/ui/switch'+import { Tip } from '@/components/ui/tooltip'+import { useI18n } from '@/i18n'+import { Loader2 } from '@/lib/icons'++interface CatalogInstallSwitchProps {+ name: string+ installed: boolean+ installing: boolean+ disabled: boolean+ onInstall: () => void+}++/** Turning it on installs. Installed entries normally show their owner's on/off+ * switch instead; this one only stays checked (and disabled) as a fallback. */+export function CatalogInstallSwitch({ name, installed, installing, disabled, onInstall }: CatalogInstallSwitchProps) {+ const { t } = useI18n()+ const label = `${installed ? t.catalog.added : t.catalog.add} ${name}`++ return (+ <Tip label={label}>+ <span className="inline-flex items-center gap-2">+ {installing && <Loader2 className="size-3 animate-spin text-(--ui-text-tertiary)" />}+ <Switch+ aria-busy={installing}+ aria-label={label}+ checked={installed}+ disabled={disabled || installing}+ onCheckedChange={checked => checked && onInstall()}+ size="xs"+ />+ </span>+ </Tip>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsxnew file mode 100644index 00000000000..f933fb7e25e--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx@@ -0,0 +1,66 @@+import { Codicon } from '@/components/ui/codicon'+import { RowButton } from '@/components/ui/row-button'+import { cn } from '@/lib/utils'++import { type CatalogEntry, type CatalogKind, catalogLabel } from './catalog-data'+import { CatalogHeaderMeta, CatalogMetadata } from './catalog-metadata'++interface CatalogListRowProps {+ entry: CatalogEntry+ kind: CatalogKind+ selected: boolean+ installed: boolean+ onOpen: (entry: CatalogEntry) => void+ onCategory: (category: string) => void+ onTag: (tag: string) => void+ onSearch: (value: string) => void+}++export function CatalogListRow({+ entry,+ kind,+ selected,+ installed,+ onOpen,+ onCategory,+ onTag,+ onSearch+}: CatalogListRowProps) {+ return (+ <div+ className={cn(+ 'row-hover relative flex w-full min-w-0 items-start gap-3 rounded-md px-2 py-2 text-left',+ selected && 'bg-(--ui-row-active-background)'+ )}+ data-entry-id={entry.id}+ >+ <RowButton+ aria-label={entry.name}+ aria-pressed={selected}+ className="absolute inset-0 rounded-md focus-visible:outline-2 focus-visible:outline-primary focus-visible:-outline-offset-2"+ onClick={() => onOpen(entry)}+ />+ <Codicon+ className="mt-0.5 shrink-0 text-(--ui-text-tertiary)"+ name={kind === 'plugins' ? 'extensions' : 'book'}+ size="1.1rem"+ />+ <span className="pointer-events-none min-w-0 flex-1">+ <span className="flex items-center gap-2">+ <span className="truncate text-[0.78rem] font-medium">{entry.name}</span>+ {installed && <Codicon className="shrink-0 text-(--ui-text-tertiary)" name="check" />}+ </span>+ <span className="mt-1 line-clamp-2 text-[length:var(--conversation-caption-font-size)] leading-(--conversation-caption-line-height) text-(--ui-text-tertiary)">+ {entry.description}+ </span>+ <span className="pointer-events-auto relative mt-2 block">+ <CatalogMetadata entry={entry} limit={2} onCategory={onCategory} onSearch={onSearch} onTag={onTag} />+ </span>+ <span className="mt-1.5 flex items-center gap-2 text-[0.65rem] text-(--ui-text-quaternary)">+ <span className="min-w-0 flex-1 truncate">{entry.author || catalogLabel(entry.source)}</span>+ <CatalogHeaderMeta entry={entry} />+ </span>+ </span>+ </div>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-metadata.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-metadata.tsxnew file mode 100644index 00000000000..3fb93c3465a--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-metadata.tsx@@ -0,0 +1,187 @@+import { useState } from 'react'++import { Badge } from '@/components/ui/badge'+import { Button } from '@/components/ui/button'+import { Tip } from '@/components/ui/tooltip'+import { useI18n } from '@/i18n'+import { fmtDateTime, relativeTime } from '@/lib/time'++import { type CatalogEntry, catalogLabel } from './catalog-data'++interface CatalogMetadataProps {+ entry: CatalogEntry+ onCategory?: (category: string) => void+ onTag?: (tag: string) => void+ /** Values without a facet (platforms, tools, env vars) browse by search. */+ onSearch?: (value: string) => void+ /** Capability counts open the entry, where each value is listed. */+ onOpen?: () => void+ /** Details show everything; cards can disclose the rest without opening. */+ limit?: number+}++interface CatalogChip {+ id: string+ label: string+ hint?: string+ quiet?: boolean+ onClick?: () => void+}++/** Source, version and stars, trailing the author line. */+export function CatalogHeaderMeta({ entry }: { entry: CatalogEntry }) {+ return (+ <span className="flex min-w-0 shrink-0 items-center gap-1">+ {entry.source && (+ <Badge className="max-w-full" size="xs" variant="muted">+ <span className="truncate">{catalogLabel(entry.source)}</span>+ </Badge>+ )}+ {entry.version && (+ <Badge size="xs" variant="muted">+ v{entry.version}+ </Badge>+ )}+ {entry.stars !== null && entry.stars > 0 && (+ <span className="flex shrink-0 items-center gap-0.5 text-[0.65rem] text-(--ui-text-tertiary)">+ <span aria-hidden>★</span>+ {entry.stars.toLocaleString()}+ </span>+ )}+ </span>+ )+}++/** One metadata projection for Skills and Plugins, in cards, lists and details. */+export function CatalogMetadata({ entry, onCategory, onTag, onSearch, onOpen, limit }: CatalogMetadataProps) {+ const { t } = useI18n()+ const c = t.catalog+ const [expanded, setExpanded] = useState(false)+ const interactive = Boolean(onCategory || onTag)+ const tags = [...new Set(entry.tags)]+ const search = (value: string) => (onSearch ? () => onSearch(value) : undefined)++ const primary: CatalogChip[] = [+ {+ id: 'category',+ label: catalogLabel(entry.categoryLabel),+ onClick: onCategory ? () => onCategory(entry.category) : undefined+ },+ ...entry.platforms.map(value => ({+ id: `platform:${value}`,+ label: value === 'macos' ? 'macOS' : catalogLabel(value),+ quiet: true,+ onClick: search(value)+ }))+ ]++ const capabilities = [+ { id: 'tools', label: c.tools, values: entry.tools },+ { id: 'hooks', label: c.hooks, values: entry.hooks },+ { id: 'middleware', label: c.middleware, values: entry.middleware ?? [] }+ ]++ const primaryLabels = new Set(primary.map(chip => chip.label.trim().toLowerCase()))++ for (const chip of primary) {+ const matchingTag = tags.find(tag => tag.trim().toLowerCase() === chip.label.trim().toLowerCase())++ if (matchingTag && onTag && (chip.quiet || !chip.onClick)) {+ chip.onClick = () => onTag(matchingTag)+ }+ }++ const secondary: CatalogChip[] = [+ ...capabilities+ .filter(group => group.values.length)+ .map(group => ({ id: group.id, label: `${group.label} ${group.values.length}`, quiet: true, onClick: onOpen })),+ ...tags+ .filter(value => !primaryLabels.has(value.trim().toLowerCase()))+ .map(value => ({ id: `tag:${value}`, label: value, onClick: onTag ? () => onTag(value) : undefined })),+ ...entry.requirements.map(value => ({+ id: `env:${value}`,+ label: value,+ hint: c.requires,+ quiet: true,+ onClick: search(value)+ }))+ ]++ const commands = (entry.commands ?? []).map(value => `/${value.replace(/^\//, '')}`)+ const visible = expanded ? secondary : secondary.slice(0, limit ?? 5)+ const remaining = secondary.length - visible.length++ const chip = ({ id, label, hint, quiet, onClick }: CatalogChip) => {+ const content = onClick ? (+ <Button className="max-w-full" onClick={onClick} size="xs" variant={quiet ? 'ghost' : 'chip'}>+ <span className="truncate">{label}</span>+ </Button>+ ) : (+ <Badge className="max-w-full" variant="muted">+ <span className="truncate">{label}</span>+ </Badge>+ )++ return hint ? (+ <Tip key={id} label={hint}>+ {content}+ </Tip>+ ) : (+ <span className="inline-flex max-w-full" key={id}>+ {content}+ </span>+ )+ }++ return (+ <span className="flex flex-col gap-2" data-catalog-metadata>+ <span className="flex flex-wrap items-center gap-1">{primary.filter(item => item.label).map(chip)}</span>+ {secondary.length > 0 && (+ <span className="flex flex-wrap items-center gap-1" data-catalog-tags>+ {visible.map(chip)}+ {remaining > 0 &&+ (interactive ? (+ <Button+ aria-label={`${c.more} (${remaining})`}+ onClick={() => setExpanded(true)}+ size="xs"+ variant="ghost"+ >+ +{remaining}+ </Button>+ ) : (+ <Badge variant="muted">+{remaining}</Badge>+ ))}+ </span>+ )}+ {commands.length > 0 && (+ <span className="truncate font-mono text-[0.65rem] text-(--ui-text-tertiary)" data-catalog-commands>+ {commands.join(' ')}+ </span>+ )}+ </span>+ )+}++export function CatalogDates({ entry }: { entry: CatalogEntry }) {+ const { t } = useI18n()++ const dates = [+ { label: t.catalog.addedDate, value: entry.addedAt },+ { label: t.catalog.updatedDate, value: entry.updatedAt !== entry.addedAt ? entry.updatedAt : undefined }+ ].filter((date): date is { label: string; value: string } => Boolean(date.value))++ if (!dates.length) {+ return null+ }++ return (+ <span className="flex flex-wrap gap-x-2 gap-y-1 text-[0.65rem] text-(--ui-text-tertiary)">+ {dates.map(({ label, value }) => (+ <time dateTime={value} key={label} title={fmtDateTime.format(Date.parse(value))}>+ {label} {relativeTime(Date.parse(value))}+ </time>+ ))}+ </span>+ )+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-pointer.ts b/apps/desktop/src/app/capabilities/catalog/catalog-pointer.tsnew file mode 100644index 00000000000..5c1ce121cc0--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-pointer.ts@@ -0,0 +1,55 @@+/** Off for now: without it every card rests at its theme's gradient anchor. */+export const CATALOG_POINTER_ENABLED = false++const FALLOFF_PX = 480++/**+ * Aims every card's gradient at the pointer. The gradient center is the pointer+ * clamped to the card, so it is radial under the pointer and anchored to the+ * nearest edge otherwise; `--catalog-near` fades 1 → 0 over FALLOFF_PX of+ * distance from that edge point. Reads all rects, then writes, once per frame.+ */+export function trackCatalogPointer(root: HTMLElement) {+ let frame = 0+ let x = 0+ let y = 0++ const paint = () => {+ frame = 0+ const cards = [...root.querySelectorAll<HTMLElement>('[data-catalog-card]')]+ const rects = cards.map(card => card.getBoundingClientRect())++ cards.forEach((card, index) => {+ const { left, top, right, bottom, width, height } = rects[index]++ if (bottom < 0 || top > innerHeight) {+ return+ }+ const px = Math.min(Math.max(x, left), right)+ const py = Math.min(Math.max(y, top), bottom)+ card.style.setProperty('--catalog-x', `${((px - left) / width) * 100}%`)+ card.style.setProperty('--catalog-y', `${((py - top) / height) * 100}%`)+ card.style.setProperty('--catalog-near', Math.max(0, 1 - Math.hypot(x - px, y - py) / FALLOFF_PX).toFixed(3))+ })+ }++ const schedule = () => void (frame ||= requestAnimationFrame(paint))++ const move = (event: PointerEvent) => {+ x = event.clientX+ y = event.clientY+ schedule()+ }++ // Scroll re-aims only once the pointer has been seen; until then cards rest.+ const scroll = () => void (x || y ? schedule() : undefined)++ root.addEventListener('pointermove', move)+ root.addEventListener('scroll', scroll, true)++ return () => {+ cancelAnimationFrame(frame)+ root.removeEventListener('pointermove', move)+ root.removeEventListener('scroll', scroll, true)+ }+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-query.ts b/apps/desktop/src/app/capabilities/catalog/catalog-query.tsnew file mode 100644index 00000000000..95d37be7215--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog-query.ts@@ -0,0 +1,127 @@+import { PLUGIN_CATEGORIES, PLUGIN_CATEGORY_ORDER, sortCatalogPlugins } from '@hermes/shared'++import type { CatalogEntry, CatalogKind } from './catalog-data'+import type { FacetRow } from './catalog-filters'++export type CatalogSort = 'discover' | 'stars' | 'newest' | 'updated' | 'name'++export interface CatalogFacets {+ sources: string[]+ categories: string[]+ tags: string[]+ installedOnly: boolean+}++export const EMPTY_FACETS: CatalogFacets = { sources: [], categories: [], tags: [], installedOnly: false }++export const catalogSources = (entries: CatalogEntry[]) => [...new Set(entries.map(entry => entry.source))]++/** Category facet rows with counts; plugins follow the shared taxonomy order. */+export function catalogCategories(entries: CatalogEntry[], kind: CatalogKind) {+ const values = new Map<string, { label: string; count: number }>()++ for (const entry of entries) {+ values.set(entry.category, { label: entry.categoryLabel, count: (values.get(entry.category)?.count ?? 0) + 1 })+ }++ if (kind === 'plugins') {+ return PLUGIN_CATEGORY_ORDER.filter(key => values.has(key)).map(+ key => [key, { ...values.get(key)!, label: PLUGIN_CATEGORIES[key].label }] as const+ )+ }++ return [...values].sort((a, b) => b[1].count - a[1].count)+}++/** The most common tags plus whatever is selected; search covers the long tail. */+export function catalogTags(entries: CatalogEntry[], selected: string[], limit: number): FacetRow[] {+ const counts = new Map<string, number>()++ for (const entry of entries) {+ for (const value of new Set(entry.tags)) {+ counts.set(value, (counts.get(value) ?? 0) + 1)+ }+ }++ const ranked = [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))+ const shown = new Set([...ranked.slice(0, limit).map(([value]) => value), ...selected])++ return ranked.filter(([value]) => shown.has(value)).map(([value, count]) => ({ value, label: value, count }))+}++/** Facets combine as AND across groups and OR within one. */+export function filterCatalog(+ entries: CatalogEntry[],+ facets: CatalogFacets,+ query: string,+ isInstalled: (entry: CatalogEntry) => boolean+) {+ const { sources, categories, tags, installedOnly } = facets++ return entries.filter(+ entry =>+ (!sources.length || sources.includes(entry.source)) &&+ (!categories.length || categories.includes(entry.category)) &&+ (!tags.length || tags.some(tag => entry.tags.includes(tag))) &&+ (!installedOnly || isInstalled(entry)) &&+ (!query || entry.search.includes(query))+ )+}++/** Returns a new array; `discover` keeps the feed's curated order. */+export function sortCatalog(entries: CatalogEntry[], sort: CatalogSort, kind: CatalogKind) {+ if (sort === 'discover') {+ return entries+ }++ if (kind === 'plugins' && sort !== 'name') {+ return sortCatalogPlugins(entries, sort)+ }++ if (sort === 'name') {+ return [...entries].sort((a, b) => a.name.localeCompare(b.name))+ }++ if (sort === 'stars') {+ return [...entries].sort((a, b) => (b.stars ?? -1) - (a.stars ?? -1) || a.name.localeCompare(b.name))+ }++ const field = sort === 'newest' ? 'addedAt' : 'updatedAt'+ const time = new Map(entries.map(entry => [entry.id, Date.parse(entry[field] ?? '') || 0]))++ return [...entries].sort((a, b) => time.get(b.id)! - time.get(a.id)! || a.name.localeCompare(b.name))+}++/** First `limit` entries sharing a category or tag with `entry`; stops early on large feeds. */+export function relatedEntries(entries: CatalogEntry[], entry: CatalogEntry, limit: number) {+ const matches: CatalogEntry[] = []++ for (const candidate of entries) {+ if (matches.length === limit) {+ break+ }++ if (+ candidate.id !== entry.id &&+ (candidate.category === entry.category || candidate.tags.some(tag => entry.tags.includes(tag)))+ ) {+ matches.push(candidate)+ }+ }++ return matches+}++export function catalogSortOptions(entries: CatalogEntry[], kind: CatalogKind, labels: Record<CatalogSort, string>) {+ const available: Record<CatalogSort, boolean> = {+ discover: kind === 'skills',+ stars: entries.some(entry => entry.stars !== null),+ newest: entries.some(entry => entry.addedAt),+ updated: entries.some(entry => entry.updatedAt),+ name: kind === 'skills'+ }++ return (Object.keys(available) as CatalogSort[])+ .filter(value => available[value])+ .map(value => ({ value, label: labels[value] }))+}diff --git a/apps/desktop/src/app/capabilities/catalog/catalog.css b/apps/desktop/src/app/capabilities/catalog/catalog.cssnew file mode 100644index 00000000000..1fd89e25886--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/catalog.css@@ -0,0 +1,87 @@+/* Registered so the gradient can glide instead of jump. Written per card by+ `trackCatalogPointer`: x/y is the pointer clamped to the card, near is 0–1. */+@property --catalog-x {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 0%;+}++@property --catalog-y {+ syntax: '<percentage>';+ inherits: false;+ initial-value: 0%;+}++@property --catalog-near {+ syntax: '<number>';+ inherits: false;+ initial-value: 0;+}++/* Each card carries one accent (`--catalog-accent`, set by class). Its gradient+ keeps one shape and strength and only its center drifts toward the pointer,+ onto it when on the card. Light surfaces show tint far more than dark ones,+ so light gets a softer wash from the bottom-left; `:root.dark` restores+ the stronger top-left glow. */+[data-catalog-card] {+ /* How far the gradient leans from its rest point toward the pointer: all the+ way on the card itself, falling off fast with distance to the box. */+ --catalog-follow: calc(var(--catalog-near) * var(--catalog-near));+ --catalog-rest-x: 0%;+ --catalog-rest-y: 100%;+ --catalog-tint: 10%;+ --catalog-edge: 20%;+ border-color: color-mix(in srgb, var(--catalog-accent) var(--catalog-edge), var(--ui-stroke-tertiary));+ background:+ radial-gradient(+ 140% 100% at calc(var(--catalog-rest-x) + (var(--catalog-x) - var(--catalog-rest-x)) * var(--catalog-follow))+ calc(var(--catalog-rest-y) + (var(--catalog-y) - var(--catalog-rest-y)) * var(--catalog-follow)),+ color-mix(in srgb, var(--catalog-accent) var(--catalog-tint), transparent),+ transparent 70%+ )+ var(--ui-chat-bubble-background);+ transition:+ border-color 0.1s ease,+ box-shadow 0.1s ease,+ opacity 0.15s ease,+ filter 0.15s ease,+ --catalog-x 5s cubic-bezier(0.2, 0.8, 0.2, 1),+ --catalog-y 5s cubic-bezier(0.2, 0.8, 0.2, 1),+ --catalog-near 5s ease;+}++:root.dark [data-catalog-card] {+ --catalog-rest-x: 0%;+ --catalog-rest-y: 0%;+ --catalog-tint: 18%;+ --catalog-edge: 24%;+}++[data-catalog-card]:hover {+ /* Matches the selected-option treatment (`border-primary ring-2 ring-primary/20`). */+ border-color: var(--color-primary);+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);+}++/* Uniform alternative to Masonry: same column tracks, cards in a row share one+ height. Rows start at a complete text card (4-line description, two chip+ rows, dates ≈ 250px) and grow for a card with a hero image, so image and+ description always show in full. */+.catalog-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));+ grid-auto-rows: minmax(16rem, auto);+ gap: calc(var(--spacing) * 3);+}++/* Store-browsing feel: hovering one card dims its siblings in the same group. */+[data-catalog-hover-group]:has([data-catalog-card]:hover) [data-catalog-card]:not(:hover) {+ opacity: 1;+ filter: saturate(0.8);+}++@media (prefers-reduced-motion: reduce) {+ [data-catalog-card] {+ transition: border-color 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease, filter 0.15s ease;+ }+}diff --git a/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx b/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsxindex e11a23b7b62..7337c43d8c1 100644--- a/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx+++ b/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx@@ -1,50 +1,298 @@-import { useCallback, useState } from 'react'+import { useQuery } from '@tanstack/react-query'+import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'-import type { ProfileScope } from '@/hermes'+import { capabilityScoped } from '@/api/client'+import { getOfficialSkills, type ProfileScope, profileScopeKey } from '@/hermes'import { useI18n } from '@/i18n'-import { installHubSkill, notifyHubActionFailed } from '@/store/hub-actions'+import { HUB_SOURCES_KEY, installHubSkill, notifyHubActionFailed, OFFICIAL_SKILLS_KEY } from '@/store/hub-actions'import { notify } from '@/store/notifications'+import type { SkillHubSourcesResponse, SkillInfo } from '@/types/hermes'+import { CatalogAlert } from './catalog-alert'import { CatalogBrowser } from './catalog-browser'-import type { CatalogEntry } from './catalog-data'+import { type CatalogEntry, parseCatalog } from './catalog-data'interface SkillCatalogProps {- installedNames: ReadonlySet<string>- profile?: ProfileScope+ skills: SkillInfo[]+ profile: ProfileScopequery?: stringonQueryChange?: (value: string) => void+ actions?: ReactNode+ installedPending?: boolean+ notice?: ReactNode+ renderInstalledDetail: (skill: SkillInfo) => ReactNode+ renderInstalledAction?: (skill: SkillInfo) => ReactNode}-export function SkillCatalog({ installedNames, profile, query = '', onQueryChange }: SkillCatalogProps) {+/** Public discovery and the profile's local skills share one browser. Management+ * stays in SkillsTab; catalog install actions have exactly one owner here. */+export function SkillCatalog(props: SkillCatalogProps) {+ return <ScopedSkillCatalog key={profileScopeKey(props.profile)} {...props} />+}++function ScopedSkillCatalog({+ skills,+ profile,+ query,+ onQueryChange,+ actions,+ installedPending,+ notice,+ renderInstalledDetail,+ renderInstalledAction+}: SkillCatalogProps) {const { t } = useI18n()const h = t.skills.hub+ const mounted = useRef(true)+ const pending = useRef(new Set<string>())const [installing, setInstalling] = useState<ReadonlySet<string>>(new Set())+ // eslint-disable-next-line no-restricted-syntax -- lifecycle guard drops stale async completions; it does not mirror an atom+ useEffect(() => {+ mounted.current = true++ return () => {+ mounted.current = false+ }+ }, [])++ const {+ data: officialData,+ error: officialError,+ refetch: refreshOfficial+ } = useQuery({+ queryKey: [...OFFICIAL_SKILLS_KEY, profileScopeKey(profile)],+ queryFn: () => getOfficialSkills(profile),+ staleTime: 60_000,+ retry: false+ })++ const hasHubSkills = skills.some(skill => skill.provenance === 'hub')++ const {+ data: hubData,+ isPending: hubPending,+ error: hubError,+ refetch: refreshHub+ } = useQuery({+ queryKey: [...HUB_SOURCES_KEY, profileScopeKey(profile)],+ // SkillInfo has provenance, not a source identifier. Read the installed+ // lock map rather than guessing identity from a community skill's name.+ // The older getSkillHubSources helper cannot carry a connection pin.+ queryFn: () =>+ window.hermesDesktop.api<SkillHubSourcesResponse>({+ ...capabilityScoped(profile),+ path: '/api/skills/hub/sources',+ timeoutMs: 45_000+ }),+ enabled: hasHubSkills,+ staleTime: 60_000,+ retry: false+ })++ const catalog = useMemo(() => {+ const skillsById = new Map<string, SkillInfo>()+ const skillsByName = new Map(skills.map(skill => [skill.name, skill]))+ const installedByName = new Map<string, CatalogEntry>()+ const installedByIdentifier = new Map<string, CatalogEntry>()+ const installedIdentifiers = new Set(Object.keys(hubData?.installed ?? {}))++ const localEntries = parseCatalog(+ 'skills',+ skills.map(skill => ({+ name: skill.name,+ description: skill.description,+ category: skill.category,+ source: skill.provenance === 'bundled' ? 'built-in' : skill.provenance === 'hub' ? 'hub' : 'local'+ }))+ ).map(entry => {+ const skill = skillsByName.get(entry.name)!+ const installed = { ...entry, id: `installed:${skill.name}`, installIdentifier: null }+ skillsById.set(installed.id, skill)+ installedByName.set(skill.name, installed)++ return installed+ })++ for (const [identifier, record] of Object.entries(hubData?.installed ?? {})) {+ const installed = record.name ? installedByName.get(record.name) : undefined++ if (installed && skillsById.get(installed.id)?.provenance === 'hub') {+ installedByIdentifier.set(identifier, installed)+ }+ }++ const official = officialData?.skills ?? []++ const officialEntries = parseCatalog(+ 'skills',+ official.map(skill => ({+ ...skill,+ source: 'optional',+ installIdentifier: skill.identifier+ }))+ )++ const officialByIdentifier = new Map(officialEntries.map(entry => [entry.identifier, entry]))++ for (const skill of official) {+ if (!skill.installed) {+ continue+ }+ installedIdentifiers.add(skill.identifier)+ const installed = installedByName.get(skill.name)++ if (installed && skillsById.get(installed.id)?.provenance === 'hub') {+ installedByIdentifier.set(skill.identifier, installed)+ }+ }++ const officialFor = (entry: CatalogEntry) => {+ if (entry.source !== 'optional') {+ return undefined+ }+ const identifier = entry.installIdentifier ?? entry.identifier+ const exact = officialByIdentifier.get(identifier)++ if (exact) {+ return exact+ }++ if (identifier !== entry.name && identifier !== `official/${entry.name}`) {+ return undefined+ }++ // Old public snapshots omit optional identifiers. Only the official+ // optional namespace can use this fallback, never community lookalikes.+ return officialEntries.find(skill => skill.name === entry.name && skill.category === entry.category)+ }++ const matchInstalled = (entry: CatalogEntry): CatalogEntry | undefined => {+ const exact = installedByIdentifier.get(entry.installIdentifier ?? entry.identifier)++ if (exact) {+ return exact+ }++ if (entry.source === 'built-in') {+ const bundled = installedByName.get(entry.name)++ if (bundled && skillsById.get(bundled.id)?.provenance === 'bundled') {+ return bundled+ }+ }++ const optional = officialFor(entry)++ return optional ? (installedByIdentifier.get(optional.identifier) ?? optional) : undefined+ }++ // CatalogBrowser merges these supplemental rows with the public feed.+ // Optional rows remain available even offline / ahead of the snapshot;+ // membership here is NOT installation — isInstalled owns that decision.+ const entries = [+ ...localEntries,+ ...officialEntries.filter(entry => !installedByIdentifier.has(entry.identifier))+ ]++ return { entries, skillsById, installedIdentifiers, matchInstalled, officialFor }+ }, [skills, hubData, officialData])+const isInstalled = useCallback(- (entry: CatalogEntry) => installedNames.has(entry.name) || installedNames.has(entry.identifier),- [installedNames]+ (entry: CatalogEntry) => {+ if (catalog.skillsById.has(entry.id)) {+ return true+ }+ const matched = catalog.matchInstalled(entry)++ if (matched && catalog.skillsById.has(matched.id)) {+ return true+ }+ const optional = catalog.officialFor(entry)++ return catalog.installedIdentifiers.has(optional?.identifier ?? entry.installIdentifier ?? entry.identifier)+ },+ [catalog])+ const installIdentifier = (entry: CatalogEntry) => catalog.officialFor(entry)?.identifier ?? entry.installIdentifier++ const identityPending = hasHubSkills && (hubPending || Boolean(hubError))+const install = (entry: CatalogEntry) => {- if (!entry.installIdentifier || isInstalled(entry) || installing.has(entry.id)) {+ const identifier = installIdentifier(entry)++ if (installedPending || identityPending || !identifier || isInstalled(entry) || pending.current.has(identifier)) {return}- setInstalling(current => new Set(current).add(entry.id))+ pending.current.add(identifier)+ setInstalling(new Set(pending.current))notify({ kind: 'success', title: h.installStarted(entry.name), message: h.actionLog })- void installHubSkill(entry.installIdentifier, profile)- .catch(err => notifyHubActionFailed(err, h.actionFailed, entry.name, profile))- .finally(() => setInstalling(current => new Set([...current].filter(id => id !== entry.id))))+ void installHubSkill(identifier, profile)+ .catch(err => {+ if (mounted.current) {+ notifyHubActionFailed(err, h.actionFailed, entry.name, profile)+ }+ })+ .finally(() => {+ pending.current.delete(identifier)++ if (mounted.current) {+ setInstalling(new Set(pending.current))+ }+ })}return (<CatalogBrowser+ actions={actions}+ installedEntries={catalog.entries}+ installedPending={installedPending || identityPending}isInstalled={isInstalled}- isInstalling={entry => installing.has(entry.id)}+ isInstalling={entry => installing.has(installIdentifier(entry) ?? '')}kind="skills"+ matchInstalled={catalog.matchInstalled}+ notice={+ <>+ {notice}+ {(officialError || hubError) && (+ <CatalogAlert+ onRetry={() => {+ if (officialError) {+ void refreshOfficial()+ }++ if (hubError) {+ void refreshHub()+ }+ }}+ retryLabel={t.skills.refresh}+ title={t.skills.skillsLoadFailed}+ >+ {(hubError ?? officialError)?.message}+ </CatalogAlert>+ )}+ {hasHubSkills && hubPending && !installedPending && !notice && (+ <p className="px-3 py-2 text-xs text-(--ui-text-tertiary)" role="status">+ {t.skills.loading}+ </p>+ )}+ </>+ }onInstall={install}onQueryChange={onQueryChange}query={query}+ renderInstalledAction={entry => {+ const skill = catalog.skillsById.get(entry.id)++ return skill && renderInstalledAction ? renderInstalledAction(skill) : null+ }}+ renderInstalledDetail={entry => {+ const skill = catalog.skillsById.get(entry.id)++ return skill ? renderInstalledDetail(skill) : null+ }}/>)}diff --git a/apps/desktop/src/app/capabilities/catalog/use-catalog-filters.ts b/apps/desktop/src/app/capabilities/catalog/use-catalog-filters.tsnew file mode 100644index 00000000000..e818666e0eb--- /dev/null+++ b/apps/desktop/src/app/capabilities/catalog/use-catalog-filters.ts@@ -0,0 +1,41 @@+import { useState } from 'react'++import type { CatalogKind } from './catalog-data'+import { type CatalogFacets, type CatalogSort, EMPTY_FACETS } from './catalog-query'++type ListFacet = 'sources' | 'categories' | 'tags'++const toggled = (list: string[], value: string) =>+ list.includes(value) ? list.filter(item => item !== value) : [...list, value]++/** Rail state for one catalog. `onChange` runs after every change so the+ * browser can drop paging and selection that no longer apply. */+export function useCatalogFilters(kind: CatalogKind, onChange: () => void) {+ const [facets, setFacets] = useState(EMPTY_FACETS)+ const [sort, setSortState] = useState<CatalogSort>(kind === 'plugins' ? 'stars' : 'discover')++ const update = (next: (current: CatalogFacets) => CatalogFacets) => {+ setFacets(next)+ onChange()+ }++ // `null` clears the facet (its "All" row).+ const toggle = (facet: ListFacet) => (value: string | null) =>+ update(current => ({ ...current, [facet]: value === null ? [] : toggled(current[facet], value) }))++ return {+ facets,+ sort,+ setSort: (value: CatalogSort) => {+ setSortState(value)+ onChange()+ },+ toggleSource: toggle('sources'),+ toggleCategory: toggle('categories'),+ toggleTag: toggle('tags'),+ toggleInstalled: () => update(current => ({ ...current, installedOnly: !current.installedOnly })),+ // Cards and "See all" drill into one category rather than toggling it.+ chooseCategory: (value: string) => update(current => ({ ...current, categories: [value], tags: [] })),+ clear: () => update(() => EMPTY_FACETS)+ }+}diff --git a/apps/desktop/src/app/capabilities/index.tsx b/apps/desktop/src/app/capabilities/index.tsxindex 8c4fe5a5731..54a9e41fd77 100644--- a/apps/desktop/src/app/capabilities/index.tsx+++ b/apps/desktop/src/app/capabilities/index.tsx@@ -1,5 +1,5 @@import type * as React from 'react'-import { useCallback, useMemo, useState } from 'react'+import { useCallback, useEffect, useMemo, useState } from 'react'import { PageLoader } from '@/components/page-loader'import { Button } from '@/components/ui/button'@@ -16,11 +16,9 @@ import { PanelEmpty } from '../overlays/panel'import { PageSearchShell } from '../page-search-shell'import type { SetStatusbarItemGroup } from '../shell/statusbar-controls'-import { CapabilityTabs, type CapabilityView } from './catalog/capability-tabs'-import { SkillCatalog } from './catalog/skill-catalog'-import { UpdateSkillsButton } from './catalog/update-skills-button'+import { prefetchCatalogWhenIdle } from './catalog/catalog-data'import { ConnectorsTab } from './connectors/connectors-tab'-import { PluginActions, PluginsTab } from './plugins/plugins-tab'+import { PluginsTab } from './plugins/plugins-tab'import { CapabilityScopeSelector, useCapabilityScope } from './scope-selector'import { SKILLS_QUERY_KEY, skillSearchTerms, useSkillsQuery } from './skills/skills-data'import { SkillsTab } from './skills/skills-tab'@@ -73,8 +71,6 @@ export function CapabilitiesView({const gateway = useStoreSelector($gateway, g => (mode === 'connectors' ? g : null))const [query, setQuery] = useState('')- const [skillsView, setSkillsView] = useState<CapabilityView>('installed')- const [pluginsView, setPluginsView] = useState<CapabilityView>('installed')const scope = useCapabilityScope({ fixedConnection, fixedProfile })@@ -82,7 +78,6 @@ export function CapabilitiesView({// pair, because the counts stay live for the tab the user is NOT on.const { data: skills, isError: skillsFailed, error: skillsError } = useSkillsQuery(scope.profile)const { data: toolsets, isError: toolsetsFailed } = useToolsetsQuery(scope.profile)- const installedSkillNames = useMemo(() => new Set((skills ?? []).map(skill => skill.name)), [skills])const refreshCapabilities = useCallback(async () => {await Promise.all([@@ -98,6 +93,10 @@ export function CapabilitiesView({useRefreshHotkey(refreshCapabilities)+ // Plugins is small enough to warm from any tab. Skills (~100k rows) only+ // loads when asked for: an idle parse of it would still block the page.+ useEffect(() => (mode === 'plugins' ? undefined : prefetchCatalogWhenIdle('plugins')), [mode])+// Rotating placeholder nudges from the user's own data — teach that search// understands categories and tool names, not just titles.const searchHints = useMemo(() => {@@ -113,7 +112,7 @@ export function CapabilitiesView({}, [mode, skills, t, toolsets])// MCP and Plugins load independently of the installed Skills/Tools lists.- const gated = mode === 'toolsets' || (mode === 'skills' && skillsView === 'installed')+ const gated = mode === 'toolsets'const pending = gated && !(skills && toolsets)const loadGate = !pending ? null : skillsFailed || toolsetsFailed ? (@@ -147,32 +146,24 @@ export function CapabilitiesView({<PluginsTabkey={`plugins-${scope.key}`}onQueryChange={setQuery}- onViewChange={setPluginsView}profile={scope.profile}query={query}scopeLabel={scope.label}scopeSelector={scope.options.length > 1 ? <CapabilityScopeSelector compact scope={scope} /> : undefined}- view={pluginsView}/>),- skills: () =>- skillsView === 'browse' ? (- <SkillCatalog- installedNames={installedSkillNames}- key={`catalog-${scope.key}`}- onQueryChange={setQuery}- profile={scope.profile}- query={query}- />- ) : (- <SkillsTab- key={`skills-${scope.key}`}- onRefresh={() => void refreshCapabilities()}- profile={scope.profile}- query={query}- skills={skills ?? []}- />- ),+ skills: () => (+ <SkillsTab+ installedError={skillsError}+ installedPending={!skills || skillsFailed}+ key={`skills-${scope.key}`}+ onQueryChange={setQuery}+ onRefresh={() => void refreshCapabilities()}+ profile={scope.profile}+ query={query}+ skills={skills ?? []}+ />+ ),toolsets: () => (<ToolsetsTab key={`toolsets-${scope.key}`} profile={scope.profile} query={query} toolsets={toolsets ?? []} />)@@ -184,8 +175,8 @@ export function CapabilitiesView({activeTab={mode}onSearchChange={setQuery}onTabChange={id => setMode(id as CapabilityMode)}- // The Connectors directory owns its search field.- searchHidden={mode === 'connectors'}+ // Catalogs keep search beside their results; Connectors owns its field too.+ searchHidden={mode !== 'toolsets'}searchHints={searchHints}searchPlaceholder={mode === 'plugins'@@ -204,19 +195,6 @@ export function CapabilitiesView({><div className="flex h-full flex-col">{mode !== 'plugins' && <CapabilityScopeSelector scope={scope} />}- {(mode === 'skills' || mode === 'plugins') && (- <CapabilityTabs- actions={- mode === 'skills' ? (- <UpdateSkillsButton profile={scope.profile} />- ) : (- <PluginActions profile={scope.profile} />- )- }- onChange={mode === 'skills' ? setSkillsView : setPluginsView}- value={mode === 'skills' ? skillsView : pluginsView}- />- )}<div className="flex min-h-0 flex-1 flex-col">{loadGate ?? tabContent[mode]()}</div></div></PageSearchShell>diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsxindex cd13ca1fe14..b5cdd6f701e 100644--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx@@ -12,29 +12,22 @@ import { $pluginInstallRequest, closePluginInstallRequest } from '@/store/pluginimport { $connection } from '@/store/session'import { PageSearchShell } from '../../page-search-shell'-import { CapabilityTabs } from '../catalog/capability-tabs'import { parseCatalog } from '../catalog/catalog-data'import { $catalogCardView } from '../catalog/store'-import { PluginActions, PluginsTab } from './plugins-tab'+import { PluginsTab } from './plugins-tab'const requestGateway = vi.fn(async (_method: string, _params?: Record<string, unknown>): Promise<unknown> => ({plugins: $agentPlugins.get()}))-// The shell owns search and navigation; exercise the same controlled composition.-function PluginsHarness({- view: initialView = 'installed',- query: initialQuery = '',- ...props-}: ComponentProps<typeof PluginsTab>) {- const [view, setView] = useState(initialView)- const [query, setQuery] = useState(initialQuery)+// The shell owns search; exercise the same controlled composition as CapabilitiesView.+function PluginsHarness({ query: initialQuery, ...props }: ComponentProps<typeof PluginsTab>) {+ const [query, setQuery] = useState(initialQuery ?? '')return (- <PageSearchShell onSearchChange={setQuery} searchPlaceholder="Search plugins" searchValue={query}>- <CapabilityTabs actions={<PluginActions profile={props.profile} />} onChange={setView} value={view} />- <PluginsTab {...props} onQueryChange={setQuery} onViewChange={setView} query={query} view={view} />+ <PageSearchShell onSearchChange={setQuery} searchHidden searchPlaceholder="Search plugins" searchValue={query}>+ <PluginsTab {...props} onQueryChange={setQuery} query={query} /></PageSearchShell>)}@@ -62,9 +55,8 @@ function seedCatalog(entries = [weatherEntry]) {}async function selectCatalogEntry(name: string) {- fireEvent.click(screen.getByRole('button', { name: 'Browse' }))- fireEvent.click(await screen.findByRole('button', { name: text => text.startsWith(name) }))- expect(screen.getByRole('heading', { name })).toBeTruthy()+ fireEvent.click((await screen.findAllByRole('button', { name }))[0])+ expect(screen.getAllByRole('heading', { name }).length).toBeGreaterThan(0)}const connectionFixture = {@@ -96,6 +88,7 @@ beforeEach(() => {$agentPlugins.set([])$agentPluginsStatus.set('ready')$catalogCardView.set(false)+ seedCatalog([])closePluginInstallRequest()requestGateway.mockReset()requestGateway.mockImplementation(async () => ({ plugins: $agentPlugins.get() }))@@ -133,16 +126,15 @@ describe('PluginsTab', () => {<QueryClientProvider client={queryClient}><MemoryRouter initialEntries={['/capabilities?tab=plugins&plugin=omega']}><Location />- <PluginsHarness profile="workbot" query="nothing-matches" view="browse" />+ <PluginsHarness profile="workbot" query="nothing-matches" /></MemoryRouter></QueryClientProvider>)await screen.findByRole('switch', { name: 'Agent: omega' })await waitFor(() => expect(screen.getByTestId('route').textContent).toBe('?tab=plugins'))- expect(screen.getByRole('button', { name: 'Installed', pressed: true })).toBeTruthy()expect(screen.getByRole<HTMLInputElement>('textbox', { name: 'Search plugins' }).value).toBe('')expect(screen.getByRole('switch', { name: 'Agent: omega' })).toBeTruthy()- fireEvent.click(screen.getByRole('button', { name: /alpha/ }))+ fireEvent.click(screen.getByRole('button', { name: 'alpha', pressed: false }))expect(screen.getByRole('switch', { name: 'Agent: alpha' })).toBeTruthy()})@@ -317,7 +309,7 @@ describe('PluginsTab', () => {await selectCatalogEntry(weatherEntry.name)expect($pluginInstallRequest.get()).toBeNull()- fireEvent.click(screen.getByRole('button', { name: 'Install' }))+ fireEvent.click(screen.getByRole('switch', { name: `Add ${weatherEntry.name}` }))expect($pluginInstallRequest.get()).toMatchObject({catalogName: weatherEntry.name,@@ -327,22 +319,21 @@ describe('PluginsTab', () => {})})- it('keeps Installed in list/detail mode and filters it through the parent search', () => {- $catalogCardView.set(true)+ it('shows installed plugins in list/detail mode and filters them through the parent search', () => {$pluginRecords.set({clock: { id: 'clock', name: 'Clock', kind: 'disk', status: 'loaded' },weather: { id: 'weather', name: 'Weather', kind: 'disk', status: 'loaded' }})renderPlugins({ profile: null })- expect(screen.getByRole('button', { name: /^Clock/, pressed: true })).toBeTruthy()+ expect(screen.getByRole('button', { name: 'Clock', pressed: true })).toBeTruthy()expect(screen.getByRole('switch', { name: 'Desktop: Clock' })).toBeTruthy()- fireEvent.click(screen.getByRole('button', { name: /^Weather/ }))+ fireEvent.click(screen.getByRole('button', { name: 'Weather', pressed: false }))expect(screen.getByRole('switch', { name: 'Desktop: Weather' })).toBeTruthy()expect(screen.queryByRole('dialog')).toBeNull()fireEvent.change(screen.getByRole('textbox', { name: 'Search plugins' }), { target: { value: 'Clock' } })- expect(screen.queryByRole('button', { name: /^Weather/ })).toBeNull()+ expect(screen.queryByRole('button', { name: 'Weather', pressed: false })).toBeNull()expect(screen.getByRole('switch', { name: 'Desktop: Clock' })).toBeTruthy()})@@ -411,7 +402,7 @@ describe('PluginsTab', () => {renderPlugins({ profile: null })await selectCatalogEntry(entry.name)- fireEvent.click(screen.getByRole('button', { name: 'Install' }))+ fireEvent.click(screen.getByRole('switch', { name: `Add ${entry.name}` }))expect($pluginInstallRequest.get()).toMatchObject({catalogName: entry.name,@@ -526,7 +517,9 @@ describe('PluginsTab catalog UX', () => {})})- it('fetches only on Browse, retaining parent search across selection and tab bounce', async () => {+ it('fetches the catalog once, retaining parent search across selection and filters', async () => {+ queryClient.clear()+const fetchCatalog = vi.fn().mockResolvedValue({ok: true,json: async () => [@@ -540,19 +533,17 @@ describe('PluginsTab catalog UX', () => {renderPlugins({ profile: null })})- expect(fetchCatalog).not.toHaveBeenCalled()- expect(screen.queryByRole('heading', { name: weatherEntry.name })).toBeNull()await selectCatalogEntry('garden-plugin')const search = screen.getByRole<HTMLInputElement>('textbox', { name: 'Search plugins' })fireEvent.change(search, { target: { value: 'weather' } })expect(await screen.findByRole('heading', { name: weatherEntry.name })).toBeTruthy()- expect(screen.queryByRole('button', { name: /^garden-plugin/ })).toBeNull()+ expect(screen.queryByRole('button', { name: 'garden-plugin' })).toBeNull()fireEvent.click(screen.getByRole('button', { name: 'Installed', pressed: false }))expect(screen.queryByRole('heading', { name: weatherEntry.name })).toBeNull()expect(search.value).toBe('weather')- fireEvent.click(screen.getByRole('button', { name: 'Clear filters' }))+ fireEvent.click(screen.getAllByRole('button', { name: 'Clear filters' })[0])expect(search.value).toBe('')await selectCatalogEntry('garden-plugin')@@ -563,24 +554,21 @@ describe('PluginsTab catalog UX', () => {})it('retries a failed catalog only when asked, not on tab bounce', async () => {+ queryClient.clear()+const fetchCatalog = vi.fn().mockResolvedValueOnce({ ok: false, status: 503 }).mockResolvedValue({ ok: true, json: async () => [weatherEntry] })vi.stubGlobal('fetch', fetchCatalog)- await act(async () => {- renderPlugins({ profile: null })- })- fireEvent.click(screen.getByRole('button', { name: 'Browse' }))+ const view = renderPlugins({ profile: null })expect(await screen.findByText('Catalog HTTP 503')).toBeTruthy()expect(fetchCatalog).toHaveBeenCalledTimes(1)+ view.unmount()await act(async () => {- fireEvent.click(screen.getByRole('button', { name: /^Installed/ }))- })- await act(async () => {- fireEvent.click(screen.getByRole('button', { name: 'Browse' }))+ renderPlugins({ profile: null })})expect(fetchCatalog).toHaveBeenCalledTimes(1)expect(screen.getByText('Catalog HTTP 503')).toBeTruthy()@@ -722,7 +710,8 @@ describe('PluginsTab catalog UX', () => {expect(screen.queryByRole('button', { name: 'Uninstall: demo-tool' })).toBeNull()})- it('disables native installation of a catalog entry that is already installed and current', async () => {+ it('toggles an installed catalog card on and off in place instead of reinstalling or uninstalling it', async () => {+ $catalogCardView.set(true)$agentPlugins.set([{catalog_name: 'demo-weather',@@ -732,52 +721,34 @@ describe('PluginsTab catalog UX', () => {name: 'demo-weather',source: 'git',status: 'enabled',- update_available: false,version: '1.0.0'}])-+ requestGateway.mockImplementation(async (_method, params) =>+ params?.action === 'toggle'+ ? { ok: true, plugin: { key: 'demo-weather', name: 'demo-weather', status: 'disabled' } }+ : { plugins: $agentPlugins.get() }+ )seedCatalog([{ ...weatherEntry, name: 'demo-weather' }])await act(async () => {- renderPlugins({ profile: null })+ renderPlugins({ profile: 'workbot' })})- await selectCatalogEntry('demo-weather')- const installed = within(screen.getByRole('main')).getByRole<HTMLButtonElement>('button', { name: 'Installed' })- expect(installed.disabled).toBe(true)- fireEvent.click(installed)- expect($pluginInstallRequest.get()).toBeNull()- })+ const card = screen+ .getAllByRole('article')+ .find(article => within(article).queryByRole('button', { name: 'demo-weather' }))!+ const toggle = within(card).getByRole('switch', { name: 'demo-weather' })+ expect(toggle.getAttribute('aria-checked')).toBe('true')+ fireEvent.click(toggle)- it('offers native catalog installation when an update is available', async () => {- $agentPlugins.set([- {- catalog_name: 'demo-weather',- description: '',- installed_sha: 'a'.repeat(40),- key: 'demo-weather',- name: 'demo-weather',- source: 'git',- status: 'enabled',- update_available: true,- version: '1.0.0'- }- ])-- const entry = { ...weatherEntry, name: 'demo-weather', sha: 'b'.repeat(40) }-- seedCatalog([entry])- await act(async () => {- renderPlugins({ profile: null })- })- await selectCatalogEntry(entry.name)- fireEvent.click(screen.getByRole('button', { name: 'Install' }))-- expect($pluginInstallRequest.get()).toMatchObject({- catalogName: entry.name,- repo: entry.repo,- profile: null,- sha: entry.sha- })+ await waitFor(() =>+ expect(requestGateway).toHaveBeenCalledWith(+ 'plugins.manage',+ expect.objectContaining({ action: 'toggle', key: 'demo-weather', enable: false, profile: 'workbot' })+ )+ )+ expect($confirmRequest.get()).toBeNull()+ expect($pluginInstallRequest.get()).toBeNull()+ expect(requestGateway).not.toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'remove' }))})})diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsxindex ffb6a0cfce2..d8d06819224 100644--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx@@ -3,7 +3,6 @@ import { memo, type ReactNode, useCallback, useEffect, useMemo, useState } fromimport { setEnvVar } from '@/api/config'import { useGatewayRequest } from '@/app/gateway/hooks/use-gateway-request'-import { PageLoader } from '@/components/page-loader'import { Button } from '@/components/ui/button'import { Codicon } from '@/components/ui/codicon'import { Switch } from '@/components/ui/switch'@@ -37,10 +36,9 @@ import { openCatalogPluginInstall } from '@/store/plugin-catalog-install'import { openPluginInstallRequest } from '@/store/plugin-install-request'import { $connection } from '@/store/session'-import { PanelEmpty } from '../../overlays/panel'import { Pill } from '../../settings/primitives'import { useDeepLinkHighlight } from '../../settings/use-deep-link-highlight'-import type { CapabilityView } from '../catalog/capability-tabs'+import { CatalogAlert } from '../catalog/catalog-alert'import { CatalogBrowser } from '../catalog/catalog-browser'import { type CatalogEntry, parseCatalog } from '../catalog/catalog-data'@@ -496,16 +494,12 @@ export const PluginsTab = memo(function PluginsTab({profile,scopeSelector,scopeLabel,- view = 'installed',- query = '',- onQueryChange,- onViewChange+ query,+ onQueryChange}: {profile: ProfileScopequery?: stringonQueryChange?: (value: string) => void- view?: CapabilityView- onViewChange?: (view: CapabilityView) => void/** The profile selector governs only the Agent half, not the app-level Desktop half. */scopeSelector?: ReactNode/** Display name of the selected profile for the Agent half label. */@@ -554,12 +548,11 @@ export const PluginsTab = memo(function PluginsTab({const pkg = packageForTarget(target)if (pkg) {- onViewChange?.('installed')onQueryChange?.('')setSelectedEntryId(`installed:${pkg.key}`)}},- [onQueryChange, onViewChange, packageForTarget]+ [onQueryChange, packageForTarget])})@@ -585,133 +578,185 @@ export const PluginsTab = memo(function PluginsTab({const packageById = useMemo(() => new Map(packages.map(pkg => [`installed:${pkg.key}`, pkg])), [packages])- const isInstalled = (entry: CatalogEntry) =>- packageById.has(entry.id) ||- agentRows.some(row => (row.catalog_name === entry.name || row.name === entry.name) && !row.update_available)+ const installedByCatalogName = useMemo(() => {+ const byName = new Map<string, CatalogEntry>()++ for (const entry of installedEntries) {+ const pkg = packageById.get(entry.id)+ const name = pkg?.agent?.catalog_name ?? pkg?.desktop?.packageOrigin?.catalogName++ if (name) {+ byName.set(name, entry)+ }+ }++ return byName+ }, [installedEntries, packageById])++ const matchInstalled = useCallback(+ (entry: CatalogEntry) => installedByCatalogName.get(entry.name),+ [installedByCatalogName]+ )+ const isInstalled = (entry: CatalogEntry) => packageById.has(entry.id)++ const handleAgentRemove = useCallback(+ (row: AgentPluginRow) => {+ void confirm({+ confirmLabel: p.uninstall,+ description: p.uninstallConfirmBody(row.name, label),+ destructive: true,+ title: p.uninstallConfirmTitle(row.name)+ }).then(async ok => {+ if (!ok) {+ return+ }++ if (await removeAgentPlugin(requestGateway, row.name, p.uninstallFailed(row.name), scope)) {+ notify({ kind: 'success', message: p.uninstalled(row.name) })+ // Prunes the app-level desktop half whose source package just went away.+ void rescanAll(requestGateway, scope)+ }+ })+ },+ [label, p, requestGateway, scope]+ )++ const handleDesktopRemove = useCallback(+ (record: PluginRecord) => {+ void confirm({+ confirmLabel: p.uninstall,+ description: p.uninstallDesktopConfirmBody(record.name),+ destructive: true,+ title: p.uninstallConfirmTitle(record.name)+ }).then(async ok => {+ if (!ok) {+ return+ }++ const result = await uninstallDiskPlugin(record.id)++ if (result.ok) {+ notify({ kind: 'success', message: p.uninstalledDesktop(record.name) })+ } else {+ notifyError(result.error, p.uninstallFailed(record.name))+ }+ })+ },+ [p]+ )++ // The card switch turns the whole package on or off, like a skill's; per-half+ // switches and uninstall (trash + confirm) live in the detail's PackageRow.+ const packageSwitch = (pkg: PluginPackage) => {+ const { agent, desktop } = pkg++ const setEnabled = (enable: boolean) => {+ if (agent?.key) {+ void toggleAgentPlugin(requestGateway, agent.key, enable, p.toggleFailed(agent.name), scope)+ }++ if (desktop) {+ void setPluginEnabled(desktop.id, enable)+ }+ }++ return (+ <Switch+ aria-label={pkg.name}+ checked={agent ? agent.status === 'enabled' : desktop?.status !== 'disabled'}+ disabled={agent ? !agent.key || agentBusy(agent) : false}+ onCheckedChange={setEnabled}+ size="xs"+ />+ )+ }++ const notice =+ status === 'error' ? (+ <CatalogAlert+ onRetry={() => void loadAgentPlugins(requestGateway, scope)}+ retryLabel={t.skills.refresh}+ title={p.loadFailed}+ >+ {error}+ </CatalogAlert>+ ) : nullreturn (- <div className="flex h-full min-h-0 flex-col">- {view === 'installed' && status === 'error' ? (- <PanelEmpty- action={- <Button onClick={() => void loadAgentPlugins(requestGateway, scope)} size="sm">- {t.skills.refresh}- </Button>- }- description={error ?? undefined}- icon="error"- title={p.loadFailed}- />- ) : view === 'installed' && status === 'loading' && packages.length === 0 ? (- <PageLoader label={t.skills.loading} />- ) : (- <CatalogBrowser- installedEntries={installedEntries}- isInstalled={isInstalled}- kind="plugins"- onInstall={entry => openCatalogPluginInstall(entry, scope)}- onQueryChange={onQueryChange}- onSelectEntry={view === 'installed' ? setSelectedEntryId : undefined}- query={query}- renderInstalledDetail={entry => {- const pkg = packageById.get(entry.id)-- if (!pkg) {- return null- }-- return (- <PackageRow- busy={pkg.agent ? agentBusy(pkg.agent) : false}- key={pkg.key}- onAgentRemove={row => {- void confirm({- confirmLabel: p.uninstall,- description: p.uninstallConfirmBody(row.name, label),- destructive: true,- title: p.uninstallConfirmTitle(row.name)- }).then(async ok => {- if (!ok) {- return- }-- if (await removeAgentPlugin(requestGateway, row.name, p.uninstallFailed(row.name), scope)) {- notify({ kind: 'success', message: p.uninstalled(row.name) })- // Prunes the app-level desktop half whose source package just went away.- void rescanAll(requestGateway, scope)- }- })- }}- onAgentToggle={(row, enable) => {- if (!row.key) {- return- }-- void toggleAgentPlugin(requestGateway, row.key, enable, p.toggleFailed(row.name), scope)- }}- onAgentUpdate={row => {- const finish = (outcome: AgentPluginUpdateOutcome) => {- if (outcome.kind === 'applied') {- notify({ kind: 'success', message: p.updated(row.name) })- void rescanAll(requestGateway, scope)- }- }-- void updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope).then(- async outcome => {- if (outcome.kind !== 'consent') {- finish(outcome)-- return- }-- // The new pin widens the plugin (tools, hooks, deps, capabilities, a Desktop- // half); the backend changed nothing until the user confirms the delta.- const ok = await confirm({- confirmLabel: p.updateConsentConfirm,- description: [p.updateConsentBody(row.name, outcome.sha), ...outcome.deltaLines].join('\n'),- title: p.updateConsentTitle(row.name)- })-- if (ok) {- finish(await updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope, true))- }- }- )- }}- onDesktopRemove={record => {- void confirm({- confirmLabel: p.uninstall,- description: p.uninstallDesktopConfirmBody(record.name),- destructive: true,- title: p.uninstallConfirmTitle(record.name)- }).then(async ok => {- if (!ok) {- return- }-- const result = await uninstallDiskPlugin(record.id)-- if (result.ok) {- notify({ kind: 'success', message: p.uninstalledDesktop(record.name) })- } else {- notifyError(result.error, p.uninstallFailed(record.name))- }- })- }}- pkg={pkg}- profile={profile}- request={requestGateway}- scope={scope}- scopeLabel={label}- scopeSelector={scopeSelector}- />- )- }}- selectedEntryId={view === 'installed' ? selectedEntryId : undefined}- view={view}- />- )}- </div>+ <CatalogBrowser+ headerActions={<PluginActions profile={profile} />}+ installedEntries={installedEntries}+ installedPending={status !== 'ready'}+ isInstalled={isInstalled}+ kind="plugins"+ matchInstalled={matchInstalled}+ notice={notice}+ onInstall={entry => openCatalogPluginInstall(entry, scope)}+ onQueryChange={onQueryChange}+ query={query}+ renderInstalledAction={entry => {+ const pkg = packageById.get(entry.id)++ return pkg ? packageSwitch(pkg) : null+ }}+ renderInstalledDetail={entry => {+ const pkg = packageById.get(entry.id)++ if (!pkg) {+ return null+ }++ return (+ <PackageRow+ busy={pkg.agent ? agentBusy(pkg.agent) : false}+ key={pkg.key}+ onAgentRemove={handleAgentRemove}+ onAgentToggle={(row, enable) => {+ if (!row.key) {+ return+ }++ void toggleAgentPlugin(requestGateway, row.key, enable, p.toggleFailed(row.name), scope)+ }}+ onAgentUpdate={row => {+ const finish = (outcome: AgentPluginUpdateOutcome) => {+ if (outcome.kind === 'applied') {+ notify({ kind: 'success', message: p.updated(row.name) })+ void rescanAll(requestGateway, scope)+ }+ }++ void updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope).then(async outcome => {+ if (outcome.kind !== 'consent') {+ finish(outcome)++ return+ }++ // The new pin widens the plugin (tools, hooks, deps, capabilities, a Desktop+ // half); the backend changed nothing until the user confirms the delta.+ const ok = await confirm({+ confirmLabel: p.updateConsentConfirm,+ description: [p.updateConsentBody(row.name, outcome.sha), ...outcome.deltaLines].join('\n'),+ title: p.updateConsentTitle(row.name)+ })++ if (ok) {+ finish(await updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope, true))+ }+ })+ }}+ onDesktopRemove={handleDesktopRemove}+ pkg={pkg}+ profile={profile}+ request={requestGateway}+ scope={scope}+ scopeLabel={label}+ scopeSelector={scopeSelector}+ />+ )+ }}+ selectedEntryId={selectedEntryId}+ />)})diff --git a/apps/desktop/src/app/capabilities/skills/skill-detail.tsx b/apps/desktop/src/app/capabilities/skills/skill-detail.tsxindex 483d01e48fb..5235593e804 100644--- a/apps/desktop/src/app/capabilities/skills/skill-detail.tsx+++ b/apps/desktop/src/app/capabilities/skills/skill-detail.tsx@@ -1,18 +1,13 @@import { useQuery } from '@tanstack/react-query'import { useMemo } from 'react'+import { PageLoader } from '@/components/page-loader'import { Button } from '@/components/ui/button'-import { CountSkeleton } from '@/components/ui/skeleton'import { getSkillContent, type ProfileScope, profileScopeKey } from '@/hermes'import { useI18n } from '@/i18n'import type { SkillInfo } from '@/types/hermes'-import { PanelPill } from '../../overlays/panel'-import { asText, prettyName } from '../../settings/helpers'-import { DetailHeader } from '../primitives'-import { parseFrontmatter } from './frontmatter'-import { categoryFor } from './skills-data'export function SkillDetail({onArchive,@@ -46,20 +41,6 @@ export function SkillDetail({return (<>- <DetailHeader- description={asText(skill.description) || t.skills.noDescription}- pills={- <>- <PanelPill>{prettyName(categoryFor(skill))}</PanelPill>- {skill.provenance && skill.provenance !== 'bundled' && (- <PanelPill tone={skill.provenance === 'agent' ? 'good' : 'muted'}>- {t.skills.provenance[skill.provenance]}- </PanelPill>- )}- </>- }- title={skill.name}- />{editable && (<div className="flex items-center gap-2"><Button onClick={onEdit} size="xs" variant="text">@@ -70,21 +51,11 @@ export function SkillDetail({</Button></div>)}- {parsed && parsed.meta.length > 0 && (- <div className="grid gap-1 rounded-lg border border-(--ui-stroke-tertiary) bg-(--ui-bg-quinary) p-3">- {parsed.meta.map(([key, value]) => (- <div className="flex gap-2 text-[0.68rem] leading-4" key={key}>- <span className="w-24 shrink-0 font-medium text-(--ui-text-tertiary)">{key}</span>- <span className="min-w-0 whitespace-pre-wrap break-words text-(--ui-text-secondary)">{value}</span>- </div>- ))}- </div>- )}{contentQuery.isLoading ? (- <CountSkeleton />+ <PageLoader className="h-40" label={t.skills.loading} />) : parsed ? (<pre- className="overflow-auto whitespace-pre-wrap wrap-break-word rounded-lg border border-(--ui-stroke-tertiary) bg-(--ui-bg-quinary) p-3 font-mono text-[0.68rem] leading-relaxed"+ className="overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-[0.68rem] leading-relaxed text-(--ui-text-secondary)"data-selectable-text="true">{parsed.body.trim() || t.skills.noDescription}diff --git a/apps/desktop/src/app/capabilities/skills/skills-tab.tsx b/apps/desktop/src/app/capabilities/skills/skills-tab.tsxindex f13b23956cf..2f003a31668 100644--- a/apps/desktop/src/app/capabilities/skills/skills-tab.tsx+++ b/apps/desktop/src/app/capabilities/skills/skills-tab.tsx@@ -1,387 +1,350 @@-import { compactNumber } from '@hermes/shared'-import { useStore } from '@nanostores/react'-import { useQuery } from '@tanstack/react-query'-import { type ReactNode, useCallback, useMemo, useState } from 'react'+import { useCallback, useEffect, useRef, useState } from 'react'import { ArchiveSkillConfirmDialog } from '@/app/learning/archive-skill-confirm-dialog'import { CodeEditor } from '@/components/chat/code-editor'-import { Badge } from '@/components/ui/badge'import { Button } from '@/components/ui/button'-import {- editLearningNode,- getLearningNode,- getOfficialSkills,- type ProfileScope,- profileScopeKey,- setSkillEnabled-} from '@/hermes'+import { Switch } from '@/components/ui/switch'+import { editLearningNode, getLearningNode, type ProfileScope, profileScopeKey, setSkillEnabled } from '@/hermes'import { useI18n } from '@/i18n'-import { Loader2 } from '@/lib/icons'-import { Codecs, persistentAtom } from '@/lib/persisted'import { queryClient } from '@/lib/query-client'import { invalidateSlashCompletions } from '@/lib/slash-completion-cache'-import { useStoreSelector } from '@/lib/use-session-slice'-import { $hubActions, installHubSkill, notifyHubActionFailed, OFFICIAL_SKILLS_KEY } from '@/store/hub-actions'import { notify, notifyError } from '@/store/notifications'-import type { OfficialSkillInfo, SkillInfo } from '@/types/hermes'--import {- CapRow,- DetailColumn,- DetailPane,- ListColumn,- ListStrip,- ListStripMenu,- type ListStripMenuToggle,- MasterDetail-} from '../../master-detail'-import { prettyName } from '../../settings/helpers'-import { CapabilityEmpty, SortButton } from '../primitives'--import { OfficialSkillDetail } from './official-skill-detail'-import { SkillDetail } from './skill-detail'-import { categoryFor, filteredOfficial, filteredSkills, skillsQueryKey, usageOf } from './skills-data'--// Sort direction for the Skills list — persisted so the tab remembers-// most/least-used across navigations and restarts.-const $skillsSortDesc = persistentAtom('hermes.desktop.capabilities.skillsSortDesc', true, Codecs.bool)+import type { SkillInfo } from '@/types/hermes'-// Row subtitle: category, with non-default origins badged.-function skillSubtitle(skill: SkillInfo): ReactNode {- const category = prettyName(categoryFor(skill))- const provenance = skill.provenance+import { DetailPane, ListStripMenu, type ListStripMenuToggle } from '../../master-detail'+import { CatalogAlert } from '../catalog/catalog-alert'+import { SkillCatalog } from '../catalog/skill-catalog'+import { UpdateSkillsButton } from '../catalog/update-skills-button'- return (- <>- <span className="truncate">{category}</span>- {provenance === 'agent' && (- <Badge className="shrink-0 normal-case" variant="default">- learned- </Badge>- )}- {provenance === 'hub' && (- <Badge className="shrink-0 normal-case" variant="muted">- hub- </Badge>- )}- </>- )-}+import { SkillDetail } from './skill-detail'+import { skillsQueryKey, usageOf } from './skills-data'interface SkillsTabProps {/** The scope's skill list, straight from the shell's query. */skills: SkillInfo[]- /** The (connection, profile) scope every read and write routes to. */+ /** Every read and write targets this connection/profile pair. */profile: ProfileScopequery: string- /** Page-level refresh: a saved skill edit reloads the same way the refresh- * hotkey does, counts and slash completions included. */+ onQueryChange?: (value: string) => void+ installedPending?: boolean+ installedError?: unknownonRefresh: () => void}-/** The Skills tab: installed skills, official optional skills, and learned-skill editing. */-export function SkillsTab({ onRefresh, profile, query, skills }: SkillsTabProps) {+/** One management controller for the unified catalog, remounted on scope changes+ * so an old profile's editor, confirmation or pending write cannot enter another. */+export function SkillsTab(props: SkillsTabProps) {+ return <ScopedSkillsTab key={profileScopeKey(props.profile)} {...props} />+}++function ScopedSkillsTab({+ onRefresh,+ profile,+ query,+ onQueryChange,+ skills,+ installedPending = false,+ installedError+}: SkillsTabProps) {const { t } = useI18n()- const skillsSortDesc = useStore($skillsSortDesc)- const [bulkBusy, setBulkBusy] = useState(false)- const [selectedSkill, setSelectedSkill] = useState<string | null>(null)- const [selectedOfficial, setSelectedOfficial] = useState<string | null>(null)-- const { data: officialData } = useQuery({- queryKey: [...OFFICIAL_SKILLS_KEY, profileScopeKey(profile)],- queryFn: () => getOfficialSkills(profile),- staleTime: 60_000,- retry: false- })-- // Learned/local skills are editable + archivable, mirroring the memory- // graph (same /api/learning/node endpoints — delete archives, restorable- // via `hermes curator restore`).- const [skillEditor, setSkillEditor] = useState<null | { content: string; name: string }>(null)+ const mounted = useRef(true)+ const mutationBusy = useRef(false)+ const editorRequest = useRef(0)+ const saving = useRef(false)+ const [busy, setBusy] = useState(false)+ const [skillEditor, setSkillEditor] = useState<null | { name: string }>(null)const [skillDraft, setSkillDraft] = useState('')const [skillSaving, setSkillSaving] = useState(false)const [archiveTarget, setArchiveTarget] = useState<null | string>(null)- // Optimistic write-through against the scoped Skills key: toggles/bulk/- // archive repaint instantly; the next background refetch reconciles.+ // eslint-disable-next-line no-restricted-syntax -- lifecycle guard drops stale async completions; it does not mirror an atom+ useEffect(() => {+ mounted.current = true++ return () => {+ mounted.current = false+ editorRequest.current += 1+ }+ }, [])+const setSkills = useCallback((fn: (cur: SkillInfo[] | undefined) => SkillInfo[] | undefined) =>queryClient.setQueryData<SkillInfo[]>(skillsQueryKey(profile), prev => fn(prev) ?? prev),[profile])- const visibleSkills = useMemo(() => filteredSkills(skills, query, skillsSortDesc), [query, skills, skillsSortDesc])-- // Installed-name set stays unfiltered so search cannot make a skill look absent.- const installedSkillNames = useMemo(() => new Set(skills.map(s => s.name)), [skills])-- const visibleOfficial = useMemo(() => {- const catalog = (officialData?.skills ?? []).filter(- skill => !skill.installed && !installedSkillNames.has(skill.name)- )-- return filteredOfficial(catalog, query)- }, [installedSkillNames, officialData, query])-- const runningInstallKey = useStoreSelector($hubActions, actions =>- Object.keys(actions)- .filter(key => actions[key]?.running)- .sort()- .join('|')- )-- const runningInstalls = useMemo(() => new Set(runningInstallKey.split('|').filter(Boolean)), [runningInstallKey])-- // Keep a valid selection: fall back to the first visible row when the- // current selection is filtered out (or nothing is selected yet).- const activeSkill = useMemo(- () => visibleSkills.find(s => s.name === selectedSkill) ?? visibleSkills[0] ?? null,- [selectedSkill, visibleSkills]- )-- const activeOfficial = useMemo(- () => visibleOfficial.find(skill => skill.identifier === selectedOfficial) ?? null,- [selectedOfficial, visibleOfficial]- )-- function handleInstallOfficial(skill: OfficialSkillInfo) {- notify({ kind: 'success', title: t.skills.hub.installStarted(skill.name), message: t.skills.hub.actionLog })- void installHubSkill(skill.identifier, profile).catch(err =>- notifyHubActionFailed(err, t.skills.hub.actionFailed, skill.name, profile)- )- }-- async function handleToggleSkill(skill: SkillInfo, enabled: boolean) {- setSkills(current => current?.map(row => (row.name === skill.name ? { ...row, enabled } : row)) ?? current)-- try {- await setSkillEnabled(skill.name, enabled, profile)- // A disabled skill loses its `/name` command, so the composer's cached- // `/` list has to be dropped along with the row repaint.- invalidateSlashCompletions()- } catch (err) {- setSkills(- current => current?.map(row => (row.name === skill.name ? { ...row, enabled: !enabled } : row)) ?? current- )- notifyError(err, t.skills.failedToUpdate(skill.name))- }- }-- // Sequential on purpose: each toggle is a config read-modify-write on the- // backend; parallel calls would race the disabled-list save.- async function bulkApply(targets: SkillInfo[], enabled: boolean) {- if (bulkBusy || targets.length === 0) {+ // The backend saves one disabled-list config value: serialize individual and+ // bulk changes together, not merely the members of a bulk action.+ async function applyEnabled(targets: SkillInfo[], enabled: boolean, bulk = false) {+ if (mutationBusy.current || installedPending || installedError || targets.length === 0) {return}-- setBulkBusy(true)-+ mutationBusy.current = true+ setBusy(true)let done = 0try {+ await queryClient.cancelQueries({ queryKey: skillsQueryKey(profile), exact: true })+for (const row of targets) {- await setSkillEnabled(row.name, enabled, profile)- setSkills(cur => cur?.map(r => (r.name === row.name ? { ...r, enabled } : r)) ?? cur)- done += 1+ if (!mounted.current) {+ break+ }+ const previous =+ queryClient.getQueryData<SkillInfo[]>(skillsQueryKey(profile))?.find(skill => skill.name === row.name) ?? row+ setSkills(current => current?.map(skill => (skill.name === row.name ? { ...skill, enabled } : skill)))++ try {+ await setSkillEnabled(row.name, enabled, profile)+ done += 1+ } catch (err) {+ if (mounted.current) {+ setSkills(current =>+ current?.map(skill =>+ skill.name === row.name && skill.enabled === enabled ? { ...skill, enabled: previous.enabled } : skill+ )+ )+ }++ throw err+ }}- notify({ kind: 'success', title: t.skills.bulkUpdated(done), message: '' })+ if (bulk && mounted.current) {+ notify({ kind: 'success', title: t.skills.bulkUpdated(done), message: '' })+ }} catch (err) {- notifyError(err, t.skills.failedToUpdate(t.skills.tabSkills))+ if (mounted.current) {+ notifyError(err, t.skills.failedToUpdate(bulk ? t.skills.tabSkills : targets[0].name))+ }} finally {invalidateSlashCompletions()- setBulkBusy(false)+ void queryClient.invalidateQueries({ queryKey: skillsQueryKey(profile), exact: true })+ mutationBusy.current = false++ if (mounted.current) {+ setBusy(false)+ }}}- // Bulk actions ("All" master switch, "Disable unused") and the master-switch- // state target the WHOLE tab, never the search-filtered view — a tab-wide- // control that silently scoped to the current query would be a lie.- const allEnabled = skills.length > 0 && skills.every(s => s.enabled)+ const controlsDisabled = busy || installedPending || Boolean(installedError)- // One switch line covering enable-all/disable-all.+ // Bulk always means the whole profile, never just a search/filter result.const bulkSwitch: ListStripMenuToggle = {- checked: allEnabled,- disabled: bulkBusy,+ checked: skills.length > 0 && skills.every(skill => skill.enabled),+ disabled: controlsDisabled || skills.length === 0,label: t.skills.all,onToggle: checked =>- void bulkApply(- skills.filter(row => row.enabled !== checked),- checked+ void applyEnabled(+ skills.filter(skill => skill.enabled !== checked),+ checked,+ true)}- // "Never used" = zero recorded activity. The pruning move for a 100+ skill- // install: keep the workhorses, shed the noise.- const disableUnused = () =>- bulkApply(- skills.filter(skill => skill.enabled && usageOf(skill) === 0),- false- )-const openSkillEditor = async (name: string) => {+ if (saving.current || skillEditor?.name === name) {+ return+ }+ const request = ++editorRequest.current+try {const node = await getLearningNode(name, profile)- setSkillEditor({ content: node.content, name })+ if (!mounted.current || request !== editorRequest.current) {+ return+ }+ setSkillEditor({ name })setSkillDraft(node.content)} catch (err) {- notifyError(err, name)+ if (mounted.current && request === editorRequest.current) {+ notifyError(err, name)+ }}}+ const closeSkillEditor = () => {+ editorRequest.current += 1+ setSkillEditor(null)+ }+const saveSkillEdit = async () => {- if (!skillEditor) {+ if (!skillEditor || saving.current) {return}-+ const editor = skillEditor+ const request = editorRequest.current+ saving.current = truesetSkillSaving(true)try {- await editLearningNode(skillEditor.name, skillDraft, profile)- notify({- kind: 'success',- title: t.skills.skillUpdated,- message: t.skills.appliesToNewSessions(skillEditor.name)- })- setSkillEditor(null)+ const result = await editLearningNode(editor.name, skillDraft, profile)++ if (!result.ok) {+ throw new Error(result.message)+ }+ void queryClient.invalidateQueries({ queryKey: ['skill-content', editor.name, profileScopeKey(profile)] })+ void queryClient.invalidateQueries({ queryKey: skillsQueryKey(profile), exact: true })+ invalidateSlashCompletions()++ if (!mounted.current) {+ return+ }+ notify({ kind: 'success', title: t.skills.skillUpdated, message: t.skills.appliesToNewSessions(editor.name) })++ if (request === editorRequest.current) {+ setSkillEditor(null)+ }onRefresh()} catch (err) {- notifyError(err, skillEditor.name)+ if (mounted.current) {+ notifyError(err, editor.name)+ }} finally {- setSkillSaving(false)+ saving.current = false++ if (mounted.current) {+ setSkillSaving(false)+ }}}- const skillEditorPane = skillEditor && (- <DetailPane- actions={- <Button disabled={skillSaving} onClick={() => void saveSkillEdit()} size="xs">- {skillSaving ? t.common.saving : t.common.save}- </Button>- }- id="skill-editor"- onClose={() => setSkillEditor(null)}- title={<span className="text-[0.68rem] font-normal text-muted-foreground/60">{skillEditor.name}/SKILL.md</span>}- >- <CodeEditor- filePath="SKILL.md"- initialValue={skillEditor.content}- key={skillEditor.name}- onCancel={() => setSkillEditor(null)}- onChange={setSkillDraft}- onSave={() => void saveSkillEdit()}- />- </DetailPane>- )+ const notice = installedError ? (+ <CatalogAlert onRetry={onRefresh} retryLabel={t.skills.refresh} title={t.skills.skillsLoadFailed}>+ {installedError instanceof Error ? installedError.message : null}+ </CatalogAlert>+ ) : installedPending ? (+ <p className="px-3 py-2 text-xs text-(--ui-text-tertiary)" role="status">+ {t.skills.loading}+ </p>+ ) : nullreturn (<>- {visibleSkills.length === 0 && visibleOfficial.length === 0 ? (- <CapabilityEmpty noun="skills" query={query} />- ) : (- <MasterDetail pane={skillEditorPane} resizeId="capabilities-split" split="wide">- <ListColumn- header={- <ListStrip- left={<SortButton desc={skillsSortDesc} onFlip={() => $skillsSortDesc.set(!$skillsSortDesc.get())} />}- right={- <ListStripMenu- items={[- {- disabled: bulkBusy,- label: t.skills.disableUnused,- onSelect: () => void disableUnused()- }- ]}- label={t.skills.tabSkills}- toggle={bulkSwitch}- />+ <SkillCatalog+ actions={+ <>+ <UpdateSkillsButton profile={profile} />+ <ListStripMenu+ items={[+ {+ disabled: controlsDisabled || !skills.some(skill => skill.enabled && usageOf(skill) === 0),+ label: t.skills.disableUnused,+ onSelect: () =>+ void applyEnabled(+ skills.filter(skill => skill.enabled && usageOf(skill) === 0),+ false,+ true+ )}- />- }- >- {visibleSkills.map(skill => (- <CapRow- active={activeOfficial === null && activeSkill?.name === skill.name}- busy={bulkBusy}- enabled={skill.enabled}- key={skill.name}- meta={usageOf(skill) > 0 ? `×${compactNumber(usageOf(skill))}` : undefined}- onSelect={() => {- setSelectedSkill(skill.name)- setSelectedOfficial(null)- }}- onToggle={enabled => void handleToggleSkill(skill, enabled)}- subtitle={skillSubtitle(skill)}- title={skill.name}- toggleLabel={skill.name}- />- ))}- {visibleOfficial.length > 0 && (- <div className="flex h-7 shrink-0 items-end px-2 pb-1 text-[0.62rem] font-medium uppercase tracking-wide text-(--ui-text-quaternary)">- {t.skills.officialCatalog}- </div>+ ]}+ label={t.skills.tabSkills}+ toggle={bulkSwitch}+ />+ </>+ }+ installedPending={installedPending || Boolean(installedError)}+ notice={notice}+ onQueryChange={onQueryChange}+ profile={profile}+ query={query}+ renderInstalledAction={skill => (+ <Switch+ aria-label={skill.name}+ checked={skill.enabled}+ disabled={controlsDisabled}+ onCheckedChange={enabled => void applyEnabled([skill], enabled)}+ size="xs"+ />+ )}+ renderInstalledDetail={skill => (+ <>+ {usageOf(skill) > 0 && (+ <p className="text-xs text-(--ui-text-tertiary)">{t.skills.usageCount(usageOf(skill))}</p>)}- {visibleOfficial.map(skill => {- const installing = runningInstalls.has(skill.identifier)-- return (- <CapRow- action={- <Button disabled={installing} onClick={() => handleInstallOfficial(skill)} size="xs" variant="text">- {installing && <Loader2 className="size-3 animate-spin" />}- {installing ? t.skills.hub.installing : t.skills.hub.install}- </Button>- }- active={activeOfficial?.identifier === skill.identifier}- enabled={false}- key={skill.identifier}- onSelect={() => setSelectedOfficial(skill.identifier)}- subtitle={prettyName(skill.category)}- title={skill.name}- />- )- })}- </ListColumn>- <DetailColumn footer={t.skills.changesApplyNewSessions}>- {activeOfficial ? (- <OfficialSkillDetail- installing={runningInstalls.has(activeOfficial.identifier)}- onInstall={() => handleInstallOfficial(activeOfficial)}- profile={profile}- skill={activeOfficial}- />- ) : (- activeSkill && (- <SkillDetail- onArchive={() => setArchiveTarget(activeSkill.name)}- onEdit={() => void openSkillEditor(activeSkill.name)}- profile={profile}- skill={activeSkill}+ <SkillDetail+ onArchive={() => {+ if (!saving.current) {+ setArchiveTarget(skill.name)+ }+ }}+ onEdit={() => void openSkillEditor(skill.name)}+ profile={profile}+ skill={skill}+ />+ <p className="text-xs text-(--ui-text-tertiary)">{t.skills.changesApplyNewSessions}</p>+ {skillEditor?.name === skill.name && (+ <DetailPane+ actions={+ <Button disabled={skillSaving} onClick={() => void saveSkillEdit()} size="xs">+ {skillSaving ? t.common.saving : t.common.save}+ </Button>+ }+ id="skill-editor"+ onClose={closeSkillEditor}+ title={+ <span className="text-[0.68rem] font-normal text-muted-foreground/60">+ {skillEditor.name}/SKILL.md+ </span>+ }+ >+ <CodeEditor+ disabled={skillSaving}+ filePath="SKILL.md"+ initialValue={skillDraft}+ key={skillEditor.name}+ onCancel={closeSkillEditor}+ onChange={setSkillDraft}+ onSave={() => void saveSkillEdit()}/>- )+ </DetailPane>)}- </DetailColumn>- </MasterDetail>- )}+ </>+ )}+ skills={skills}+ />{archiveTarget && (<ArchiveSkillConfirmDialogonApply={() => {const name = archiveTarget- const snapshot = skills- setSkills(current => current?.filter(skill => skill.name !== name) ?? current)+ const snapshot =+ queryClient.getQueryData<SkillInfo[]>(skillsQueryKey(profile))?.find(skill => skill.name === name) ??+ skills.find(skill => skill.name === name)++ void queryClient.cancelQueries({ queryKey: skillsQueryKey(profile), exact: true })+ setSkills(current => current?.filter(skill => skill.name !== name))invalidateSlashCompletions()if (skillEditor?.name === name) {- setSkillEditor(null)+ closeSkillEditor()}- return () => setSkills(() => snapshot)+ // Restore only this row; never clobber intervening toggles or installs.+ return () => {+ if (mounted.current) {+ setSkills(current =>+ snapshot && current && !current.some(skill => skill.name === name) ? [...current, snapshot] : current+ )+ }++ void queryClient.invalidateQueries({ queryKey: skillsQueryKey(profile), exact: true })+ }}}onClose={() => setArchiveTarget(null)}- onFailure={(err, name) => notifyError(err, name)}+ onFailure={(err, name) => {+ if (mounted.current) {+ notifyError(err, name)+ }+ }}+ onSuccess={() => {+ void queryClient.invalidateQueries({ queryKey: skillsQueryKey(profile), exact: true })++ if (mounted.current) {+ onRefresh()+ }+ }}openprofile={profile}skillId={archiveTarget}diff --git a/apps/desktop/src/app/overlays/overlay-split-layout.tsx b/apps/desktop/src/app/overlays/overlay-split-layout.tsxindex ecbc9fe2866..f322acd0e9c 100644--- a/apps/desktop/src/app/overlays/overlay-split-layout.tsx+++ b/apps/desktop/src/app/overlays/overlay-split-layout.tsx@@ -34,13 +34,18 @@ interface OverlayMainProps {interface OverlayNavItemProps {active: booleancurrent?: boolean- icon: IconComponent+ /** Optional: filter/value rows (catalog facets) read as plain labels. */+ icon?: IconComponent/** Stable identity for the row, used as its `data-tour` handle. */id?: stringlabel: string// Renders as an indented child of another nav item: smaller icon and a// lighter active state so it never competes with the boxed parent item.nested?: boolean+ /** Presentational only (e.g. `CheckboxMark`); the row stays the one control. */+ leading?: ReactNode+ /** Toggle rows (multi-select facets) announce their state. */+ pressed?: booleanonClick: () => voidtrailing?: ReactNode}@@ -112,19 +117,22 @@ export const OverlayNavItem = memo(function OverlayNavItem({label,nested,onClick,+ leading,+ pressed,trailing}: OverlayNavItemProps) {return (<buttonaria-current={current ? 'page' : undefined}+ aria-pressed={pressed}className={cn(- 'flex h-7 w-full items-center justify-start gap-2 rounded-md border px-2 text-left text-[length:var(--conversation-text-font-size)] font-normal transition-colors',+ 'row-hover flex h-7 w-full shrink-0 items-center justify-start gap-2 rounded-md border px-2 text-left text-[length:var(--conversation-text-font-size)] font-normal transition-colors',nested? active- ? 'border-transparent bg-(--chrome-action-hover) font-medium text-foreground'+ ? 'border-transparent bg-(--ui-row-active-background) font-medium text-foreground': 'border-transparent bg-transparent text-(--ui-text-tertiary) hover:bg-(--chrome-action-hover) hover:text-foreground': active- ? 'border-(--ui-stroke-tertiary) bg-(--ui-bg-tertiary) text-foreground'+ ? 'border-(--ui-stroke-tertiary) bg-(--ui-row-active-background) text-foreground': 'border-transparent bg-transparent text-(--ui-text-secondary) hover:bg-(--chrome-action-hover) hover:text-foreground')}// Names the row by its own id, so a tour can address one link@@ -133,13 +141,16 @@ export const OverlayNavItem = memo(function OverlayNavItem({onClick={onClick}type="button">- <Icon- className={cn(- 'shrink-0',- nested ? 'size-3.5' : 'size-4',- active ? 'text-foreground/80' : 'text-muted-foreground/80'- )}- />+ {leading}+ {Icon && (+ <Icon+ className={cn(+ 'shrink-0',+ nested ? 'size-3.5' : 'size-4',+ active ? 'text-foreground/80' : 'text-muted-foreground/80'+ )}+ />+ )}<span className="min-w-0 flex-1 truncate">{label}</span>{trailing}</button>diff --git a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx b/apps/desktop/src/app/settings/plugin-install-modal.test.tsxindex 4e8ed0afba8..70bd96b131d 100644--- a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx+++ b/apps/desktop/src/app/settings/plugin-install-modal.test.tsx@@ -27,7 +27,6 @@ import {import { $activeGatewayProfile, $profiles } from '@/store/profile'import { $connection, $gatewayState } from '@/store/session'-import { CapabilityTabs } from '../capabilities/catalog/capability-tabs'import { PluginActions } from '../capabilities/plugins/plugins-tab'import { PluginInstallModal } from './plugin-install-modal'@@ -39,7 +38,7 @@ const renderFlow = () =>render(<MemoryRouter initialEntries={['/capabilities?tab=plugins']}><QueryClientProvider client={queryClient}>- <CapabilityTabs actions={<PluginActions profile={null} />} onChange={() => undefined} value="installed" />+ <PluginActions profile={null} /><PluginInstallModal /></QueryClientProvider></MemoryRouter>diff --git a/apps/desktop/src/app/shell/sidebar-label.tsx b/apps/desktop/src/app/shell/sidebar-label.tsxindex 759bae1d5c6..6fa727b036f 100644--- a/apps/desktop/src/app/shell/sidebar-label.tsx+++ b/apps/desktop/src/app/shell/sidebar-label.tsx@@ -4,9 +4,10 @@ import { cn } from '@/lib/utils'interface SidebarPanelLabelProps extends React.ComponentProps<'span'> {dotClassName?: string+ meta?: React.ReactNode}-export function SidebarPanelLabel({ children, className, dotClassName, ...props }: SidebarPanelLabelProps) {+export function SidebarPanelLabel({ children, className, dotClassName, meta, ...props }: SidebarPanelLabelProps) {return (<spanclassName={cn(@@ -17,6 +18,11 @@ export function SidebarPanelLabel({ children, className, dotClassName, ...props><span aria-hidden="true" className={cn('dither inline-block size-2 shrink-0 rounded-[1px]', dotClassName)} /><span className="min-w-0 truncate leading-none">{children}</span>+ {meta && (+ <span className="shrink-0 text-[0.6875rem] font-medium tracking-normal text-(--ui-text-quaternary)">+ {meta}+ </span>+ )}</span>)}diff --git a/apps/desktop/src/components/ui/segmented-control.test.tsx b/apps/desktop/src/components/ui/segmented-control.test.tsxdeleted file mode 100644index 110acbe9fa7..00000000000--- a/apps/desktop/src/components/ui/segmented-control.test.tsx+++ /dev/null@@ -1,51 +0,0 @@-import { cleanup, fireEvent, render, screen } from '@testing-library/react'-import { afterEach, describe, expect, it, vi } from 'vitest'--import { codiconIcon } from './codicon'-import { SegmentedControl } from './segmented-control'--const options = [- { id: 'list', label: 'List view', icon: codiconIcon('list-unordered') },- { id: 'cards', label: 'Card view', icon: codiconIcon('extensions') }-]--afterEach(cleanup)--describe('SegmentedControl', () => {- it('preserves visible labels by default', () => {- render(<SegmentedControl onChange={vi.fn()} options={options} value="cards" />)-- expect(screen.getByRole('button', { name: 'Card view', pressed: true }).textContent).toBe('Card view')- expect(screen.getByRole('button', { name: 'List view', pressed: false }).textContent).toBe('List view')- })-- it('keeps accessible labels and selection behavior for icon-only controls', () => {- const onChange = vi.fn()- render(<SegmentedControl iconOnly onChange={onChange} options={options} value="cards" />)- const list = screen.getByRole('button', { name: 'List view', pressed: false })- const cards = screen.getByRole('button', { name: 'Card view', pressed: true })-- expect(list.textContent).toBe('')- expect(cards.textContent).toBe('')- expect(list.querySelector('.codicon-list-unordered')).not.toBeNull()- expect(cards.querySelector('.codicon-extensions')).not.toBeNull()- fireEvent.click(list)- expect(onChange).toHaveBeenCalledExactlyOnceWith('list')- })-- it('retains a visible label when an icon-only option has no icon', () => {- render(<SegmentedControl iconOnly onChange={vi.fn()} options={[{ id: 'list', label: 'List view' }]} value="list" />)-- expect(screen.getByRole('button', { name: 'List view' }).textContent).toBe('List view')- })-- it('does not change a disabled icon-only control', () => {- const onChange = vi.fn()- render(<SegmentedControl disabled iconOnly onChange={onChange} options={options} value="cards" />)- const list = screen.getByRole<HTMLButtonElement>('button', { name: 'List view' })-- expect(list.disabled).toBe(true)- fireEvent.click(list)- expect(onChange).not.toHaveBeenCalled()- })-})diff --git a/apps/desktop/src/components/ui/segmented-control.tsx b/apps/desktop/src/components/ui/segmented-control.tsxindex 91cfbd6fa43..45c854ecf2b 100644--- a/apps/desktop/src/components/ui/segmented-control.tsx+++ b/apps/desktop/src/components/ui/segmented-control.tsx@@ -1,4 +1,3 @@-import { Tip } from '@/components/ui/tooltip'import type { IconComponent } from '@/lib/icons'import { cn } from '@/lib/utils'@@ -13,8 +12,6 @@ interface SegmentedControlProps<T extends string> {value: TonChange: (id: T) => voidclassName?: string- /** Icon buttons retain localized labels for tooltips and screen readers. */- iconOnly?: boolean/** Dims the whole track and blocks selection (e.g. gated behind a prerequisite). */disabled?: boolean}@@ -27,7 +24,6 @@ interface SegmentedControlProps<T extends string> {export function SegmentedControl<T extends string>({className,disabled = false,- iconOnly = false,onChange,options,value@@ -43,14 +39,12 @@ export function SegmentedControl<T extends string>({{options.map(({ id, label, icon: Icon }) => {const active = value === id- const button = (+ return (<button- aria-label={iconOnly ? label : undefined}aria-pressed={active}className={cn('flex items-center justify-center gap-1 rounded-[3px] px-2.5 py-0.5 text-[0.6875rem] font-medium transition-colors disabled:cursor-default',- active ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground',- iconOnly && Icon && 'size-6 p-0 text-sm'+ active ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground')}disabled={disabled}key={id}@@ -58,17 +52,9 @@ export function SegmentedControl<T extends string>({type="button">{Icon && <Icon className="size-3" />}- {(!iconOnly || !Icon) && label}+ {label}</button>)-- return iconOnly && Icon ? (- <Tip key={id} label={label}>- {button}- </Tip>- ) : (- button- )})}</div>)diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex e3989dd1584..637962341c6 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -9,6 +9,21 @@ export const ar = defineLocale({},catalog: {+ add: 'إضافة',+ added: 'تمت الإضافة',+ discover: 'اكتشف',+ featured: 'مميزة',+ explorePlugins: 'استكشف الإضافات',+ exploreSkills: 'استكشف المهارات',+ mostStarred: 'الأكثر حصولًا على نجوم',+ newest: 'الأحدث',+ recentlyUpdated: 'المحدثة مؤخرًا',+ alphabetical: 'الاسم',+ sortBy: 'ترتيب حسب',+ seeAll: 'عرض الكل',+ related: 'عناصر مشابهة',+ tags: 'الوسوم',+ screenshots: 'لقطات الشاشة',listView: 'عرض القائمة',cardView: 'عرض البطاقات',installTitle: (name: string) => `تثبيت «${name}»؟`,@@ -18,7 +33,6 @@ export const ar = defineLocale({installing: 'جارٍ التثبيت…',installComplete: (name: string) => `تم تثبيت «${name}»`,destinationChanged: 'تغيرت وجهة التثبيت. أغلق هذا الحوار وافتح رابط التثبيت مجددًا.',- browse: 'تصفح',installed: 'المثبتة',searchSkills: 'البحث في المهارات',searchPlugins: 'البحث في الإضافات',@@ -33,11 +47,17 @@ export const ar = defineLocale({requires: 'المتطلبات',tools: 'الأدوات',hooks: 'الخطافات',+ middleware: 'البرمجيات الوسيطة',+ commands: 'الأوامر',+ license: 'الترخيص',+ addedDate: 'تاريخ الإضافة',+ updatedDate: 'تاريخ التحديث',repository: 'المستودع',documentation: 'التوثيق',noResults: 'لا توجد نتائج مطابقة',tryAnother: 'جرّب بحثًا آخر أو امسح عوامل التصفية.',clearFilters: 'مسح عوامل التصفية',+ filters: 'عوامل التصفية',loadFailed: 'تعذر تحميل الكتالوج',retry: 'حاول مرة أخرى',more: 'عرض المزيد',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 7e68147f992..5a94cc21209 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -12,6 +12,21 @@ export const en: Translations = {// English editorial copy stays in the shipped JSONL; other locales override it.intro: { stock: {}, custom: () => [] },catalog: {+ add: 'Add',+ added: 'Added',+ discover: 'Discover',+ featured: 'Featured',+ explorePlugins: 'Explore plugins',+ exploreSkills: 'Explore skills',+ mostStarred: 'Most starred',+ newest: 'Newest',+ recentlyUpdated: 'Recently updated',+ alphabetical: 'Name',+ sortBy: 'Sort by',+ seeAll: 'See all',+ related: 'More like this',+ tags: 'Tags',+ screenshots: 'Screenshots',listView: 'List view',cardView: 'Card view',installTitle: (name: string) => `Install “${name}”?`,@@ -21,7 +36,6 @@ export const en: Translations = {installing: 'Installing…',installComplete: (name: string) => `“${name}” installed`,destinationChanged: 'The destination changed. Close this dialog and open the install link again.',- browse: 'Browse',installed: 'Installed',searchSkills: 'Search skills',searchPlugins: 'Search plugins',@@ -36,11 +50,17 @@ export const en: Translations = {requires: 'Requires',tools: 'Tools',hooks: 'Hooks',+ middleware: 'Middleware',+ commands: 'Commands',+ license: 'License',+ addedDate: 'Added',+ updatedDate: 'Updated',repository: 'Repository',documentation: 'Documentation',noResults: 'No matches',tryAnother: 'Try another search or clear your filters.',clearFilters: 'Clear filters',+ filters: 'Filters',loadFailed: 'Could not load the catalog',retry: 'Try again',more: 'Show more',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 54dc3a26f15..bad46da2fd0 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -12,6 +12,21 @@ export const ja = defineLocale({},intro: introJa,catalog: {+ add: '追加',+ added: '追加済み',+ discover: '見つける',+ featured: 'おすすめ',+ explorePlugins: 'プラグインを探す',+ exploreSkills: 'スキルを探す',+ mostStarred: 'スターが多い順',+ newest: '新着',+ recentlyUpdated: '最近の更新',+ alphabetical: '名前',+ sortBy: '並べ替え',+ seeAll: 'すべて表示',+ related: '類似の項目',+ tags: 'タグ',+ screenshots: 'スクリーンショット',listView: 'リスト表示',cardView: 'カード表示',installTitle: (name: string) => `「${name}」をインストールしますか?`,@@ -23,7 +38,6 @@ export const ja = defineLocale({installComplete: (name: string) => `「${name}」をインストールしました`,destinationChanged:'インストール先が変更されました。このダイアログを閉じ、インストールリンクを開き直してください。',- browse: '閲覧',installed: 'インストール済み',searchSkills: 'スキルを検索',searchPlugins: 'プラグインを検索',@@ -38,11 +52,17 @@ export const ja = defineLocale({requires: '必要なもの',tools: 'ツール',hooks: 'フック',+ middleware: 'ミドルウェア',+ commands: 'コマンド',+ license: 'ライセンス',+ addedDate: '追加日',+ updatedDate: '更新日',repository: 'リポジトリ',documentation: 'ドキュメント',noResults: '一致する項目がありません',tryAnother: '別の検索を試すか、フィルターをクリアしてください。',clearFilters: 'フィルターをクリア',+ filters: 'フィルター',loadFailed: 'カタログを読み込めませんでした',retry: '再試行',more: 'さらに表示',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex e821f2a63b3..20bab74a8d5 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -25,6 +25,21 @@ const RU_NOUN = (count: number | string, one: string, few: string, many: string)export const ru = defineLocale({catalog: {+ add: 'Добавить',+ added: 'Добавлено',+ discover: 'Открывайте новое',+ featured: 'Рекомендуемые',+ explorePlugins: 'Обзор плагинов',+ exploreSkills: 'Обзор навыков',+ mostStarred: 'Больше всего звёзд',+ newest: 'Новинки',+ recentlyUpdated: 'Недавно обновлённые',+ alphabetical: 'Название',+ sortBy: 'Сортировать по',+ seeAll: 'Показать все',+ related: 'Похожие',+ tags: 'Теги',+ screenshots: 'Снимки экрана',listView: 'Список',cardView: 'Карточки',installTitle: (name: string) => `Установить «${name}»?`,@@ -34,7 +49,6 @@ export const ru = defineLocale({installing: 'Установка…',installComplete: (name: string) => `«${name}» установлен`,destinationChanged: 'Место установки изменилось. Закройте диалог и снова откройте ссылку установки.',- browse: 'Обзор',installed: 'Установленные',searchSkills: 'Поиск навыков',searchPlugins: 'Поиск плагинов',@@ -49,11 +63,17 @@ export const ru = defineLocale({requires: 'Требования',tools: 'Инструменты',hooks: 'Хуки',+ middleware: 'Промежуточное ПО',+ commands: 'Команды',+ license: 'Лицензия',+ addedDate: 'Добавлено',+ updatedDate: 'Обновлено',repository: 'Репозиторий',documentation: 'Документация',noResults: 'Совпадений нет',tryAnother: 'Попробуйте другой запрос или сбросьте фильтры.',clearFilters: 'Сбросить фильтры',+ filters: 'Фильтры',loadFailed: 'Не удалось загрузить каталог',retry: 'Попробовать снова',more: 'Показать ещё',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 6a0fd52d1e6..201d9f95c37 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -70,6 +70,21 @@ export interface Translations {custom: (label: string) => string[]}catalog: {+ add: string+ added: string+ discover: string+ featured: string+ explorePlugins: string+ exploreSkills: string+ mostStarred: string+ newest: string+ recentlyUpdated: string+ alphabetical: string+ sortBy: string+ seeAll: string+ related: string+ tags: string+ screenshots: stringlistView: stringcardView: stringinstallTitle: (name: string) => string@@ -79,7 +94,6 @@ export interface Translations {installing: stringinstallComplete: (name: string) => stringdestinationChanged: string- browse: stringinstalled: stringsearchSkills: stringsearchPlugins: string@@ -94,11 +108,17 @@ export interface Translations {requires: stringtools: stringhooks: string+ middleware: string+ commands: string+ license: string+ addedDate: string+ updatedDate: stringrepository: stringdocumentation: stringnoResults: stringtryAnother: stringclearFilters: string+ filters: stringloadFailed: stringretry: stringmore: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 67e58ee4122..d3d2dbec36f 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -12,6 +12,21 @@ export const zhHant = defineLocale({},intro: introZhHant,catalog: {+ add: '新增',+ added: '已新增',+ discover: '探索',+ featured: '精選',+ explorePlugins: '探索外掛',+ exploreSkills: '探索技能',+ mostStarred: '星標最多',+ newest: '最新發布',+ recentlyUpdated: '最近更新',+ alphabetical: '名稱',+ sortBy: '排序方式',+ seeAll: '查看全部',+ related: '類似推薦',+ tags: '標籤',+ screenshots: '螢幕截圖',listView: '清單檢視',cardView: '卡片檢視',installTitle: (name: string) => `安裝「${name}」?`,@@ -21,7 +36,6 @@ export const zhHant = defineLocale({installing: '正在安裝…',installComplete: (name: string) => `已安裝「${name}」`,destinationChanged: '安裝目標已變更。請關閉此對話框並重新開啟安裝連結。',- browse: '瀏覽',installed: '已安裝',searchSkills: '搜尋技能',searchPlugins: '搜尋外掛',@@ -36,11 +50,17 @@ export const zhHant = defineLocale({requires: '相依項目',tools: '工具',hooks: '掛鉤',+ middleware: '中介軟體',+ commands: '指令',+ license: '授權條款',+ addedDate: '新增日期',+ updatedDate: '更新日期',repository: '程式碼儲存庫',documentation: '文件',noResults: '沒有符合的項目',tryAnother: '請嘗試其他搜尋或清除篩選條件。',clearFilters: '清除篩選條件',+ filters: '篩選條件',loadFailed: '無法載入目錄',retry: '再試一次',more: '顯示更多',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 842196176d0..4485d53ab98 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -12,6 +12,21 @@ export const zh = defineLocale({},intro: introZh,catalog: {+ add: '添加',+ added: '已添加',+ discover: '发现',+ featured: '精选',+ explorePlugins: '探索插件',+ exploreSkills: '探索技能',+ mostStarred: '星标最多',+ newest: '最新发布',+ recentlyUpdated: '最近更新',+ alphabetical: '名称',+ sortBy: '排序方式',+ seeAll: '查看全部',+ related: '类似推荐',+ tags: '标签',+ screenshots: '截图',listView: '列表视图',cardView: '卡片视图',installTitle: (name: string) => `安装“${name}”?`,@@ -21,7 +36,6 @@ export const zh = defineLocale({installing: '正在安装…',installComplete: (name: string) => `已安装“${name}”`,destinationChanged: '安装目标已更改。请关闭此对话框并重新打开安装链接。',- browse: '浏览',installed: '已安装',searchSkills: '搜索技能',searchPlugins: '搜索插件',@@ -36,11 +50,17 @@ export const zh = defineLocale({requires: '依赖项',tools: '工具',hooks: '钩子',+ middleware: '中间件',+ commands: '命令',+ license: '许可证',+ addedDate: '添加日期',+ updatedDate: '更新日期',repository: '代码仓库',documentation: '文档',noResults: '没有匹配项',tryAnother: '请尝试其他搜索或清除筛选条件。',clearFilters: '清除筛选条件',+ filters: '筛选条件',loadFailed: '无法加载目录',retry: '重试',more: '显示更多',diff --git a/apps/desktop/src/test/jsdom.ts b/apps/desktop/src/test/jsdom.tsindex e9034e8c335..92e57093013 100644--- a/apps/desktop/src/test/jsdom.ts+++ b/apps/desktop/src/test/jsdom.ts@@ -5,7 +5,7 @@import { vi } from 'vitest'-class InertResizeObserver {+export class InertResizeObserver {disconnect() {}observe() {}unobserve() {}diff --git a/apps/desktop/vitest.setup.ts b/apps/desktop/vitest.setup.tsindex 5cd9db95745..4d322b49ebb 100644--- a/apps/desktop/vitest.setup.ts+++ b/apps/desktop/vitest.setup.ts@@ -1,10 +1,11 @@import { configure } from '@testing-library/react'-import { stubResizeObserver } from './src/test/jsdom'+import { InertResizeObserver } from './src/test/jsdom'-// Shared tooltips now measure their arrow through Radix's useSize hook.-// Geometry assertions still belong in a real browser, not this inert observer.-stubResizeObserver()+// Shared tooltips measure their arrow through Radix's useSize hook; Masonry measures lanes.+// Geometry assertions still belong in a real browser, not this inert observer. Assigned,+// not `vi.stubGlobal`, so a test's `vi.unstubAllGlobals()` cannot strip it.+globalThis.ResizeObserver ??= InertResizeObserver as unknown as typeof ResizeObserver// Node 26 defines its own `localStorage` accessor on the global object, which// returns `undefined` unless the process was started with --localstorage-file@@ -24,14 +25,14 @@ if (typeof (globalThis as any).localStorage === 'undefined') {getItem: (k: string) => store.get(String(k)) ?? null,setItem: (k: string, v: string) => void store.set(String(k), String(v)),removeItem: (k: string) => void store.delete(String(k)),- clear: () => store.clear(),+ clear: () => store.clear()}for (const target of [globalThis, (globalThis as any).window].filter(Boolean)) {Object.defineProperty(target, 'localStorage', {value: storage,configurable: true,- writable: true,+ writable: true})}}@@ -45,12 +46,25 @@ globalThis.IntersectionObserver = class {observe() {}unobserve() {}disconnect() {}- takeRecords(): IntersectionObserverEntry[] { return [] }+ takeRecords(): IntersectionObserverEntry[] {+ return []+ }} as typeof IntersectionObserver-// React 19 + Testing Library 16: opt into the act environment so render(),-// fireEvent(), and findBy* queries automatically flush state updates without-// spurious "not wrapped in act(...)" warnings.+// Idle prefetches and feature queries (Masonry's `CSS.supports`) run on mount.+// jsdom has neither API; idle work never fires and every feature reads as absent.+globalThis.requestIdleCallback ??= () => 0+globalThis.cancelIdleCallback ??= () => undefined+globalThis.CSS ??= { escape: (value: string) => value, supports: () => false } as unknown as typeof CSS++if ('Element' in globalThis) {+ Element.prototype.scrollTo ??= () => undefined++ // React 19 + Testing Library 16: opt into the act environment so render(),+ // fireEvent(), and findBy* queries automatically flush state updates without+ // spurious "not wrapped in act(...)" warnings.+}+;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true// findBy*/waitFor default to a 1000ms deadline — too tight for async-heavydiff --git a/apps/shared/src/catalog-browse.ts b/apps/shared/src/catalog-browse.tsnew file mode 100644index 00000000000..ff7d56a9c3d--- /dev/null+++ b/apps/shared/src/catalog-browse.ts@@ -0,0 +1,39 @@+/** Shared with the docs catalog: taxonomy order is independent of popularity. Keep keys in sync+ * with CATALOG_CATEGORIES in hermes_cli/plugin_catalog.py and website/scripts/extract-plugins.py. */+export const PLUGIN_CATEGORIES: Record<string, { label: string; icon: string; blurb: string }> = {+ desktop: { label: 'Desktop', icon: '🖥️', blurb: 'Panes, tabs and views for Hermes Desktop' },+ memory: { label: 'Memory', icon: '🧠', blurb: 'Memory providers and context engines' },+ platform: { label: 'Platforms', icon: '💬', blurb: 'Messaging and channel adapters' },+ web: { label: 'Web & Browser', icon: '🌐', blurb: 'Search backends, extraction and browser control' },+ tools: { label: 'Tools', icon: '🛠️', blurb: 'New tools the agent can call' },+ voice: { label: 'Voice', icon: '🎙️', blurb: 'Speech, TTS and realtime audio' },+ automation: { label: 'Automation', icon: '⏱️', blurb: 'Hooks, wake triggers and session automation' },+ models: { label: 'Models', icon: '✨', blurb: 'Model and inference providers' },+ general: { label: 'General', icon: '📦', blurb: 'Plugins that span several areas' }+}++export const PLUGIN_CATEGORY_ORDER = Object.keys(PLUGIN_CATEGORIES)+export type PluginCatalogSort = 'stars' | 'newest' | 'updated'++export function sortCatalogPlugins<T extends { name: string; addedAt?: string | null; updatedAt?: string | null }>(entries: T[], sort: PluginCatalogSort): T[] {+ // The published snapshot already sorts stars descending, then name. Preserve+ // its order, including ties, rather than reinterpreting missing star counts.+ if (sort === 'stars') return entries+ const field = sort === 'newest' ? 'addedAt' : 'updatedAt'+ const date = (value?: string | null) => {+ const ms = value ? Date.parse(value) : NaN+ return Number.isFinite(ms) ? ms : -Infinity+ }+ return [...entries].sort((a, b) => date(b[field]) - date(a[field]) || a.name.localeCompare(b.name))+}++export function groupCatalogPlugins<T extends { category: string }>(entries: T[]): [string, T[]][] {+ const buckets = new Map<string, T[]>()+ for (const entry of entries) {+ const key = Object.hasOwn(PLUGIN_CATEGORIES, entry.category) ? entry.category : 'general'+ const bucket = buckets.get(key) ?? []+ bucket.push(entry)+ buckets.set(key, bucket)+ }+ return PLUGIN_CATEGORY_ORDER.filter(key => buckets.has(key)).map(key => [key, buckets.get(key)!])+}diff --git a/apps/shared/src/index.ts b/apps/shared/src/index.tsindex 1ff335bebff..5628eb9085c 100644--- a/apps/shared/src/index.ts+++ b/apps/shared/src/index.ts@@ -28,6 +28,7 @@ export type {UsageModelData} from './billing-types'export { pluginCatalogInstallUrl, skillCatalogInstallIdentifier, skillCatalogInstallUrl } from './catalog-install'+export { groupCatalogPlugins, PLUGIN_CATEGORIES, PLUGIN_CATEGORY_ORDER, sortCatalogPlugins } from './catalog-browse'export {driveChargeSettlement,SETTLEMENT_MAX_RETRY_AFTER_MS,diff --git a/website/src/components/PluginCatalog/catalog.ts b/website/src/components/PluginCatalog/catalog.tsindex 6fb0d046661..cb30ee62597 100644--- a/website/src/components/PluginCatalog/catalog.ts+++ b/website/src/components/PluginCatalog/catalog.ts@@ -3,6 +3,7 @@// shape, the tier/category taxonomy and the link builders keeps the three surfaces from drifting.import { pluginCatalogInstallUrl } from "../../../../apps/shared/src/catalog-install";+import { PLUGIN_CATEGORIES } from "../../../../apps/shared/src/catalog-browse";export interface PluginCapabilities {providesTools?: string[];@@ -105,20 +106,8 @@ export const TIER_CONFIG: Record<},};-// Browse taxonomy. Order here is the order of the filter pills and of the-// grouped sections; keep it in sync with CATALOG_CATEGORIES in-// hermes_cli/plugin_catalog.py and website/scripts/extract-plugins.py.-export const CATEGORY_CONFIG: Record<string, { label: string; icon: string; blurb: string }> = {- desktop: { label: "Desktop", icon: "\u{1F5A5}\u{FE0F}", blurb: "Panes, tabs and views for Hermes Desktop" },- memory: { label: "Memory", icon: "\u{1F9E0}", blurb: "Memory providers and context engines" },- platform: { label: "Platforms", icon: "\u{1F4AC}", blurb: "Messaging and channel adapters" },- web: { label: "Web & Browser", icon: "\u{1F310}", blurb: "Search backends, extraction and browser control" },- tools: { label: "Tools", icon: "\u{1F6E0}\u{FE0F}", blurb: "New tools the agent can call" },- voice: { label: "Voice", icon: "\u{1F399}\u{FE0F}", blurb: "Speech, TTS and realtime audio" },- automation: { label: "Automation", icon: "\u{23F1}\u{FE0F}", blurb: "Hooks, wake triggers and session automation" },- models: { label: "Models", icon: "\u{2728}", blurb: "Model and inference providers" },- general: { label: "General", icon: "\u{1F4E6}", blurb: "Plugins that span several areas" },-};+// Browse taxonomy, shared with Desktop. Its order is the order of the filter pills and grouped sections.+export const CATEGORY_CONFIG = PLUGIN_CATEGORIES;export const CATEGORY_ORDER = Object.keys(CATEGORY_CONFIG);export function categoryOf(plugin: Pick<CatalogPlugin, "category">) {diff --git a/website/src/pages/plugins/index.tsx b/website/src/pages/plugins/index.tsxindex f855ad8180f..78356abc38c 100644--- a/website/src/pages/plugins/index.tsx+++ b/website/src/pages/plugins/index.tsx@@ -24,6 +24,7 @@ import {tierOf,} from "../../components/PluginCatalog/catalog";import CopyButton from "../../components/PluginCatalog/CopyButton";+import { groupCatalogPlugins, sortCatalogPlugins } from "../../../../apps/shared/src/catalog-browse";// Routes Docusaurus serves the static API JSON from. `baseUrl` is `/docs/`,// `static/api/` ends up at `/docs/api/` — same pattern as the Skills Hub.@@ -44,17 +45,8 @@ const SORT_OPTIONS: { key: SortKey; label: string; title: string }[] = [{ key: "updated", label: "Recently updated", title: "Most recently re-pinned or edited first" },];-function dateMs(iso?: string | null): number {- const t = iso ? new Date(iso).getTime() : NaN;- return Number.isFinite(t) ? t : -Infinity;-}-function sortPlugins(list: CatalogPlugin[], sort: SortKey): CatalogPlugin[] {- if (sort === "stars") return list;- const field = sort === "newest" ? "addedAt" : "updatedAt";- return [...list].sort(- (a, b) => dateMs(b[field]) - dateMs(a[field]) || a.name.localeCompare(b.name),- );+ return sortCatalogPlugins(list, sort);}function highlightMatch(text: string, query: string): React.ReactNode {@@ -477,12 +469,7 @@ export default function PluginCatalogPage() {// than one undifferentiated wall. Filtering or searching flattens to a grid.const grouped = useMemo(() => {if (search.trim() || categoryFilter !== "all") return null;- const buckets = new Map<string, CatalogPlugin[]>();- for (const p of filtered) {- const key = CATEGORY_CONFIG[p.category] ? p.category : "general";- (buckets.get(key) ?? buckets.set(key, []).get(key)!).push(p);- }- return CATEGORY_ORDER.filter((c) => buckets.has(c)).map((c) => [c, buckets.get(c)!] as const);+ return groupCatalogPlugins(filtered);}, [filtered, search, categoryFilter]);const categoryCounts = useMemo(() => {