fix(claude): stop restoring stale local env after external provider switch - #80
Open
yan-6 wants to merge 1 commit into
Open
fix(claude): stop restoring stale local env after external provider switch#80yan-6 wants to merge 1 commit into
yan-6 wants to merge 1 commit into
Conversation
…witch
The __wesight_managed.claudeCode.originalEnv snapshot was captured once
("first seen wins") and never updated. When the local Claude Code provider
was changed outside WeSight (e.g. by a config switcher that rewrites
settings.json), switching to or restarting with "local CLI config" restored
the outdated snapshot and silently reverted the user's provider/model.
Record the overlay env WeSight last wrote as managedEnv. On merge/cleanup,
if the live env no longer matches that overlay, treat it as an external
change: keep the live values and refresh the snapshot instead of restoring
the stale one. Legacy metadata without managedEnv keeps the old behavior.
|
@yanyanyanyan0918-cmyk is attempting to deploy a commit to the canghe's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
__wesight_managed.claudeCode.originalEnvsnapshot in~/.claude/settings.jsonis captured once ("first seen wins") and never updated.settings.jsonwhile preserving the__wesight_managedblock — restarting WeSight or switching the config source to "local CLI config" (本机配置) restores the outdated snapshot, silently reverting the user's provider/model to a previously used one.managedEnvin the managed metadata. On merge/cleanup, if the live env no longer matches that overlay, treat it as an external change: keep the live values and refresh the snapshot instead of restoring the stale one. Legacy metadata withoutmanagedEnvkeeps the previous behavior.Reproduction
settings.json, preserving__wesight_managedwith snapshot A).removeWesightManagedClaudeSettingsrestores provider A intoenv; the UI and launched Claude Code use A instead of B.Test plan
npx vitest run src/main/libs/externalAgentConfigSync.test.ts— 27/27 pass (4 new cases: managedEnv recording, external switch preserved on cleanup, snapshot refresh on next merge, legacy metadata backward compatibility)npx vitest run— no new failures (1 pre-existing environment-dependent failure inexternalAgentEnvironment.test.ts, also fails on cleanmain)npx tsc --noEmitclean;npx eslinton changed files clean