fix: use deep merge for config updates and save inputs on blur
- Backend: replace shallow merge with recursive deepMerge in PUT /api/hermes/config to prevent nested config fields from being lost when updating partial values - Frontend: switch all NInput fields to default-value + @change (save on blur) instead of :value + @update:value (save on every keystroke) in both PlatformSettings.vue and SettingsView.vue api_server tab - Remove unused debounce logic and dead changeKey function Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,20 @@ function getNested(obj: Record<string, any>, path: string): any {
|
||||
return cur
|
||||
}
|
||||
|
||||
function deepMerge(target: Record<string, any>, source: Record<string, any>): Record<string, any> {
|
||||
for (const key of Object.keys(source)) {
|
||||
if (
|
||||
source[key] && typeof source[key] === 'object' && !Array.isArray(source[key]) &&
|
||||
target[key] && typeof target[key] === 'object' && !Array.isArray(target[key])
|
||||
) {
|
||||
target[key] = deepMerge(target[key], source[key])
|
||||
} else {
|
||||
target[key] = source[key]
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
async function readEnvPlatforms(): Promise<Record<string, any>> {
|
||||
try {
|
||||
const raw = await readFile(envPath(), 'utf-8')
|
||||
@@ -217,7 +231,7 @@ configRoutes.put('/api/hermes/config', async (ctx) => {
|
||||
|
||||
try {
|
||||
const config = await readConfig()
|
||||
config[section] = { ...(config[section] || {}), ...values }
|
||||
config[section] = deepMerge(config[section] || {}, values)
|
||||
await writeConfig(config)
|
||||
// Restart gateway for platform/channel config changes
|
||||
if (PLATFORM_SECTIONS.has(section)) {
|
||||
|
||||
Reference in New Issue
Block a user