Repository navigation
feat(model): forward instance_id on per-model verify and auto-populate models - #17055
Conversation
📝 WalkthroughWalkthroughModel verification now supports optional instance identifiers, and draft instances populate their model lists from the catalog once while preserving manually removed models. ChangesInstance model updates
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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
🤖 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/instance-card/models-section/index.tsx`:
- Around line 104-107: Remove the providerName/instanceName reset useEffect that
calls setDraftModels and clears hasAutoPopulatedDraftRef. Leave draft
initialization to component remounting via the host’s React key and preserve the
existing catalog auto-population effect.
🪄 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: 1840c7d8-3bba-49f7-8b63-0991131bb9eb
📒 Files selected for processing (3)
web/src/hooks/use-llm-request.tsxweb/src/pages/user-setting/setting-model/instance-card/models-section/hooks.tsweb/src/pages/user-setting/setting-model/instance-card/models-section/index.tsx
| useEffect(() => { | ||
| setDraftModels([]); | ||
| hasAutoPopulatedDraftRef.current = false; | ||
| }, [providerName, instanceName]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Remove broken "safety net" reset effect.
If the component is not remounted on provider/instance change, this manual reset creates a race condition. Because catalog (returned by useModelsCatalog) is not synchronously cleared on provider switch, this effect clears draftModels, only for the second useEffect to immediately auto-populate it with the previous provider's catalog.
Since useModelsCatalog also relies on component remounting to trigger fresh auto-fetches, the host must remount this section via a React key on provider/instance switch. Therefore, this manual state reset is redundant and flawed, and should be removed.
♻️ Proposed fix
- useEffect(() => {
- setDraftModels([]);
- hasAutoPopulatedDraftRef.current = false;
- }, [providerName, instanceName]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| setDraftModels([]); | |
| hasAutoPopulatedDraftRef.current = false; | |
| }, [providerName, instanceName]); |
🤖 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/instance-card/models-section/index.tsx`
around lines 104 - 107, Remove the providerName/instanceName reset useEffect
that calls setDraftModels and clears hasAutoPopulatedDraftRef. Leave draft
initialization to component remounting via the host’s React key and preserve the
existing catalog auto-population effect.
Summary
feat(model): forward instance_id on per-model verify and auto-populate models