Skip to content

Fix: The newly added model did not appear in the drop-down menu. - #15476

Merged
wangq8 merged 4 commits into
infiniflow:mainfrom
cike8899:fix-search-required
Jun 1, 2026
Merged

wangq8 merged 4 commits into
infiniflow:mainfrom
cike8899:fix-search-required

Conversation

@cike8899

@cike8899 cike8899 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Fix: The newly added model did not appear in the drop-down menu.

Type of change

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

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 1, 2026
@cike8899 cike8899 added ci Continue Integration and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 1, 2026
@dosubot dosubot Bot added the 🐞 bug Something isn't working, pull request that fix bug. label Jun 1, 2026
@cike8899
cike8899 marked this pull request as draft June 1, 2026 08:07
@cike8899
cike8899 marked this pull request as ready for review June 1, 2026 08:07
@coderabbitai

coderabbitai Bot commented Jun 1, 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: 64ad9f76-25e1-4270-947d-4b93f0b3eaeb

📥 Commits

Reviewing files that changed from the base of the PR and between 4b951a6 and aaccef7.

📒 Files selected for processing (2)
  • web/public/iconfont.js
  • web/src/components/svg-icon.tsx

📝 Walkthrough

Walkthrough

Cache invalidation for several LLM provider/model mutations now targets LlmKeys.allModels(). The Ollama modal adds buildModelTypesWithVision and uses it for defaults, submission, and verification. The Tencent modal footer renders an empty padded <div>. Icon font symbols and injection code were updated.

Changes

Model Management and Modal Adjustments

Layer / File(s) Summary
Cache invalidation strategy for LLM mutations
web/src/hooks/use-llm-request.tsx
After successful useAddProviderInstance, useAddInstanceModel, and useDeleteProviderInstance mutations, the hooks now invalidate LlmKeys.allModels() instead of prior provider-specific cache keys.
Ollama modal model_type normalization and wiring
web/src/pages/user-setting/setting-model/modal/ollama-modal/index.tsx
Introduce buildModelTypesWithVision to normalize model_type into an array and append image2text when vision + chat; use it for edit-mode defaults, handleOk submission mapping, and verifyParamsFunc verification.
Modal footer UI update
web/src/pages/user-setting/setting-model/modal/next-tencent-modal/index.tsx
The Modal footer prop renders an empty padded <div className="p-4"></div> instead of null.
Icon additions and injection tweaks
web/public/iconfont.js, web/src/components/svg-icon.tsx
Added JiekouAI and Perplexity icon symbols (bright/dark) and adjusted the generated DOM injection/closure logic; themeIcons extended to include the new LLM factories.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size:S

Poem

🐰 I hopped through keys and modal light,
I folded visions into type just right,
One query now wakes all models at dawn,
A tiny footer rests on the lawn,
Hooray—small fixes, neatly drawn.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title clearly identifies the main issue being fixed (newly added model not appearing in dropdown menu), matching the primary objective of the PR.
Description check ✅ Passed The description includes the required problem statement and bug fix type selection, matching the template structure and clearly addressing the PR purpose.
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.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 1, 2026

@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.

🧹 Nitpick comments (1)
web/src/hooks/use-llm-request.tsx (1)

230-232: ⚡ Quick win

Refine 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 no modelType argument, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 82202fa and 496de41.

📒 Files selected for processing (2)
  • web/src/hooks/use-llm-request.tsx
  • web/src/pages/user-setting/setting-model/modal/next-tencent-modal/index.tsx

@codecov

codecov Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

Codecov Report

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

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.
📢 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.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 1, 2026

@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

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 win

Incorrect array comparison for vision default value.

Line 272 compares initialValues.model_type === 'image2text', but model_type is expected to be an array (as seen on line 267 where it defaults to ['chat']). This comparison will always be false when model_type is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 496de41 and 4b951a6.

📒 Files selected for processing (1)
  • web/src/pages/user-setting/setting-model/modal/ollama-modal/index.tsx

Comment on lines +45 to +56
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;
}

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@wangq8
wangq8 merged commit f194e8b into infiniflow:main Jun 1, 2026
1 check 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants