The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): one config speed-tier parse for the composer and Settings
kshitijk4poorcf8f9a803f19
diff --git a/apps/desktop/src/app/session/hooks/use-hermes-config.ts b/apps/desktop/src/app/session/hooks/use-hermes-config.tsindex 824dce123e8..6ecc132aa8f 100644--- a/apps/desktop/src/app/session/hooks/use-hermes-config.ts+++ b/apps/desktop/src/app/session/hooks/use-hermes-config.ts@@ -3,6 +3,7 @@ import { type MutableRefObject, useCallback, useRef, useState } from 'react'import { setTerminalFontFamilyFromConfig } from '@/app/right-sidebar/terminal/terminal-font'import { getHermesConfig, getHermesConfigDefaults } from '@/hermes'import { BUILTIN_PERSONALITIES, normalizePersonalityValue, personalityNamesFromConfig } from '@/lib/chat-runtime'+import { composerServiceTier } from '@/lib/model-status-label'import { normalize } from '@/lib/text'import { setDisplayTimestampsFromConfig } from '@/store/display-timestamps'import { setShowReasoningFromConfig } from '@/store/reasoning-disclosure'@@ -30,18 +31,6 @@ import {import { setChatFontFamilyFromConfig } from '@/themes/chat-font'const DEFAULT_VOICE_SECONDS = 120-const FAST_TIERS = new Set(['fast', 'priority', 'on'])--/** `agent.service_tier` is whatever the user wrote (`flex`, `scale`, `auto`, …);- * the composer only speaks the three exact tiers `session.create` accepts.- * Unset stays unset (the profile default rides). */-function composerServiceTier(value: unknown): string {- const tier = String(value ?? '')- .trim()- .toLowerCase()-- return !tier ? '' : tier === 'ultrafast' ? 'ultrafast' : FAST_TIERS.has(tier) ? 'priority' : 'normal'-}function recordingLimit(value: unknown) {return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : DEFAULT_VOICE_SECONDSdiff --git a/apps/desktop/src/app/settings/model-settings.tsx b/apps/desktop/src/app/settings/model-settings.tsxindex 35fb6221f6d..c0ae7bf5138 100644--- a/apps/desktop/src/app/settings/model-settings.tsx+++ b/apps/desktop/src/app/settings/model-settings.tsx@@ -31,6 +31,7 @@ import { isCodeSkewRestartRequired } from '@/lib/code-skew-error'import { AlertTriangle, Cpu, Loader2 } from '@/lib/icons'import { isSubmitEnter } from '@/lib/ime'import { findCatalogProvider } from '@/lib/model-options'+import { composerServiceTier } from '@/lib/model-status-label'import { cn } from '@/lib/utils'import { $customModels, withCustomModels } from '@/store/custom-models'import { setMainModelAssignment } from '@/store/model-assignment'@@ -86,14 +87,6 @@ export function ModelSettingsSkeleton({ subpage }: Pick<ModelSettingsProps, 'subtype SpeedTier = 'fast' | 'normal' | 'ultrafast'-// Priority aliases and Ultrafast are distinct choices in the profile default.-const isFastTier = (tier: unknown): boolean =>- ['fast', 'priority', 'on'].includes(- String(tier ?? '')- .trim()- .toLowerCase()- )-// A provider row is "ready" to pick a model from when it reports models. The// backend now surfaces the full `hermes model` universe (every canonical// provider), so unconfigured providers come back with `authenticated:false`@@ -636,19 +629,11 @@ export function ModelSettings({ onMainModelChanged, scopeProfile, subpage }: Modconst effortValue = rawEffort === 'false' || rawEffort === 'disabled' ? 'none' : rawEffort || DEFAULT_REASONING_EFFORT- const rawTier = getNested(config ?? {}, 'agent.service_tier')- const fastOn = isFastTier(rawTier)-// One profile-default speed: Standard, Fast (Priority) or Ultrafast. Ultrafast// only shows as a choice on models that offer it.- const speedValue: SpeedTier =- String(rawTier ?? '')- .trim()- .toLowerCase() === 'ultrafast'- ? 'ultrafast'- : fastOn- ? 'fast'- : 'normal'+ const tier = composerServiceTier(getNested(config ?? {}, 'agent.service_tier'))+ const fastOn = tier === 'priority'+ const speedValue: SpeedTier = fastOn ? 'fast' : tier === 'ultrafast' ? 'ultrafast' : 'normal'// Persist a single agent.* default as a sparse patch (PUT /api/config// deep-merges onto disk). Never send the whole cached record: it is adiff --git a/apps/desktop/src/lib/model-status-label.ts b/apps/desktop/src/lib/model-status-label.tsindex fafe1d9d678..14b4fea2b53 100644--- a/apps/desktop/src/lib/model-status-label.ts+++ b/apps/desktop/src/lib/model-status-label.ts@@ -238,3 +238,16 @@ export function formatModelPillLabel(model: string, options?: { fastMode?: boolereturn tag ? `${name} · ${tag}` : name}++const FAST_TIERS = new Set(['fast', 'priority', 'on'])++/** `agent.service_tier` is whatever the user wrote (`flex`, `scale`, `auto`, …);+ * the composer only speaks the three exact tiers `session.create` accepts.+ * Unset stays unset (the profile default rides). */+export function composerServiceTier(value: unknown): string {+ const tier = String(value ?? '')+ .trim()+ .toLowerCase()++ return !tier ? '' : tier === 'ultrafast' ? 'ultrafast' : FAST_TIERS.has(tier) ? 'priority' : 'normal'+}