Skip to content

fix(usage-logs): show provider icons for CN models (align with classic frontend) - #5631

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
DeliciousBuding:fix/usage-logs-model-icons
Jun 21, 2026
Merged

fix(usage-logs): show provider icons for CN models (align with classic frontend)#5631
seefs001 merged 1 commit into
QuantumNous:mainfrom
DeliciousBuding:fix/usage-logs-model-icons

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Jun 20, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

Fixes the usage-logs model badge so models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek (spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi render their brand icon instead of a grey dot.

Why it works: resolveModelProvider() in web/default/src/features/usage-logs/components/model-badge.tsx maps a model name to a provider via keyword matching, then renders the @lobehub/icons glyph. It previously only covered the mainstream providers and returned null for the ones above, which triggered the grey-dot fallback. This PR adds the missing keyword→icon mappings, aligned with what the classic frontend already does in getModelCategories() (web/classic/src/helpers/render.jsx) — so the two frontends now agree. No new dependency; all icons already exist in @lobehub/icons.

Only web/default is changed (the file where the bug lives). web/classic already covers these providers, so it is left untouched to keep the diff focused.

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 已关联 Issue [Bug] Usage logs: provider icons missing for CN models (grey dot instead of brand logo) #5630
  • 变更理解: 改动是纯前端的关键字→图标映射扩展,沿用现有 resolveModelProvider 模式,无副作用。
  • 范围聚焦: 仅改动 web/default/src/features/usage-logs/components/model-badge.tsx 一个文件(+30 行)。
  • 本地验证: tsc --noEmit 通过;已在生产部署验证(usage-logs 现正确显示 Zhipu/MiniMax/XiaomiMiMo 等图标)。
  • 安全合规: 无敏感凭据,符合代码规范。

📸 运行证明 / Proof of Work

Before: usage-logs Model column showed a grey dot for glm-5.2 / minimax-m3 / mimo-v2.5-pro.

After (verified on a live deployment): the same column renders the Zhipu / MiniMax / XiaomiMiMo SVG brand icons, matching the pricing page. Icons confirmed present in the production JS bundle via <svg><title> (Zhipu, Minimax, XiaomiMiMo, …).

Summary by CodeRabbit

  • New Features
    • Added support for recognizing additional AI model providers including Minimax, Zhipu, MiMo, Baidu, iFlyTek, Tencent, Baichuan, InternLM, StepFun, and Yi. The application now properly identifies and displays these models in usage logs.

resolveModelProvider in model-badge.tsx only covered mainstream providers
(OpenAI/Claude/Gemini/Grok/DeepSeek/Qwen/Doubao/Moonshot/Mistral/Meta/Cohere).
Models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek
(spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi rendered
as grey dots instead of their brand icons in the usage logs table.

Add keyword mappings for these providers, aligning coverage with the
classic frontend's getModelCategories. Icons resolved via @lobehub/icons.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

resolveModelProvider in model-badge.tsx is extended with ten new hasAny(...) branches inserted before the existing Mistral/Meta/Cohere checks. Each branch maps model name substrings or prefixes (minimax/abab, glm-/chatglm/cogview/cogvideo, mimo-, ernie, spark, hunyuan, baichuan, internlm, step-, yi-) to the corresponding provider icon and label.

Changes

CN Provider Icon Mappings

Layer / File(s) Summary
New hasAny branches in resolveModelProvider
web/default/src/features/usage-logs/components/model-badge.tsx
Adds ten keyword-matched branches for Minimax, Zhipu, MiMo, Baidu/Wenxin, iFlyTek/Spark, Tencent/Hunyuan, Baichuan, InternLM, StepFun, and Yi, each returning an icon/label object instead of falling through to null.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

  • #5630 — This PR directly implements the fix described in the bug report: adding the missing resolveModelProvider keyword→icon mappings for the exact set of Chinese providers (Zhipu, MiniMax, MiMo, Baidu, iFlyTek, Tencent, Baichuan, InternLM, StepFun, Yi) that were rendering grey-dot placeholders in usage logs.
  • #5629 — The changes implement the suggested fix for the missing keyword→icon mappings identified in this issue for the same set of Chinese model providers.

Poem

🐇 A rabbit hopped through logs one day,
And found grey dots where icons should stay.
With minimax, ernie, glm, and spark,
No brand shall remain lost in the dark!
Hunyuan, baichuan, yi—all aligned,
Each provider badge now easy to find. ✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding provider icons for Chinese models in usage logs to align with the classic frontend implementation.
Linked Issues check ✅ Passed The PR successfully addresses issue #5630 by adding keyword-to-icon mappings for all 10 affected Chinese providers (Zhipu, MiniMax, Xiaomi MiMo, Baidu, iFlyTek, Tencent, Baichuan, InternLM, StepFun, Yi) in resolveModelProvider().
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the reported bug; only model-badge.tsx is modified with keyword-matching logic for the specified providers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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

🧹 Nitpick comments (1)
web/default/src/features/usage-logs/components/model-badge.tsx (1)

82-111: ⚡ Quick win

Consider replacing the growing if chain with a mapping table.

This block is now long and repetitive; a config-driven matcher (pattern list + provider payload) will be easier to extend and less error-prone.

As per coding guidelines, “Keep functions with low cyclomatic complexity; extract complex logic into smaller functions with meaningful variable and function names following camelCase conventions.”

🤖 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/default/src/features/usage-logs/components/model-badge.tsx` around lines
82 - 111, Replace the repetitive if-chain that checks various model patterns
(minimax, glm-, mimo-, ernie, spark, hunyuan, baichuan, internlm, step-, yi-)
with a configuration-driven mapping table. Create an array or object that maps
pattern lists to provider objects containing icon and label properties, then
iterate through this config to find the matching provider based on the model
name instead of executing multiple hasAny() conditional statements. This will
reduce cyclomatic complexity and make the code easier to maintain and extend
with new providers.

Source: Coding guidelines

🤖 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/default/src/features/usage-logs/components/model-badge.tsx`:
- Around line 91-95: The provider detection logic in model-badge.tsx uses
substring matching with hasAny() calls that can incorrectly match unrelated
model IDs containing those substrings (e.g., 'ernie' or 'spark'). Replace the
simple substring-based checks in the conditions for Baidu (hasAny(['ernie']))
and iFlyTek (hasAny(['spark'])) with boundary-aware or prefix-aware matching
that checks for these tokens as complete identifiers or at word boundaries,
ensuring only actual models from these providers are detected correctly.

---

Nitpick comments:
In `@web/default/src/features/usage-logs/components/model-badge.tsx`:
- Around line 82-111: Replace the repetitive if-chain that checks various model
patterns (minimax, glm-, mimo-, ernie, spark, hunyuan, baichuan, internlm,
step-, yi-) with a configuration-driven mapping table. Create an array or object
that maps pattern lists to provider objects containing icon and label
properties, then iterate through this config to find the matching provider based
on the model name instead of executing multiple hasAny() conditional statements.
This will reduce cyclomatic complexity and make the code easier to maintain and
extend with new providers.
🪄 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: ff665242-bff6-4f80-919f-c52b78371fba

📥 Commits

Reviewing files that changed from the base of the PR and between 5e86644 and 8f4e508.

📒 Files selected for processing (1)
  • web/default/src/features/usage-logs/components/model-badge.tsx

Comment on lines +91 to +95
if (hasAny(['ernie'])) {
return { icon: 'Wenxin.Color', label: 'Baidu' }
}
if (hasAny(['spark'])) {
return { icon: 'Spark.Color', label: 'iFlyTek' }

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

Avoid ambiguous substring matching for provider detection.

Using plain includes('ernie') / includes('spark') can misclassify unrelated model IDs that merely contain those substrings. Prefer boundary/prefix-aware checks for these tokens.

Suggested tightening
-  if (hasAny(['ernie'])) {
+  if (/\bernie(?:-|$)/.test(model)) {
     return { icon: 'Wenxin.Color', label: 'Baidu' }
   }
-  if (hasAny(['spark'])) {
+  if (/\bspark(?:-|$)/.test(model)) {
     return { icon: 'Spark.Color', label: 'iFlyTek' }
   }
🤖 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/default/src/features/usage-logs/components/model-badge.tsx` around lines
91 - 95, The provider detection logic in model-badge.tsx uses substring matching
with hasAny() calls that can incorrectly match unrelated model IDs containing
those substrings (e.g., 'ernie' or 'spark'). Replace the simple substring-based
checks in the conditions for Baidu (hasAny(['ernie'])) and iFlyTek
(hasAny(['spark'])) with boundary-aware or prefix-aware matching that checks for
these tokens as complete identifiers or at word boundaries, ensuring only actual
models from these providers are detected correctly.

@seefs001
seefs001 merged commit 1f1da55 into QuantumNous:main Jun 21, 2026
2 checks passed
@seefs001 seefs001 mentioned this pull request Jun 21, 2026
11 tasks
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
…c frontend) (QuantumNous#5631)

resolveModelProvider in model-badge.tsx only covered mainstream providers
(OpenAI/Claude/Gemini/Grok/DeepSeek/Qwen/Doubao/Moonshot/Mistral/Meta/Cohere).
Models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek
(spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi rendered
as grey dots instead of their brand icons in the usage logs table.

Add keyword mappings for these providers, aligning coverage with the
classic frontend's getModelCategories. Icons resolved via @lobehub/icons.
noah-wung pushed a commit to noah-wung/new-api that referenced this pull request Jul 17, 2026
…c frontend) (QuantumNous#5631)

resolveModelProvider in model-badge.tsx only covered mainstream providers
(OpenAI/Claude/Gemini/Grok/DeepSeek/Qwen/Doubao/Moonshot/Mistral/Meta/Cohere).
Models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek
(spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi rendered
as grey dots instead of their brand icons in the usage logs table.

Add keyword mappings for these providers, aligning coverage with the
classic frontend's getModelCategories. Icons resolved via @lobehub/icons.
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
…c frontend) (QuantumNous#5631)

resolveModelProvider in model-badge.tsx only covered mainstream providers
(OpenAI/Claude/Gemini/Grok/DeepSeek/Qwen/Doubao/Moonshot/Mistral/Meta/Cohere).
Models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek
(spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi rendered
as grey dots instead of their brand icons in the usage logs table.

Add keyword mappings for these providers, aligning coverage with the
classic frontend's getModelCategories. Icons resolved via @lobehub/icons.
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
…c frontend) (QuantumNous#5631)

resolveModelProvider in model-badge.tsx only covered mainstream providers
(OpenAI/Claude/Gemini/Grok/DeepSeek/Qwen/Doubao/Moonshot/Mistral/Meta/Cohere).
Models from Zhipu (glm-), MiniMax, Xiaomi MiMo, Baidu (ernie), iFlyTek
(spark), Tencent (hunyuan), Baichuan, InternLM, StepFun, and Yi rendered
as grey dots instead of their brand icons in the usage logs table.

Add keyword mappings for these providers, aligning coverage with the
classic frontend's getModelCategories. Icons resolved via @lobehub/icons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Usage logs: provider icons missing for CN models (grey dot instead of brand logo)

2 participants