Skip to content

The agent that grows with you

fix(desktop): plugin gear keeps the Settings ▸ Plugins hand-off

Austin Pickettb0b696667b05
diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx
index 8b2a6600ea6..a93a3c4d1ac 100644
--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx
+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { $pluginDecisions, $pluginRecords, dropPlugin, patchPlugin, publishPlugin } from '@/contrib/plugins-store'
import { queryClient } from '@/lib/query-client'
-import { $agentPlugins, $agentPluginsStatus, type AgentPluginRow } from '@/store/agent-plugins'
+import { $agentPlugins, $agentPluginsStatus } from '@/store/agent-plugins'
import { $confirmRequest, settleConfirm } from '@/store/confirm'
import { $notifications } from '@/store/notifications'
import { $pluginInstallRequest, closePluginInstallRequest } from '@/store/plugin-install-request'
@@ -585,59 +585,6 @@ describe('PluginsTab', () => {
})
describe('PluginsTab catalog UX', () => {
- 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)
- })
-
it('requires widening consent before retrying an update, and leaves a declined update untouched', async () => {
$agentPlugins.set([
{
diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
index 44085df1841..30a000c7129 100644
--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
@@ -1,7 +1,6 @@
import { useStore } from '@nanostores/react'
import { memo, type ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
-import { setEnvVar } from '@/api/config'
import { getToolsets, setToolsetEnabled } from '@/api/toolsets'
import { useGatewayRequest } from '@/app/gateway/hooks/use-gateway-request'
import { Button } from '@/components/ui/button'
@@ -9,7 +8,9 @@ import { Codicon } from '@/components/ui/codicon'
import { Switch } from '@/components/ui/switch'
import { Tip } from '@/components/ui/tooltip'
import { $pluginRecords, type PluginRecord, setPluginEnabled } from '@/contrib/plugins-store'
+import { useContributions } from '@/contrib/react/use-contributions'
import { discoverRuntimePlugins, uninstallDiskPlugin } from '@/contrib/runtime-loader'
+import { pluginSettingsRouteHref, SETTINGS_PLUGINS_AREA } from '@/contrib/settings-pages'
import type { ProfileScope } from '@/hermes'
import { useI18n } from '@/i18n'
import { DESKTOP_PLUGIN_TOOLSETS } from '@/lib/desktop-toolsets'
@@ -29,7 +30,6 @@ import {
isDesktopRelevantPlugin,
loadAgentPlugins,
removeAgentPlugin,
- saveAgentPluginSettings,
toggleAgentPlugin,
updateAgentPlugin
} from '@/store/agent-plugins'
@@ -48,7 +48,6 @@ import { CatalogSwitch } from '../catalog/catalog-switch'
import { TOOLSETS_QUERY_KEY } from '../toolsets/toolsets-data'
import { mergePluginPackages, type PackageKind, type PluginPackage } from './plugin-packages'
-import { PluginSettingsForm } from './plugin-settings-form'
/** Deep-link anchor for a package row (`/capabilities?tab=plugins&plugin=<key>`).
* Accepts the agent key, the agent name, or the desktop record id. */
@@ -228,10 +227,24 @@ function PackageRow({
const d = t.settings.plugins
const desktop = pkg.desktop
const agent = pkg.agent
- // Manifest `config_schema` → an inline settings form under the row (#46600, #87934).
- const settingsFields = agent?.settings_schema ?? []
- const hasSettings = Boolean(agent?.key) && settingsFields.length > 0
- const [settingsOpen, setSettingsOpen] = useState(false)
+ // Settings live in Settings ▸ Plugins: a manifest `config_schema` gets an
+ // automatic page there, a desktop half may register its own. The gear is
+ // the shortcut to that page (#46600, #87934).
+ const settingsPages = useContributions(SETTINGS_PLUGINS_AREA)
+ const desktopSettings = Boolean(desktop && settingsPages.some(page => page.source === `plugin:${desktop.id}`))
+ const agentSettings = Boolean(agent?.key) && Boolean(agent?.settings_schema?.length)
+ const hasSettings = desktopSettings || agentSettings
+
+ const openSettings = () => {
+ // A desktop page absorbs the package's schema form as a sub-page, so its
+ // plugin id is the one entry that covers both halves. The link carries
+ // the profile THIS page has selected: Settings keeps its own scope, and
+ // without the hand-off the page would open (and save) that one instead.
+ const route = desktopSettings ? { plugin: desktop!.id } : { agent: agent!.key! }
+
+ window.location.hash = `#${pluginSettingsRouteHref(route, scope)}`
+ }
+
const [desktopBusy, setDesktopBusy] = useState(false)
const desktopOn = desktop ? desktop.status !== 'disabled' : false
const agentOn = agent?.status === 'enabled'
@@ -353,19 +366,12 @@ function PackageRow({
</Tip>
)}
</span>
- {/* Fixed slot for the settings gear: only plugins whose manifest declares
- a config_schema get one. */}
+ {/* Fixed slot for the settings gear: only plugins with a page in
+ Settings ▸ Plugins (config_schema or a registered page) get one. */}
<span className="flex size-7 shrink-0 items-center justify-center">
{hasSettings && (
<Tip label={p.settingsToggle(pkg.name)}>
- <Button
- aria-expanded={settingsOpen}
- aria-label={p.settingsToggle(pkg.name)}
- className={cn(settingsOpen && 'text-foreground')}
- onClick={() => setSettingsOpen(open => !open)}
- size="icon"
- variant="ghost"
- >
+ <Button aria-label={p.settingsToggle(pkg.name)} onClick={openSettings} size="icon" variant="ghost">
<Codicon name="settings-gear" size="0.85rem" />
</Button>
</Tip>
@@ -479,31 +485,6 @@ function PackageRow({
)}
</HalfCell>
</div>
- {hasSettings && settingsOpen && agent?.key && (
- <div className="mt-5">
- <PluginSettingsForm
- disabled={busy}
- fields={settingsFields}
- idPrefix={`plugin-settings-${agent.key}`}
- onSave={async changes => {
- const ok = await saveAgentPluginSettings(request, {
- key: agent.key!,
- values: changes.values,
- secrets: changes.secrets,
- writeSecret: (env, value) => setEnvVar(env, value, profile),
- failMessage: p.settingsForm.saveFailed(pkg.name),
- profile: scope
- })
-
- if (ok) {
- notify({ kind: 'success', message: p.settingsForm.saved(pkg.name) })
- }
-
- return ok
- }}
- />
- </div>
- )}
</>
)
}
diff --git a/apps/desktop/src/app/settings/plugin-settings-ownership.test.tsx b/apps/desktop/src/app/settings/plugin-settings-ownership.test.tsx
index ba578047a9f..2dd4e776823 100644
--- a/apps/desktop/src/app/settings/plugin-settings-ownership.test.tsx
+++ b/apps/desktop/src/app/settings/plugin-settings-ownership.test.tsx
@@ -1,3 +1,4 @@
+import { QueryClientProvider } from '@tanstack/react-query'
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { MemoryRouter, useLocation } from 'react-router'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -5,11 +6,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createPluginContext } from '@/contrib/plugin'
import { $pluginRecords, dropPlugin, publishPlugin } from '@/contrib/plugins-store'
import { pluginSettingsHref } from '@/contrib/settings-pages'
+import { queryClient } from '@/lib/query-client'
import { $agentPlugins, $agentPluginsStatus, type AgentPluginRow } from '@/store/agent-plugins'
import { $activeGatewayProfile, $profiles } from '@/store/profile'
import { $settingsScopeOverride } from '@/store/settings-scope'
import type { ProfileInfo } from '@/types/hermes'
+import { $catalogCardView } from '../capabilities/catalog/store'
import { PluginsTab } from '../capabilities/plugins/plugins-tab'
import { OverlayNav } from '../overlays/overlay-split-layout'
@@ -135,7 +138,12 @@ const settingsCalls = () =>
/** Click a Capabilities ▸ Plugins gear and return the deep link it produced. */
function gearHref(props: Parameters<typeof PluginsTab>[0], label: string): string {
window.location.hash = ''
- const view = render(<PluginsTab {...props} />)
+
+ const view = render(
+ <QueryClientProvider client={queryClient}>
+ <PluginsTab {...props} />
+ </QueryClientProvider>
+ )
fireEvent.click(screen.getByRole('button', { name: label }))
view.unmount()
@@ -155,6 +163,7 @@ describe('Settings ▸ Plugins ownership (review of #133182)', () => {
$agentPluginsStatus.set('idle')
$activeGatewayProfile.set('default')
$settingsScopeOverride.set(null)
+ $catalogCardView.set(false)
$profiles.set([profile('default', true), profile('review-b'), profile('review-empty')])
})