From e17990c2f83e07c63a209bfc4f336a5f5b0f3c7f Mon Sep 17 00:00:00 2001 From: RCD <90105158+Finesssee@users.noreply.github.com> Date: Fri, 30 Jan 2026 15:31:58 +0700 Subject: [PATCH] fix(config): ensure empty mapping persists for oauth-model-alias deletions When all oauth-model-alias entries are deleted, ensure an empty map is persisted to config file rather than being omitted entirely. Fixes #1305 Cherry-picked from upstream: a709e5a1 Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) --- internal/config/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 7aef0a15..c1cbfc7a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1558,6 +1558,16 @@ func pruneMappingToGeneratedKeys(dstRoot, srcRoot *yaml.Node, key string) { } srcIdx := findMapKeyIndex(srcRoot, key) if srcIdx < 0 { + // Keep an explicit empty mapping for oauth-model-alias when it was previously present. + // + // Rationale: LoadConfig runs MigrateOAuthModelAlias before unmarshalling. If the + // oauth-model-alias key is missing, migration will add the default antigravity aliases. + // When users delete the last channel from oauth-model-alias via the management API, + // we want that deletion to persist across hot reloads and restarts. + if key == "oauth-model-alias" { + dstRoot.Content[dstIdx+1] = &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"} + return + } removeMapKey(dstRoot, key) return }