Skip to content

The agent that grows with you

fix(desktop): Agent on turns a unified package's desktop half on again

Austin Pickett0b3593a5615f
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 a93a3c4d1ac..f67b41896ef 100644
--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx
+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.test.tsx
@@ -383,6 +383,58 @@ 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)
+
+ renderPlugins({ 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)
+
+ renderPlugins({ 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.
diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
index 9ceb86ac98f..8c168b0387f 100644
--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
@@ -7,7 +7,7 @@ import { Button } from '@/components/ui/button'
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 { $pluginRecords, enablePackageDesktopHalf, 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'
@@ -761,7 +761,17 @@ export const PluginsTab = memo(function PluginsTab({
return
}
- void toggleAgentPlugin(requestGateway, row.key, enable, p.toggleFailed(row.name), scope)
+ void toggleAgentPlugin(requestGateway, row.key, enable, p.toggleFailed(row.name), scope).then(ok => {
+ // Turning a unified package on turns its desktop half on too
+ // (unless the user switched that half off on purpose). Off
+ // stays per half: the desktop half is app-wide, and another
+ // profile may still run the agent half.
+ const half = pkg.desktop?.packageName
+
+ if (ok && enable && half) {
+ void enablePackageDesktopHalf(half, { keepUserChoice: true })
+ }
+ })
}}
onAgentUpdate={row => {
const finish = (outcome: AgentPluginUpdateOutcome) => {