Skip to content

fix(provider): prevent config JSON blinking when editing with proxy running#1922

Open
timwuhaotian wants to merge 1 commit intofarion1231:mainfrom
timwuhaotian:fix/config-blink
Open

fix(provider): prevent config JSON blinking when editing with proxy running#1922
timwuhaotian wants to merge 1 commit intofarion1231:mainfrom
timwuhaotian:fix/config-blink

Conversation

@timwuhaotian
Copy link
Copy Markdown

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:

  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 → blinking

Fix

  • ProviderForm.tsx: Skip form.reset() in edit mode - the form should only initialize once when the dialog opens, not on every provider data change
  • EditProviderDialog.tsx: Remove provider?.meta from initialData dependencies to stabilize memoization

Test Plan

  1. Start the app with proxy running
  2. Open edit dialog for a provider
  3. Observe the config JSON - it should remain stable without blinking
  4. Wait 10+ seconds (through multiple refetch cycles)
  5. Confirm config still stable

Checklist

  • pnpm typecheck passes
  • pnpm format:check passes
  • No Rust code changed
  • No user-facing text changed (no i18n updates needed)

…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.
@yovinchen
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +391 to +393
if (isEditMode && initialData) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants