The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): pin models to the top of the model menu
SHL0MScc2306e33612
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex dbbf6f99046..21750ba1944 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -2940,6 +2940,7 @@ export const ar = defineLocale({editModels: 'تحرير النماذج',followDefault: 'استخدام الافتراضي من الإعدادات',refreshModels: 'تحديث النماذج',+ pinned: 'المثبتة',fast: 'سريع',free: 'مجاني',cacheRead: 'قراءة من الذاكرة المؤقتة',@@ -2951,6 +2952,9 @@ export const ar = defineLocale({options: 'الخيارات',thinking: 'التفكير',fast: 'سريع',+ pin: 'تثبيت',+ unpin: 'إلغاء التثبيت',+ shiftClickHint: 'انقر مع Shift على نموذج لتثبيته',effort: 'الجهد',minimal: 'أدنى',low: 'منخفض',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 30abb1805e0..bbe73ce47ae 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -5044,6 +5044,7 @@ export const deOverrides = {editModels: 'Modelle bearbeiten…',followDefault: 'Standard aus den Einstellungen verwenden',refreshModels: 'Modelle aktualisieren',+ pinned: 'Angepinnt',fast: 'Schnell',free: 'kostenlos',cacheRead: 'Cache-Lesung',@@ -5055,6 +5056,9 @@ export const deOverrides = {options: 'Optionen',thinking: 'Denken',fast: 'Schnell',+ pin: 'Anpinnen',+ unpin: 'Lösen',+ shiftClickHint: 'Shift-Klick auf ein Modell zum Anpinnen',effort: 'Aufwand',minimal: 'Minimal',low: 'Niedrig',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 343ccbf9d3e..7bd00b4fbc9 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -4647,6 +4647,7 @@ export const en: Translations = {editModels: 'Edit models…',followDefault: 'Use Settings default',refreshModels: 'Refresh models',+ pinned: 'Pinned',fast: 'Fast',free: 'free',cacheRead: 'cached read',@@ -4658,6 +4659,9 @@ export const en: Translations = {options: 'Options',thinking: 'Thinking',fast: 'Fast',+ pin: 'Pin',+ unpin: 'Unpin',+ shiftClickHint: 'Shift-click a model to pin',effort: 'Effort',minimal: 'Minimal',low: 'Low',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 8192265ed5b..2733a65fef7 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -5036,6 +5036,7 @@ export const esOverrides = {editModels: 'Editar modelos…',followDefault: 'Usar el predeterminado de Ajustes',refreshModels: 'Actualizar modelos',+ pinned: 'Fijadas',fast: 'Rápido',free: 'gratis',cacheRead: 'lectura en caché',@@ -5047,6 +5048,9 @@ export const esOverrides = {options: 'Opciones',thinking: 'Razonamiento',fast: 'Rápido',+ pin: 'Fijar',+ unpin: 'Desfijar',+ shiftClickHint: 'Mayús-clic en un modelo para fijarlo',effort: 'Esfuerzo',minimal: 'Mínimo',low: 'Bajo',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex 9b36e260f95..0cca296e3c4 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -5058,6 +5058,7 @@ export const frOverrides = {editModels: 'Modifier les modèles…',followDefault: 'Utiliser le modèle par défaut des Réglages',refreshModels: 'Actualiser les modèles',+ pinned: 'Épinglées',fast: 'Rapide',free: 'gratuit',cacheRead: 'lecture en cache',@@ -5069,6 +5070,9 @@ export const frOverrides = {options: 'Options',thinking: 'Réflexion',fast: 'Rapide',+ pin: 'Épingler',+ unpin: 'Désépingler',+ shiftClickHint: "Shift-clic sur un modèle pour l'épingler",effort: 'Effort',minimal: 'Minimal',low: 'Faible',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 7482ae6c254..13cf95f1797 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -3389,6 +3389,7 @@ export const ja = defineLocale({editModels: 'モデルを編集…',followDefault: '設定のデフォルトを使用',refreshModels: 'モデルを更新',+ pinned: 'ピン留め',fast: '高速',free: '無料',cacheRead: 'キャッシュ読み取り',@@ -3400,6 +3401,9 @@ export const ja = defineLocale({options: 'オプション',thinking: '思考',fast: '高速',+ pin: 'ピン留め',+ unpin: 'ピン留めを解除',+ shiftClickHint: 'Shift クリックでモデルをピン留め',effort: '努力度',minimal: '最小',low: '低',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex f29eb46e54c..ca23bd47c5c 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -3616,6 +3616,7 @@ export const ru = defineLocale({editModels: 'Изменить модели…',followDefault: 'Использовать модель по умолчанию из настроек',refreshModels: 'Обновить модели',+ pinned: 'Закреплённые',fast: 'Быстрая',free: 'бесплатно',cacheRead: 'чтение из кэша',@@ -3627,6 +3628,9 @@ export const ru = defineLocale({options: 'Опции',thinking: 'Размышление',fast: 'Быстрая',+ pin: 'Закрепить',+ unpin: 'Открепить',+ shiftClickHint: 'Shift-клик по модели, чтобы закрепить',effort: 'Усилия',minimal: 'Минимально',low: 'Низкое',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 9e66e1b2698..406f6ed33c5 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -3899,6 +3899,7 @@ export interface Translations {editModels: stringfollowDefault: stringrefreshModels: string+ pinned: stringfast: stringfree: stringcacheRead: string@@ -3909,6 +3910,9 @@ export interface Translations {options: stringthinking: stringfast: string+ pin: string+ unpin: string+ shiftClickHint: stringeffort: stringminimal: stringlow: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex f471cd22737..75cafd88b6b 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -3570,6 +3570,7 @@ export const zhHant = defineLocale({editModels: '編輯模型…',followDefault: '使用設定中的預設模型',refreshModels: '重新整理模型',+ pinned: '已釘選',fast: '快速',free: '免費',cacheRead: '快取讀取',@@ -3581,6 +3582,9 @@ export const zhHant = defineLocale({options: '選項',thinking: '思考',fast: '快速',+ pin: '釘選',+ unpin: '取消釘選',+ shiftClickHint: 'Shift + 點擊模型以釘選',effort: '推理強度',minimal: '最小',low: '低',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex f12c03c5fc2..e6af324bf5b 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -4345,6 +4345,7 @@ export const zh = defineLocale({editModels: '编辑模型…',followDefault: '使用设置中的默认模型',refreshModels: '刷新模型',+ pinned: '已置顶',fast: '快速',free: '免费',cacheRead: '缓存读取',@@ -4356,6 +4357,9 @@ export const zh = defineLocale({options: '选项',thinking: '思考',fast: '快速',+ pin: '置顶',+ unpin: '取消置顶',+ shiftClickHint: 'Shift+ 单击模型以置顶',effort: '推理强度',minimal: '最小',low: '低',diff --git a/apps/desktop/src/store/pinned-models.test.ts b/apps/desktop/src/store/pinned-models.test.tsnew file mode 100644index 00000000000..ca0f67bff3a--- /dev/null+++ b/apps/desktop/src/store/pinned-models.test.ts@@ -0,0 +1,103 @@+import { afterEach, beforeEach, describe, expect, it } from 'vitest'++import {+ $pinnedModels,+ isModelPinned,+ pinnedModelKey,+ setPinnedModels,+ togglePinnedModel+} from './pinned-models'++const STORAGE_KEY = 'hermes.desktop.pinned-models'++beforeEach(() => {+ window.localStorage.clear()+ $pinnedModels.set([])+})++afterEach(() => {+ window.localStorage.clear()+})++// Pin order IS the display order — the catalog renders pins in this array's+// order, so "most recently pinned wins the top slot" would be a behaviour+// change, not a detail. Appending keeps a user's first pin where they put it.+describe('pinned models keep their pin order', () => {+ it('appends new pins after existing ones', () => {+ togglePinnedModel('nous', 'opus-5')+ togglePinnedModel('anthropic', 'claude-sonnet-5')++ expect($pinnedModels.get()).toEqual([+ pinnedModelKey('nous', 'opus-5'),+ pinnedModelKey('anthropic', 'claude-sonnet-5')+ ])+ })++ it('unpinning leaves the remaining order intact', () => {+ togglePinnedModel('nous', 'opus-5')+ togglePinnedModel('anthropic', 'claude-sonnet-5')+ togglePinnedModel('google', 'gemini-3.1-pro')++ togglePinnedModel('anthropic', 'claude-sonnet-5')++ expect($pinnedModels.get()).toEqual([+ pinnedModelKey('nous', 'opus-5'),+ pinnedModelKey('google', 'gemini-3.1-pro')+ ])+ })++ it('re-pinning an unpinned model puts it at the end, not back in its old slot', () => {+ togglePinnedModel('nous', 'opus-5')+ togglePinnedModel('google', 'gemini-3.1-pro')++ togglePinnedModel('nous', 'opus-5')+ togglePinnedModel('nous', 'opus-5')++ expect($pinnedModels.get()).toEqual([+ pinnedModelKey('google', 'gemini-3.1-pro'),+ pinnedModelKey('nous', 'opus-5')+ ])+ })+})++// A pin is a durable preference: it has to survive the window closing, so the+// store must reach localStorage rather than only the atom.+describe('pins persist', () => {+ it('writes the pin list to storage', () => {+ togglePinnedModel('nous', 'opus-5')++ expect(JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? '[]')).toEqual([+ pinnedModelKey('nous', 'opus-5')+ ])+ })++ it('clears the key once the last pin is removed', () => {+ togglePinnedModel('nous', 'opus-5')+ togglePinnedModel('nous', 'opus-5')++ expect(window.localStorage.getItem(STORAGE_KEY)).toBeNull()+ })+})++// Models from different providers can share an id (an aggregator and the lab+// both serve `claude-opus-5`); pinning one must not pin the other.+describe('pins are provider-scoped', () => {+ it('does not report a same-named model on another provider as pinned', () => {+ togglePinnedModel('nous', 'claude-opus-5')++ expect(isModelPinned('nous', 'claude-opus-5')).toBe(true)+ expect(isModelPinned('openrouter', 'claude-opus-5')).toBe(false)+ })+})++// The whole list can be staged in one write (tests, a future settings UI);+// it must not grow a duplicate entry for one model.+describe('the pin list dedupes on replace', () => {+ it('collapses duplicate keys', () => {+ const key = pinnedModelKey('google', 'gemini-3.1-pro')++ setPinnedModels([key, key])++ expect($pinnedModels.get()).toEqual([key])+ })+})diff --git a/apps/desktop/src/store/pinned-models.ts b/apps/desktop/src/store/pinned-models.tsnew file mode 100644index 00000000000..1fdbfe60f1b--- /dev/null+++ b/apps/desktop/src/store/pinned-models.ts@@ -0,0 +1,42 @@+import { atom } from 'nanostores'++import { persistStringArray, storedStringArray } from '@/lib/storage'++import { modelVisibilityKey } from './model-visibility'++const STORAGE_KEY = 'hermes.desktop.pinned-models'++/** Stable `provider::model` key for a pin. Reuses the visibility-store format+ * so every model identity in the app is written the same way. */+export const pinnedModelKey = modelVisibilityKey++/**+ * Models the user pinned to the top of the model catalog menu, ordered by pin+ * time (first pinned = first shown). A renderer-local presentation preference+ * in the same family as the Edit Models shortlist and model presets: pins only+ * reshape THIS dropdown's ordering, never the backend catalog or another+ * surface's picker. A key whose model the current catalog no longer carries is+ * kept, not dropped, so it returns when its provider does.+ */+export const $pinnedModels = atom<string[]>(storedStringArray(STORAGE_KEY))++/** Whether a provider/model pair is currently pinned. */+export function isModelPinned(provider: string, model: string): boolean {+ return $pinnedModels.get().includes(pinnedModelKey(provider, model))+}++/** Replace the whole pin list. Deduped, and an empty list clears the key. */+export function setPinnedModels(keys: readonly string[]): void {+ const next = [...new Set(keys)]++ $pinnedModels.set(next)+ persistStringArray(STORAGE_KEY, next)+}++/** Pin a provider/model pair (appended to the order) or unpin it. */+export function togglePinnedModel(provider: string, model: string): void {+ const key = pinnedModelKey(provider, model)+ const current = $pinnedModels.get()++ setPinnedModels(current.includes(key) ? current.filter(entry => entry !== key) : [...current, key])+}