codeburn/tests/model-display-consistency-1530.test.ts
ozymandiashh 0259392a20
fix(models): name dot-form Claude minors and future GPT ids consistently (#1531)
* fix(models): name dot-form Claude minors and future GPT ids consistently (#1530)

One model id resolved to different display names per provider, and new
models showed truncated names until a hand-maintained entry landed:

- deriveClaudeShortName now accepts the dot-form minor some doors write
  on disk (GitHub Copilot's session store: claude-opus-4.8), so the name
  keeps its minor instead of truncating to "Opus 4".
- Unknown dotted-version GPT ids derive their display name (gpt-5.7-terra
  -> "GPT-5.7 Terra") the way unreleased Claude versions already do, so a
  new release needs no SHORT_NAMES entry. Legacy bare-major /
  date-packaged ids (gpt-9, gpt-4-1106-preview) stay raw, and curated
  labels keep winning.
- Pi/OMP/Copilot local display tables now match keys on segment
  boundaries via modelKeyMatches, so a bare `gpt-5` key can no longer
  capture `gpt-5.5` / `gpt-5.6-luna`; unmatched ids fall through to the
  global resolver, making one id show one name on every provider.
- The JetBrains token scan rejects a trailing dot, so `gpt-5` /
  `claude-opus-4` cannot match inside `gpt-5.6-luna` / `claude-opus-4.8`.

Fixes #1530

* fix(copilot): list the current JetBrains model ids in the token scan (#1530)

Review of #1531: the tighter #1530 boundary is right, but with no token
entries the newer ids fell through to copilot-anthropic-auto and priced
as Sonnet 4.5. Add the current dotted ids, longest first per the list's
order, so "model":"gpt-5.5", gpt-5.6-luna and claude-opus-4.8 resolve to
their own priced, correctly named rows; unknown future versions (a dot
followed by a digit) still return no token.
2026-09-28 18:48:21 +02:00

53 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { fallbackRawModelDisplayName } from '../src/models.js'
import { pi, createOmpProvider } from '../src/providers/pi.js'
import { copilot } from '../src/providers/copilot.js'
// The exact composition models-report/audit-report use: the provider's local
// table first, then the global resolver when the provider echoed the raw id.
// One model id must resolve to one display name on every provider (#1530).
function displayNameOf(provider: { modelDisplayName?: (m: string) => string }, model: string): string {
return fallbackRawModelDisplayName(provider.modelDisplayName!(model), model)
}
describe('model display name consistency across providers (#1530)', () => {
const omp = createOmpProvider()
const providers = [
{ name: 'pi', modelDisplayName: pi.modelDisplayName },
{ name: 'omp', modelDisplayName: omp.modelDisplayName },
{ name: 'copilot', modelDisplayName: copilot.modelDisplayName },
]
// The rows from the issue: copilot and pi showed "GPT-5" / "Opus 4" because
// a bare `gpt-5` key prefix-matched `gpt-5.5` / `gpt-5.6-luna`, and the
// dot-form Claude minor was dropped by the dash-only derivation.
it('shows GPT-5.5 and the GPT-5.6 variants on every provider', () => {
for (const p of providers) {
expect(displayNameOf(p, 'gpt-5.5')).toBe('GPT-5.5')
expect(displayNameOf(p, 'gpt-5.6-terra')).toBe('GPT-5.6 Terra')
expect(displayNameOf(p, 'gpt-5.6-luna')).toBe('GPT-5.6 Luna')
expect(displayNameOf(p, 'gpt-5.5')).not.toBe('GPT-5')
}
})
it('shows the Claude minor for dot-form ids on every provider', () => {
for (const p of providers) {
expect(displayNameOf(p, 'claude-opus-4.8')).toBe('Opus 4.8')
expect(displayNameOf(p, 'claude-sonnet-4.5')).toBe('Sonnet 4.5')
}
})
it('resolves one id to the same name on every provider', () => {
const ids = ['gpt-5.5', 'gpt-5.6-terra', 'gpt-5.6-luna', 'claude-opus-4.8', 'gpt-5.4-mini', 'gpt-5-mini', 'gpt-5', 'gpt-4o']
for (const id of ids) {
const names = new Set(providers.map(p => displayNameOf(p, id)))
expect([...names], id).toHaveLength(1)
}
})
it('keeps the provider-specific auto-model overrides', () => {
expect(displayNameOf(copilot, 'copilot-openai-auto')).toBe('Copilot (OpenAI auto)')
expect(displayNameOf(copilot, 'copilot-anthropic-auto')).toBe('Copilot (Anthropic auto)')
})
})