Skip to content

Fix: Model provider add verify and fixed form in modal not resetting issue - #15520

Merged
wangq8 merged 4 commits into
infiniflow:mainfrom
dcc123456:feature/provider-verify
Jun 3, 2026
Merged

wangq8 merged 4 commits into
infiniflow:mainfrom
dcc123456:feature/provider-verify

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Fix: Model provider add verify and fixed form in modal not resetting issue

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 87f6f2ca-1945-46a0-9229-cba525853ae7

📥 Commits

Reviewing files that changed from the base of the PR and between 3061048 and bd95767.

📒 Files selected for processing (1)
  • web/src/pages/user-setting/setting-model/hooks.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/user-setting/setting-model/hooks.tsx

📝 Walkthrough

Walkthrough

A new provider connection verification endpoint is added and wired into llmService and a new useVerifyProviderConnection hook. Settings integrate a normalized useVerifyConnection and call it during verification flows. All provider modals now reset form state when closed.

Changes

Provider Connection Verification & Modal Management

Layer / File(s) Summary
Backend API endpoint and service wiring
web/src/utils/api.ts, web/src/services/llm-service.ts
New /api/v1/providers/{provider_name}/connection POST endpoint is registered in the API map and wired into llmService as verifyProviderConnection.
Provider connection verification hook
web/src/hooks/use-llm-request.tsx
Added LLMApiAction.VerifyProviderConnection enum member and useVerifyProviderConnection hook exposing a mutation-based verifyProviderConnection(provider_name, api_key, base_url?, region?) interface.
Settings verification integration and request types
web/src/interfaces/request/llm.ts, web/src/pages/user-setting/setting-model/hooks.tsx
IAddProviderInstanceRequestBody gains optional region. New useVerifyConnection hook normalizes verification responses to VerifyResult (isValid + logs). useSubmitApiKey now calls verifyConnection directly when isVerify is true.
Modal form reset on close
web/src/pages/user-setting/setting-model/modal/{api-key,azure-openai,bedrock,fish-audio,google,mineru,next-tencent,opendataloader,paddleocr,spark,volcengine}-modal/index.tsx
Each modal now uses useEffect to call form.reset() or formRef.current?.reset() when visible becomes false, clearing stale form state on close.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#15517: Adds backend region-aware provider verification mapping that aligns with this PR's frontend region parameter handling.

Poem

🐰 I nudge the keys, I ping the door,
A tiny hop to test once more.
Forms go quiet when modals close,
Verification hums and shows —
All tidy now where bunny goes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description follows the required template with both sections completed, but lacks implementation details about the changes made. Add specific details about which form modal components were fixed, the new verification hook/service implementation, and the API endpoint changes to clarify the scope and impact of changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding provider verification functionality and fixing form reset issues in modals across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@dcc123456 dcc123456 added the ci Continue Integration label Jun 2, 2026
@dcc123456
dcc123456 marked this pull request as draft June 2, 2026 11:36
@dcc123456
dcc123456 marked this pull request as ready for review June 2, 2026 11:36

@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 (2)
web/src/interfaces/request/llm.ts (1)

25-28: 💤 Low value

Redundant region field.

IAddLlmRequestBody (Line 9) already declares region?: string, and IAddProviderInstanceRequestBody intersects it. The new region?: string on Line 27 is a duplicate with identical type/optionality and can be dropped.

♻️ Proposed cleanup
 export type IAddProviderInstanceRequestBody = IAddLlmRequestBody & {
   instance_name: string;
-  region?: string;
 };
🤖 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/interfaces/request/llm.ts` around lines 25 - 28, The interface
IAddProviderInstanceRequestBody redundantly re-declares region?: string even
though IAddLlmRequestBody already defines region?: string; remove the duplicate
region declaration from IAddProviderInstanceRequestBody so it only extends
IAddLlmRequestBody and adds instance_name, ensuring you keep the intersection
with IAddLlmRequestBody and the instance_name property intact.
web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx (1)

95-99: ⚡ Quick win

Extract the close-reset effect into a shared hook.

This visible → form.reset() effect is now repeated across the modal cohort in this PR. Centralizing it will keep reset timing consistent and reduce drift the next time modal-close behavior changes.

♻️ Possible extraction
+// web/src/hooks/use-reset-form-on-close.ts
+import { useEffect } from 'react';
+
+export const useResetFormOnClose = (
+  visible: boolean,
+  reset: () => void,
+) => {
+  useEffect(() => {
+    if (!visible) {
+      reset();
+    }
+  }, [visible, reset]);
+};
-import { memo, useEffect } from 'react';
+import { memo } from 'react';
+import { useResetFormOnClose } from '`@/hooks/use-reset-form-on-close`';
@@
-  useEffect(() => {
-    if (!visible) {
-      form.reset();
-    }
-  }, [visible, form]);
+  useResetFormOnClose(visible, form.reset);

As per coding guidelines, "Extract complex logic into hooks or utils; keep components lean."

🤖 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/modal/mineru-modal/index.tsx` around
lines 95 - 99, The useEffect in mineru-modal's index.tsx that runs form.reset()
when visible becomes false should be extracted into a reusable hook (e.g.,
useResetOnClose) to centralize modal-close reset behavior; implement a hook that
accepts the visibility flag and the form instance (or a reset callback) and
invokes reset when visible toggles from true to false, replace the inline
useEffect in the MineruModal component with a call to this hook (and update
other modals in the PR to use the same hook) so reset timing/semantics are
consistent across modals.
🤖 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/hooks.tsx`:
- Around line 130-165: The verifyConnection logic in useSubmitApiKey duplicates
the exported useVerifyConnection hook (both convert verifyProviderConnection's
ret.code→VerifyResult) causing drift; refactor useSubmitApiKey to import/use the
existing useVerifyConnection hook instead of re-implementing verifyConnection,
and ensure the returned VerifyResult.logs behavior matches the canonical
implementation (use ret.message with the same fallback if present) so logs are
consistent; update references to the local verifyConnection inside
useSubmitApiKey to call the hook-provided verifyConnection and remove the
duplicate function that wraps useVerifyProviderConnection.

---

Nitpick comments:
In `@web/src/interfaces/request/llm.ts`:
- Around line 25-28: The interface IAddProviderInstanceRequestBody redundantly
re-declares region?: string even though IAddLlmRequestBody already defines
region?: string; remove the duplicate region declaration from
IAddProviderInstanceRequestBody so it only extends IAddLlmRequestBody and adds
instance_name, ensuring you keep the intersection with IAddLlmRequestBody and
the instance_name property intact.

In `@web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx`:
- Around line 95-99: The useEffect in mineru-modal's index.tsx that runs
form.reset() when visible becomes false should be extracted into a reusable hook
(e.g., useResetOnClose) to centralize modal-close reset behavior; implement a
hook that accepts the visibility flag and the form instance (or a reset
callback) and invokes reset when visible toggles from true to false, replace the
inline useEffect in the MineruModal component with a call to this hook (and
update other modals in the PR to use the same hook) so reset timing/semantics
are consistent across modals.
🪄 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: d3fe8a10-6f68-45ae-86c3-0ada847a750e

📥 Commits

Reviewing files that changed from the base of the PR and between 9799f33 and 3061048.

📒 Files selected for processing (16)
  • web/src/hooks/use-llm-request.tsx
  • web/src/interfaces/request/llm.ts
  • web/src/pages/user-setting/setting-model/hooks.tsx
  • web/src/pages/user-setting/setting-model/modal/api-key-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/azure-openai-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/bedrock-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/fish-audio-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/google-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/next-tencent-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/opendataloader-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/paddleocr-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/spark-modal/index.tsx
  • web/src/pages/user-setting/setting-model/modal/volcengine-modal/index.tsx
  • web/src/services/llm-service.ts
  • web/src/utils/api.ts

@codecov

codecov Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (36357a6) to head (bd95767).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15520   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dcc123456
dcc123456 marked this pull request as draft June 3, 2026 02:09
@dcc123456
dcc123456 marked this pull request as ready for review June 3, 2026 02:09
@wangq8
wangq8 merged commit c41855d into infiniflow:main Jun 3, 2026
1 of 2 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:L This PR changes 100-499 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