[codex] improve LobeHub brand detection coverage (#464)
* Recognize more LobeHub-backed model brands so marketplace filters stop collapsing into other Metapi was leaving many models under the uncategorized bucket even though the current LobeHub icon set already contains matching provider or vendor brands. This change moves brand detection into one shared registry, expands the rules with the user-reported gaps that have real upstream icon coverage, and makes server-side brand blocking reuse the same classification result as the web UI. Constraint: Existing workspace has unrelated in-progress edits, so this commit stages only the brand-classification slice Constraint: Brand matching must stay consistent between marketplace display and server-side blocked-brand filtering Rejected: Add more ad hoc rules separately in web and server files | would keep the drift bug alive Rejected: Blindly import every LobeHub slug as a model brand | would pollute filters with tool and app brands Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep new brand additions in src/server/shared/modelBrand.ts and let web/server consume that single source of truth Tested: npm test -- src/web/components/BrandIcon.test.ts src/server/services/brandMatcher.test.ts src/web/pages/Models.marketplace-text.test.tsx src/web/components/BrandIcon.architecture.test.ts src/web/components/BrandIcon.render.test.tsx Tested: npm run typecheck Tested: npm run repo:drift-check Not-tested: Live browser verification against the user's current marketplace dataset after deployment * Preserve provider brand blocking without changing display-brand priority The first pass unified brand detection but server-side blocked-brand checks started relying on the single display brand. Mixed model paths such as `deepinfra/meta-llama/...` and `azureai/gpt-4o` still need provider markers to match global blocked brands even while the UI continues to show the preferred vendor label. Constraint: Marketplace display should keep the current preferred vendor-first brand label Constraint: Server-side blocked-brand matching must still recognize provider and vendor markers on the same model id Rejected: Reorder display-brand priority to make provider blocks pass | would regress the marketplace labels the PR was improving Rejected: Reintroduce a separate server-only matcher | would recreate the web/server drift this PR removed Confidence: high Scope-risk: narrow Reversibility: clean Directive: Use getMatchingBrandNames for blocking-style checks and reserve getBrand for single-label display surfaces Tested: npm test -- src/server/shared/modelBrand.test.ts src/server/services/brandMatcher.test.ts src/web/components/BrandIcon.test.ts src/web/pages/Models.marketplace-text.test.tsx src/web/components/BrandIcon.architecture.test.ts src/web/components/BrandIcon.render.test.tsx Tested: npm run typecheck Tested: npm run repo:drift-check Not-tested: Live GitHub review-thread auto-resolution behavior after push * Honor legacy blocked brand casing when canonicalizing global brand filters The shared brand matcher now supports multi-match provider blocking, but the blocked-brand rule parser still required exact display-case brand names. That meant imported or legacy settings like `openai` or `aws bedrock` were silently ignored even though they should map to known brands. Constraint: Existing saved settings may contain lower-case or whitespace-variant brand names from imports or older data Constraint: The server should keep emitting canonical display names after normalizing user-provided blocked brand entries Rejected: Assume the settings UI always writes canonical brand strings | does not cover imported or hand-edited configuration Rejected: Normalize only at the settings route | would still leave hydrated legacy config values ineffective in modelService Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep blocked-brand parsing tolerant of case and spacing drift, but always return canonical brand names for downstream use Tested: npm test -- src/server/services/brandMatcher.test.ts src/server/shared/modelBrand.test.ts src/web/components/BrandIcon.test.ts src/web/pages/Models.marketplace-text.test.tsx src/web/components/BrandIcon.architecture.test.ts src/web/components/BrandIcon.render.test.tsx Tested: npm run typecheck Tested: npm run repo:drift-check Not-tested: Manual settings UI round-trip with legacy lowercase globalBlockedBrands payloads
This commit is contained in:
@@ -195,6 +195,214 @@ describe('Models marketplace text', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('shows newly added provider fallback brands without losing vendor brands in the filter panel', async () => {
|
||||
apiMock.getModelsMarketplace.mockResolvedValue({
|
||||
models: [
|
||||
{
|
||||
name: 'openrouter/openrouter-auto',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 180,
|
||||
successRate: 99,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 1,
|
||||
site: '平台站 A',
|
||||
username: 'tester',
|
||||
latency: 180,
|
||||
balance: 9.9,
|
||||
tokens: [{ id: 1, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'deepinfra/meta-llama/llama-3.3-70b-instruct',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 240,
|
||||
successRate: 98,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 2,
|
||||
site: '平台站 B',
|
||||
username: 'tester',
|
||||
latency: 240,
|
||||
balance: 7.2,
|
||||
tokens: [{ id: 2, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'groq/compound-beta',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 95,
|
||||
successRate: 99,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 3,
|
||||
site: '平台站 C',
|
||||
username: 'tester',
|
||||
latency: 95,
|
||||
balance: 5.1,
|
||||
tokens: [{ id: 3, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let root!: WebTestRenderer;
|
||||
|
||||
try {
|
||||
await act(async () => {
|
||||
root = create(
|
||||
<MemoryRouter initialEntries={['/models']}>
|
||||
<ToastProvider>
|
||||
<Models />
|
||||
</ToastProvider>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
});
|
||||
await flushMicrotasks();
|
||||
|
||||
const text = collectText(root!.root);
|
||||
expect(text).toContain('OpenRouter');
|
||||
expect(text).toContain('Meta');
|
||||
expect(text).toContain('Groq');
|
||||
expect(text).not.toContain('其他未归类的模型');
|
||||
} finally {
|
||||
root?.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it('shows user-reported recognizable brands in the marketplace filter panel', async () => {
|
||||
apiMock.getModelsMarketplace.mockResolvedValue({
|
||||
models: [
|
||||
{
|
||||
name: 'xiaomi/mimo-v2-pro',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 180,
|
||||
successRate: 99,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 1,
|
||||
site: '平台站 A',
|
||||
username: 'tester',
|
||||
latency: 180,
|
||||
balance: 9.9,
|
||||
tokens: [{ id: 1, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'arcee-ai/trinity-mini',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 240,
|
||||
successRate: 98,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 2,
|
||||
site: '平台站 B',
|
||||
username: 'tester',
|
||||
latency: 240,
|
||||
balance: 7.2,
|
||||
tokens: [{ id: 2, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'amazon/nova-premier-v1',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 95,
|
||||
successRate: 99,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 3,
|
||||
site: '平台站 C',
|
||||
username: 'tester',
|
||||
latency: 95,
|
||||
balance: 5.1,
|
||||
tokens: [{ id: 3, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'LongCat-Flash-Lite',
|
||||
accountCount: 1,
|
||||
tokenCount: 1,
|
||||
avgLatency: 95,
|
||||
successRate: 99,
|
||||
description: null,
|
||||
tags: [],
|
||||
supportedEndpointTypes: [],
|
||||
pricingSources: [],
|
||||
accounts: [
|
||||
{
|
||||
id: 4,
|
||||
site: '平台站 D',
|
||||
username: 'tester',
|
||||
latency: 95,
|
||||
balance: 5.1,
|
||||
tokens: [{ id: 4, name: 'default', isDefault: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let root!: WebTestRenderer;
|
||||
|
||||
try {
|
||||
await act(async () => {
|
||||
root = create(
|
||||
<MemoryRouter initialEntries={['/models']}>
|
||||
<ToastProvider>
|
||||
<Models />
|
||||
</ToastProvider>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
});
|
||||
await flushMicrotasks();
|
||||
|
||||
const text = collectText(root!.root);
|
||||
expect(text).toContain('Xiaomi MiMo');
|
||||
expect(text).toContain('Arcee');
|
||||
expect(text).toContain('Amazon Nova');
|
||||
expect(text).toContain('LongCat');
|
||||
expect(text).not.toContain('其他未归类的模型');
|
||||
} finally {
|
||||
root?.unmount();
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps a visible mobile filter entry on small screens', async () => {
|
||||
const nextWindow = (originalWindow ? { ...originalWindow } : {}) as Window & typeof globalThis;
|
||||
nextWindow.innerWidth = 768;
|
||||
|
||||
Reference in New Issue
Block a user