fix(provider): prevent config JSON blinking when editing with proxy running#1922
fix(provider): prevent config JSON blinking when editing with proxy running#1922timwuhaotian wants to merge 1 commit intofarion1231:mainfrom
Conversation
…unning When the proxy is running, providers query refetches every 10 seconds, which triggered a cascade of state updates causing the config JSON editor to blink/flash: 1. Provider object reference changes on refetch 2. initialData recomputes (due to provider?.meta dependency) 3. defaultValues recomputes → form.reset() was called 4. settingsConfig changes → useCommonConfigSnippet triggers state updates Fix: - Skip form.reset() in edit mode (only reset on initial dialog open) - Remove provider?.meta from initialData dependencies to stabilize memoization The form should only initialize once when the dialog opens, not on every provider data change during editing.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8c0a5aaa2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isEditMode && initialData) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Reset form after async live settings arrive
When editing a provider, EditProviderDialog can fetch liveSettings asynchronously and updates initialData.settingsConfig afterwards, but this new guard makes ProviderForm skip form.reset(...) for all edit sessions. As a result, the form keeps the initial DB snapshot and never applies the later live config, so users may unknowingly edit/save stale JSON for the current active provider. This regression is triggered whenever live settings are loaded after the dialog first renders.
Useful? React with 👍 / 👎.
Summary
Fixes an issue where the config JSON editor would blink/flash constantly when editing a provider while the proxy is running.
Root Cause
When the proxy is running, the providers query refetches every 10 seconds (queries.ts:64). This triggered a cascade of state updates:
initialDatarecomputes (due toprovider?.metadependency)defaultValuesrecomputes →form.reset()was calledsettingsConfigchanges →useCommonConfigSnippettriggers state updates → blinkingFix
form.reset()in edit mode - the form should only initialize once when the dialog opens, not on every provider data changeprovider?.metafrominitialDatadependencies to stabilize memoizationTest Plan
Checklist
pnpm typecheckpassespnpm format:checkpasses