Skip to content

The agent that grows with you

fix(desktop): confirm before clearing the entire Enabled Toolsets list (#73319)

PRATHAMESH758e35ff0a628e
diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsx
index 45e0ff5f156..1dc47357973 100644
--- a/apps/desktop/src/app/settings/config-settings.tsx
+++ b/apps/desktop/src/app/settings/config-settings.tsx
@@ -28,7 +28,7 @@ import { useOnProfileSwitch } from '../hooks/use-on-profile-switch'
import { PanelEmpty } from '../overlays/panel'
import { ConfigField } from './config-field'
-import { enumOptionsFor, getNested, isExternalMemoryProvider, sectionFieldEntries, setNested } from './helpers'
+import { clearsEnabledToolsets, enumOptionsFor, getNested, isExternalMemoryProvider, sectionFieldEntries, setNested } from './helpers'
import { MemoryConnect } from './memory/connect'
import { ProviderConfigPanel } from './memory/provider-config-panel'
import { ModelSettings, ModelSettingsSkeleton } from './model-settings'
@@ -183,6 +183,15 @@ export function ConfigSettings({
}, [config, onConfigSaved, saveVersion])
const updateConfig = (next: HermesConfigRecord) => {
+ // Guard the single most destructive config edit: clearing the entire
+ // "Enabled Toolsets" list silently disables memory, terminal, web search,
+ // delegation, and most tools, and a stray select-all + Backspace can do it.
+ // Auto-save is debounced with no undo, so confirm a non-empty → empty
+ // transition before applying it. Every other edit passes through untouched.
+ if (config && clearsEnabledToolsets(config, next) && !window.confirm(c.toolsetsWipeConfirm)) {
+ return
+ }
+
saveVersionRef.current += 1
setConfig(next)
setSaveVersion(saveVersionRef.current)
diff --git a/apps/desktop/src/app/settings/helpers.test.ts b/apps/desktop/src/app/settings/helpers.test.ts
index cd0a455b3cc..8e7a300038f 100644
--- a/apps/desktop/src/app/settings/helpers.test.ts
+++ b/apps/desktop/src/app/settings/helpers.test.ts
@@ -5,6 +5,7 @@ import type { HermesConfigRecord } from '@/types/hermes'
import { FIELD_DESCRIPTIONS, FIELD_LABELS, SECTIONS } from './constants'
import { defineFieldCopy, fieldCopyForSchemaKey, schemaKeyToFieldCopyKey } from './field-copy'
import {
+ clearsEnabledToolsets,
enumOptionsFor,
getNested,
isExternalMemoryProvider,
@@ -363,4 +364,44 @@ describe('settings helpers', () => {
expect(sectionFieldEntries({}, {}).get('memory') ?? []).toHaveLength(0)
})
})
+
+ describe('clearsEnabledToolsets', () => {
+ it('flags a non-empty → empty transition', () => {
+ const prev: HermesConfigRecord = { toolsets: ['memory', 'terminal', 'web_search'] }
+ const next: HermesConfigRecord = { toolsets: [] }
+
+ expect(clearsEnabledToolsets(prev, next)).toBe(true)
+ })
+
+ it('does not flag a non-empty → missing transition (deep-merge preserves the key)', () => {
+ // PUT /api/config deep-merges the override onto the stored config, so an
+ // import that omits `toolsets` keeps the existing list — no wipe happens,
+ // so there is nothing to confirm.
+ const prev: HermesConfigRecord = { toolsets: ['memory'] }
+ const next: HermesConfigRecord = {}
+
+ expect(clearsEnabledToolsets(prev, next)).toBe(false)
+ })
+
+ it('does not flag when at least one toolset remains', () => {
+ const prev: HermesConfigRecord = { toolsets: ['memory', 'terminal'] }
+ const next: HermesConfigRecord = { toolsets: ['memory'] }
+
+ expect(clearsEnabledToolsets(prev, next)).toBe(false)
+ })
+
+ it('does not flag when the list was already empty', () => {
+ const prev: HermesConfigRecord = { toolsets: [] }
+ const next: HermesConfigRecord = { toolsets: [] }
+
+ expect(clearsEnabledToolsets(prev, next)).toBe(false)
+ })
+
+ it('does not flag an unrelated edit that never touched toolsets', () => {
+ const prev: HermesConfigRecord = { model: 'a', toolsets: ['memory'] }
+ const next: HermesConfigRecord = { model: 'b', toolsets: ['memory'] }
+
+ expect(clearsEnabledToolsets(prev, next)).toBe(false)
+ })
+ })
})
diff --git a/apps/desktop/src/app/settings/helpers.ts b/apps/desktop/src/app/settings/helpers.ts
index e3f0fe14e2a..8806e5e421b 100644
--- a/apps/desktop/src/app/settings/helpers.ts
+++ b/apps/desktop/src/app/settings/helpers.ts
@@ -97,6 +97,31 @@ export function getNested(obj: HermesConfigRecord, path: string): unknown {
return cur
}
+/**
+ * True when an edit clears the entire "Enabled Toolsets" list — i.e. the
+ * previous config had a non-empty toolsets array and the next one is an
+ * explicit empty array.
+ *
+ * A *missing* toolsets key is deliberately NOT a clear: `PUT /api/config`
+ * deep-merges the override onto the stored config (`_deep_merge` preserves base
+ * keys absent from the override), so an import that omits `toolsets` leaves the
+ * existing toolsets intact. Prompting there would warn about a wipe that never
+ * happens. Only an explicit `[]` actually empties the list.
+ *
+ * Clearing every toolset silently disables memory, terminal, web search,
+ * delegation, and most tools, and config auto-saves with no undo, so callers
+ * use this to confirm the destructive transition before applying it. Any edit
+ * that keeps at least one toolset — or that never had one — returns false.
+ */
+export function clearsEnabledToolsets(prev: HermesConfigRecord, next: HermesConfigRecord): boolean {
+ const prevToolsets = getNested(prev, 'toolsets')
+ const nextToolsets = getNested(next, 'toolsets')
+ const hadToolsets = Array.isArray(prevToolsets) && prevToolsets.length > 0
+ const clearsToolsets = Array.isArray(nextToolsets) && nextToolsets.length === 0
+
+ return hadToolsets && clearsToolsets
+}
+
export function inferFieldSchema(value: unknown): ConfigFieldSchema {
if (typeof value === 'boolean') {
return { type: 'boolean' }
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index dfe0374cc5f..1e836201ec6 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -584,6 +584,8 @@ export const en: Translations = {
autosaveFailed: 'Autosave failed',
imported: 'Config imported',
invalidJson: 'Invalid config JSON',
+ toolsetsWipeConfirm:
+ 'Remove all enabled toolsets? This disables memory, terminal, web search, delegation, and most other tools until you re-enable them.',
keepAwakeTitle: 'Keep computer awake',
keepAwakeDesc: 'Stop this machine from sleeping so long or overnight runs keep going. The display can still dim.',
attachmentSizeTitle: 'Max preview / image load size',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 68eab864c18..ce2066bedae 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -480,6 +480,7 @@ export interface Translations {
autosaveFailed: string
imported: string
invalidJson: string
+ toolsetsWipeConfirm: string
keepAwakeTitle: string
keepAwakeDesc: string
attachmentSizeTitle: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 2f720b190e2..b133f1c6b35 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -792,6 +792,7 @@ export const zh: Translations = {
autosaveFailed: '自动保存失败',
imported: '配置已导入',
invalidJson: '配置 JSON 无效',
+ toolsetsWipeConfirm: '确定移除所有已启用的工具集吗?这将禁用记忆、终端、网络搜索、委派以及大多数其他工具,直到你重新启用它们。',
keepAwakeTitle: '保持电脑唤醒',
keepAwakeDesc: '阻止本机休眠,让长时间或通宵运行继续进行。屏幕仍可变暗。',
attachmentSizeTitle: '预览 / 图片加载大小上限',