The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): retain config routes for font and reset
KoNit-Kf63c7c803ddc
diff --git a/apps/desktop/src/api/config-route-binding.test.ts b/apps/desktop/src/api/config-route-binding.test.tsindex 6366ad7ac98..96aa44ec72d 100644--- a/apps/desktop/src/api/config-route-binding.test.ts+++ b/apps/desktop/src/api/config-route-binding.test.ts@@ -1,6 +1,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import {+ getHermesConfigDefaults,getHermesConfigRecord,peekConfigReadOrigin,resolveConfigWriteScope,@@ -86,4 +87,27 @@ describe('config read/write route binding', () => {profile: 'coder'})})++ it('treats a null read scope as absent and preserves the active profile', async () => {+ setApiRequestConnection('connection-a')+ setApiRequestProfile('worker')++ const record = await getHermesConfigRecord(null)++ expect(peekConfigReadOrigin(record)).toEqual({ connectionId: 'connection-a', profile: 'worker' })+ })++ it('writes reset defaults back through the route that fetched them', async () => {+ setApiRequestConnection('connection-a')+ setApiRequestProfile('default')++ const defaults = await getHermesConfigDefaults()+ setApiRequestConnection('connection-b')++ await saveHermesConfig(defaults)++ expect(api.mock.calls.find(call => call[0].method === 'PUT')?.[0]).toEqual(+ expect.objectContaining({ connectionId: 'connection-a', profile: 'default' })+ )+ })})diff --git a/apps/desktop/src/api/config.ts b/apps/desktop/src/api/config.tsindex ba90ec4a9ad..c04beea0cfd 100644--- a/apps/desktop/src/api/config.ts+++ b/apps/desktop/src/api/config.ts@@ -131,12 +131,20 @@ export async function getHermesConfigRecord(return record}-export function getHermesConfigDefaults(): Promise<HermesConfigRecord> {- return hermesApi<HermesConfigRecord>({- ...profileScoped(),+export async function getHermesConfigDefaults(profile?: ProfileScope): Promise<HermesConfigRecord> {+ const origin = capabilityScoped(profile ?? undefined)++ const record = await window.hermesDesktop.api<HermesConfigRecord>({+ ...origin,path: '/api/config/defaults',timeoutMs: STARTUP_REQUEST_TIMEOUT_MS})++ if (record && typeof record === 'object') {+ bindConfigReadOrigin(record, origin)+ }++ return record}export function getHermesConfigSchema(profile?: null | string): Promise<ConfigSchemaResponse> {diff --git a/apps/desktop/src/app/settings/chat-font-setting.test.tsx b/apps/desktop/src/app/settings/chat-font-setting.test.tsxindex e8c0d3cfd45..d7464e5b098 100644--- a/apps/desktop/src/app/settings/chat-font-setting.test.tsx+++ b/apps/desktop/src/app/settings/chat-font-setting.test.tsx@@ -12,11 +12,12 @@ const mocks = vi.hoisted(() => ({loadedConfig: {} as Record<string, unknown>,notifyError: vi.fn(),profileSwitch: null as null | (() => void),- save: vi.fn()+ save: vi.fn(),+ writeScope: { connectionId: 'connection-a', profile: 'default' }}))vi.mock('@/hermes', () => ({- saveHermesConfig: (config: Record<string, unknown>) => mocks.save(config)+ saveHermesConfig: (config: Record<string, unknown>, scope?: unknown) => mocks.save(config, scope)}))vi.mock('@/i18n', () => ({@@ -43,7 +44,7 @@ vi.mock('@/store/notifications', () => ({vi.mock('../hooks/use-config-record', () => ({setHermesConfigCache: (config: Record<string, unknown>) => mocks.cache(config),- useHermesConfigRecord: () => ({ data: mocks.loadedConfig, dataUpdatedAt: mocks.configUpdatedAt })+ useHermesConfigRecord: () => ({ data: mocks.loadedConfig, dataUpdatedAt: mocks.configUpdatedAt, writeScope: mocks.writeScope })}))vi.mock('../hooks/use-on-profile-switch', () => ({@@ -84,7 +85,10 @@ describe('ChatFontSetting', () => {await flushAutosave()- expect(mocks.save).toHaveBeenCalledWith({ desktop: { font_family: 'OpenDyslexic' } })+ expect(mocks.save).toHaveBeenCalledWith(+ { desktop: { font_family: 'OpenDyslexic' } },+ { connectionId: 'connection-a', profile: 'default' }+ )expect(mocks.cache).toHaveBeenCalledWith({ desktop: { font_family: 'OpenDyslexic', repo_scan_enabled: true } })})diff --git a/apps/desktop/src/app/settings/chat-font-setting.tsx b/apps/desktop/src/app/settings/chat-font-setting.tsxindex 54ea38331f1..c71a6c393c7 100644--- a/apps/desktop/src/app/settings/chat-font-setting.tsx+++ b/apps/desktop/src/app/settings/chat-font-setting.tsx@@ -30,7 +30,7 @@ function fontFamilyFromConfig(config: HermesConfigRecord): string {export function ChatFontSetting() {const { t } = useI18n()const copy = t.settings.appearance- const { data: loadedConfig, dataUpdatedAt } = useHermesConfigRecord()+ const { data: loadedConfig, dataUpdatedAt, writeScope } = useHermesConfigRecord()const [draft, setDraft] = useState<string | null>(null)// The seed effect refuses to reseed while the query still carries the// previous profile's stamp. A structurally-shared refetch keeps the object@@ -80,7 +80,7 @@ export function ChatFontSetting() {// Sparse patch: PUT /api/config deep-merges; echoing the cached snapshot// would overwrite keys other surfaces changed since it loaded.- void saveHermesConfig(setNested({}, CONFIG_PATH, value))+ void saveHermesConfig(setNested({}, CONFIG_PATH, value), writeScope).then(result => {if (!result.ok) {throw new Error(t.settings.config.autosaveFailed)@@ -106,7 +106,7 @@ export function ChatFontSetting() {}, AUTOSAVE_DELAY_MS)return () => window.clearTimeout(timeout)- }, [draft, loadedConfig, saveVersion, t.settings.config.autosaveFailed])+ }, [draft, loadedConfig, saveVersion, t.settings.config.autosaveFailed, writeScope])const update = (value: string) => {saveVersionRef.current += 1