Skip to content

The agent that grows with you

fix(desktop): add model visibility recovery action

Brooklyn Nicholson71cb7d60f846
diff --git a/apps/desktop/src/components/model-visibility-dialog.test.tsx b/apps/desktop/src/components/model-visibility-dialog.test.tsx
new file mode 100644
index 00000000000..4ba942d71b1
--- /dev/null
+++ b/apps/desktop/src/components/model-visibility-dialog.test.tsx
@@ -0,0 +1,143 @@
+import type { ModelOptionsResult } from '@hermes/shared'
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import { ConfirmHost } from '@/components/confirm-host'
+import { I18nProvider } from '@/i18n'
+import { $confirmRequest } from '@/store/confirm'
+import { $customModels } from '@/store/custom-models'
+import { $knownModels, $visibleModels, modelVisibilityKey, setVisibleModels } from '@/store/model-visibility'
+import { stubResizeObserver } from '@/test/jsdom'
+
+import { ModelVisibilityDialog } from './model-visibility-dialog'
+
+vi.mock('@/lib/model-options', async importOriginal => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ requestModelOptions: vi.fn()
+}))
+
+import { requestModelOptions } from '@/lib/model-options'
+
+stubResizeObserver()
+
+const OPTIONS: ModelOptionsResult = {
+ providers: [
+ { authenticated: true, models: ['gpt-5.5', 'gpt-6'], name: 'OpenAI Codex', slug: 'openai-codex' },
+ { authenticated: true, models: ['qwen3-coder'], name: 'Qwen', slug: 'qwen' }
+ ]
+}
+
+function renderDialog() {
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
+
+ return render(
+ <QueryClientProvider client={client}>
+ <I18nProvider>
+ <ModelVisibilityDialog onOpenChange={() => {}} onOpenProviders={() => {}} open />
+ <ConfirmHost />
+ </I18nProvider>
+ </QueryClientProvider>
+ )
+}
+
+const isShown = async (label: RegExp) =>
+ (await screen.findByRole('switch', { name: label })).getAttribute('aria-checked') === 'true'
+
+beforeEach(() => {
+ window.localStorage.clear()
+ $customModels.set([])
+ $visibleModels.set(null)
+ $knownModels.set(null)
+ vi.mocked(requestModelOptions).mockResolvedValue(OPTIONS)
+})
+
+afterEach(() => {
+ cleanup()
+ $confirmRequest.set(null)
+ vi.clearAllMocks()
+})
+
+describe('Edit Models reset', () => {
+ it('restores the default shortlist when a model is stuck hidden by the known snapshot', async () => {
+ // A curation saved while the snapshot machinery was live: gpt-6 was listed
+ // when the user kept gpt-5.5 and switched it off, so the snapshot counts it
+ // as judged and the default rule never re-admits it — the dialog shows it
+ // switched off with no per-model way back that survives a catalog change.
+ setVisibleModels(new Set([modelVisibilityKey('openai-codex', 'gpt-5.5')]), OPTIONS.providers!)
+
+ renderDialog()
+
+ expect(await isShown(/gpt-6/i)).toBe(false)
+
+ fireEvent.click(screen.getByRole('button', { name: /reset to defaults/i }))
+ fireEvent.click(await screen.findByRole('button', { name: /^reset$/i }))
+
+ await waitFor(async () => expect(await isShown(/gpt-6/i)).toBe(true))
+ expect(await isShown(/gpt-5\.5/i)).toBe(true)
+ expect(window.localStorage.getItem('hermes.desktop.visible-models')).toBeNull()
+ expect(window.localStorage.getItem('hermes.desktop.known-models')).toBeNull()
+ })
+
+ it('keeps the user’s choices when the reset is cancelled', async () => {
+ setVisibleModels(new Set([modelVisibilityKey('openai-codex', 'gpt-5.5')]), OPTIONS.providers!)
+
+ renderDialog()
+ await isShown(/gpt-6/i)
+
+ fireEvent.click(screen.getByRole('button', { name: /reset to defaults/i }))
+ fireEvent.click(await screen.findByRole('button', { name: /cancel/i }))
+
+ await waitFor(() => expect($confirmRequest.get()).toBeNull())
+ expect(await isShown(/gpt-6/i)).toBe(false)
+ })
+
+ it('keeps a custom model stored and switched on where the defaults would hide it', async () => {
+ // An aggregator row defaults to its featured shortlist; the typed id is
+ // appended after the catalog, so the bare default rule would hide it.
+ vi.mocked(requestModelOptions).mockResolvedValue({
+ providers: [
+ {
+ authenticated: true,
+ featured_models: ['openai/gpt-6'],
+ models: ['openai/gpt-5', 'openai/gpt-6', 'anthropic/claude-x'],
+ name: 'OpenRouter',
+ slug: 'openrouter'
+ }
+ ]
+ })
+ $customModels.set([{ model: 'acme/model-x', provider: 'openrouter' }])
+ $visibleModels.set(new Set([modelVisibilityKey('openrouter', 'acme/model-x')]))
+
+ renderDialog()
+
+ expect(await isShown(/gpt-6/i)).toBe(false)
+
+ fireEvent.click(screen.getByRole('button', { name: /reset to defaults/i }))
+ fireEvent.click(await screen.findByRole('button', { name: /^reset$/i }))
+
+ await waitFor(async () => expect(await isShown(/gpt-6/i)).toBe(true))
+ // The custom row's <label> also wraps its remove button, so its switch has
+ // no accessible name of its own; find it through the row instead.
+ const customRow = screen.getByText('Model X').closest('label')!
+ expect(within(customRow).getByRole('switch').getAttribute('aria-checked')).toBe('true')
+ expect(screen.getByRole('button', { name: /remove custom model/i })).toBeTruthy()
+ expect($customModels.get()).toEqual([{ model: 'acme/model-x', provider: 'openrouter' }])
+ })
+
+ it('offers no reset while the list is still the default', async () => {
+ renderDialog()
+
+ expect(await isShown(/gpt-6/i)).toBe(true)
+ expect(screen.queryByRole('button', { name: /reset to defaults/i })).toBeNull()
+ })
+
+ it('does not offer reset before the provider catalog has loaded', () => {
+ $visibleModels.set(new Set([modelVisibilityKey('openai-codex', 'gpt-5.5')]))
+ vi.mocked(requestModelOptions).mockReturnValue(new Promise(() => {}))
+
+ renderDialog()
+
+ expect(screen.queryByRole('button', { name: /reset to defaults/i })).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/components/model-visibility-dialog.tsx b/apps/desktop/src/components/model-visibility-dialog.tsx
index 0553b4a114d..d97f80ae061 100644
--- a/apps/desktop/src/components/model-visibility-dialog.tsx
+++ b/apps/desktop/src/components/model-visibility-dialog.tsx
@@ -16,12 +16,14 @@ import { Plus, Search, X } from '@/lib/icons'
import { modelOptionsQueryKey, requestModelOptions } from '@/lib/model-options'
import { displayModelName, modelDisplayParts } from '@/lib/model-status-label'
import { foldIncludes, normalize } from '@/lib/text'
+import { confirm } from '@/store/confirm'
import {
$customModels,
addCustomModel,
customModelCandidate,
isCustomModel,
removeCustomModel,
+ resetModelVisibilityKeepingCustoms,
withCustomModels
} from '@/store/custom-models'
import {
@@ -89,6 +91,19 @@ export function ModelVisibilityDialog({
setVisibleModels(setProviderVisibility($visibleModels.get(), providers, provider.slug, next), providers)
}
+ const resetToDefaults = async () => {
+ const ok = await confirm({
+ confirmLabel: copy.resetAction,
+ description: copy.resetDescription,
+ destructive: true,
+ title: copy.resetConfirm
+ })
+
+ if (ok) {
+ resetModelVisibilityKeepingCustoms(providers)
+ }
+ }
+
const q = normalize(search)
const matches = (provider: ModelOptionProvider, model: string) =>
@@ -234,7 +249,7 @@ export function ModelVisibilityDialog({
)}
</div>
- <div className="px-3 py-2">
+ <div className="flex items-center justify-between px-3 py-2">
<Button
className="-ml-2 text-(--ui-text-tertiary)"
onClick={() => {
@@ -247,6 +262,18 @@ export function ModelVisibilityDialog({
>
{copy.addProvider}
</Button>
+ {/* Only once there is something to undo, like the sidebar view reset. */}
+ {stored !== null && modelOptions.isSuccess && (
+ <Button
+ className="-mr-2 text-(--ui-text-tertiary)"
+ onClick={() => void resetToDefaults()}
+ size="xs"
+ type="button"
+ variant="text"
+ >
+ {copy.resetToDefaults}
+ </Button>
+ )}
</div>
</DialogContent>
</Dialog>
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 96a9c3b2175..e5b54312ff7 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2875,7 +2875,11 @@ export const ar = defineLocale({
noAuthenticatedProviders: 'لا يوجد مزوّدون مصادق عليهم.',
addProvider: 'إضافة مزوّد…',
addCustomModel: 'إضافة نموذج مخصص',
- removeCustomModel: 'إزالة النموذج المخصص'
+ removeCustomModel: 'إزالة النموذج المخصص',
+ resetToDefaults: 'إعادة التعيين إلى الافتراضي',
+ resetConfirm: 'إعادة إعدادات ظهور النماذج إلى الافتراضي؟',
+ resetDescription: 'ستُمسح اختياراتك للنماذج الظاهرة والمخفية وتعود قائمة كل مزوّد الافتراضية. تُحفظ النماذج المخصصة التي أضفتها وتظهر.',
+ resetAction: 'إعادة التعيين'
},
shell: {
windowControls: 'تحكم النافذة',
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 307db9b3f2b..c12c8a7195b 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -4980,7 +4980,11 @@ export const deOverrides = {
noAuthenticatedProviders: 'Keine authentifizierten Anbieter.',
addProvider: 'Anbieter hinzufügen…',
addCustomModel: 'Eigenes Modell hinzufügen',
- removeCustomModel: 'Eigenes Modell entfernen'
+ removeCustomModel: 'Eigenes Modell entfernen',
+ resetToDefaults: 'Auf Standard zurücksetzen',
+ resetConfirm: 'Modellsichtbarkeit auf Standard zurücksetzen?',
+ resetDescription: 'Ihre Auswahl sichtbarer und ausgeblendeter Modelle wird gelöscht, und jeder Anbieter zeigt wieder seine Standardliste. Eigene Modelle bleiben erhalten und werden angezeigt.',
+ resetAction: 'Zurücksetzen'
},
shell: {
windowControls: 'Fenster-Bedienelemente',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index dd74deb158f..8094173077c 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -4583,7 +4583,11 @@ export const en: Translations = {
noAuthenticatedProviders: 'No authenticated providers.',
addProvider: 'Add provider…',
addCustomModel: 'Add custom model',
- removeCustomModel: 'Remove custom model'
+ removeCustomModel: 'Remove custom model',
+ resetToDefaults: 'Reset to defaults',
+ resetConfirm: 'Reset model visibility to defaults?',
+ resetDescription: 'Your shown and hidden model choices are cleared and every provider’s default list comes back. Custom models you added are kept and shown.',
+ resetAction: 'Reset'
},
shell: {
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 04e03529abb..789ea789aac 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -4970,7 +4970,11 @@ export const esOverrides = {
noAuthenticatedProviders: 'No hay proveedores autenticados.',
addProvider: 'Añadir proveedor…',
addCustomModel: 'Añadir modelo personalizado',
- removeCustomModel: 'Quitar modelo personalizado'
+ removeCustomModel: 'Quitar modelo personalizado',
+ resetToDefaults: 'Restablecer valores predeterminados',
+ resetConfirm: '¿Restablecer la visibilidad de los modelos?',
+ resetDescription: 'Se borran tus elecciones de modelos visibles y ocultos, y cada proveedor vuelve a su lista predeterminada. Los modelos personalizados que añadiste se conservan y se muestran.',
+ resetAction: 'Restablecer'
},
shell: {
windowControls: 'Controles de ventana',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index 4ab29df2a89..e8a4a87a66f 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -4992,7 +4992,11 @@ export const frOverrides = {
noAuthenticatedProviders: 'Aucun fournisseur authentifié.',
addProvider: 'Ajouter un fournisseur…',
addCustomModel: 'Ajouter un modèle personnalisé',
- removeCustomModel: 'Retirer le modèle personnalisé'
+ removeCustomModel: 'Retirer le modèle personnalisé',
+ resetToDefaults: 'Rétablir les valeurs par défaut',
+ resetConfirm: 'Rétablir la visibilité des modèles par défaut ?',
+ resetDescription: 'Vos choix de modèles affichés et masqués sont effacés et chaque fournisseur retrouve sa liste par défaut. Les modèles personnalisés ajoutés sont conservés et affichés.',
+ resetAction: 'Rétablir'
},
shell: {
windowControls: 'Contrôles de fenêtre',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index e4d49797e13..abe4ae06f4e 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -3322,7 +3322,11 @@ export const ja = defineLocale({
noAuthenticatedProviders: '認証済みプロバイダーがありません。',
addProvider: 'プロバイダーを追加…',
addCustomModel: 'カスタムモデルを追加',
- removeCustomModel: 'カスタムモデルを削除'
+ removeCustomModel: 'カスタムモデルを削除',
+ resetToDefaults: 'デフォルトに戻す',
+ resetConfirm: 'モデルの表示設定をデフォルトに戻しますか?',
+ resetDescription: '表示・非表示の選択が消去され、各プロバイダーのデフォルトの一覧に戻ります。追加したカスタムモデルは残り、表示されます。',
+ resetAction: 'リセット'
},
shell: {
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 7acf3103f4f..2b5c3f66801 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3552,7 +3552,11 @@ export const ru = defineLocale({
noAuthenticatedProviders: 'Нет провайдеров с аутентификацией.',
addProvider: 'Добавить провайдера…',
addCustomModel: 'Добавить свою модель',
- removeCustomModel: 'Удалить свою модель'
+ removeCustomModel: 'Удалить свою модель',
+ resetToDefaults: 'Сбросить к значениям по умолчанию',
+ resetConfirm: 'Сбросить видимость моделей по умолчанию?',
+ resetDescription: 'Ваш выбор показанных и скрытых моделей будет очищен, и у каждого провайдера вернётся список по умолчанию. Добавленные вами модели сохранятся и будут показаны.',
+ resetAction: 'Сбросить'
},
shell: {
windowControls: 'Управление окном',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index f3eea8dfa23..613ddab7580 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -3837,6 +3837,10 @@ export interface Translations {
addProvider: string
addCustomModel: string
removeCustomModel: string
+ resetToDefaults: string
+ resetConfirm: string
+ resetDescription: string
+ resetAction: string
}
shell: {
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index c2d580fe5ec..ead74e702fc 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -3508,7 +3508,11 @@ export const zhHant = defineLocale({
noAuthenticatedProviders: '沒有已驗證的提供方。',
addProvider: '新增提供方…',
addCustomModel: '新增自訂模型',
- removeCustomModel: '移除自訂模型'
+ removeCustomModel: '移除自訂模型',
+ resetToDefaults: '恢復預設',
+ resetConfirm: '將模型可見性恢復為預設?',
+ resetDescription: '你對模型顯示與隱藏的選擇將被清除,每個提供方都會恢復預設清單。你新增的自訂模型會保留並顯示。',
+ resetAction: '恢復'
},
shell: {
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 3d8d5762f05..86ba1746634 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -4284,7 +4284,11 @@ export const zh = defineLocale({
noAuthenticatedProviders: '没有已认证的提供方。',
addProvider: '添加提供方…',
addCustomModel: '添加自定义模型',
- removeCustomModel: '移除自定义模型'
+ removeCustomModel: '移除自定义模型',
+ resetToDefaults: '恢复默认',
+ resetConfirm: '将模型可见性恢复为默认?',
+ resetDescription: '你对模型显示与隐藏的选择将被清除,每个提供方都会恢复默认列表。你添加的自定义模型会保留并显示。',
+ resetAction: '恢复'
},
shell: {
diff --git a/apps/desktop/src/store/custom-models.test.ts b/apps/desktop/src/store/custom-models.test.ts
index 72d1be40063..e10c0575387 100644
--- a/apps/desktop/src/store/custom-models.test.ts
+++ b/apps/desktop/src/store/custom-models.test.ts
@@ -1,7 +1,21 @@
import type { ModelOptionProvider } from '@hermes/shared'
-import { describe, expect, it } from 'vitest'
+import { beforeEach, describe, expect, it } from 'vitest'
-import { customModelCandidate, withCustomModels } from './custom-models'
+import {
+ $customModels,
+ addCustomModel,
+ customModelCandidate,
+ resetModelVisibilityKeepingCustoms,
+ withCustomModels
+} from './custom-models'
+import {
+ $knownModels,
+ $visibleModels,
+ defaultVisibleKeys,
+ effectiveVisibleKeys,
+ modelVisibilityKey,
+ setVisibleModels
+} from './model-visibility'
const provider = (slug: string, models: string[]): ModelOptionProvider => ({
models,
@@ -34,3 +48,60 @@ describe('custom models', () => {
expect(withCustomModels(providers, [])).toBe(providers)
})
})
+
+describe('resetModelVisibilityKeepingCustoms', () => {
+ beforeEach(() => {
+ window.localStorage.clear()
+ $customModels.set([])
+ $visibleModels.set(null)
+ $knownModels.set(null)
+ })
+
+ // An aggregator row: defaults are its featured shortlist, which a typed id
+ // (appended after the catalog) is never part of.
+ const openrouter = (): ModelOptionProvider => ({
+ ...provider('openrouter', ['openai/gpt-5', 'openai/gpt-6', 'anthropic/claude-x']),
+ featured_models: ['openai/gpt-6', 'anthropic/claude-x']
+ })
+
+ const qwen = provider('qwen', ['qwen3-coder'])
+
+ it('clears the stale snapshot but keeps a custom model stored and shown', () => {
+ const catalog = withCustomModels([openrouter(), qwen], $customModels.get())
+
+ addCustomModel('openrouter', 'acme/model-x', openrouter())
+ // A curation saved while the snapshot machinery was live: gpt-6 was listed
+ // (a featured default) but left hidden, so the snapshot counts it as judged
+ // and the default rule never re-admits it.
+ setVisibleModels(new Set([modelVisibilityKey('openrouter', 'acme/model-x')]), catalog)
+ expect(effectiveVisibleKeys($visibleModels.get(), catalog).has(modelVisibilityKey('openrouter', 'openai/gpt-6'))).toBe(
+ false
+ )
+
+ resetModelVisibilityKeepingCustoms(catalog)
+
+ const visible = effectiveVisibleKeys($visibleModels.get(), catalog)
+
+ expect($customModels.get()).toEqual([{ model: 'acme/model-x', provider: 'openrouter' }])
+ expect(window.localStorage.getItem('hermes.desktop.custom-models')).toContain('acme/model-x')
+ expect(visible.has(modelVisibilityKey('openrouter', 'acme/model-x'))).toBe(true)
+
+ for (const key of defaultVisibleKeys(catalog)) {
+ expect(visible.has(key)).toBe(true)
+ }
+
+ // A provider with no custom model is not re-curated: it tracks live defaults.
+ expect([...($visibleModels.get() ?? [])].some(key => key.startsWith('qwen::'))).toBe(false)
+ })
+
+ it('returns to the uncustomized state when every custom model is already a default', () => {
+ addCustomModel('qwen', 'qwen-next', qwen)
+ const catalog = withCustomModels([openrouter(), qwen], $customModels.get())
+
+ resetModelVisibilityKeepingCustoms(catalog)
+
+ expect($visibleModels.get()).toBeNull()
+ expect($knownModels.get()).toBeNull()
+ expect(effectiveVisibleKeys(null, catalog).has(modelVisibilityKey('qwen', 'qwen-next'))).toBe(true)
+ })
+})
diff --git a/apps/desktop/src/store/custom-models.ts b/apps/desktop/src/store/custom-models.ts
index 502ea7625c8..d7b494a6a48 100644
--- a/apps/desktop/src/store/custom-models.ts
+++ b/apps/desktop/src/store/custom-models.ts
@@ -6,8 +6,10 @@ import { normalize } from '@/lib/text'
import {
$visibleModels,
+ defaultVisibleKeys,
emptyProviderSentinelKey,
modelVisibilityKey,
+ resetModelVisibility,
resolveVisibleKeys,
setVisibleModels
} from './model-visibility'
@@ -147,6 +149,24 @@ export function addCustomModel(provider: string, model: string, row?: ModelOptio
setVisibleModels(next, merged)
}
+/** Edit Models' "Reset to defaults". A custom id sits after the catalog, so on
+ * a featured-shortlist row or past the top-N the bare default rule would bring
+ * it back hidden. Only a provider holding such an id is curated again, the way
+ * adding the id curated it; every other provider returns to the live defaults. */
+export function resetModelVisibilityKeepingCustoms(providers: readonly ModelOptionProvider[]): void {
+ resetModelVisibility()
+
+ const defaults = defaultVisibleKeys(providers)
+
+ for (const { model, provider } of $customModels.get()) {
+ const row = providers.find(candidate => candidate.slug === provider)
+
+ if (row && !defaults.has(modelVisibilityKey(provider, model))) {
+ addCustomModel(provider, model, row)
+ }
+ }
+}
+
export function removeCustomModel(provider: string, model: string): void {
const customs = $customModels.get()
diff --git a/apps/desktop/src/store/model-visibility.test.ts b/apps/desktop/src/store/model-visibility.test.ts
index e3d9aaac662..cdff70f6384 100644
--- a/apps/desktop/src/store/model-visibility.test.ts
+++ b/apps/desktop/src/store/model-visibility.test.ts
@@ -419,3 +419,68 @@ describe('setProviderVisibility', () => {
expect(next.has(modelVisibilityKey('nous', 'model-fast'))).toBe(false)
})
})
+
+describe('resetModelVisibility', () => {
+ // Fresh module per load: the atoms read localStorage at import, so a
+ // re-import is a renderer reload.
+ const loadStore = () => import('./model-visibility')
+
+ const catalog = [provider('openai-codex', ['gpt-5.5', 'gpt-6']), provider('qwen', ['qwen3-coder'])]
+ const gpt6 = modelVisibilityKey('openai-codex', 'gpt-6')
+
+ beforeEach(() => {
+ window.localStorage.clear()
+ vi.resetModules()
+ })
+
+ it('brings back a model the known snapshot froze hidden, and the reset survives a reload', async () => {
+ // A curation saved while the snapshot machinery was live: gpt-6 was listed
+ // when the user kept gpt-5.5 and switched it off, so the snapshot counts it
+ // as judged and the default rule never re-admits it.
+ window.localStorage.setItem('hermes.desktop.visible-models', JSON.stringify(['openai-codex::gpt-5.5']))
+ window.localStorage.setItem(
+ 'hermes.desktop.known-models',
+ JSON.stringify(['openai-codex::gpt-5.5', 'openai-codex::gpt-6', 'qwen::qwen3-coder'])
+ )
+
+ const stuck = await loadStore()
+
+ const before = stuck.effectiveVisibleKeys(stuck.$visibleModels.get(), catalog)
+ expect(before.has(gpt6)).toBe(false)
+ expect(before.has(modelVisibilityKey('qwen', 'qwen3-coder'))).toBe(true)
+
+ stuck.resetModelVisibility()
+
+ expect(stuck.effectiveVisibleKeys(stuck.$visibleModels.get(), catalog)).toEqual(stuck.defaultVisibleKeys(catalog))
+
+ vi.resetModules()
+ const reloaded = await loadStore()
+ reloaded.seedKnownModels(catalog)
+
+ expect(reloaded.effectiveVisibleKeys(reloaded.$visibleModels.get(), catalog)).toEqual(
+ reloaded.defaultVisibleKeys(catalog)
+ )
+ })
+
+ it('forgets what the old snapshot counted as judged, so later arrivals are new again', async () => {
+ // gpt-6-mini was listed (and left hidden) before the reset, then dropped
+ // out of the catalog.
+ const store = await loadStore()
+ store.setVisibleModels(new Set(['openai-codex::gpt-5.5']), [provider('openai-codex', ['gpt-5.5', 'gpt-6-mini'])])
+
+ store.resetModelVisibility()
+
+ // Curate again without it, then it comes back: the user never judged it
+ // since the reset, so it lands visible through the default rule.
+ store.setVisibleModels(
+ store.toggleModelVisibility(store.$visibleModels.get(), catalog, 'openai-codex', 'gpt-5.5'),
+ catalog
+ )
+
+ const returned = [provider('openai-codex', ['gpt-5.5', 'gpt-6', 'gpt-6-mini']), catalog[1]]
+ const visible = store.effectiveVisibleKeys(store.$visibleModels.get(), returned)
+
+ expect(visible.has(modelVisibilityKey('openai-codex', 'gpt-6-mini'))).toBe(true)
+ expect(visible.has(modelVisibilityKey('openai-codex', 'gpt-5.5'))).toBe(false)
+ })
+})
diff --git a/apps/desktop/src/store/model-visibility.ts b/apps/desktop/src/store/model-visibility.ts
index 2ca7d3ce79c..f1de3997852 100644
--- a/apps/desktop/src/store/model-visibility.ts
+++ b/apps/desktop/src/store/model-visibility.ts
@@ -172,6 +172,19 @@ export function seedKnownModels(providers: readonly ModelOptionProvider[]): void
persistKnownModels(known)
}
+/** Back to "never customized": the curated defaults apply again and the known
+ * snapshot starts over. The snapshot records what was LISTED at each persist,
+ * not what the user chose, so a model hidden when it was recorded (e.g. by the
+ * one-time adoption above) stays hidden through every later catalog change.
+ * This is the user's way out of that without a global storage-key bump; Edit
+ * Models reaches it through `resetModelVisibilityKeepingCustoms`. */
+export function resetModelVisibility(): void {
+ $visibleModels.set(null)
+ persistString(STORAGE_KEY, null)
+ $knownModels.set(null)
+ persistString(KNOWN_STORAGE_KEY, null)
+}
+
export function setModelVisibilityOpen(open: boolean): void {
$modelVisibilityOpen.set(open)
}