Mirror: fix: Improve Kimi model search and add fallback models (#5704)#15
Mirror: fix: Improve Kimi model search and add fallback models (#5704)#15jeremylongshore merged 3 commits intomainfrom
Conversation
Make model search case-insensitive so users can find models regardless of casing.
For example, searching for "kimi k2.5" will now find models like "Kimi-K2.5-Instruct".
Changes:
- Add custom filtering with toLowerCase() for case-insensitive search
- Disable default Command filtering with shouldFilter={false}
- Use filtered model lists for displaying results
Fixes Kilo-Org#5694
Fixes Kimi model search in OpenAI Compatible provider by: 1. Search normalization - Model search now normalizes dashes, spaces, and underscores for fuzzy matching: - matches - matches 2. Kimi fallback models - Kimi models are now included as fallback when using OpenAI Compatible with Kimi endpoints: - Detects Kimi endpoints (kimi, moonshot, api.moonshot.ai/cn) - Always includes all Kimi models even if API fetch fails - Uses as default model for Kimi endpoints
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
Summary of ChangesHello @jeremylongshore, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the user experience for selecting AI models by making the model search functionality more robust and intelligent. It addresses issues with case-sensitive searches and ensures that relevant Kimi/Moonshot models are readily available when their respective API endpoints are configured, streamlining the process of finding and utilizing diverse AI models. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Review Summary by QodoImprove model search and add Kimi fallback support
WalkthroughsDescription• Implement case-insensitive model search with dash/space normalization • Add Kimi/Moonshot models as fallback for OpenAI Compatible provider • Detect Kimi endpoints and use appropriate default model • Improve model discoverability across different casing conventions Diagramflowchart LR
A["ModelPicker Component"] -->|"normalize search"| B["Case-insensitive Filtering"]
B -->|"filter results"| C["Filtered Model Lists"]
D["OpenAI Compatible Provider"] -->|"detect endpoint"| E["Kimi Endpoint Check"]
E -->|"if Kimi"| F["Include Moonshot Models"]
E -->|"set default"| G["Use Moonshot Default Model"]
F -->|"merge with"| H["Final Models List"]
File Changes1. .changeset/fix-case-insensitive-model-search.md
|
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Code Review
This pull request introduces two main improvements: case-insensitive model searching in the ModelPicker and fallback support for Kimi/Moonshot models in the OpenAICompatible provider. The changes are well-implemented. I've provided a couple of suggestions to improve performance and code clarity.
In ModelPicker.tsx, I've suggested an optimization for the search functionality to prevent unnecessary re-renders and to reduce code duplication.
In OpenAICompatible.tsx, I've pointed out a small redundancy in the logic for detecting Kimi endpoints which can be simplified.
Overall, these are good enhancements that will improve the user experience.
| const normalizeForSearch = (str: string) => str.toLowerCase().replace(/[-_\s]/g, "") | ||
|
|
||
| const filteredPreferredIds = useMemo(() => { | ||
| if (!searchValue.trim()) return preferredModelIds | ||
| const searchNormalized = normalizeForSearch(searchValue) | ||
| return preferredModelIds.filter((id) => normalizeForSearch(id).includes(searchNormalized)) | ||
| }, [preferredModelIds, searchValue]) | ||
|
|
||
| const filteredRestIds = useMemo(() => { | ||
| if (!searchValue.trim()) return restModelIds | ||
| const searchNormalized = normalizeForSearch(searchValue) | ||
| return restModelIds.filter((id) => normalizeForSearch(id).includes(searchNormalized)) | ||
| }, [restModelIds, searchValue]) |
There was a problem hiding this comment.
The normalizeForSearch function is redefined on every render, which causes the useMemo hooks to re-evaluate unnecessarily. This negates the performance benefits of memoization. Additionally, the filtering logic for preferredModelIds and restModelIds is duplicated.
To improve performance and maintainability, you should:
- Wrap
normalizeForSearchinuseCallbackto ensure it's stable across renders. - Combine the two
useMemohooks into a single one to avoid code duplication.
const normalizeForSearch = useCallback((str: string) => str.toLowerCase().replace(/[-_\s]/g, ""), [])
const { filteredPreferredIds, filteredRestIds } = useMemo(() => {
if (!searchValue.trim()) {
return { filteredPreferredIds: preferredModelIds, filteredRestIds: restModelIds }
}
const searchNormalized = normalizeForSearch(searchValue)
const filterModels = (ids: string[]) =>
ids.filter((id) => normalizeForSearch(id).includes(searchNormalized))
return {
filteredPreferredIds: filterModels(preferredModelIds),
filteredRestIds: filterModels(restModelIds),
}
}, [preferredModelIds, restModelIds, searchValue, normalizeForSearch])
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("api.moonshot.ai") || | ||
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("api.moonshot.cn") |
Code Review by Qodo
1. ModelPicker search untested
|
| // kilocode_change: Case-insensitive search with dash/space normalization | ||
| const normalizeForSearch = (str: string) => str.toLowerCase().replace(/[-_\s]/g, "") | ||
|
|
||
| const filteredPreferredIds = useMemo(() => { | ||
| if (!searchValue.trim()) return preferredModelIds | ||
| const searchNormalized = normalizeForSearch(searchValue) | ||
| return preferredModelIds.filter((id) => normalizeForSearch(id).includes(searchNormalized)) | ||
| }, [preferredModelIds, searchValue]) | ||
|
|
||
| const filteredRestIds = useMemo(() => { | ||
| if (!searchValue.trim()) return restModelIds | ||
| const searchNormalized = normalizeForSearch(searchValue) | ||
| return restModelIds.filter((id) => normalizeForSearch(id).includes(searchNormalized)) | ||
| }, [restModelIds, searchValue]) |
There was a problem hiding this comment.
1. modelpicker search untested 📘 Rule violation ⛯ Reliability
The PR changes ModelPicker search behavior to be case-insensitive and normalize dashes/spaces, but there are no updated/additional tests asserting the new matching behavior. This risks regressions where searches may not return expected models across different casing/formatting.
Agent Prompt
## Issue description
`ModelPicker` search behavior was changed to be case-insensitive and to normalize separators, but there is no corresponding test coverage validating the new search filtering outcomes.
## Issue Context
The PR introduces `normalizeForSearch()` and uses it to filter both preferred and rest model IDs, which is a behavior change that should be covered to prevent regressions.
## Fix Focus Areas
- webview-ui/src/components/settings/ModelPicker.tsx[101-114]
- webview-ui/src/components/settings/__tests__/ModelPicker.spec.tsx[74-151]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const isKimiEndpoint = | ||
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("kimi") || | ||
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("moonshot") || | ||
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("api.moonshot.ai") || | ||
| apiConfiguration.openAiBaseUrl?.toLowerCase().includes("api.moonshot.cn") | ||
|
|
||
| const modelsToUse = useMemo(() => { | ||
| const fetchedModels = openAiModels ?? {} | ||
| if (isKimiEndpoint) { | ||
| return { ...moonshotModels, ...fetchedModels } | ||
| } | ||
| return fetchedModels | ||
| }, [isKimiEndpoint, openAiModels]) | ||
|
|
||
| const defaultModelId = isKimiEndpoint ? moonshotDefaultModelId : "gpt-4o" | ||
|
|
There was a problem hiding this comment.
2. Kimi fallback untested 📘 Rule violation ⛯ Reliability
The PR adds Kimi endpoint detection and fallback model/default model selection for OpenAICompatible, but existing tests do not validate the new defaultModelId/models behavior passed to ModelPicker. This can break provider configuration silently if endpoint detection or merging logic changes.
Agent Prompt
## Issue description
`OpenAICompatible` now conditionally merges `moonshotModels` and changes `defaultModelId` when the base URL indicates a Kimi/Moonshot endpoint, but tests do not cover this new behavior.
## Issue Context
The component computes `isKimiEndpoint`, builds `modelsToUse`, and sets `defaultModelId` based on that flag. These changes should be validated in Vitest to prevent regressions.
## Fix Focus Areas
- webview-ui/src/components/settings/providers/OpenAICompatible.tsx[53-68]
- webview-ui/src/components/settings/providers/__tests__/OpenAICompatible.spec.tsx[88-160]গুলো
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| {filteredPreferredIds.length > 0 && ( | ||
| <CommandGroup | ||
| heading={ | ||
| searchValue.trim() | ||
| ? t("settings:modelPicker.matchingModels") | ||
| : t("settings:modelPicker.recommendedModels") | ||
| }> |
There was a problem hiding this comment.
3. Missing i18n key 🐞 Bug ✓ Correctness
ModelPicker now references the translation key settings:modelPicker.matchingModels, but it is not defined in locale files (at least en), so the UI will likely show the raw key string when searching.
Agent Prompt
### Issue description
ModelPicker renders `t("settings:modelPicker.matchingModels")` while searching, but that key is missing from locale JSON files, causing untranslated/raw-key UI text.
### Issue Context
The new label is used when `searchValue.trim()` is truthy.
### Fix Focus Areas
- webview-ui/src/components/settings/ModelPicker.tsx[225-231]
- webview-ui/src/i18n/locales/en/settings.json[1107-1116]
- webview-ui/src/i18n/locales/*/settings.json (add `modelPicker.matchingModels`)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Review Summary
Checklist
Findings1. Missing i18n key
|
| Test | Command | Result | Details |
|---|---|---|---|
| TypeScript | pnpm check-types |
PASS | 22/22 packages |
| Lint | pnpm lint |
PASS | 18/18 packages |
| Unit Tests | pnpm test --continue |
PASS | 7,831 tests, 0 failures |
Tested on fork branch
review/PR-5704
CI Status
| Check | Result |
|---|---|
| Upstream CI | PASS (11/11 — all checks green) |
| Fork CI | PR #15 |
| Local verification | PASS (7,831 tests, 0 failures) |
Code Analysis
Search normalization (ModelPicker.tsx)
The core improvement — normalizeForSearch strips dashes, underscores, and spaces, then lowercases. This means:
"kimi k2.5"matches"kimi-k2.5"(space → dash normalization)"KimiK2"matches"kimi-k2-thinking"(case + dash normalization)"gpt 4o"matches"gpt-4o"(general improvement)
The PR disables the built-in Command component's shouldFilter={false} and implements custom filtering via useMemo. This is the correct approach — the built-in filter doesn't support normalization.
Kimi fallback (OpenAICompatible.tsx)
Detects Kimi/Moonshot endpoints by URL substring matching, then:
- Merges
moonshotModelsas fallback (spread beforefetchedModelsso fetched models take precedence) - Sets
moonshotDefaultModelIdinstead of"gpt-4o"as the default
The key prop on ModelPicker forces a re-render when the base URL changes or endpoint type changes, preventing stale model lists.
Verdict
REQUEST_CHANGES — The search normalization and Kimi fallback logic are both correct and well-implemented. All existing tests pass. However, the missing matchingModels i18n key is a user-visible bug — the model picker heading will show a raw translation key when searching. Once the locale key is added, this is a clean approval.
Review Journal: kilocode Kilo-Org#5704
SummaryTwo related UX improvements: case-insensitive model search with dash/space normalization in What ChangedFour files, 64 additions, 10 deletions. Two distinct improvements: Search normalization ( Kimi fallback ( Two changesets included — one for AnalysisThe search normalization is the kind of small UX fix that has outsized impact. Model IDs in the AI provider ecosystem use every delimiter convention — The Kimi fallback addresses a real pain point: if the API fetch fails (network issues, auth problems), users see zero models. By merging Gemini flagged The i18n bug is the one real issue. The PR adds VerificationRegression (existing tests)
Pre-existing failures (not from this PR)
Bot Review Synthesis
Qodo caught the missing i18n key — the most impactful finding. Gemini's endpoint redundancy flag is correct but cosmetic. Both bots flagged missing tests, which is fair for a tier 3 PR but not unusual for UI fixes in this codebase. Lessons Learned
Review #22 of 75 | Multi-AI analysis | Methodology |
Mirror of Kilo-Org#5704
This PR mirrors the upstream change for multi-AI review analysis.
Bot Review Tracker