Repository navigation
Fix: The newly added model did not appear in the drop-down menu. - #15476
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 (2)
📝 WalkthroughWalkthroughCache invalidation for several LLM provider/model mutations now targets ChangesModel Management and Modal Adjustments
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ 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.
🧹 Nitpick comments (1)
web/src/hooks/use-llm-request.tsx (1)
230-232: ⚡ Quick winRefine cache invalidation for model-type keys (current call sites are untyped, so this is optional)
LlmKeys.allModels()yields the key['allModels', undefined], which would not match type-specific keys like['allModels', 'chat']/['allModels', 'embedding'].- In this codebase,
useFetchAllAddedModels(...)is only used with nomodelTypeargument, so there are currently no type-specific queries that could be missed.- Optional: future-proof the invalidation by targeting the
['allModels']prefix at all three sites.💡 Proposed change
queryClient.invalidateQueries({ - queryKey: LlmKeys.allModels(), + queryKey: [LLMApiAction.AllModels], });🤖 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/hooks/use-llm-request.tsx` around lines 230 - 232, The current cache invalidation uses LlmKeys.allModels() which yields ['allModels', undefined] and won't match type-specific keys like ['allModels','chat']; update the invalidate call in use-llm-request.tsx to target the prefix instead — change queryClient.invalidateQueries({ queryKey: LlmKeys.allModels() }) to queryClient.invalidateQueries({ queryKey: ['allModels'] }) (or otherwise pass the bare prefix string/key) so it invalidates all ['allModels', ...] variants; locate the call by the identifiers queryClient.invalidateQueries and LlmKeys.allModels and adjust similarly where useFetchAllAddedModels is referenced.
🤖 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.
Nitpick comments:
In `@web/src/hooks/use-llm-request.tsx`:
- Around line 230-232: The current cache invalidation uses LlmKeys.allModels()
which yields ['allModels', undefined] and won't match type-specific keys like
['allModels','chat']; update the invalidate call in use-llm-request.tsx to
target the prefix instead — change queryClient.invalidateQueries({ queryKey:
LlmKeys.allModels() }) to queryClient.invalidateQueries({ queryKey:
['allModels'] }) (or otherwise pass the bare prefix string/key) so it
invalidates all ['allModels', ...] variants; locate the call by the identifiers
queryClient.invalidateQueries and LlmKeys.allModels and adjust similarly where
useFetchAllAddedModels is referenced.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 62fd85f2-b624-4764-82f9-ec44d71b29f7
📒 Files selected for processing (2)
web/src/hooks/use-llm-request.tsxweb/src/pages/user-setting/setting-model/modal/next-tencent-modal/index.tsx
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15476 +/- ##
=======================================
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:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/pages/user-setting/setting-model/modal/ollama-modal/index.tsx (1)
272-272:⚠️ Potential issue | 🟠 Major | ⚡ Quick winIncorrect array comparison for vision default value.
Line 272 compares
initialValues.model_type === 'image2text', butmodel_typeis expected to be an array (as seen on line 267 where it defaults to['chat']). This comparison will always befalsewhenmodel_typeis an array, causing the vision checkbox to not be checked correctly in edit mode.🐛 Proposed fix to check array membership
- vision: initialValues.model_type === 'image2text', + vision: Array.isArray(initialValues.model_type) + ? initialValues.model_type.includes('image2text') + : initialValues.model_type === 'image2text',🤖 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/ollama-modal/index.tsx` at line 272, The vision default is computed incorrectly by comparing initialValues.model_type to a string; update the logic for vision (the property named vision in this component) to handle model_type as an array by checking membership (e.g., use Array.isArray(initialValues.model_type) ? initialValues.model_type.includes('image2text') : initialValues.model_type === 'image2text') so the checkbox reflects edit-mode values when initialValues.model_type defaults to ['chat'] or other arrays.
🤖 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/modal/ollama-modal/index.tsx`:
- Around line 45-56: The buildModelTypesWithVision function can append a
duplicate 'image2text' when modelType already contains it; update
buildModelTypesWithVision to deduplicate before returning by ensuring
'image2text' is only added if vision is true, 'chat' is present, and
'image2text' is not already in modelTypeArray (or convert to a Set and back to
array) so the returned array has unique model types.
---
Outside diff comments:
In `@web/src/pages/user-setting/setting-model/modal/ollama-modal/index.tsx`:
- Line 272: The vision default is computed incorrectly by comparing
initialValues.model_type to a string; update the logic for vision (the property
named vision in this component) to handle model_type as an array by checking
membership (e.g., use Array.isArray(initialValues.model_type) ?
initialValues.model_type.includes('image2text') : initialValues.model_type ===
'image2text') so the checkbox reflects edit-mode values when
initialValues.model_type defaults to ['chat'] or other arrays.
🪄 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: 2e7636d5-d587-4312-b2d2-9416c182bb25
📒 Files selected for processing (1)
web/src/pages/user-setting/setting-model/modal/ollama-modal/index.tsx
| function buildModelTypesWithVision( | ||
| modelType: string[] | string, | ||
| vision = false, | ||
| ): string[] { | ||
| const modelTypeArray = Array.isArray(modelType) ? modelType : [modelType]; | ||
|
|
||
| if (modelTypeArray.includes('chat') && vision) { | ||
| return [...modelTypeArray, 'image2text']; | ||
| } | ||
|
|
||
| return modelTypeArray; | ||
| } |
There was a problem hiding this comment.
Potential duplicate 'image2text' in model_type array.
If modelType already contains 'image2text' and vision is true while 'chat' is present, the function will append a duplicate 'image2text' entry. For example: ['chat', 'image2text'] with vision=true becomes ['chat', 'image2text', 'image2text'].
🔧 Proposed fix to deduplicate model types
function buildModelTypesWithVision(
modelType: string[] | string,
vision = false,
): string[] {
const modelTypeArray = Array.isArray(modelType) ? modelType : [modelType];
if (modelTypeArray.includes('chat') && vision) {
- return [...modelTypeArray, 'image2text'];
+ const result = [...modelTypeArray, 'image2text'];
+ return [...new Set(result)];
}
return modelTypeArray;
}🤖 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/ollama-modal/index.tsx` around
lines 45 - 56, The buildModelTypesWithVision function can append a duplicate
'image2text' when modelType already contains it; update
buildModelTypesWithVision to deduplicate before returning by ensuring
'image2text' is only added if vision is true, 'chat' is present, and
'image2text' is not already in modelTypeArray (or convert to a Set and back to
array) so the returned array has unique model types.
What problem does this PR solve?
Fix: The newly added model did not appear in the drop-down menu.
Type of change