refactor(desktop): agent plugins live ONLY in Capabilities — Settings keeps desktop plugins + drift badge
Settings > Plugins no longer duplicates the agent-plugin list: management (list, toggles, profile scope, catalog installs) is Capabilities > Plugins. Settings keeps desktop plugins, the agent-half-missing drift badge (still fed by the connected backend's list), and a pointer link to Capabilities.
This commit is contained in:
@@ -1,65 +1,34 @@
|
||||
import { QueryClientProvider } from '@tanstack/react-query'
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { MemoryRouter } from 'react-router'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { requestGateway, getProfiles } = vi.hoisted(() => ({
|
||||
requestGateway: vi.fn(),
|
||||
getProfiles: vi.fn<() => Promise<{ profiles: { name: string; is_default: boolean }[] }>>(async () => ({
|
||||
profiles: []
|
||||
}))
|
||||
const { requestGateway } = vi.hoisted(() => ({
|
||||
requestGateway: vi.fn(async () => ({ plugins: [] }))
|
||||
}))
|
||||
|
||||
vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({
|
||||
useGatewayRequest: () => ({ requestGateway })
|
||||
}))
|
||||
|
||||
vi.mock('@/hermes', async importOriginal => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
getProfiles
|
||||
}))
|
||||
|
||||
import { $pluginRecords } from '@/contrib/plugins-store'
|
||||
import { queryClient } from '@/lib/query-client'
|
||||
import {
|
||||
$agentPluginBusy,
|
||||
$agentPlugins,
|
||||
$agentPluginsError,
|
||||
$agentPluginsStatus,
|
||||
type AgentPluginRow
|
||||
} from '@/store/agent-plugins'
|
||||
import { $activeGatewayProfile } from '@/store/profile'
|
||||
import { $connection, $gatewayState } from '@/store/session'
|
||||
import { $agentPlugins, $agentPluginsStatus } from '@/store/agent-plugins'
|
||||
import { $gatewayState } from '@/store/session'
|
||||
|
||||
import { PluginsSettings } from './plugins-settings'
|
||||
|
||||
const legacyRow = {
|
||||
name: 'Legacy plugin',
|
||||
version: '0.20.0',
|
||||
description: 'Returned by a pre-key backend',
|
||||
source: 'user',
|
||||
status: 'disabled'
|
||||
} satisfies AgentPluginRow
|
||||
|
||||
const renderSettings = () =>
|
||||
render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<MemoryRouter>
|
||||
<PluginsSettings />
|
||||
</QueryClientProvider>
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
beforeEach(() => {
|
||||
requestGateway.mockReset()
|
||||
getProfiles.mockReset()
|
||||
getProfiles.mockResolvedValue({ profiles: [] })
|
||||
queryClient.clear()
|
||||
requestGateway.mockClear()
|
||||
$pluginRecords.set({})
|
||||
$agentPlugins.set([legacyRow])
|
||||
$agentPlugins.set([])
|
||||
$agentPluginsStatus.set('ready')
|
||||
$agentPluginsError.set(null)
|
||||
$agentPluginBusy.set(null)
|
||||
$gatewayState.set('idle')
|
||||
$connection.set(null)
|
||||
$activeGatewayProfile.set('default')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -68,166 +37,93 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('PluginsSettings', () => {
|
||||
it('renders and searches plugin rows returned without a canonical key', () => {
|
||||
renderSettings()
|
||||
|
||||
expect(screen.getByText('Legacy plugin')).toBeTruthy()
|
||||
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'pre-key' } })
|
||||
|
||||
expect(screen.getByText('Legacy plugin')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('renders keyless rows read-only instead of falling back to name-addressed toggles', () => {
|
||||
// Name-addressed toggles flip every same-named plugin across category
|
||||
// dirs (image_gen/fal vs video_gen/fal) — the reason toggles moved to
|
||||
// canonical keys. A pre-contract-v6 row must never reach the RPC.
|
||||
renderSettings()
|
||||
|
||||
const toggle = screen.getByRole('switch', { name: 'Enable Legacy plugin' })
|
||||
|
||||
expect(toggle.hasAttribute('disabled') || toggle.getAttribute('aria-disabled') === 'true').toBe(true)
|
||||
|
||||
fireEvent.click(toggle)
|
||||
|
||||
expect(requestGateway).not.toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'toggle' }))
|
||||
})
|
||||
|
||||
it('keeps duplicate-named keyless rows distinct (no React key collision)', () => {
|
||||
const sibling = {
|
||||
...legacyRow,
|
||||
description: 'A second plugin category with the same legacy name'
|
||||
}
|
||||
|
||||
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined)
|
||||
|
||||
$agentPlugins.set([legacyRow, sibling])
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.getAllByRole('switch', { name: 'Enable Legacy plugin' })).toHaveLength(2)
|
||||
expect(screen.getByText(sibling.description)).toBeTruthy()
|
||||
expect(consoleError.mock.calls.flat().join(' ')).not.toContain('same key')
|
||||
})
|
||||
|
||||
it('keeps using the canonical key when the backend provides one', async () => {
|
||||
const keyedRow = { ...legacyRow, key: 'image_gen/legacy' }
|
||||
|
||||
$agentPlugins.set([keyedRow])
|
||||
requestGateway.mockResolvedValue({ ok: true, plugin: { ...keyedRow, status: 'enabled' } })
|
||||
|
||||
renderSettings()
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'Enable Legacy plugin' }))
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestGateway).toHaveBeenCalledWith('plugins.manage', {
|
||||
action: 'toggle',
|
||||
key: 'image_gen/legacy',
|
||||
enable: true
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('hides repo-bundled built-ins and keeps the count pill in sync', () => {
|
||||
// The Agent plugins section is the control panel for plugins the USER
|
||||
// installed — built-ins (browser backends, cron providers, model
|
||||
// providers…) ship enabled-by-default and are configured elsewhere.
|
||||
it('points agent-plugin management at Capabilities instead of duplicating the list', () => {
|
||||
// Agent plugins are profile-scoped and managed in Capabilities → Plugins;
|
||||
// Settings keeps desktop plugins only, plus a pointer.
|
||||
$agentPlugins.set([
|
||||
legacyRow,
|
||||
{ ...legacyRow, name: 'browserbase', key: 'browser/browserbase', source: 'bundled' },
|
||||
{ ...legacyRow, name: 'chronos', key: 'cron_providers/chronos', source: 'bundled' },
|
||||
{ ...legacyRow, name: 'deepinfra', key: 'model-providers/deepinfra', source: 'bundled' }
|
||||
{
|
||||
description: 'Should NOT be listed here anymore',
|
||||
key: 'demo-plugin',
|
||||
name: 'demo-plugin',
|
||||
source: 'git',
|
||||
status: 'enabled',
|
||||
version: '1.0.0'
|
||||
}
|
||||
])
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.getByText('Legacy plugin')).toBeTruthy()
|
||||
expect(screen.queryByText('browserbase')).toBeNull()
|
||||
expect(screen.queryByText('chronos')).toBeNull()
|
||||
expect(screen.queryByText('deepinfra')).toBeNull()
|
||||
// Count pill reflects the filtered list, not the raw RPC row count.
|
||||
expect(screen.getByText('1 installed', { exact: false })).toBeTruthy()
|
||||
expect(screen.queryByText('demo-plugin')).toBeNull()
|
||||
expect(screen.getByText(/managed per profile in Capabilities/)).toBeTruthy()
|
||||
expect(screen.getByRole('link', { name: /Capabilities/ }).getAttribute('href')).toContain('/skills?tab=plugins')
|
||||
})
|
||||
|
||||
it('hides legacy other-surface categories even when the backend omits source', () => {
|
||||
// Older backends may not report source reliably — the key-prefix
|
||||
// fallback still hides categories other surfaces own.
|
||||
$agentPlugins.set([{ ...legacyRow, name: 'deepinfra', key: 'model-providers/deepinfra', source: 'user' }])
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.queryByText('deepinfra')).toBeNull()
|
||||
})
|
||||
|
||||
it('shows no profile selector with a single profile', async () => {
|
||||
getProfiles.mockResolvedValue({ profiles: [{ name: 'default', is_default: true }] })
|
||||
|
||||
renderSettings()
|
||||
|
||||
await waitFor(() => expect(getProfiles).toHaveBeenCalled())
|
||||
expect(screen.queryByText('Applies to:')).toBeNull()
|
||||
})
|
||||
|
||||
it('lists the active profile scope without a profile param and reloads scoped on change', async () => {
|
||||
getProfiles.mockResolvedValue({
|
||||
profiles: [
|
||||
{ name: 'default', is_default: true },
|
||||
{ name: 'work', is_default: false }
|
||||
]
|
||||
})
|
||||
requestGateway.mockResolvedValue({ plugins: [legacyRow] })
|
||||
$gatewayState.set('open')
|
||||
|
||||
renderSettings()
|
||||
|
||||
// Active profile scope: no profile param — older backends unchanged.
|
||||
await waitFor(() => expect(requestGateway).toHaveBeenCalledWith('plugins.manage', { action: 'list' }))
|
||||
await waitFor(() => expect(screen.getByText('Applies to:')).toBeTruthy())
|
||||
})
|
||||
|
||||
it('sends toggles through the selected profile scope', async () => {
|
||||
// jsdom's scrollIntoView is missing/non-functional; Radix Select calls it
|
||||
// when the dropdown opens.
|
||||
Element.prototype.scrollIntoView = vi.fn()
|
||||
|
||||
const keyedRow = { ...legacyRow, key: 'image_gen/legacy' }
|
||||
|
||||
getProfiles.mockResolvedValue({
|
||||
profiles: [
|
||||
{ name: 'default', is_default: true },
|
||||
{ name: 'work', is_default: false }
|
||||
]
|
||||
})
|
||||
requestGateway.mockImplementation(async (method: string, params?: Record<string, unknown>) => {
|
||||
if (params?.action === 'list') {
|
||||
return { plugins: [keyedRow] }
|
||||
it('flags a unified-root desktop half whose agent half is missing on this backend', () => {
|
||||
$pluginRecords.set({
|
||||
'pixel-overlay': {
|
||||
id: 'pixel-overlay',
|
||||
name: 'Pixel Overlay',
|
||||
kind: 'disk',
|
||||
status: 'loaded',
|
||||
file: '/home/user/.hermes/plugins/pixel-overlay/desktop/plugin.js'
|
||||
}
|
||||
|
||||
return { ok: true, plugin: { ...keyedRow, status: 'enabled' } }
|
||||
})
|
||||
$agentPlugins.set([]) // connected backend has no agent half
|
||||
$agentPluginsStatus.set('ready')
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.getByText('agent half missing here')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('does not flag when the agent half exists on the connected backend', () => {
|
||||
$pluginRecords.set({
|
||||
'pixel-overlay': {
|
||||
id: 'pixel-overlay',
|
||||
name: 'Pixel Overlay',
|
||||
kind: 'disk',
|
||||
status: 'loaded',
|
||||
file: '/home/user/.hermes/plugins/pixel-overlay/desktop/plugin.js'
|
||||
}
|
||||
})
|
||||
$agentPlugins.set([
|
||||
{
|
||||
description: '',
|
||||
key: 'pixel-overlay',
|
||||
name: 'pixel-overlay',
|
||||
source: 'user',
|
||||
status: 'enabled',
|
||||
version: '1.0.0'
|
||||
}
|
||||
])
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.queryByText('agent half missing here')).toBeNull()
|
||||
})
|
||||
|
||||
it('does not flag standalone desktop plugins (not from the unified root)', () => {
|
||||
$pluginRecords.set({
|
||||
standalone: {
|
||||
id: 'standalone',
|
||||
name: 'Standalone Theme',
|
||||
kind: 'disk',
|
||||
status: 'loaded',
|
||||
file: '/home/user/.config/hermes-desktop/desktop-plugins/standalone/plugin.js'
|
||||
}
|
||||
})
|
||||
$agentPlugins.set([])
|
||||
|
||||
renderSettings()
|
||||
|
||||
expect(screen.queryByText('agent half missing here')).toBeNull()
|
||||
})
|
||||
|
||||
it('loads the connected backend plugin list once the gateway opens (badge data)', () => {
|
||||
$gatewayState.set('open')
|
||||
|
||||
renderSettings()
|
||||
|
||||
await waitFor(() => expect(screen.getByText('Applies to:')).toBeTruthy())
|
||||
|
||||
// Select the non-active profile scope.
|
||||
fireEvent.click(screen.getByRole('combobox'))
|
||||
fireEvent.click(await screen.findByText('work'))
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestGateway).toHaveBeenCalledWith('plugins.manage', { action: 'list', profile: 'work' })
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'Enable Legacy plugin' }))
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestGateway).toHaveBeenCalledWith('plugins.manage', {
|
||||
action: 'toggle',
|
||||
key: 'image_gen/legacy',
|
||||
enable: true,
|
||||
profile: 'work'
|
||||
})
|
||||
)
|
||||
expect(requestGateway).toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'list' }))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,46 +1,26 @@
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { type ReactNode, useEffect, useState } from 'react'
|
||||
import { type ReactNode, useEffect } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import { useGatewayRequest } from '@/app/gateway/hooks/use-gateway-request'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Codicon } from '@/components/ui/codicon'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { Tip } from '@/components/ui/tooltip'
|
||||
import { $pluginRecords, type PluginRecord, setPluginEnabled } from '@/contrib/plugins-store'
|
||||
import { discoverRuntimePlugins } from '@/contrib/runtime-loader'
|
||||
import { getProfiles } from '@/hermes'
|
||||
import { useI18n } from '@/i18n'
|
||||
import { triggerHaptic } from '@/lib/haptics'
|
||||
import { FolderOpen, Monitor, Package, RefreshCw } from '@/lib/icons'
|
||||
import { normalize } from '@/lib/text'
|
||||
import {
|
||||
$agentPluginBusy,
|
||||
$agentPlugins,
|
||||
$agentPluginsError,
|
||||
$agentPluginsStatus,
|
||||
type AgentPluginRow,
|
||||
type GatewayRequest,
|
||||
isDesktopRelevantPlugin,
|
||||
loadAgentPlugins,
|
||||
toggleAgentPlugin
|
||||
} from '@/store/agent-plugins'
|
||||
import { $agentPlugins, $agentPluginsStatus, loadAgentPlugins } from '@/store/agent-plugins'
|
||||
import { notifyError } from '@/store/notifications'
|
||||
import { $activeGatewayProfile } from '@/store/profile'
|
||||
import { $connection, $gatewayState } from '@/store/session'
|
||||
import { $gatewayState } from '@/store/session'
|
||||
|
||||
import { EmptyState, ListRowSkeleton, Pill, SettingsContent, SettingsSection } from './primitives'
|
||||
import { EmptyState, Pill, SettingsContent, SettingsSection } from './primitives'
|
||||
import { useDeepLinkHighlight } from './use-deep-link-highlight'
|
||||
|
||||
const KIND_ORDER: Record<PluginRecord['kind'], number> = { disk: 0, runtime: 1, bundled: 2 }
|
||||
|
||||
// User-installed plugins first — mirrors `hermes plugins list --user`.
|
||||
const SOURCE_ORDER: Record<string, number> = { user: 0, git: 0, project: 1, entrypoint: 2 }
|
||||
|
||||
const agentPluginRowKey = (row: AgentPluginRow) =>
|
||||
row.key ?? [row.name, row.source, row.version, row.description].join('\0')
|
||||
|
||||
/** Deep-link anchor for a plugin row (`?tab=plugins&plugin=<id>`). */
|
||||
export const pluginElementId = (target: string) => `plugin-${target}`
|
||||
|
||||
@@ -72,31 +52,6 @@ async function revealPluginsDir() {
|
||||
}
|
||||
}
|
||||
|
||||
// Agent plugins live under the BACKEND's hermes home (profile-aware), so the
|
||||
// path comes from the gateway — not from the renderer's local HERMES_HOME.
|
||||
// Callers gate on a local connection: openDir mkdir-creates the path, which
|
||||
// must never happen for a directory that belongs to a remote box.
|
||||
async function revealAgentPluginsDir(request: GatewayRequest) {
|
||||
try {
|
||||
const result = await request<{ home?: string }>('config.get', { key: 'profile' })
|
||||
const home = (result?.home ?? '').trim()
|
||||
|
||||
if (!home) {
|
||||
notifyError('The backend did not report its home directory', 'Could not open the plugins folder')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const opened = await window.hermesDesktop?.openDir?.(`${home}/plugins`)
|
||||
|
||||
if (opened && !opened.ok) {
|
||||
notifyError(opened.error ?? 'unknown error', 'Could not open the plugins folder')
|
||||
}
|
||||
} catch (err) {
|
||||
notifyError(err, 'Could not open the plugins folder')
|
||||
}
|
||||
}
|
||||
|
||||
// Compact row: name + pills and a wrapping description on the left, controls
|
||||
// pinned top-right. Same type scale as ListRow, without its wide control grid.
|
||||
function PluginLine({
|
||||
@@ -127,189 +82,6 @@ function PluginLine({
|
||||
)
|
||||
}
|
||||
|
||||
function AgentPluginRowView({ row, profile }: { row: AgentPluginRow; profile: string | null }) {
|
||||
const { t } = useI18n()
|
||||
const p = t.settings.plugins
|
||||
const { requestGateway } = useGatewayRequest()
|
||||
const busy = useStore($agentPluginBusy)
|
||||
const key = row.key
|
||||
|
||||
// Pre-contract-v6 backends return rows without a canonical key. Name-addressed
|
||||
// toggles silently flip every same-named plugin across category dirs
|
||||
// (image_gen/fal vs video_gen/fal), so keyless rows are read-only — the
|
||||
// backend-contract skew toast tells the user to update.
|
||||
const toggle = (
|
||||
<Switch
|
||||
aria-label={`${row.status === 'enabled' ? p.disable : p.enable} ${row.name}`}
|
||||
checked={row.status === 'enabled'}
|
||||
disabled={!key || busy === key}
|
||||
onCheckedChange={on => {
|
||||
if (!key) {
|
||||
return
|
||||
}
|
||||
|
||||
triggerHaptic('selection')
|
||||
void toggleAgentPlugin(requestGateway, key, on, p.agent.toggleFailed(row.name), profile)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<PluginLine
|
||||
controls={key ? toggle : <Tip label={p.agent.updateBackendToManage}>{toggle}</Tip>}
|
||||
description={row.description || (row.version ? `v${row.version}` : undefined)}
|
||||
id={pluginElementId(key ?? row.name)}
|
||||
title={
|
||||
<>
|
||||
<span>{row.name}</span>
|
||||
<Pill>{p.agent.sources[row.source] ?? row.source}</Pill>
|
||||
{row.portable && <Pill tone="primary">{p.agent.portable}</Pill>}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AgentPluginsSection() {
|
||||
const { t } = useI18n()
|
||||
const p = t.settings.plugins
|
||||
const { requestGateway } = useGatewayRequest()
|
||||
const gatewayState = useStore($gatewayState)
|
||||
const connection = useStore($connection)
|
||||
const rows = useStore($agentPlugins)
|
||||
const status = useStore($agentPluginsStatus)
|
||||
const error = useStore($agentPluginsError)
|
||||
const [query, setQuery] = useState('')
|
||||
|
||||
// 'Applies to' profile scope: which profile's plugins we list/toggle.
|
||||
// Defaults to the app-wide active profile; overriding it here lets the user
|
||||
// manage ANY profile's plugins without switching the whole app (same
|
||||
// pattern as the Capabilities scope selector in app/skills). null = the
|
||||
// active profile — the RPC is sent without a profile param so older
|
||||
// backends keep working unchanged.
|
||||
const activeProfile = useStore($activeGatewayProfile)
|
||||
const [scopeOverride, setScopeOverride] = useState<null | string>(null)
|
||||
const scopeProfile = scopeOverride ?? activeProfile ?? null
|
||||
// The param we actually send: omit it for the active profile.
|
||||
const requestProfile = scopeOverride && scopeOverride !== activeProfile ? scopeOverride : null
|
||||
|
||||
const { data: profilesData } = useQuery({
|
||||
queryKey: ['agent-plugins-profiles'],
|
||||
queryFn: getProfiles,
|
||||
staleTime: 60_000
|
||||
})
|
||||
|
||||
const profiles = profilesData?.profiles ?? []
|
||||
|
||||
// An app-wide profile switch retargets the default scope — drop the
|
||||
// override so the list reloads for the profile the user just switched to.
|
||||
useEffect(() => {
|
||||
setScopeOverride(null)
|
||||
}, [activeProfile])
|
||||
|
||||
useEffect(() => {
|
||||
if (gatewayState !== 'open') {
|
||||
return
|
||||
}
|
||||
|
||||
void loadAgentPlugins(requestGateway, requestProfile)
|
||||
}, [gatewayState, requestGateway, requestProfile])
|
||||
|
||||
const needle = normalize(query)
|
||||
|
||||
const sorted = rows
|
||||
.filter(isDesktopRelevantPlugin)
|
||||
.filter(
|
||||
row =>
|
||||
!needle ||
|
||||
row.name.toLowerCase().includes(needle) ||
|
||||
(row.key ?? '').toLowerCase().includes(needle) ||
|
||||
row.description.toLowerCase().includes(needle)
|
||||
)
|
||||
.sort((a, b) => (SOURCE_ORDER[a.source] ?? 9) - (SOURCE_ORDER[b.source] ?? 9) || a.name.localeCompare(b.name))
|
||||
|
||||
return (
|
||||
<SettingsSection
|
||||
icon={Package}
|
||||
meta={status === 'ready' ? p.count(sorted.length) : undefined}
|
||||
title={p.agent.title}
|
||||
>
|
||||
<p className="mb-2 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">
|
||||
{p.agent.blurb}
|
||||
</p>
|
||||
|
||||
{profiles.length > 1 && (
|
||||
<div className="mb-2 flex items-center gap-2">
|
||||
<span className="text-[length:var(--conversation-caption-font-size)] font-medium text-(--ui-text-tertiary)">
|
||||
{p.agent.appliesTo}
|
||||
</span>
|
||||
<Select
|
||||
onValueChange={name => setScopeOverride(name === activeProfile ? null : name)}
|
||||
value={scopeProfile ?? ''}
|
||||
>
|
||||
<SelectTrigger className="h-7 w-56 text-xs">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{profiles.map(profile => (
|
||||
<SelectItem key={profile.name} value={profile.name}>
|
||||
{profile.is_default ? 'Hermes (default)' : profile.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{connection?.mode !== 'remote' && !requestProfile && (
|
||||
<div className="mb-2 flex items-center gap-3">
|
||||
<Button
|
||||
onClick={() => void revealAgentPluginsDir(requestGateway)}
|
||||
size="sm"
|
||||
type="button"
|
||||
variant="textStrong"
|
||||
>
|
||||
<FolderOpen className="size-3.5" />
|
||||
<span>{p.openFolder}</span>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<input
|
||||
className="mb-2 w-full rounded-lg border border-(--ui-stroke-tertiary) bg-(--ui-bg-quinary) px-3 py-1.5 text-[length:var(--conversation-caption-font-size)] outline-none placeholder:text-(--ui-text-tertiary) focus:border-(--ui-stroke-secondary)"
|
||||
onChange={event => setQuery(event.target.value)}
|
||||
placeholder={p.agent.search}
|
||||
spellCheck={false}
|
||||
value={query}
|
||||
/>
|
||||
|
||||
{status === 'loading' || status === 'idle' ? (
|
||||
<div>
|
||||
<ListRowSkeleton />
|
||||
<ListRowSkeleton />
|
||||
<ListRowSkeleton />
|
||||
</div>
|
||||
) : status === 'error' ? (
|
||||
<EmptyState description={error ?? undefined} title={p.agent.loadFailed} />
|
||||
) : sorted.length === 0 ? (
|
||||
needle ? (
|
||||
<p className="text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">
|
||||
{p.agent.noMatches}
|
||||
</p>
|
||||
) : (
|
||||
<EmptyState title={p.agent.empty} />
|
||||
)
|
||||
) : (
|
||||
<div>
|
||||
{sorted.map(row => (
|
||||
<AgentPluginRowView key={agentPluginRowKey(row)} profile={requestProfile} row={row} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</SettingsSection>
|
||||
)
|
||||
}
|
||||
|
||||
/** Folder name when a desktop plugin entry lives in the UNIFIED agent-plugins
|
||||
* root (`~/.hermes/plugins/<name>/desktop/plugin.js`) — i.e. it is the
|
||||
* desktop half of a bundled agent+desktop package. Null for standalone
|
||||
@@ -379,14 +151,26 @@ export function PluginsSettings() {
|
||||
const { t } = useI18n()
|
||||
const p = t.settings.plugins
|
||||
const records = useStore($pluginRecords)
|
||||
// The agent-plugin list for the CURRENTLY scoped backend/profile — used to
|
||||
// flag bundled packages whose desktop half is local but whose agent half is
|
||||
// not installed where the app is now pointing (one desktop app, N agents:
|
||||
// switching gateway/profile makes this drift visible instead of silent).
|
||||
const { requestGateway } = useGatewayRequest()
|
||||
const gatewayState = useStore($gatewayState)
|
||||
// The agent-plugin list for the CURRENTLY connected backend's active
|
||||
// profile — used only to flag bundled packages whose desktop half is local
|
||||
// but whose agent half is not installed where the app is now pointing (one
|
||||
// desktop app, N agents: switching gateway/profile makes this drift visible
|
||||
// instead of silent). Management of agent plugins lives in Capabilities →
|
||||
// Plugins; this page keeps just the badge.
|
||||
const agentRows = useStore($agentPlugins)
|
||||
const agentStatus = useStore($agentPluginsStatus)
|
||||
const agentNames = new Set(agentRows.flatMap(row => [row.name, row.key ?? row.name]))
|
||||
|
||||
useEffect(() => {
|
||||
if (gatewayState !== 'open') {
|
||||
return
|
||||
}
|
||||
|
||||
void loadAgentPlugins(requestGateway)
|
||||
}, [gatewayState, requestGateway])
|
||||
|
||||
// Deep-link from settings search (?plugin=<id or key>): rows render as soon
|
||||
// as their store hydrates, so "ready" is simply target-present; the polling
|
||||
// in the hook rides out the async list loads (agent rows arrive via RPC).
|
||||
@@ -445,7 +229,14 @@ export function PluginsSettings() {
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
<AgentPluginsSection />
|
||||
<SettingsSection icon={Package} title={p.agent.title}>
|
||||
<p className="text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">
|
||||
{p.agent.movedToCapabilities}{' '}
|
||||
<Link className="text-(--ui-text-link,var(--ui-accent))" to="/skills?tab=plugins">
|
||||
{p.agent.openCapabilities}
|
||||
</Link>
|
||||
</p>
|
||||
</SettingsSection>
|
||||
</SettingsContent>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -112,6 +112,61 @@ describe('PluginsTab', () => {
|
||||
expect($pluginInstallRequest.get()).toBeNull()
|
||||
})
|
||||
|
||||
it('toggles by canonical key through plugins.manage', async () => {
|
||||
$agentPlugins.set([
|
||||
{
|
||||
description: '',
|
||||
key: 'image_gen/legacy',
|
||||
name: 'Legacy plugin',
|
||||
source: 'user',
|
||||
status: 'disabled',
|
||||
version: '0.20.0'
|
||||
}
|
||||
])
|
||||
requestGateway.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
plugin: { key: 'image_gen/legacy', name: 'Legacy plugin', status: 'enabled' }
|
||||
} as never)
|
||||
|
||||
render(<PluginsTab profile={null} />)
|
||||
|
||||
screen.getByRole('switch', { name: 'Legacy plugin' }).click()
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestGateway).toHaveBeenCalledWith(
|
||||
'plugins.manage',
|
||||
expect.objectContaining({ action: 'toggle', key: 'image_gen/legacy', enable: true })
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
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.
|
||||
$agentPlugins.set([
|
||||
{
|
||||
description: 'Returned by a pre-key backend',
|
||||
name: 'Legacy plugin',
|
||||
source: 'user',
|
||||
status: 'disabled',
|
||||
version: '0.20.0'
|
||||
}
|
||||
])
|
||||
|
||||
render(<PluginsTab profile={null} />)
|
||||
|
||||
const toggle = screen.getByRole('switch', { name: 'Legacy plugin' })
|
||||
|
||||
expect(toggle.hasAttribute('disabled') || toggle.getAttribute('aria-disabled') === 'true').toBe(true)
|
||||
|
||||
toggle.click()
|
||||
|
||||
expect(requestGateway).not.toHaveBeenCalledWith(
|
||||
'plugins.manage',
|
||||
expect.objectContaining({ action: 'toggle' })
|
||||
)
|
||||
})
|
||||
|
||||
it('appends the subdir fragment for multi-plugin repos', async () => {
|
||||
render(<PluginsTab profile={null} />)
|
||||
|
||||
|
||||
@@ -423,17 +423,9 @@ export const en: Translations = {
|
||||
'This is the desktop half of a bundled plugin, but its agent half is not installed on the currently connected backend/profile. Install it from Capabilities → Plugins.',
|
||||
agent: {
|
||||
title: 'Agent plugins',
|
||||
blurb:
|
||||
'Plugins you installed into the Hermes backend — tools, skills, MCP servers, hooks, and slash commands. Portable ones are Agent Plugins packages (skills + MCP bundles that work in other agents too). Toggles apply to new sessions.',
|
||||
appliesTo: 'Applies to:',
|
||||
empty: 'No agent plugins installed yet.',
|
||||
loadFailed: 'Could not load agent plugins',
|
||||
portable: 'portable',
|
||||
search: 'Search plugins…',
|
||||
noMatches: 'No plugins match your search.',
|
||||
toggleFailed: (name: string) => `Could not toggle ${name}`,
|
||||
updateBackendToManage: 'Update the Hermes backend to manage this plugin from Desktop.',
|
||||
sources: { bundled: 'bundled', user: 'user', git: 'git', project: 'project', entrypoint: 'pip' }
|
||||
movedToCapabilities:
|
||||
'Agent plugins are managed per profile in Capabilities — installed list, toggles, and the plugin catalog live there.',
|
||||
openCapabilities: 'Open Capabilities → Plugins'
|
||||
},
|
||||
installModal: {
|
||||
title: 'Install plugin',
|
||||
|
||||
@@ -365,16 +365,8 @@ export interface Translations {
|
||||
agentHalfMissingTip: string
|
||||
agent: {
|
||||
title: string
|
||||
blurb: string
|
||||
appliesTo: string
|
||||
empty: string
|
||||
loadFailed: string
|
||||
portable: string
|
||||
search: string
|
||||
noMatches: string
|
||||
toggleFailed: (name: string) => string
|
||||
updateBackendToManage: string
|
||||
sources: Record<string, string>
|
||||
movedToCapabilities: string
|
||||
openCapabilities: string
|
||||
}
|
||||
installModal: {
|
||||
title: string
|
||||
|
||||
@@ -410,18 +410,10 @@ export const zh: Translations = {
|
||||
agentHalfMissingTip:
|
||||
'这是捆绑插件的桌面部分,但其 agent 部分未安装在当前连接的后端/配置上。请在 能力 → 插件 中安装。',
|
||||
agent: {
|
||||
title: '智能体插件',
|
||||
blurb:
|
||||
'你安装到 Hermes 后端的插件——工具、技能、MCP 服务器、钩子和斜杠命令。「便携」插件是 Agent Plugins 标准包(技能 + MCP 组合,也可在其他智能体中使用)。开关在新会话中生效。',
|
||||
appliesTo: '应用于:',
|
||||
empty: '尚未安装智能体插件。',
|
||||
loadFailed: '无法加载智能体插件',
|
||||
portable: '便携',
|
||||
search: '搜索插件…',
|
||||
noMatches: '没有匹配的插件。',
|
||||
toggleFailed: (name: string) => `无法切换 ${name}`,
|
||||
updateBackendToManage: '请更新 Hermes 后端以便在桌面端管理此插件。',
|
||||
sources: { bundled: '内置', user: '用户', git: 'git', project: '项目', entrypoint: 'pip' }
|
||||
title: 'Agent 插件',
|
||||
movedToCapabilities:
|
||||
'Agent 插件按配置在「能力」页管理 — 已安装列表、开关和插件目录都在那里。',
|
||||
openCapabilities: '打开 能力 → 插件'
|
||||
},
|
||||
installModal: {
|
||||
title: '安装插件',
|
||||
|
||||
Reference in New Issue
Block a user