Skip to content

The agent that grows with you

fix(desktop): read-only keyless plugin rows + backend contract v6

Teknium7e1bfeab8899
diff --git a/apps/desktop/src/app/settings/plugins-settings.test.tsx b/apps/desktop/src/app/settings/plugins-settings.test.tsx
index 547633fdbcc..ad640882910 100644
--- a/apps/desktop/src/app/settings/plugins-settings.test.tsx
+++ b/apps/desktop/src/app/settings/plugins-settings.test.tsx
@@ -54,22 +54,22 @@ describe('PluginsSettings', () => {
expect(screen.getByText('Legacy plugin')).toBeTruthy()
})
- it('uses the legacy name address when toggling a row without a key', async () => {
- requestGateway.mockResolvedValue({ ok: true, plugin: { ...legacyRow, status: 'enabled' } })
-
+ 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.
render(<PluginsSettings />)
- fireEvent.click(screen.getByRole('switch', { name: 'Enable Legacy plugin' }))
- await waitFor(() =>
- expect(requestGateway).toHaveBeenCalledWith('plugins.manage', {
- action: 'toggle',
- name: 'Legacy plugin',
- enable: true
- })
- )
+ 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 legacy rows distinct after a name-addressed toggle', async () => {
+ it('keeps duplicate-named keyless rows distinct (no React key collision)', () => {
const sibling = {
...legacyRow,
description: 'A second plugin category with the same legacy name'
@@ -77,15 +77,10 @@ describe('PluginsSettings', () => {
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined)
$agentPlugins.set([legacyRow, sibling])
- requestGateway.mockResolvedValue({ ok: true, plugin: { ...legacyRow, status: 'enabled' } })
render(<PluginsSettings />)
- fireEvent.click(screen.getAllByRole('switch', { name: 'Enable Legacy plugin' })[0])
-
- await waitFor(() =>
- expect(screen.getAllByRole('switch', { name: 'Disable Legacy plugin' })).toHaveLength(2)
- )
+ 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')
})
diff --git a/apps/desktop/src/app/settings/plugins-settings.tsx b/apps/desktop/src/app/settings/plugins-settings.tsx
index cfc4700d1b3..ca31ff38383 100644
--- a/apps/desktop/src/app/settings/plugins-settings.tsx
+++ b/apps/desktop/src/app/settings/plugins-settings.tsx
@@ -134,20 +134,31 @@ function AgentPluginRowView({ row }: { row: AgentPluginRow }) {
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))
+ }}
+ />
+ )
return (
<PluginLine
- controls={
- <Switch
- aria-label={`${row.status === 'enabled' ? p.disable : p.enable} ${row.name}`}
- checked={row.status === 'enabled'}
- disabled={busy === (row.key ?? row.name)}
- onCheckedChange={on => {
- triggerHaptic('selection')
- void toggleAgentPlugin(requestGateway, row, on, p.agent.toggleFailed(row.name))
- }}
- />
- }
+ controls={key ? toggle : <Tip label={p.agent.updateBackendToManage}>{toggle}</Tip>}
description={row.description || (row.version ? `v${row.version}` : undefined)}
title={
<>
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 807bfadd771..b0dba1f0e9d 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -376,6 +376,7 @@ export const en: Translations = {
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' }
}
},
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 4132d501576..d6110861430 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -326,6 +326,7 @@ export interface Translations {
search: string
noMatches: string
toggleFailed: (name: string) => string
+ updateBackendToManage: string
sources: Record<string, string>
}
}
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index c1a98c251df..71eb545f70f 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -367,6 +367,7 @@ export const zh: Translations = {
search: '搜索插件…',
noMatches: '没有匹配的插件。',
toggleFailed: (name: string) => `无法切换 ${name}`,
+ updateBackendToManage: '请更新 Hermes 后端以便在桌面端管理此插件。',
sources: { bundled: '内置', user: '用户', git: 'git', project: '项目', entrypoint: 'pip' }
}
},
diff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.ts
index aaf9218fbc7..505e6b0b3d1 100644
--- a/apps/desktop/src/store/agent-plugins.ts
+++ b/apps/desktop/src/store/agent-plugins.ts
@@ -70,22 +70,24 @@ export function loadAgentPlugins(request: GatewayRequest): Promise<void> {
}
/** Flip a backend plugin on/off and patch the row from the RPC's refreshed
- * copy. Current backends use canonical keys; legacy keyless rows fall back
- * to the name-addressed protocol they were returned by. */
+ * copy. Addressed by canonical key ONLY — bare names collide across category
+ * dirs (image_gen/fal vs video_gen/fal), which is exactly why the backend
+ * moved to key-addressed toggles. Rows without a key (pre-contract-v6
+ * backends) render read-only instead of falling back to the collision-prone
+ * name protocol; the backend-contract skew toast points the user at the
+ * update. Returns whether the toggle stuck. */
export async function toggleAgentPlugin(
request: GatewayRequest,
- row: Pick<AgentPluginRow, 'key' | 'name'>,
+ key: string,
enable: boolean,
failMessage: string
): Promise<boolean> {
- const address = row.key ?? row.name
-
- $agentPluginBusy.set(address)
+ $agentPluginBusy.set(key)
try {
const result = await request<{ ok?: boolean; plugin?: AgentPluginRow | null }>('plugins.manage', {
action: 'toggle',
- ...(row.key ? { key: row.key } : { name: row.name }),
+ key,
enable
})
@@ -96,15 +98,7 @@ export async function toggleAgentPlugin(
const refreshed = result.plugin
if (refreshed) {
- const currentRows = $agentPlugins.get()
-
- $agentPlugins.set(
- row.key
- ? currentRows.map(current => (current.key === row.key ? { ...current, ...refreshed } : current))
- : currentRows.map(current =>
- current.name === row.name ? { ...current, status: refreshed.status } : current
- )
- )
+ $agentPlugins.set($agentPlugins.get().map(row => (row.key === key ? { ...row, ...refreshed } : row)))
} else {
await loadAgentPlugins(request)
}
diff --git a/apps/desktop/src/store/updates.test.ts b/apps/desktop/src/store/updates.test.ts
index bb6f775f588..7507a2f53c5 100644
--- a/apps/desktop/src/store/updates.test.ts
+++ b/apps/desktop/src/store/updates.test.ts
@@ -134,7 +134,7 @@ describe('reportBackendContract', () => {
})
it('dismisses the toast when the backend meets the contract', () => {
- reportBackendContract(5)
+ reportBackendContract(6)
expect(dismissSpy).toHaveBeenCalledWith('backend-contract-skew')
expect(notifySpy).not.toHaveBeenCalled()
})
@@ -174,8 +174,8 @@ describe('reportBackendContract', () => {
lastToast().onDismiss()
notifySpy.mockClear()
- reportBackendContract(5) // backend updated → satisfied, snooze cleared
- reportBackendContract(4) // a later regression must warn immediately
+ reportBackendContract(6) // backend updated → satisfied, snooze cleared
+ reportBackendContract(5) // a later regression must warn immediately
expect(notifySpy).toHaveBeenCalledTimes(1)
})
})
diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.ts
index 8b95b2eaded..19739a977ec 100644
--- a/apps/desktop/src/store/updates.ts
+++ b/apps/desktop/src/store/updates.ts
@@ -94,7 +94,9 @@ function isUpdateToastSnoozed(): boolean {
// v3: requires approvals.mode config RPCs and session.info reconciliation.
// v4: requires explicit Fast-off session creation and session-scoped Fast edits.
// v5: requires raised WebSocket frame size for large one-shot file.attach.
-const REQUIRED_BACKEND_CONTRACT = 5
+// v6: requires key-addressed plugins.manage rows (keyless rows render
+// read-only in Settings → Plugins).
+const REQUIRED_BACKEND_CONTRACT = 6
const SKEW_TOAST_ID = 'backend-contract-skew'
// The contract check runs on every session.resume (applyRuntimeInfo), so
// without a snooze the warning re-popped on every thread the user opened, even
diff --git a/tui_gateway/server.py b/tui_gateway/server.py
index 874e8d3188c..28c3e091570 100644
--- a/tui_gateway/server.py
+++ b/tui_gateway/server.py
@@ -5134,7 +5134,9 @@ def _current_profile_name() -> str:
# v3: adds approvals.mode config RPCs and session.info reconciliation.
# v4: session.create fast=false is an explicit per-session normal-tier override.
# v5: uvicorn ws_max_size raised for one-shot base64 file.attach frames (>16 MiB).
-DESKTOP_BACKEND_CONTRACT = 5
+# v6: plugins.manage list rows carry the canonical registry key; toggles are
+# key-addressed (keyless rows render read-only in Desktop Settings).
+DESKTOP_BACKEND_CONTRACT = 6
def _session_usage_snapshot(session: dict | None) -> dict: