feat(frontend): centralize client family labels

This commit is contained in:
RWDai
2026-05-22 15:28:19 +08:00
parent ca341703bc
commit 9633bce2e1
5 changed files with 60 additions and 34 deletions
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest'
import { formatClientFamily } from '../clientFamily'
describe('formatClientFamily', () => {
it('labels supported clients and SDKs', () => {
expect(formatClientFamily('qwen_code')).toBe('Qwen Code')
expect(formatClientFamily('roo_code')).toBe('Roo Code')
expect(formatClientFamily('kilocode')).toBe('KiloCode')
expect(formatClientFamily('cherrystudio')).toBe('Cherry Studio')
expect(formatClientFamily('openui')).toBe('OpenUI')
expect(formatClientFamily('openai_python_sdk')).toBe('OpenAI Python SDK')
expect(formatClientFamily('anthropic_js_sdk')).toBe('Anthropic JS SDK')
})
it('renders unrecognized families as unknown', () => {
expect(formatClientFamily(null)).toBe('unknown')
expect(formatClientFamily('')).toBe('unknown')
expect(formatClientFamily('custom-client')).toBe('unknown')
})
})
@@ -0,0 +1,29 @@
export function formatClientFamily(value: string | null | undefined): string {
const normalized = value?.trim().toLowerCase()
if (!normalized) return 'unknown'
if (normalized === 'codex') return 'Codex'
if (normalized === 'codex_vscode') return 'Codex VS Code'
if (normalized === 'claude_code') return 'Claude Code'
if (normalized === 'opencode') return 'OpenCode'
if (normalized === 'gemini_cli') return 'Gemini CLI'
if (normalized === 'openai_js_sdk') return 'OpenAI JS SDK'
if (normalized === 'openai_python_sdk') return 'OpenAI Python SDK'
if (normalized === 'anthropic_js_sdk') return 'Anthropic JS SDK'
if (normalized === 'anthropic_python_sdk') return 'Anthropic Python SDK'
if (normalized === 'qwen_code') return 'Qwen Code'
if (normalized === 'roo_code') return 'Roo Code'
if (normalized === 'kilocode') return 'KiloCode'
if (normalized === 'cherrystudio') return 'Cherry Studio'
if (normalized === 'openui') return 'OpenUI'
if (normalized === 'cursor') return 'Cursor'
if (normalized === 'windsurf') return 'Windsurf'
if (normalized === 'continue') return 'Continue'
if (normalized === 'cline') return 'Cline'
if (normalized === 'aider') return 'Aider'
if (normalized === 'langchain') return 'LangChain'
if (normalized === 'llamaindex') return 'LlamaIndex'
if (normalized === 'sdk') return 'SDK'
if (normalized === 'generic') return 'generic'
if (normalized === 'unknown') return 'unknown'
return 'unknown'
}