The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): read config helpers through the @/hermes barrel
kshitijk4poor0024eee068da
diff --git a/apps/desktop/src/app/hooks/use-config-record.test.tsx b/apps/desktop/src/app/hooks/use-config-record.test.tsxindex 95dea55b5d4..8bbac0e57fc 100644--- a/apps/desktop/src/app/hooks/use-config-record.test.tsx+++ b/apps/desktop/src/app/hooks/use-config-record.test.tsx@@ -3,13 +3,16 @@ import { cleanup, renderHook, waitFor } from '@testing-library/react'import { createElement } from 'react'import { afterEach, expect, it, vi } from 'vitest'-import { bindConfigReadOrigin } from '@/api/config'-import { getHermesConfigRecord } from '@/hermes'+import type * as HermesApi from '@/hermes'+import { bindConfigReadOrigin, getHermesConfigRecord } from '@/hermes'import { queryClient } from '@/lib/query-client'import { HERMES_CONFIG_KEY, useHermesConfigRecord } from './use-config-record'-vi.mock('@/hermes', () => ({ getHermesConfigRecord: vi.fn() }))+vi.mock('@/hermes', async importOriginal => ({+ ...(await importOriginal<typeof HermesApi>()),+ getHermesConfigRecord: vi.fn()+}))afterEach(() => {cleanup()diff --git a/apps/desktop/src/app/hooks/use-config-record.ts b/apps/desktop/src/app/hooks/use-config-record.tsindex 162a8e38d0a..514ecce0d87 100644--- a/apps/desktop/src/app/hooks/use-config-record.ts+++ b/apps/desktop/src/app/hooks/use-config-record.ts@@ -1,8 +1,7 @@import { useQuery } from '@tanstack/react-query'import { type ProfileScope, profileScopeKey } from '@/api/client'-import { peekConfigReadOrigin, retainConfigReadOrigin } from '@/api/config'-import { getHermesConfigRecord } from '@/hermes'+import { getHermesConfigRecord, peekConfigReadOrigin, retainConfigReadOrigin } from '@/hermes'import { queryClient } from '@/lib/query-client'import type { HermesConfigRecord } from '@/types/hermes'@@ -35,11 +34,7 @@ export const useHermesConfigRecord = (profile?: ProfileScope) => {// null/undefined both mean "no override" → fetch with undefined so// capabilityScoped falls back to the app-wide active profile (passing null// would wrongly target the primary backend).- queryFn: async () => {- const record = await getHermesConfigRecord(profile ?? undefined)-- return record- },+ queryFn: () => getHermesConfigRecord(profile ?? undefined),staleTime: 0,// The read origin is held in a WeakMap keyed by the record itself. Keep// the fetched object intact so the cached record and its origin cannotdiff --git a/apps/desktop/src/app/settings/config-settings.test.tsx b/apps/desktop/src/app/settings/config-settings.test.tsxindex 0efdd235960..b9371b49f81 100644--- a/apps/desktop/src/app/settings/config-settings.test.tsx+++ b/apps/desktop/src/app/settings/config-settings.test.tsx@@ -5,6 +5,8 @@ import { createRef } from 'react'import { MemoryRouter } from 'react-router'import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'+import type * as ConfigApi from '@/api/config'+import type { ConfigSettings as ConfigSettingsType } from './config-settings'const getHermesConfigRecord = vi.fn()@@ -12,7 +14,10 @@ const getHermesConfigSchema = vi.fn()const saveHermesConfig = vi.fn()const getElevenLabsVoices = vi.fn()-vi.mock('@/hermes', () => ({+// Keep the real read-origin helpers (WeakMap peek/bind) live: the shared+// config hook reaches them through the barrel, and a bare mock would throw.+vi.mock('@/hermes', async () => ({+ ...(await vi.importActual<typeof ConfigApi>('@/api/config')),getHermesConfigRecord: () => getHermesConfigRecord(),getHermesConfigSchema: () => getHermesConfigSchema(),saveHermesConfig: (config: unknown, profile?: string) => saveHermesConfig(config, profile),diff --git a/apps/desktop/src/app/settings/model-settings.test.tsx b/apps/desktop/src/app/settings/model-settings.test.tsxindex 47e0f8be5e0..e9c914d7f63 100644--- a/apps/desktop/src/app/settings/model-settings.test.tsx+++ b/apps/desktop/src/app/settings/model-settings.test.tsx@@ -3,6 +3,8 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-libraimport { MemoryRouter } from 'react-router'import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'+import type * as ConfigApi from '@/api/config'+// Radix Select calls scrollIntoView on its items when the content opens; jsdom// doesn't implement it (nor hasPointerCapture / releasePointerCapture), so stub// them to let the dropdown open in tests.@@ -27,7 +29,10 @@ const startManualOnboarding = vi.fn()const startManualProviderOAuth = vi.fn()let profileSwitchHandler: (() => void) | null = null-vi.mock('@/hermes', () => ({+// Keep the real read-origin helpers (WeakMap peek/bind) live: the shared+// config hook reaches them through the barrel, and a bare mock would throw.+vi.mock('@/hermes', async () => ({+ ...(await vi.importActual<typeof ConfigApi>('@/api/config')),getGlobalModelInfo: (profile?: null | string) => getGlobalModelInfo(profile),getGlobalModelOptions: (opts?: unknown, profile?: null | string) => getGlobalModelOptions(opts, profile),getAuxiliaryModels: (profile?: null | string) => getAuxiliaryModels(profile),