Repository navigation
Fix: Model provider add verify and fixed form in modal not resetting issue - #15520
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA 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. ChangesProvider Connection Verification & Modal Management
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
web/src/interfaces/request/llm.ts (1)
25-28: 💤 Low valueRedundant
regionfield.
IAddLlmRequestBody(Line 9) already declaresregion?: string, andIAddProviderInstanceRequestBodyintersects it. The newregion?: stringon 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 winExtract 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
📒 Files selected for processing (16)
web/src/hooks/use-llm-request.tsxweb/src/interfaces/request/llm.tsweb/src/pages/user-setting/setting-model/hooks.tsxweb/src/pages/user-setting/setting-model/modal/api-key-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/azure-openai-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/bedrock-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/fish-audio-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/google-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/mineru-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/next-tencent-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/opendataloader-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/paddleocr-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/spark-modal/index.tsxweb/src/pages/user-setting/setting-model/modal/volcengine-modal/index.tsxweb/src/services/llm-service.tsweb/src/utils/api.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Fix: Model provider add verify and fixed form in modal not resetting issue
Type of change