Conversation
修复: - 将分组过滤提前到所有过滤步骤之前(Step 1) - 被分组排除的供应商不再记录到 filteredProviders - totalProviders 和 enabledProviders 只统计用户可见的供应商 - 保持原有全局扫描逻辑(用户未配置分组时可见所有供应商) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @Hwwwww-dev, 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! 此拉取请求通过将基于分组的供应商过滤逻辑前置,显著优化了供应商选择流程。核心目标是确保用户仅能访问其所属分组中明确指定的供应商,从而增强了系统的安全性和相关性。通过在初始阶段执行分组过滤,系统能够更准确地反映用户实际可用的供应商集合,简化了后续的过滤步骤,并避免了处理不相关的供应商。 Highlights
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
|
| const groups = effectiveGroupPick | ||
| .split(",") | ||
| .map((g) => g.trim()) | ||
| .filter(Boolean); | ||
|
|
||
| const groupFiltered = allProviders.filter((p) => { | ||
| if (!p.groupTag) return false; | ||
| const providerTags = p.groupTag | ||
| .split(",") | ||
| .map((tag) => tag.trim()) | ||
| .filter(Boolean); | ||
| return providerTags.some((tag) => groups.includes(tag)); | ||
| }); |
There was a problem hiding this comment.
这部分代码中,处理逗号分隔标签的逻辑(split, map, filter)在两个地方重复了。为了提高代码的可维护性和复用性,建议将此逻辑提取到一个辅助函数中。
const parseTags = (tags: string): string[] => {
return tags.split(",").map((t) => t.trim()).filter(Boolean);
};
const groups = parseTags(effectiveGroupPick);
const groupFiltered = allProviders.filter((p) => {
if (!p.groupTag) return false;
const providerTags = parseTags(p.groupTag);
return providerTags.some((tag) => groups.includes(tag));
});There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR. The changes correctly move group filtering to be a pre-filter step (Step 1), ensuring that users only see providers within their assigned groups. The logic changes are well-structured and the implementation achieves the stated goal of provider group visibility isolation.
PR Size: S
- Lines changed: 151 (77 additions, 74 deletions)
- Files changed: 1
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - No tests for ProxyProviderResolver (pre-existing)
- Code clarity - Good
Notes
- The refactoring correctly ensures
visibleProvidersis used consistently after group pre-filtering - Error handling properly returns null with appropriate context when user's group has no providers
- Step numbering was appropriately updated to reflect the new order (Steps 1-6)
- Logging maintains consistency with the new filtering approach
Automated review by Claude AI
Summary
Optimizes the provider group filtering logic to ensure providers outside the user's configured groups are completely hidden from view, making the decision context cleaner and more accurate for debugging and monitoring.
Problem
After the key-level provider group feature was implemented (#281, #296), providers outside the user's group were still being recorded in the
filteredProviderslist (decision chain logs). This caused:totalProvidersandenabledProviderscounts included providers the user shouldn't seeRelated Issues:
Solution
Move group filtering to Step 1 (before all other filtering steps), treating it as a "silent pre-filter" that:
visibleProviderssubset fromallProvidersbased on user/key group configurationtotalProviders/enabledProvidersnow reflect only user-visible countsfilteredProvidersFiltering order change:
Backward compatible: Users without configured groups still see all providers (global scan behavior preserved).
Changes
Core Changes
src/app/v1/_lib/proxy/provider-selector.ts: Restructured filtering pipelinevisibleProvidersinstead ofallProvidersBehavior Changes
Testing
Manual Testing
totalProvidersonly counts "group-a" providersfilteredProvidersdoesn't include "group-b" providersEdge Cases
Checklist
Description enhanced by Claude AI