fix(pricing): trim enable_groups to the user's usable groups - #6176
fix(pricing): trim enable_groups to the user's usable groups#6176Dashsoap wants to merge 1 commit into
Conversation
GetPricing already filters which models are returned by the user's usable groups, but each pricing item still carried the raw channel group list in enable_groups. The default theme renders that list as-is (model detail Groups section, model card badge, table column), so groups hidden from a user via UserUsableGroups or a -:group special rule were still displayed even though they could not be selected. The classic theme already intersects enable_groups with usable groups on the client. Trim enable_groups server-side to the intersection with the user's usable groups so hidden group names are no longer exposed by the API. Entries enabled for "all" groups keep their original list, and the shared pricing cache is never mutated.
|
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)
WalkthroughPricing filtering now trims each entry’s ChangesPricing group filtering
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
移植自上游 PR QuantumNous#6176(issue QuantumNous#6175)。原逻辑「有交集就整条返回」, 把用户无权使用的分组名原样带给前端分组徽章——本 fork 有团队 计价分组与代理分销分组,内部分组命名泄露面更大。改为按可用 分组求交集后重建 EnableGroup;item 是共享定价缓存的值拷贝, 赋新 slice 不会污染缓存。带 "all" 的条目保持原语义整条放行。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51fdfc5 to
2b6f1df
Compare
Important
📝 变更描述 / Description
GetPricing之前只按用户可用分组过滤返回哪些模型(#4123),但每个模型条目里的enable_groups仍是渠道原始分组列表。default 主题会在模型详情页底部「分组」栏和表格视图分组列原样渲染,导致对用户隐藏的分组名(不在UserUsableGroups、或被-:分组特殊规则移除)虽然选不了,却仍然展示了出来。本次在
filterPricingByUsableGroups里把每个条目的enable_groups裁剪为与用户可用分组的交集,这样能生效的原因是 default 主题的分组徽章、表格分组列都直接读这个字段,服务端裁剪后两个主题一起修好:all的条目保持原有列表与语义不变;enable_groups字段内容变化;item是共享定价缓存的值拷贝,写入的是新建 slice,不会改动缓存;ModelPricingTable.jsx),行为不变。按仓库贡献规范说明:本次修改在 AI 辅助下完成,我已逐行审阅代码,并在本地构建后按下方运行证明实测验证(前后端同配置对照 + 单测)。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
新增单测
controller/pricing_test.go(覆盖:交集裁剪、all保持原样、缓存不被改动、空输入):本地实测(
UserUsableGroups只有 default/vip,渠道分组default,internal):修复前——「按分组定价」只有 default,底部「分组」却显示 internal:
修复后——同一份配置与前端构建,只换后端,internal 不再展示:
/api/pricing响应对比(同一请求):Summary by CodeRabbit
Bug Fixes
Tests