The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): capabilities tests follow the redesigned catalog
Brooklyn Nicholson0cce60a808c4
diff --git a/apps/desktop/src/app/capabilities/index.test.tsx b/apps/desktop/src/app/capabilities/index.test.tsxindex 20a16c623a4..825b7f9a23e 100644--- a/apps/desktop/src/app/capabilities/index.test.tsx+++ b/apps/desktop/src/app/capabilities/index.test.tsx@@ -1,6 +1,6 @@// @vitest-environment jsdomimport { QueryClientProvider } from '@tanstack/react-query'-import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'import { MemoryRouter } from 'react-router'import type * as ReactRouterDom from 'react-router'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'@@ -9,6 +9,9 @@ import type * as HermesApi from '@/hermes'import { queryClient } from '@/lib/query-client'import type * as HubActions from '@/store/hub-actions'+import { parseCatalog } from './catalog/catalog-data'+import { $catalogCardView } from './catalog/store'+const getSkills = vi.fn()const getToolsets = vi.fn()const setSkillEnabled = vi.fn()@@ -97,6 +100,7 @@ async function renderSkills() {}beforeEach(() => {+ $catalogCardView.set(true)getSkills.mockResolvedValue([])getToolsets.mockResolvedValue([toolset()])setToolsetEnabled.mockResolvedValue({ ok: true, name: 'web', enabled: false })@@ -111,6 +115,7 @@ beforeEach(() => {// Single profile by default → the scope selector stays hidden (>1 gate),// so existing tests see unchanged single-profile behavior.getProfiles.mockResolvedValue({ profiles: [{ name: 'default', is_default: true }] })+ queryClient.setQueryData(['public-catalog', 'skills'], [])})afterEach(() => {@@ -209,7 +214,7 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {)})- // The selector renders on the Skills tab too (Capabilities-wide).+ // The selector renders on the Skills tab too (Capabilities-wide); the catalog's sort lives in its Filters popover.const trigger = await screen.findByRole('combobox')await act(async () => {fireEvent.click(trigger)@@ -230,7 +235,8 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {await waitFor(() => expect(setSkillEnabled).toHaveBeenCalledWith('web-research', false, 'researcher'))})- it('shows the FULL skill in the detail pane — frontmatter metadata + body', async () => {+ it('shows the FULL skill body in the detail pane, not just the description or raw frontmatter', async () => {+ $catalogCardView.set(false)getSkills.mockResolvedValue([{name: 'web-research',@@ -252,74 +258,79 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {)})- // Frontmatter renders as metadata rows, the body as full text — not just- // the one-line description.await waitFor(() => expect(getSkillContent).toHaveBeenCalled())expect(getSkillContent.mock.calls[0][0]).toBe('web-research')- expect(await screen.findByText('version')).toBeTruthy()- expect(await screen.findByText('1.2.0')).toBeTruthy()expect(await screen.findByText(/Deep research steps/)).toBeTruthy()+ expect(screen.queryByText(/version: 1\.2\.0/)).toBeNull()})- it('hub picker refuses to reinstall an already-installed skill', async () => {- const { notify } = await import('@/store/notifications')- const { EmbeddedHubPicker } = await import('./skills/embedded-hub-picker')-- render(<EmbeddedHubPicker installedNames={new Set(['web-research'])} profile={null} />)-- // The picker is expanded by default — the hub iframe is live on mount.- expect(document.querySelector('iframe')).toBeTruthy()+ it('keeps installed skills on their toggle and installs new cards into the pinned remote profile', async () => {+ const { installHubSkill } = await import('@/store/hub-actions')+ getSkills.mockResolvedValue([+ { name: 'web-research', description: 'Research', enabled: true, category: 'research' }+ ])+ queryClient.setQueryData(+ ['public-catalog', 'skills'],+ parseCatalog('skills', [+ { name: 'web-research', source: 'official', identifier: 'official/research/web-research' },+ { name: 'gif-search', source: 'official', identifier: 'official/gifs/gif-search' }+ ])+ )- await act(async () => {- window.dispatchEvent(- new MessageEvent('message', {- data: { type: 'hermes-skill-pick', name: 'web-research', identifier: 'web-research' },- origin: 'https://hermes-agent.nousresearch.com'- })- )- })+ render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter>+ <CapabilitiesView embedded fixedConnection="homelab" fixedProfile="inbox-bot" />+ </MemoryRouter>+ </QueryClientProvider>+ )- // Refused with an informational toast, no install action spawned.+ await screen.findByRole('switch', { name: 'web-research' })+ expect(screen.getByRole<HTMLButtonElement>('switch', { name: 'Added web-research' }).disabled).toBe(true)+ expect(screen.queryByRole('switch', { name: 'Add web-research' })).toBeNull()+ const available = screen.getByRole('button', { name: 'gif-search' }).closest('article')!+ fireEvent.click(within(available).getByRole('switch', { name: 'Add gif-search' }))await waitFor(() =>- expect(vi.mocked(notify)).toHaveBeenCalledWith(- expect.objectContaining({ title: expect.stringContaining('web-research') })- )+ expect(installHubSkill).toHaveBeenCalledExactlyOnceWith('official/gifs/gif-search', {+ connectionId: 'homelab',+ profile: 'inbox-bot'+ }))+ expect(document.querySelector('iframe')).toBeNull()})- it('mounts the hub iframe lazily and keeps it (hidden) across tab switches', async () => {- // On a non-Skills tab the docs-site iframe must not exist at all — an- // eagerly mounted hub is exactly the Capabilities lag bug.- await renderSkills() // ?tab=toolsets- await screen.findByRole('switch', { name: 'Turn Web Search toolset off' })- expect(document.querySelector('iframe')).toBeNull()- cleanup()+ it('fetches the public catalog once across remounts and keeps one search input', async () => {+ queryClient.clear()- // Embedded mode drives tabs through local state (the route hooks are- // mocked here), starting on Skills: the picker mounts with the tab.- await act(async () => {+ const fetch = vi.fn().mockResolvedValue({+ ok: true,+ json: async () => [{ name: 'example', source: 'official', identifier: 'official/example' }]+ })++ vi.stubGlobal('fetch', fetch)++ const view = () =>render(<QueryClientProvider client={queryClient}>- <MemoryRouter initialEntries={['/capabilities']}>- <CapabilitiesView embedded />+ <MemoryRouter>+ <CapabilitiesView embedded fixedProfile="default" /></MemoryRouter></QueryClientProvider>)- })-- const iframe = document.querySelector('iframe')- expect(iframe).toBeTruthy()- expect(iframe!.closest('section')!.classList.contains('hidden')).toBe(false)- // Switch to Tools → the iframe STAYS mounted (no docs-site reload on the- // next visit) but its section is fully hidden, so nothing from the hub- // can paint over the toolsets UI.- await act(async () => {- fireEvent.click(screen.getByRole('button', { name: /Tools/ }))- })- const kept = document.querySelector('iframe')- expect(kept).toBeTruthy()- expect(kept!.closest('section')!.classList.contains('hidden')).toBe(true)+ try {+ const first = view()+ await screen.findByRole('button', { name: 'example' })+ expect(fetch).toHaveBeenCalledTimes(1)+ first.unmount()+ view()+ await screen.findByRole('button', { name: 'example' })+ expect(fetch).toHaveBeenCalledTimes(1)+ expect(screen.getAllByRole('textbox', { name: 'Search skills' })).toHaveLength(1)+ expect(document.querySelector('iframe')).toBeNull()+ } finally {+ vi.unstubAllGlobals()+ }})it('shows a vision explainer that deep-links to Settings → Models', async () => {@@ -421,11 +432,11 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {}})- it('lists the built-in optional-skills catalog with Install buttons that route through the hub pipeline', async () => {- // The full official catalog renders BELOW the installed list; each row- // carries an Install button (no toggle until installed) that routes- // through the standard hub action pipeline scoped to the Capabilities- // profile. Already-installed catalog entries are filtered out.+ it('lists the built-in optional-skills catalog with Add switches that route through the hub pipeline', async () => {+ // Official optional skills merge into the same catalog as installed ones;+ // an uninstalled row carries an Add switch that routes through the hub+ // action pipeline scoped to the Capabilities profile. A name collision with+ // an installed skill keeps the installed toggle, never a second Add.const { installHubSkill } = await import('@/store/hub-actions')getSkills.mockResolvedValue([@@ -477,15 +488,10 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {)})- // Catalog section header + the one genuinely-available row. Rows already- // installed (lock flag OR name collision with the installed list) are gone.- expect(await screen.findByText('gif-search')).toBeTruthy()- expect(screen.queryByText('ascii-art')).toBeNull()-- // The installed skill still shows its toggle; the catalog row shows- // Install instead of a switch.+ const install = await screen.findByRole('switch', { name: 'Add gif-search' })expect(screen.getByRole('switch', { name: 'web-research' })).toBeTruthy()- const install = screen.getByRole('button', { name: 'Install' })+ expect(screen.queryByRole('switch', { name: 'Add web-research' })).toBeNull()+ expect(screen.getByRole<HTMLButtonElement>('switch', { name: 'Added ascii-art' }).disabled).toBe(true)await act(async () => {fireEvent.click(install)@@ -495,4 +501,42 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {expect(vi.mocked(installHubSkill)).toHaveBeenCalledWith('official/gifs/gif-search', expect.anything()))})++ it('drops community feed rows that only share a name with an installed skill', async () => {+ // Installs are name-keyed, so a community lookalike of an installed skill+ // can neither be added beside it nor is it the installed skill itself —+ // it must not surface as a second "installed" row under the same name.+ getSkills.mockResolvedValue([+ {+ name: 'docx',+ description: 'Bundled document tools',+ category: 'documents',+ enabled: true,+ usage: 0,+ provenance: 'bundled'+ }+ ])+ queryClient.setQueryData(+ ['public-catalog', 'skills'],+ parseCatalog('skills', [+ { name: 'docx', source: 'ClawHub', identifier: 'wordpro' },+ { name: 'gif-search', source: 'ClawHub', identifier: 'gif-raccoon' }+ ])+ )++ await act(async () => {+ render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter initialEntries={['/capabilities?tab=skills']}>+ <CapabilitiesView />+ </MemoryRouter>+ </QueryClientProvider>+ )+ })++ // The feed settles first; then only the installed row keeps the name,+ // while the distinct community skill stays installable.+ await screen.findByRole('switch', { name: 'Add gif-search' })+ expect(screen.getAllByRole('button', { name: 'docx' })).toHaveLength(1)+ })})diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsxindex 11c0ddaaa34..8b2a6600ea6 100644--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx@@ -1,19 +1,64 @@-import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'+import { QueryClientProvider } from '@tanstack/react-query'+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'+import { type ComponentProps, useState } from 'react'+import { MemoryRouter, useLocation } from 'react-router'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { createPluginContext } from '@/contrib/plugin'import { $pluginDecisions, $pluginRecords, dropPlugin, patchPlugin, publishPlugin } from '@/contrib/plugins-store'import { queryClient } from '@/lib/query-client'-import { $agentPlugins, $agentPluginsStatus } from '@/store/agent-plugins'+import { $agentPlugins, $agentPluginsStatus, type AgentPluginRow } from '@/store/agent-plugins'import { $confirmRequest, settleConfirm } from '@/store/confirm'import { $notifications } from '@/store/notifications'-import { $paneHeightOverride, setPaneHeightOverride } from '@/store/panes'import { $pluginInstallRequest, closePluginInstallRequest } from '@/store/plugin-install-request'-import { $connection } from '@/store/session'+import { $connection, $gatewayState } from '@/store/session'++import { PageSearchShell } from '../../page-search-shell'+import { parseCatalog } from '../catalog/catalog-data'+import { $catalogCardView } from '../catalog/store'import { PluginsTab } from './plugins-tab'-const requestGateway = vi.fn(async () => ({ plugins: [] }))+const requestGateway = vi.fn(async (_method: string, _params?: Record<string, unknown>): Promise<unknown> => ({+ plugins: $agentPlugins.get()+}))++// 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} searchHidden searchPlaceholder="Search plugins" searchValue={query}>+ <PluginsTab {...props} onQueryChange={setQuery} query={query} />+ </PageSearchShell>+ )+}++function renderPlugins(props: ComponentProps<typeof PluginsTab>) {+ return render(+ <QueryClientProvider client={queryClient}>+ <PluginsHarness {...props} />+ </QueryClientProvider>+ )+}++const weatherEntry = {+ name: 'weather-plugin',+ repo: 'https://github.com/example/weather-plugin',+ sha: 'a'.repeat(40),+ subdir: '',+ tier: 'community',+ category: 'weather',+ description: 'Local weather forecasts'+}++function seedCatalog(entries = [weatherEntry]) {+ queryClient.setQueryData(['public-catalog', 'plugins'], parseCatalog('plugins', entries))+}++async function selectCatalogEntry(name: string) {+ fireEvent.click((await screen.findAllByRole('button', { name }))[0])+ expect(screen.getAllByRole('heading', { name }).length).toBeGreaterThan(0)+}const connectionFixture = {baseUrl: 'http://localhost',@@ -30,6 +75,9 @@ vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({}))const uninstallDiskPlugin = vi.fn(async (_id: string) => ({ ok: true }))+const setEnvVar = vi.fn(async (..._args: unknown[]) => ({}))++vi.mock('@/api/config', () => ({ setEnvVar: (...args: unknown[]) => setEnvVar(...args) }))vi.mock('@/contrib/runtime-loader', async importOriginal => ({...(await importOriginal<Record<string, unknown>>()),@@ -47,23 +95,64 @@ vi.mock('@/api/toolsets', async importOriginal => ({setToolsetEnabled: (...args: unknown[]) => setToolsetEnabled(...(args as Parameters<typeof setToolsetEnabled>))}))+beforeEach(() => {+ $gatewayState.set('open')+ $pluginRecords.set({})+ $agentPlugins.set([])+ $agentPluginsStatus.set('ready')+ $catalogCardView.set(false)+ seedCatalog([])+ closePluginInstallRequest()+ requestGateway.mockReset()+ requestGateway.mockImplementation(async () => ({ plugins: $agentPlugins.get() }))+ setEnvVar.mockClear()+ setToolsetEnabled.mockReset()+ setToolsetEnabled.mockResolvedValue({ enabled: true, name: 'kanban', ok: true })+ getToolsets.mockReset()+ getToolsets.mockResolvedValue([])+})++afterEach(() => {+ cleanup()+ settleConfirm(false)+ $connection.set(null)+ queryClient.clear()+ vi.unstubAllGlobals()+})+describe('PluginsTab', () => {- beforeEach(() => {- $pluginRecords.set({})- $agentPlugins.set([])- $agentPluginsStatus.set('ready')- closePluginInstallRequest()- requestGateway.mockClear()- setToolsetEnabled.mockReset()- setToolsetEnabled.mockResolvedValue({ enabled: true, name: 'kanban', ok: true })- getToolsets.mockReset()- getToolsets.mockResolvedValue([])- })+ it('opens a non-first installed deep-link target from Browse and keeps that selection after consuming the link', async () => {+ Element.prototype.scrollIntoView = vi.fn()+ $agentPlugins.set(+ ['alpha', 'omega'].map(name => ({+ key: name,+ name,+ description: `${name} plugin`,+ source: 'git',+ status: 'enabled',+ version: '1'+ }))+ )+ seedCatalog()- afterEach(() => {- cleanup()- $connection.set(null)- queryClient.clear()+ function Location() {+ return <output data-testid="route">{useLocation().search}</output>+ }++ render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter initialEntries={['/capabilities?tab=plugins&plugin=omega']}>+ <Location />+ <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<HTMLInputElement>('textbox', { name: 'Search plugins' }).value).toBe('')+ expect(screen.getByRole('switch', { name: 'Agent: omega' })).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'alpha', pressed: false }))+ expect(screen.getByRole('switch', { name: 'Agent: alpha' })).toBeTruthy()})it('renders declared server pills and the unavailable sentence under the description', () => {@@ -86,7 +175,7 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile="workbot" />)+ renderPlugins({ profile: 'workbot' })expect(screen.getByTestId('server-pill-ready-server')).toBeTruthy()expect(screen.getByTestId('server-pill-setup-server')).toBeTruthy()@@ -106,10 +195,11 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })expect(screen.queryByText('fal')).toBeNull()- expect(screen.getByText(/No plugins yet/)).toBeTruthy()+ expect(screen.queryByRole('row')).toBeNull()+ expect(screen.getByText('No matches')).toBeTruthy()})// A desktop half can only be copied out of a backend that runs on THIS@@ -129,7 +219,7 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })const detail = within(screen.getByRole('row', { name: /^nous-prices/ }))expect(detail.getByText('unavailable (remote backend)')).toBeTruthy()@@ -149,7 +239,7 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })const detail = within(screen.getByRole('row', { name: /^nous-prices/ }))expect(detail.getByText('copying…')).toBeTruthy()@@ -171,7 +261,7 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })expect(screen.getAllByTestId(/^plugin-row-/)).toHaveLength(1)expect(screen.getByText('Agent + Desktop')).toBeTruthy()@@ -192,7 +282,7 @@ describe('PluginsTab', () => {}})- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })expect(screen.queryByRole('switch', { name: /^Agent:/ })).toBeNull()screen.getByRole('button', { name: 'Install here' }).click()@@ -212,13 +302,13 @@ describe('PluginsTab', () => {media: { id: 'media', name: 'Media Studio', kind: 'disk', status: 'loaded', packageName: 'hermes-media-studio' }})- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })expect((screen.getByRole('button', { name: 'Install here' }) as HTMLButtonElement).disabled).toBe(true)})it('loads the plugin list scoped to the selected profile', () => {- render(<PluginsTab profile="workbot" />)+ renderPlugins({ profile: 'workbot' })expect(requestGateway).toHaveBeenCalledWith('plugins.manage',@@ -226,49 +316,42 @@ describe('PluginsTab', () => {)})- it('opens the dual-target install modal from a catalog pick message', async () => {- render(<PluginsTab profile="workbot" />)-- window.dispatchEvent(- new MessageEvent('message', {- data: {- name: 'weather-plugin',- repo: 'https://github.com/example/weather-plugin',- sha: 'a'.repeat(40),- subdir: '',- tier: 'community',- type: 'hermes-plugin-pick'- },- origin: 'https://hermes-agent.nousresearch.com'- })- )+ it.each([false, true])('opens the scoped native install dialog from the selected entry (cards=%s)', async cards => {+ $catalogCardView.set(cards)+ seedCatalog([+ { ...weatherEntry, name: 'other-plugin', repo: 'https://github.com/example/other-plugin' },+ weatherEntry+ ])+ renderPlugins({ profile: 'workbot' })- await waitFor(() => {- const request = $pluginInstallRequest.get()+ await selectCatalogEntry(weatherEntry.name)+ expect($pluginInstallRequest.get()).toBeNull()+ fireEvent.click(screen.getByRole('switch', { name: `Add ${weatherEntry.name}` }))- expect(request).not.toBeNull()- expect(request?.catalogName).toBe('weather-plugin')- expect(request?.repo).toBe('https://github.com/example/weather-plugin')- expect(request?.profile).toBe('workbot')- expect(request?.sha).toBe('a'.repeat(40))+ expect($pluginInstallRequest.get()).toMatchObject({+ catalogName: weatherEntry.name,+ repo: weatherEntry.repo,+ profile: 'workbot',+ sha: weatherEntry.sha})})- it('ignores pick messages from foreign origins', () => {- render(<PluginsTab profile={null} />)-- window.dispatchEvent(- new MessageEvent('message', {- data: {- name: 'evil-plugin',- repo: 'https://github.com/evil/evil-plugin',- type: 'hermes-plugin-pick'- },- origin: 'https://evil.example.com'- })- )+ 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($pluginInstallRequest.get()).toBeNull()+ expect(screen.getByRole('button', { name: 'Clock', pressed: true })).toBeTruthy()+ expect(screen.getByRole('switch', { name: 'Desktop: Clock' })).toBeTruthy()+ 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', pressed: false })).toBeNull()+ expect(screen.getByRole('switch', { name: 'Desktop: Clock' })).toBeTruthy()})it('toggles by canonical key through plugins.manage', async () => {@@ -282,12 +365,13 @@ describe('PluginsTab', () => {version: '0.20.0'}])- requestGateway.mockResolvedValueOnce({- ok: true,- plugin: { key: 'image_gen/legacy', name: 'Legacy plugin', status: 'enabled' }- } as never)+ requestGateway.mockImplementation(async (_method, params) =>+ params?.action === 'toggle'+ ? { ok: true, plugin: { key: 'image_gen/legacy', name: 'Legacy plugin', status: 'enabled' } }+ : { plugins: $agentPlugins.get() }+ )- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })screen.getByRole('switch', { name: 'Agent: Legacy plugin' }).click()@@ -299,58 +383,6 @@ describe('PluginsTab', () => {)})- it('turns a unified package on with ONE switch: Agent on also turns its desktop half on', async () => {- publishPlugin(- { id: 'meter-ui', name: 'Meter', kind: 'disk', status: 'disabled', packageName: 'meter' },- { activate: () => patchPlugin('meter-ui', { status: 'loaded' }), deactivate: () => undefined }- )- $agentPlugins.set([- { description: '', key: 'meter', name: 'meter', source: 'git', status: 'not enabled', version: '1' }- ])- requestGateway.mockImplementation((async (_method: string, params?: { action?: string }) =>- params?.action === 'toggle'- ? { ok: true, plugin: { key: 'meter', name: 'meter', status: 'enabled' } }- : { plugins: [] }) as never)-- render(<PluginsTab profile={null} />)-- screen.getByRole('switch', { name: 'Agent: Meter' }).click()-- await waitFor(() =>- expect(screen.getByRole('switch', { name: 'Desktop: Meter' }).getAttribute('aria-checked')).toBe('true')- )- expect($pluginDecisions.get()['meter-ui']).toBe(true)- requestGateway.mockImplementation(async () => ({ plugins: [] }))- $pluginDecisions.set({})- })-- it('leaves a desktop half the user switched off alone when its agent half is turned on', async () => {- $pluginDecisions.set({ 'meter-ui': false })- publishPlugin(- { id: 'meter-ui', name: 'Meter', kind: 'disk', status: 'disabled', packageName: 'meter' },- { activate: () => patchPlugin('meter-ui', { status: 'loaded' }), deactivate: () => undefined }- )- $agentPlugins.set([- { description: '', key: 'meter', name: 'meter', source: 'git', status: 'not enabled', version: '1' }- ])- requestGateway.mockImplementation((async (_method: string, params?: { action?: string }) =>- params?.action === 'toggle'- ? { ok: true, plugin: { key: 'meter', name: 'meter', status: 'enabled' } }- : { plugins: [] }) as never)-- render(<PluginsTab profile={null} />)-- screen.getByRole('switch', { name: 'Agent: Meter' }).click()-- await waitFor(() =>- expect(requestGateway).toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'toggle' }))- )- expect($pluginDecisions.get()['meter-ui']).toBe(false)- expect(screen.getByRole('switch', { name: 'Desktop: Meter' }).getAttribute('aria-checked')).toBe('false')- requestGateway.mockImplementation(async () => ({ plugins: [] }))- $pluginDecisions.set({})- })-it('renders keyless rows read-only (no name-addressed toggle RPC)', () => {// Name-addressed toggles flip every same-named plugin across category// dirs — pre-contract-v6 rows must never reach the RPC.@@ -364,7 +396,7 @@ describe('PluginsTab', () => {}])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })const toggle = screen.getByRole('switch', { name: 'Agent: Legacy plugin' })@@ -375,23 +407,25 @@ describe('PluginsTab', () => {expect(requestGateway).not.toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'toggle' }))})- it('appends the subdir fragment for multi-plugin repos', async () => {- render(<PluginsTab profile={null} />)-- window.dispatchEvent(- new MessageEvent('message', {- data: {- name: 'nested-plugin',- repo: 'https://github.com/example/plugins-monorepo',- subdir: 'nested-plugin',- type: 'hermes-plugin-pick'- },- origin: 'https://hermes-agent.nousresearch.com'- })- )+ it('appends the selected subdir for multi-plugin repos without changing the catalog pin', async () => {+ const entry = {+ ...weatherEntry,+ name: 'nested-plugin',+ repo: 'https://github.com/example/plugins-monorepo',+ subdir: 'packages/nested-plugin'+ }- await waitFor(() => {- expect($pluginInstallRequest.get()?.repo).toBe('https://github.com/example/plugins-monorepo#nested-plugin')+ seedCatalog([entry])+ renderPlugins({ profile: null })++ await selectCatalogEntry(entry.name)+ fireEvent.click(screen.getByRole('switch', { name: `Add ${entry.name}` }))++ expect($pluginInstallRequest.get()).toMatchObject({+ catalogName: entry.name,+ repo: `${entry.repo}#${entry.subdir}`,+ profile: null,+ sha: entry.sha})})@@ -407,7 +441,7 @@ describe('PluginsTab', () => {kanban: { id: 'kanban', name: 'Kanban', kind: 'bundled', status: 'disabled' }})- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })screen.getByRole('switch', { name: 'Desktop: Kanban' }).click()@@ -424,7 +458,7 @@ describe('PluginsTab', () => {kanban: { id: 'kanban', name: 'Kanban', kind: 'bundled', status: 'loaded' }})- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })screen.getByRole('switch', { name: 'Desktop: Kanban' }).click()@@ -463,7 +497,7 @@ describe('PluginsTab', () => {setToolsetEnabled.mockRejectedValueOnce(new Error('HTTP 500'))getToolsets.mockResolvedValueOnce(toolsetReads(false))- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })fireEvent.click(kanbanSwitch())await waitFor(() => expect(notices('error')).toHaveLength(1))await settled()@@ -488,7 +522,7 @@ describe('PluginsTab', () => {setToolsetEnabled.mockRejectedValueOnce(new Error('HTTP 500'))getToolsets.mockResolvedValueOnce(toolsetReads(true))- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })fireEvent.click(kanbanSwitch())await waitFor(() => expect(notices('error')).toHaveLength(1))await settled()@@ -511,7 +545,7 @@ describe('PluginsTab', () => {setToolsetEnabled.mockRejectedValueOnce(new Error('Request timed out'))getToolsets.mockResolvedValueOnce(toolsetReads(true))- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })fireEvent.click(kanbanSwitch())await waitFor(() => expect(checked()).toBe('true'))@@ -525,7 +559,7 @@ describe('PluginsTab', () => {setToolsetEnabled.mockRejectedValueOnce(new Error('Request timed out'))getToolsets.mockRejectedValueOnce(new Error('Request timed out'))- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })fireEvent.click(kanbanSwitch())await waitFor(() => expect(notices('error')).toHaveLength(1))await settled()@@ -542,7 +576,7 @@ describe('PluginsTab', () => {media: { id: 'media', name: 'Media Studio', kind: 'disk', status: 'loaded' }})- render(<PluginsTab profile="workbot" scopeLabel="workbot" />)+ renderPlugins({ profile: 'workbot', scopeLabel: 'workbot' })screen.getByRole('switch', { name: 'Desktop: Media Studio' }).click()@@ -551,34 +585,169 @@ describe('PluginsTab', () => {})describe('PluginsTab catalog UX', () => {- beforeEach(() => {- $agentPlugins.set([])- $agentPluginsStatus.set('ready')- closePluginInstallRequest()- requestGateway.mockClear()- setPaneHeightOverride('capabilities-plugin-catalog', undefined)+ it('saves declared settings from the installed detail with values and secrets on their scoped routes', async () => {+ const row: AgentPluginRow = {+ name: 'demo-settings',+ key: 'category/demo-settings',+ description: 'Configurable plugin',+ source: 'git',+ status: 'enabled',+ version: '1',+ settings_schema: [+ { key: 'retries', label: 'Retries', type: 'number', description: '', required: true, value: 3 },+ { key: 'api_key', label: 'API key', type: 'secret', description: '', required: true, env: 'DEMO_API_KEY' }+ ]+ }++ $agentPlugins.set([row])+ requestGateway.mockImplementation(async (_method, params) =>+ params?.action === 'settings'+ ? {+ ok: true,+ plugin: {+ ...row,+ settings_schema: row.settings_schema!.map(field =>+ field.key === 'retries' ? { ...field, value: 9 } : field+ )+ }+ }+ : { plugins: $agentPlugins.get() }+ )++ const profile = { profile: 'workbot', connectionId: 'remote-work' }++ await act(async () => {+ renderPlugins({ profile })+ })++ fireEvent.click(screen.getByRole('button', { name: 'Settings: demo-settings' }))+ fireEvent.change(screen.getByRole('spinbutton', { name: 'Retries' }), { target: { value: '9' } })+ fireEvent.change(screen.getByLabelText('API key'), { target: { value: 'test-api-key' } })+ fireEvent.click(screen.getByRole('button', { name: 'Save settings' }))++ await waitFor(() => expect(setEnvVar).toHaveBeenCalledWith('DEMO_API_KEY', 'test-api-key', profile))+ await waitFor(() =>+ expect(requestGateway).toHaveBeenCalledWith('plugins.manage', {+ action: 'settings',+ key: row.key,+ values: { retries: 9 },+ profile: 'workbot'+ })+ )+ await waitFor(() => expect(screen.getByLabelText<HTMLInputElement>('API key').value).toBe(''))+ expect(screen.getByRole<HTMLButtonElement>('button', { name: 'Save settings' }).disabled).toBe(true)})- afterEach(cleanup)+ it('requires widening consent before retrying an update, and leaves a declined update untouched', async () => {+ $agentPlugins.set([+ {+ name: 'demo-weather',+ key: 'demo-weather',+ description: '',+ source: 'git',+ status: 'enabled',+ version: '1',+ catalog_sha: 'b'.repeat(40),+ update_available: true+ }+ ])+ requestGateway.mockImplementation(async (_method, params) => {+ if (params?.action !== 'update') {+ return { plugins: $agentPlugins.get() }+ }++ return params.accept_capabilities+ ? { ok: true, unchanged: false }+ : { consent_required: true, sha: 'b'.repeat(40), delta_lines: ['Tools: weather-alerts'] }+ })+ await act(async () => {+ renderPlugins({ profile: 'workbot' })+ })+ fireEvent.click(screen.getByRole('button', { name: `Update to ${'b'.repeat(8)}` }))+ await waitFor(() => expect($confirmRequest.get()?.description).toContain('Tools: weather-alerts'))+ expect($confirmRequest.get()?.title).toBe('demo-weather asks for more')+ await act(async () => {+ settleConfirm(false)+ })+ expect(requestGateway).not.toHaveBeenCalledWith(+ 'plugins.manage',+ expect.objectContaining({ accept_capabilities: true })+ )+ expect(screen.getByRole('button', { name: `Update to ${'b'.repeat(8)}` })).toBeTruthy()++ fireEvent.click(screen.getByRole('button', { name: `Update to ${'b'.repeat(8)}` }))+ await waitFor(() => expect($confirmRequest.get()).not.toBeNull())+ await act(async () => {+ settleConfirm(true)+ })+ expect(requestGateway).toHaveBeenCalledWith('plugins.manage', {+ action: 'update',+ name: 'demo-weather',+ profile: 'workbot',+ accept_capabilities: true+ })+ })++ it('fetches the catalog once, retaining parent search across selection and filters', async () => {+ queryClient.clear()- it('grows the catalog when its top-edge sash is dragged up, and resets on double-click', () => {- // jsdom has no layout: give the Capabilities column a real height so the- // "never crush the lists above" clamp has something to clamp against.- const clientHeight = vi.spyOn(HTMLElement.prototype, 'clientHeight', 'get').mockReturnValue(900)- Object.defineProperty(window, 'innerHeight', { configurable: true, value: 1000 })- render(<PluginsTab profile={null} />)- const sash = screen.getByTestId('plugin-catalog-sash')+ const fetchCatalog = vi.fn().mockResolvedValue({+ ok: true,+ json: async () => [+ weatherEntry,+ { ...weatherEntry, name: 'garden-plugin', category: 'garden', description: 'Garden planning' }+ ]+ })++ vi.stubGlobal('fetch', fetchCatalog)+ await act(async () => {+ renderPlugins({ profile: null })+ })++ await selectCatalogEntry('garden-plugin')- fireEvent.pointerDown(sash, { button: 0, clientY: 600 })- fireEvent.pointerMove(window, { clientY: 400 })- fireEvent.pointerUp(window)+ const search = screen.getByRole<HTMLInputElement>('textbox', { name: 'Search plugins' })- // Default 380px + 200px of upward drag (clamped only by window/column size).- expect($paneHeightOverride('capabilities-plugin-catalog').get()).toBe(580)+ fireEvent.change(search, { target: { value: 'weather' } })+ expect(await screen.findByRole('heading', { name: weatherEntry.name })).toBeTruthy()+ expect(screen.queryByRole('button', { name: 'garden-plugin' })).toBeNull()+ fireEvent.click(screen.getByRole('button', { name: /^Filters/ }))+ fireEvent.click(await screen.findByRole('button', { name: 'Installed', pressed: false }))+ expect(screen.queryByRole('heading', { name: weatherEntry.name })).toBeNull()+ expect(search.value).toBe('weather')+ fireEvent.click(screen.getAllByRole('button', { name: 'Clear filters' })[0])+ expect(search.value).toBe('')+ await selectCatalogEntry('garden-plugin')- fireEvent.doubleClick(sash)- expect($paneHeightOverride('capabilities-plugin-catalog').get()).toBeUndefined()- clientHeight.mockRestore()+ expect(fetchCatalog).toHaveBeenCalledTimes(1)+ expect(fetchCatalog.mock.calls[0][0]).toMatch(/\/docs\/api\/plugins\.json$/)+ expect(fetchCatalog.mock.calls[0][1]).toMatchObject({ credentials: 'omit' })+ expect($pluginInstallRequest.get()).toBeNull()+ })++ 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)+ const view = renderPlugins({ profile: null })++ expect(await screen.findByText('Catalog HTTP 503')).toBeTruthy()+ expect(fetchCatalog).toHaveBeenCalledTimes(1)+ view.unmount()+ await act(async () => {+ renderPlugins({ profile: null })+ })+ expect(fetchCatalog).toHaveBeenCalledTimes(1)+ expect(screen.getByText('Catalog HTTP 503')).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'Try again' }))++ expect(await screen.findByRole('heading', { name: weatherEntry.name })).toBeTruthy()+ expect(fetchCatalog).toHaveBeenCalledTimes(2)})it('shows an Update chip when the catalog pin moved past the installed SHA', () => {@@ -598,7 +767,7 @@ describe('PluginsTab catalog UX', () => {}])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })expect(screen.getByRole('button', { name: `Update to ${'b'.repeat(8)}` })).toBeTruthy()})@@ -621,7 +790,7 @@ describe('PluginsTab catalog UX', () => {])requestGateway.mockResolvedValue({ ok: true, unchanged: false, plugins: [] } as never)- render(<PluginsTab profile="workbot" />)+ renderPlugins({ profile: 'workbot' })screen.getByRole('button', { name: `Update to ${'b'.repeat(8)}` }).click()@@ -644,14 +813,17 @@ describe('PluginsTab catalog UX', () => {version: '1.0.0'}])- requestGateway.mockResolvedValue({ ok: true, name: 'demo-weather', plugins: [] } as never)+ requestGateway.mockImplementation(async (_method, params) =>+ params?.action === 'remove' ? { ok: true, name: 'demo-weather' } : { plugins: $agentPlugins.get() }+ )- render(<PluginsTab profile="workbot" />)+ renderPlugins({ profile: 'workbot' })screen.getByRole('button', { name: 'Uninstall: demo-weather' }).click()// The click only asks; nothing is deleted until the destructive confirm is answered.await waitFor(() => expect($confirmRequest.get()?.title).toContain('demo-weather'))+ expect(screen.getByRole('row', { name: /^demo-weather/ })).toBeTruthy()expect(requestGateway).not.toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'remove' }))settleConfirm(true)@@ -671,7 +843,7 @@ describe('PluginsTab catalog UX', () => {})uninstallDiskPlugin.mockClear()- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })screen.getByRole('button', { name: 'Uninstall: Clock' }).click()@@ -691,10 +863,11 @@ describe('PluginsTab catalog UX', () => {media: { id: 'media', name: 'Media Studio', kind: 'disk', status: 'loaded', packageName: 'hermes-media-studio' }})- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })- expect(screen.getByText('Bot Mode')).toBeTruthy()- expect(screen.getByText('Media Studio')).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: /^Bot Mode/ }))+ expect(screen.queryByRole('button', { name: /^Uninstall:/ })).toBeNull()+ fireEvent.click(screen.getByRole('button', { name: /^Media Studio/ }))expect(screen.queryByRole('button', { name: /^Uninstall:/ })).toBeNull()})@@ -703,13 +876,14 @@ describe('PluginsTab catalog UX', () => {{ description: '', key: 'demo-tool', name: 'demo-tool', source: 'entrypoint', status: 'enabled', version: '' }])- render(<PluginsTab profile={null} />)+ renderPlugins({ profile: null })- expect(screen.getByText('demo-tool')).toBeTruthy()+ expect(screen.getByRole('row', { name: /^demo-tool/ })).toBeTruthy()expect(screen.queryByRole('button', { name: 'Uninstall: demo-tool' })).toBeNull()})- it('refuses a catalog pick 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',@@ -719,100 +893,35 @@ describe('PluginsTab catalog UX', () => {name: 'demo-weather',source: 'git',status: 'enabled',- update_available: false,version: '1.0.0'}])-- render(<PluginsTab profile={null} />)-- window.dispatchEvent(- new MessageEvent('message', {- data: {- name: 'demo-weather',- repo: 'https://github.com/example/demo-weather',- type: 'hermes-plugin-pick'- },- origin: 'https://hermes-agent.nousresearch.com'- })- )-- // The modal must NOT open — the pick is refused with a toast.- await new Promise(resolve => setTimeout(resolve, 20))- expect($pluginInstallRequest.get()).toBeNull()- })-- it('still opens the modal for an installed pick 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'- }- ])-- render(<PluginsTab profile={null} />)-- window.dispatchEvent(- new MessageEvent('message', {- data: {- name: 'demo-weather',- repo: 'https://github.com/example/demo-weather',- type: 'hermes-plugin-pick'- },- origin: 'https://hermes-agent.nousresearch.com'- })+ 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: 'workbot' })+ })- await waitFor(() => expect($pluginInstallRequest.get()).not.toBeNull())- })- // The gear no longer unfolds an inline form under the row: plugin settings- // live in Settings ▸ Plugins (one entry per plugin, WoW-AddOns style) and the- // gear deep-links there.- it('sends the settings gear to the plugin’s page in Settings ▸ Plugins', () => {- $agentPlugins.set([- {- description: '',- key: 'notes',- name: 'notes',- settings_schema: [{ description: '', key: 'region', label: 'Region', required: false, type: 'string' }],- source: 'user',- status: 'enabled',- version: '1.0.0'- }- ])-- render(<PluginsTab profile={null} />)- fireEvent.click(screen.getByRole('button', { name: 'Settings: notes' }))+ const card = screen+ .getAllByRole('article')+ .find(article => within(article).queryByRole('button', { name: 'demo-weather' }))!- expect(window.location.hash).toBe('#/settings?tab=plugins&agent=notes')- expect(screen.queryByTestId('plugin-settings-notes-settings-form')).toBeNull()- })+ const toggle = within(card).getByRole('switch', { name: 'demo-weather' })+ expect(toggle.getAttribute('aria-checked')).toBe('true')+ fireEvent.click(toggle)- it('gives a desktop plugin that registered a settings page a gear too', () => {- publishPlugin(- { id: 'weather', kind: 'disk', name: 'Weather', status: 'loaded' },- {- activate: () => undefined,- deactivate: () => undefined- }+ await waitFor(() =>+ expect(requestGateway).toHaveBeenCalledWith(+ 'plugins.manage',+ expect.objectContaining({ action: 'toggle', key: 'demo-weather', enable: false, profile: 'workbot' })+ ))- const ctx = createPluginContext('weather')- const dispose = ctx.registerSettingsPage({ id: 'main', render: () => null, title: 'Weather' })-- try {- render(<PluginsTab profile={null} />)- fireEvent.click(screen.getByRole('button', { name: 'Settings: Weather' }))- expect(window.location.hash).toBe('#/settings?tab=plugins&plugin=weather')- } finally {- dispose()- dropPlugin('weather')- }+ expect($confirmRequest.get()).toBeNull()+ expect($pluginInstallRequest.get()).toBeNull()+ expect(requestGateway).not.toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'remove' }))})})