fix(claude): preserve user-defined settings on provider switch#75
Open
zj1123581321 wants to merge 1 commit intoSaladDay:mainfrom
Open
fix(claude): preserve user-defined settings on provider switch#75zj1123581321 wants to merge 1 commit intoSaladDay:mainfrom
zj1123581321 wants to merge 1 commit intoSaladDay:mainfrom
Conversation
When switching providers, write_claude_live() previously overwrote the entire settings.json, causing user-defined fields like statusLine (used by HUD plugins) and hooks to be lost. Now preserves known user-configurable top-level keys (statusLine, hooks, permissions, apiKeyHelper) from the existing file when writing new provider config. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
Owner
|
这一部分的逻辑目前我们在考虑怎么做,暂时不准备合入 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
write_claude_live()previously overwrote the entiresettings.json, causing user-defined fields to be loststatusLine,hooks,permissions,apiKeyHelper) from the existing file when writing new provider configclaude-hud) stop working after a provider switch becausestatusLineconfig is droppedDetails
The root cause is in
write_claude_live()(src-tauri/src/services/provider/claude.rs): it constructs the new config from the provider'ssettings_config+ common config snippet, then writes it directly tosettings.jsonwithout reading the existing file. Any fields not stored in the provider's database record are lost.The fix reads the existing
settings.jsonbefore writing and carries over user-defined fields that are not present in the new provider config. A whitelist approach (PRESERVE_KEYS) is used instead of preserving all unknown keys, to avoid conflicts with common config management (e.g. clearing a common config snippet should still remove its fields).Test plan
statusLinepreserved throughoutenvcorrectly switches between providersclear_updates_live_config_even_without_apply_flagpasses (common config fields are correctly removed when cleared)🤖 Generated with Claude Code