Skip to content

fix(setting-model): fix instance display and api_key loss after auto-save - #16853

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/model-provider-0713
Jul 13, 2026
Merged

fix(setting-model): fix instance display and api_key loss after auto-save #16853
wangq8 merged 1 commit into
infiniflow:mainfrom
dcc123456:fix/model-provider-0713

Conversation

@dcc123456

Copy link
Copy Markdown
Contributor

Summary

fix(setting-model): fix instance display and api_key loss after auto-save

@dosubot dosubot Bot added 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 13, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 13, 2026 07:06
@dcc123456 dcc123456 added the ci Continue Integration label Jul 13, 2026
@dcc123456
dcc123456 marked this pull request as draft July 13, 2026 07:07
@dcc123456
dcc123456 marked this pull request as ready for review July 13, 2026 07:07
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Provider settings now validate added-provider availability, refresh provider caches after instance creation, defer credential-dependent model loading, preserve form baselines, refine verification output, and render secret credentials as password fields.

Changes

Provider model settings

Layer / File(s) Summary
Provider availability and cache state
web/src/hooks/use-llm-request.tsx, web/src/pages/user-setting/setting-model/index.tsx
Added-provider data gates provider queries, and successful instance creation invalidates the added-providers cache.
Credential-gated model catalog
web/src/pages/user-setting/setting-model/instance-card/models-section/*
Model catalog fetching waits for instance details, resolves credentials before requests, and skips empty-key VolcEngine requests.
Form lifecycle and verification behavior
web/src/pages/user-setting/setting-model/instance-card/{hooks.tsx,verify-button.tsx,components/saved-mode-card.tsx}
Saved form baselines and default-value memoization are adjusted, verification callbacks use the resolved form, invalid logs render only for invalid results, and model loading receives instance readiness.
Secret credential field presentation
web/src/pages/user-setting/setting-model/provider-schema/field-config/*
API keys, tokens, passwords, and service account keys use password-style inputs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingModelV2
  participant ModelsSection
  participant useModelsCatalog
  participant LLMFactory
  SettingModelV2->>ModelsSection: pass instanceDetailsLoaded
  ModelsSection->>useModelsCatalog: provide readiness state
  useModelsCatalog->>LLMFactory: identify provider credential requirements
  useModelsCatalog->>useModelsCatalog: resolve credentials and conditionally fetch models
Loading

Suggested reviewers: wangq8

Poem

A rabbit hops through keys kept bright,
Guards model calls till creds are right.
Caches bloom when instances land,
Forms remember what edits planned.
Secrets hide beneath the moonlit glow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main changes: instance display fixes and preserving api_key during auto-save.
Description check ✅ Passed The description includes the required Summary section and states the PR goal clearly, though it is brief.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/pages/user-setting/setting-model/index.tsx (1)

65-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

handleDraftSave invalidation becomes a no-op for first-instance saves.

The new providerQueryName returns '' when a provider has no has_instance, so the queryClient.invalidateQueries at line 139–141 (which uses providerQueryName) is a no-op for the first instance of a provider. This is safe because useAddProviderInstance internally invalidates providerInstances(params.llm_factory) with the correct provider name (lines 297–299 of use-llm-request.tsx), and the addedProviders refetch will flip providerQueryName to enable the query. Consider replacing providerQueryName with selection as string at line 140 to keep the invalidation effective for all cases, or remove it entirely since useAddProviderInstance already handles it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/pages/user-setting/setting-model/index.tsx` around lines 65 - 71, The
handleDraftSave invalidation currently uses providerQueryName, which is empty
when saving a provider’s first instance. Update the
queryClient.invalidateQueries call in handleDraftSave to use selection as the
provider name, or remove the redundant invalidation because
useAddProviderInstance already invalidates providerInstances. Preserve effective
invalidation for both existing and first-instance saves.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts`:
- Around line 246-252: Update the XunFei Spark provider configuration entries
for spark_api_secret and spark_api_key to use FormFieldType.Password, matching
spark_api_password, while preserving their existing labels, required settings,
placeholders, and rendering conditions.

---

Nitpick comments:
In `@web/src/pages/user-setting/setting-model/index.tsx`:
- Around line 65-71: The handleDraftSave invalidation currently uses
providerQueryName, which is empty when saving a provider’s first instance.
Update the queryClient.invalidateQueries call in handleDraftSave to use
selection as the provider name, or remove the redundant invalidation because
useAddProviderInstance already invalidates providerInstances. Preserve effective
invalidation for both existing and first-instance saves.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d3744f96-d12c-447e-b2b8-8ae9b54fbfa8

📥 Commits

Reviewing files that changed from the base of the PR and between 2b9569f and 4fc17af.

📒 Files selected for processing (11)
  • web/src/hooks/use-llm-request.tsx
  • web/src/pages/user-setting/setting-model/index.tsx
  • web/src/pages/user-setting/setting-model/instance-card/components/saved-mode-card.tsx
  • web/src/pages/user-setting/setting-model/instance-card/hooks.tsx
  • web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts
  • web/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx
  • web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts
  • web/src/pages/user-setting/setting-model/instance-card/verify-button.tsx
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/generic-api-key-config.ts
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/local-llm-configs.ts
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts

Comment on lines 246 to 252
{
name: 'spark_api_password',
label: 'addSparkAPIPassword',
type: FormFieldType.Text,
type: FormFieldType.Password,
required: true,
placeholder: 'SparkAPIPasswordMessage',
shouldRender: 'hideWhenInstanceExists',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Mask all XunFei Spark credentials.

spark_api_password is now rendered as a password, but the same provider still renders spark_api_secret (Lines 265-271) and spark_api_key (Lines 274-280) as plain text. These values are submitted as credentials and should receive the same protection.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts`
around lines 246 - 252, Update the XunFei Spark provider configuration entries
for spark_api_secret and spark_api_key to use FormFieldType.Password, matching
spark_api_password, while preserving their existing labels, required settings,
placeholders, and rendering conditions.

@wangq8
wangq8 merged commit f213680 into infiniflow:main Jul 13, 2026
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants