Skip to content

The agent that grows with you

fix(desktop): default config writeScope to undefined, not null

kshitijk4poor744634fd9440
diff --git a/apps/desktop/src/app/hooks/use-config-record.ts b/apps/desktop/src/app/hooks/use-config-record.ts
index 632646d63f0..3b291b254db 100644
--- a/apps/desktop/src/app/hooks/use-config-record.ts
+++ b/apps/desktop/src/app/hooks/use-config-record.ts
@@ -49,7 +49,13 @@ export const useHermesConfigRecord = (profile?: ProfileScope) => {
return {
...query,
- writeScope: peekConfigReadOrigin(query.data) ?? null
+ // `undefined`, never `null`: callers hand this straight to saveHermesConfig
+ // with sparse `setNested({}, …)` patches, so the WeakMap misses and the
+ // fallback is capabilityScoped(writeScope) → profileScoped(writeScope).
+ // profileScoped(undefined) keeps the app-wide `_apiProfile`; profileScoped
+ // (null) drops it and would write the PRIMARY profile before the first
+ // GET resolves.
+ writeScope: peekConfigReadOrigin(query.data) ?? undefined
}
}