Skip to content

The agent that grows with you

fix(desktop): bind config writes to the config-read route

KoNit-K8961499ff6d7
diff --git a/apps/desktop/src/api/config-route-binding.test.ts b/apps/desktop/src/api/config-route-binding.test.ts
new file mode 100644
index 00000000000..6366ad7ac98
--- /dev/null
+++ b/apps/desktop/src/api/config-route-binding.test.ts
@@ -0,0 +1,89 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import {
+ getHermesConfigRecord,
+ peekConfigReadOrigin,
+ resolveConfigWriteScope,
+ saveHermesConfig,
+ saveHermesConfigRecord,
+ setApiRequestConnection,
+ setApiRequestProfile
+} from '@/hermes'
+
+describe('config read/write route binding', () => {
+ let api: ReturnType<typeof vi.fn>
+
+ beforeEach(() => {
+ api = vi.fn(async (request: { method?: string }) =>
+ request.method === 'PUT' ? { ok: true } : { model: 'from-read' }
+ )
+ Object.defineProperty(window, 'hermesDesktop', {
+ configurable: true,
+ value: { api }
+ })
+ setApiRequestConnection(null)
+ setApiRequestProfile(null)
+ })
+
+ afterEach(() => {
+ setApiRequestConnection(null)
+ setApiRequestProfile(null)
+ vi.restoreAllMocks()
+ Reflect.deleteProperty(window, 'hermesDesktop')
+ })
+
+ it('config record read from A cannot be written to B after primary changes', async () => {
+ setApiRequestConnection('connection-a')
+ setApiRequestProfile('default')
+
+ const record = await getHermesConfigRecord()
+
+ expect(peekConfigReadOrigin(record)).toEqual({ connectionId: 'connection-a', profile: 'default' })
+ expect(api).toHaveBeenCalledWith(
+ expect.objectContaining({ connectionId: 'connection-a', path: '/api/config', profile: 'default' })
+ )
+
+ setApiRequestConnection('connection-b')
+ await saveHermesConfig(record)
+
+ const puts = api.mock.calls.filter(call => call[0].method === 'PUT')
+
+ expect(puts).toHaveLength(1)
+ expect(puts[0][0]).toEqual(
+ expect.objectContaining({
+ connectionId: 'connection-a',
+ method: 'PUT',
+ path: '/api/config',
+ profile: 'default'
+ })
+ )
+ expect(puts.filter(call => call[0].connectionId === 'connection-b')).toHaveLength(0)
+ })
+
+ it('explicit connection/profile pins still win over a captured origin', async () => {
+ setApiRequestConnection('connection-a')
+ const record = await getHermesConfigRecord()
+ setApiRequestConnection('connection-b')
+
+ await saveHermesConfigRecord(record, { connectionId: 'explicit-pin', profile: 'worker' })
+
+ const put = api.mock.calls.find(call => call[0].method === 'PUT')?.[0]
+
+ expect(put).toEqual(
+ expect.objectContaining({
+ connectionId: 'explicit-pin',
+ profile: 'worker'
+ })
+ )
+ })
+
+ it('unbound local writes keep the live ambient path', () => {
+ setApiRequestConnection('connection-b')
+ setApiRequestProfile('coder')
+
+ expect(resolveConfigWriteScope({ model: 'fresh' })).toEqual({
+ connectionId: 'connection-b',
+ profile: 'coder'
+ })
+ })
+})
diff --git a/apps/desktop/src/api/config.ts b/apps/desktop/src/api/config.ts
index 509b81f074f..ba90ec4a9ad 100644
--- a/apps/desktop/src/api/config.ts
+++ b/apps/desktop/src/api/config.ts
@@ -16,6 +16,52 @@ import type {
import { capabilityScoped, hermesApi, type ProfileScope, profileScoped, STARTUP_REQUEST_TIMEOUT_MS } from './client'
+const configReadOrigins = new WeakMap<object, { connectionId?: string; profile?: string }>()
+
+/** Snapshot the `(connectionId, profile)` that served a config GET. */
+export function bindConfigReadOrigin(
+ record: object,
+ origin: { connectionId?: string; profile?: string }
+): void {
+ configReadOrigins.set(record, origin)
+}
+
+export function peekConfigReadOrigin(
+ record: object | undefined | null
+): { connectionId?: string; profile?: string } | undefined {
+ return record ? configReadOrigins.get(record) : undefined
+}
+
+/**
+ * Route a config write to the identity that served the matching read.
+ * An explicit `{ connectionId, profile }` pin wins. A GET-derived record
+ * keeps its captured origin even after the registry primary changes.
+ * Unbound writes (no captured origin, no object pin) keep the live ambient
+ * capability scope — e.g. reset-to-defaults on the current connection.
+ */
+export function resolveConfigWriteScope(
+ record: object | undefined,
+ requestScope?: ProfileScope
+): { connectionId?: string; profile?: string } {
+ if (requestScope && typeof requestScope === 'object') {
+ return capabilityScoped(requestScope)
+ }
+
+ const captured = peekConfigReadOrigin(record)
+
+ if (captured) {
+ const profile =
+ typeof requestScope === 'string' && requestScope.trim() ? requestScope.trim() : captured.profile
+
+ return {
+ ...(profile ? { profile } : {}),
+ ...(captured.connectionId ? { connectionId: captured.connectionId } : {})
+ }
+ }
+
+ return capabilityScoped(requestScope)
+}
+
export function getStatus(): Promise<StatusResponse> {
return hermesApi<StatusResponse>({
...profileScoped(),
@@ -68,14 +114,21 @@ export function getHermesConfig(profile?: string): Promise<HermesConfig> {
})
}
-export function getHermesConfigRecord(
+export async function getHermesConfigRecord(
profile?: ProfileScope,
{ includeDefaults = true }: { includeDefaults?: boolean } = {}
): Promise<HermesConfigRecord> {
- return window.hermesDesktop.api<HermesConfigRecord>({
- ...capabilityScoped(profile),
+ const origin = capabilityScoped(profile)
+ const record = await window.hermesDesktop.api<HermesConfigRecord>({
+ ...origin,
path: includeDefaults ? '/api/config' : '/api/config?include_defaults=false'
})
+
+ if (record && typeof record === 'object') {
+ bindConfigReadOrigin(record, origin)
+ }
+
+ return record
}
export function getHermesConfigDefaults(): Promise<HermesConfigRecord> {
@@ -95,11 +148,11 @@ export function getHermesConfigSchema(profile?: null | string): Promise<ConfigSc
export function saveHermesConfig(
config: HermesConfigRecord,
- profile?: null | string,
+ profile?: ProfileScope,
{ preserveLanguage = false }: { preserveLanguage?: boolean } = {}
): Promise<{ ok: boolean }> {
- return hermesApi<{ ok: boolean }>({
- ...profileScoped(profile),
+ return window.hermesDesktop.api<{ ok: boolean }>({
+ ...resolveConfigWriteScope(config, profile),
path: preserveLanguage ? '/api/config?preserve_language=true' : '/api/config',
method: 'PUT',
body: { config }
@@ -111,7 +164,7 @@ export function saveHermesConfig(
* on another registered gateway), mirroring getHermesConfigRecord. */
export function saveHermesConfigRecord(config: HermesConfigRecord, profile?: ProfileScope): Promise<{ ok: boolean }> {
return window.hermesDesktop.api<{ ok: boolean }>({
- ...capabilityScoped(profile),
+ ...resolveConfigWriteScope(config, profile),
path: '/api/config',
method: 'PUT',
body: { config }
diff --git a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx
index 81b4413a75a..893e8e290db 100644
--- a/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx
+++ b/apps/desktop/src/app/chat/right-rail/real-profile-consent-dialog.tsx
@@ -50,7 +50,7 @@ export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogProp
const dismissed = useStore($realProfilePromptDismissed)
const muted = useStore($realProfilePromptMuted)
const claim = useStore($realProfilePromptClaim)
- const { data: config } = useHermesConfigRecord()
+ const { data: config, writeScope } = useHermesConfigRecord()
const setConfig = hermesConfigCacheWriter()
const [busy, setBusy] = useState(false)
@@ -80,7 +80,8 @@ export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogProp
try {
// Sparse patch: PUT /api/config deep-merges, and echoing the cached
// snapshot would overwrite keys other surfaces changed since it loaded.
- await saveHermesConfigRecord({ browser: { use_real_profile: true } })
+ await saveHermesConfigRecord({ browser: { use_real_profile: true } }, writeScope)
+
notify({ kind: 'info', title: copy.enabledTitle, message: copy.enabledMessage })
} catch (err) {
setConfig(config)
@@ -88,7 +89,7 @@ export function RealProfileConsentDialog({ tabId }: RealProfileConsentDialogProp
} finally {
setBusy(false)
}
- }, [busy, config, copy, setConfig])
+ }, [busy, config, copy, setConfig, writeScope])
// Config not loaded yet, feature already on, opted out, or another pane
// owns the prompt — render nothing. `enabled` flipping true after a
diff --git a/apps/desktop/src/app/hooks/use-config-record.ts b/apps/desktop/src/app/hooks/use-config-record.ts
index 678743c786c..3d32e5e0cb1 100644
--- a/apps/desktop/src/app/hooks/use-config-record.ts
+++ b/apps/desktop/src/app/hooks/use-config-record.ts
@@ -1,6 +1,9 @@
import { useQuery } from '@tanstack/react-query'
+import { useRef } from 'react'
-import { getHermesConfigRecord, type ProfileScope, profileScopeKey } from '@/hermes'
+import { type ProfileScope, profileScopeKey } from '@/api/client'
+import { peekConfigReadOrigin } from '@/api/config'
+import { getHermesConfigRecord } from '@/hermes'
import { queryClient, writeCache } from '@/lib/query-client'
import type { HermesConfigRecord } from '@/types/hermes'
@@ -27,16 +30,39 @@ export const hermesConfigKey = (profile?: ProfileScope) =>
// staleTime 0 → serve cache instantly, background-revalidate on every mount.
// `profile` scopes both the query key and the fetch; omitting it preserves the
// exact app-wide behavior (base key, `profileScoped(undefined)` fallback).
-export const useHermesConfigRecord = (profile?: ProfileScope) =>
- useQuery({
+export const useHermesConfigRecord = (profile?: ProfileScope) => {
+ const writeScopeRef = useRef<{ connectionId?: string; profile?: string } | null>(null)
+ const scopeKey = profileScopeKey(profile)
+ const scopeKeyRef = useRef(scopeKey)
+
+ if (scopeKeyRef.current !== scopeKey) {
+ scopeKeyRef.current = scopeKey
+ writeScopeRef.current = null
+ }
+
+ const query = useQuery({
queryKey: hermesConfigKey(profile),
// 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: () => getHermesConfigRecord(profile ?? undefined),
+ queryFn: async () => {
+ const record = await getHermesConfigRecord(profile ?? undefined)
+
+ if (!writeScopeRef.current) {
+ writeScopeRef.current = peekConfigReadOrigin(record) ?? {}
+ }
+
+ return record
+ },
staleTime: 0
})
+ return {
+ ...query,
+ writeScope: writeScopeRef.current
+ }
+}
+
// setHermesConfigCache writes the app-wide (base-key) record. Pass a profile to
// write the suffixed per-profile cache instead — keeps the selector's optimistic
// write-through landing on the same key its query reads.
diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsx
index d24390282c3..1d5414daa26 100644
--- a/apps/desktop/src/app/settings/appearance-settings.tsx
+++ b/apps/desktop/src/app/settings/appearance-settings.tsx
@@ -83,6 +83,7 @@ function ResumeLastSessionSetting() {
const a = t.settings.appearance
const configQuery = useHermesConfigRecord()
const config = configQuery.data
+ const writeScope = configQuery.writeScope
const checked = (config?.display as { resume_last_session?: unknown } | undefined)?.resume_last_session !== false
const update = (on: boolean) => {
@@ -94,7 +95,8 @@ function ResumeLastSessionSetting() {
setHermesConfigCache(next)
// Sparse patch: PUT /api/config deep-merges, and echoing the cached
// snapshot would overwrite keys other surfaces changed since it loaded.
- void saveHermesConfig(setNested({}, 'display.resume_last_session', on))
+ void saveHermesConfig(setNested({}, 'display.resume_last_session', on), writeScope)
+
.then(result => {
if (!result.ok) {
throw new Error(t.settings.config.autosaveFailed)
diff --git a/apps/desktop/src/app/settings/browser-real-profile-panel.tsx b/apps/desktop/src/app/settings/browser-real-profile-panel.tsx
index 602244a06c8..91f14f051d1 100644
--- a/apps/desktop/src/app/settings/browser-real-profile-panel.tsx
+++ b/apps/desktop/src/app/settings/browser-real-profile-panel.tsx
@@ -42,7 +42,7 @@ export function readUseRealProfile(record: Record<string, unknown> | undefined):
export function BrowserRealProfilePanel({ profile }: BrowserRealProfilePanelProps) {
const { t } = useI18n()
const copy = t.settings.toolsets.browserRealProfile
- const { data: config } = useHermesConfigRecord(profile)
+ const { data: config, writeScope } = useHermesConfigRecord(profile)
const setConfig = hermesConfigCacheWriter(profile)
const [busy, setBusy] = useState(false)
@@ -67,7 +67,8 @@ export function BrowserRealProfilePanel({ profile }: BrowserRealProfilePanelProp
try {
// Sparse patch: PUT /api/config deep-merges, and echoing the cached
// snapshot would overwrite keys other surfaces changed since it loaded.
- await saveHermesConfigRecord({ browser: { use_real_profile: on } }, profile)
+ await saveHermesConfigRecord({ browser: { use_real_profile: on } }, writeScope ?? profile)
+
notify({
kind: 'info',
title: on ? copy.enabledTitle : copy.disabledTitle,
@@ -80,7 +81,7 @@ export function BrowserRealProfilePanel({ profile }: BrowserRealProfilePanelProp
setBusy(false)
}
},
- [config, copy, profile, setConfig]
+ [config, copy, profile, setConfig, writeScope]
)
return (
diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsx
index a1bfd35407e..c3ca2b32a99 100644
--- a/apps/desktop/src/app/settings/config-settings.tsx
+++ b/apps/desktop/src/app/settings/config-settings.tsx
@@ -103,7 +103,12 @@ function ConfigSettingsInner({
// from — and saved back through — the shared config cache, so edits are visible
// in the MCP/model surfaces and reopening the page doesn't reload-flash.
const [config, setConfig] = useState<HermesConfigRecord | null>(null)
- const { data: loadedConfig, isError: configLoadFailed, refetch: refetchConfig } = useHermesConfigRecord(scopeProfile)
+ const {
+ data: loadedConfig,
+ isError: configLoadFailed,
+ refetch: refetchConfig,
+ writeScope
+ } = useHermesConfigRecord(scopeProfile)
// Writes land on the same cache key the query above reads (base key when
// following the active profile, suffixed when a scope override is set).
const writeConfigCache = useMemo(() => hermesConfigCacheWriter(scopeProfile), [scopeProfile])
@@ -205,7 +210,7 @@ function ConfigSettingsInner({
saveQueueRef.current = saveQueueRef.current.then(async () => {
try {
const patch = diffConfig(configBaselineRef.current ?? {}, snapshot)
- const result = await saveHermesConfig(patch, scopeProfile)
+ const result = await saveHermesConfig(patch, writeScope ?? scopeProfile)
if (!result.ok) {
throw new Error(c.autosaveFailed)
@@ -245,7 +250,7 @@ function ConfigSettingsInner({
return () => window.clearTimeout(t)
// eslint-disable-next-line react-hooks/exhaustive-deps -- copy is stable; avoid re-scheduling autosave on locale change
- }, [config, onConfigSaved, saveVersion])
+ }, [config, onConfigSaved, saveVersion, writeScope, scopeProfile])
const applyConfig = (next: HermesConfigRecord) => {
saveVersionRef.current += 1
diff --git a/apps/desktop/src/app/settings/model-settings.tsx b/apps/desktop/src/app/settings/model-settings.tsx
index dbe002938da..9a1cee2c1c4 100644
--- a/apps/desktop/src/app/settings/model-settings.tsx
+++ b/apps/desktop/src/app/settings/model-settings.tsx
@@ -249,7 +249,7 @@ export function ModelSettings({ onMainModelChanged, scopeProfile, subpage }: Mod
const [newMoaPresetName, setNewMoaPresetName] = useState('')
// agent.* defaults round-trip through the shared config cache (read → write
// back the whole record), so a save here shows in the MCP/model surfaces.
- const { data: config } = useHermesConfigRecord(scopeProfile)
+ const { data: config, writeScope } = useHermesConfigRecord(scopeProfile)
const setConfig = useMemo(() => hermesConfigCacheWriter(scopeProfile), [scopeProfile])
const [applying, setApplying] = useState(false)
const [editingAuxTask, setEditingAuxTask] = useState<null | string>(null)
@@ -592,13 +592,14 @@ export function ModelSettings({ onMainModelChanged, scopeProfile, subpage }: Mod
setConfig(next)
try {
- await saveHermesConfig(setNested({}, key, value), scopeProfile)
+ await saveHermesConfig(setNested({}, key, value), writeScope ?? scopeProfile)
+
} catch (err) {
setConfig(prev)
notifyError(err, m.defaultsFailed)
}
},
- [config, m.defaultsFailed, scopeProfile, setConfig]
+ [config, m.defaultsFailed, scopeProfile, setConfig, writeScope]
)
// Paste an API key for the selected `api_key` provider, persist it, then
diff --git a/apps/desktop/src/app/settings/sessions-settings.tsx b/apps/desktop/src/app/settings/sessions-settings.tsx
index 5f4b7b6be9e..02de9766535 100644
--- a/apps/desktop/src/app/settings/sessions-settings.tsx
+++ b/apps/desktop/src/app/settings/sessions-settings.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { restoreListedSession } from '@/app/session/hooks/use-session-actions/utils'
import { Button } from '@/components/ui/button'
@@ -8,6 +8,7 @@ import {
deleteSession,
getHermesConfigRecord,
listAllProfileSessions,
+ peekConfigReadOrigin,
saveHermesConfig,
setSessionArchived
} from '@/hermes'
@@ -209,6 +210,7 @@ function AutoArchiveSetting() {
const [config, setConfig] = useState<HermesConfigRecord | null>(null)
const [enabled, setEnabled] = useState(false)
const [days, setDays] = useState(DEFAULT_AUTO_ARCHIVE_DAYS)
+ const writeScopeRef = useRef<ReturnType<typeof peekConfigReadOrigin>>(undefined)
useEffect(() => {
// Config REST is only reachable through the Electron bridge; skip in
@@ -227,6 +229,7 @@ function AutoArchiveSetting() {
const sessions = (record.sessions ?? {}) as Record<string, unknown>
const parsedDays = Number(sessions.auto_archive_days)
+ writeScopeRef.current = peekConfigReadOrigin(record)
setConfig(record)
setEnabled(Boolean(sessions.auto_archive))
setDays(Number.isFinite(parsedDays) && parsedDays > 0 ? Math.round(parsedDays) : DEFAULT_AUTO_ARCHIVE_DAYS)
@@ -258,7 +261,8 @@ function AutoArchiveSetting() {
try {
// Sparse patch: PUT /api/config deep-merges, and echoing the cached
// snapshot would overwrite keys other surfaces changed since it loaded.
- await saveHermesConfig({ sessions: { auto_archive: autoArchive, auto_archive_days: archiveDays } })
+ await saveHermesConfig({ sessions: { auto_archive: autoArchive, auto_archive_days: archiveDays } }, writeScopeRef.current)
+
} catch (err) {
notifyError(err, s.autoArchiveFailed)
}
diff --git a/apps/desktop/src/app/settings/terminal-font-setting.tsx b/apps/desktop/src/app/settings/terminal-font-setting.tsx
index d4d3df73d00..f2b48c107a4 100644
--- a/apps/desktop/src/app/settings/terminal-font-setting.tsx
+++ b/apps/desktop/src/app/settings/terminal-font-setting.tsx
@@ -29,7 +29,7 @@ function fontFamilyFromConfig(config: HermesConfigRecord): string {
export function TerminalFontSetting() {
const { t } = useI18n()
const copy = t.settings.appearance
- const { data: loadedConfig, dataUpdatedAt } = useHermesConfigRecord()
+ const { data: loadedConfig, dataUpdatedAt, writeScope } = useHermesConfigRecord()
// draft === null ⇔ unseeded: nothing painted yet for this profile. The
// profile-switch handler keeps it unseeded until a config refetch completes;
// the timestamp is the freshness proof because React Query can reuse the
@@ -91,7 +91,8 @@ export function TerminalFontSetting() {
// Sparse patch: PUT /api/config deep-merges, and echoing the cached
// snapshot would overwrite keys other surfaces changed since it loaded.
- void saveHermesConfig(setNested({}, 'terminal.font_family', value))
+ void saveHermesConfig(setNested({}, 'terminal.font_family', value), writeScope)
+
.then(result => {
if (!result.ok) {
throw new Error(t.settings.config.autosaveFailed)
diff --git a/apps/desktop/src/app/settings/voice-provider-fields.tsx b/apps/desktop/src/app/settings/voice-provider-fields.tsx
index b20c45cf1bf..7ff42c980b5 100644
--- a/apps/desktop/src/app/settings/voice-provider-fields.tsx
+++ b/apps/desktop/src/app/settings/voice-provider-fields.tsx
@@ -53,7 +53,7 @@ export function VoiceProviderFields({
}) {
const { t } = useI18n()
const keys = useMemo(() => voiceProviderKeys(section, providerKey), [section, providerKey])
- const { data: loadedConfig } = useHermesConfigRecord(profile)
+ const { data: loadedConfig, writeScope } = useHermesConfigRecord(profile)
// Parents pass `profile` as a fresh object literal each render; keying the
// writer and the autosave effect on its identity would re-arm the 550ms
// timer on every unrelated re-render. Key on the scope string instead
@@ -97,11 +97,12 @@ export function VoiceProviderFields({
}
const timeout = window.setTimeout(() => {
- void saveHermesConfigRecord(diffConfig(baseline ?? {}, config), profile)
+ void saveHermesConfigRecord(diffConfig(baseline ?? {}, config), writeScope ?? profile)
.then(() => {
setBaseline(config)
writeConfigCache(config)
})
+
.catch(err => notifyError(err, t.settings.config.autosaveFailed))
}, 550)
diff --git a/apps/desktop/src/i18n/context.tsx b/apps/desktop/src/i18n/context.tsx
index 870b35ab1d9..cb863a70d88 100644
--- a/apps/desktop/src/i18n/context.tsx
+++ b/apps/desktop/src/i18n/context.tsx
@@ -1,7 +1,13 @@
import { applyDocumentLocale, isRecord } from '@hermes/shared/i18n'
import { createContext, type ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
-import { getHermesConfigRecord, type HermesConfigRecord, saveHermesConfig } from '@/hermes'
+import {
+ bindConfigReadOrigin,
+ getHermesConfigRecord,
+ type HermesConfigRecord,
+ peekConfigReadOrigin,
+ saveHermesConfig
+} from '@/hermes'
import { TRANSLATIONS } from './catalog'
import {
@@ -36,7 +42,7 @@ const defaultConfigClient: I18nConfigClient = {
return Promise.resolve({ ok: true })
}
- return saveHermesConfig(config, undefined, { preserveLanguage: true })
+ return saveHermesConfig(config, peekConfigReadOrigin(config), { preserveLanguage: true })
}
}
@@ -47,13 +53,20 @@ export function getConfigDisplayLanguage(config: HermesConfigRecord): unknown {
export function withConfigDisplayLanguage(config: HermesConfigRecord, locale: Locale): HermesConfigRecord {
const display = isRecord(config.display) ? config.display : {}
- return {
+ const next = {
...config,
display: {
...display,
language: localeConfigValue(locale)
}
}
+ const origin = peekConfigReadOrigin(config)
+
+ if (origin) {
+ bindConfigReadOrigin(next, origin)
+ }
+
+ return next
}
function toError(error: unknown): Error {