fix(admin): show kinds and endpoints in the providers panel

The provider accordion reads the overview response, not the catalog, so
the earlier change never reached it. Add kinds and endpoints to the
overview provider view and group the accordion rows by kind. Endpoint ids
now read gx10/v1/decide, without a doubled slash.
This commit is contained in:
2026-11-10 12:38:33 +00:00
parent 085292143c
commit 6fb048b599
9 changed files with 212 additions and 62 deletions
+45 -22
View File
@@ -12,6 +12,8 @@ import DetailField from '@/components/DetailField.vue'
import EmptyState from '@/components/EmptyState.vue'
import EntityLink from '@/components/EntityLink.vue'
import ErrorState from '@/components/ErrorState.vue'
import { providerSections } from '@/lib/provider-sections'
import type { ProviderSection } from '@/lib/provider-sections'
import ModelChip from '@/components/ModelChip.vue'
import ProviderRateBadge from '@/components/ProviderRateBadge.vue'
import SearchInput from '@/components/SearchInput.vue'
@@ -146,6 +148,14 @@ function visibleModels(p: AdminProviderView): string[] {
return hasQuery.value ? p.models.filter((m) => modelMatches(p.name, m)) : p.models
}
function visibleSections(p: AdminProviderView): ProviderSection[] {
const sections = providerSections({ models: visibleModels(p), kinds: p.kinds, endpoints: p.endpoints })
if (!hasQuery.value) return sections.filter((s) => s.models.length > 0 || s.endpoints.length > 0)
return sections
.map((s) => ({ ...s, endpoints: s.endpoints.filter((e) => modelMatches(p.name, e)) }))
.filter((s) => s.models.length > 0 || s.endpoints.length > 0)
}
const ZERO_MODEL_RATE: AdminModelRateView = { attemptsDay: 0, failuresDay: 0 }
function modelRateFor(p: AdminProviderView, model: string): AdminModelRateView {
@@ -494,28 +504,41 @@ const aliasEmptyMessage = computed(() =>
</DetailField>
<DetailField v-if="p.lastErr" label="Last error" class="text-destructive">{{ p.lastErr }}</DetailField>
</dl>
<div v-if="visibleModels(p).length" class="flex flex-wrap gap-1.5">
<span v-for="m in visibleModels(p)" :key="m" class="inline-flex min-w-0 max-w-full items-center gap-1">
<ModelChip
:id="routableModelId(p.name, m)"
:context-tokens="modelMetaFor(p, m).contextTokens"
:input-per-m-tok-usd="modelMetaFor(p, m).inputPerMTokUsd"
:output-per-m-tok-usd="modelMetaFor(p, m).outputPerMTokUsd"
/>
<EntityLink :label="routableModelId(p.name, m)" kind="model" :id="routableModelId(p.name, m)" class="min-w-0" label-class="truncate" />
<span
v-if="modelMetaFor(p, m).contextTokens !== undefined"
title="context window"
class="text-xs text-muted-foreground tabular-nums"
>
{{ formatContextWindow(modelMetaFor(p, m).contextTokens as number) }}
</span>
<ProviderRateBadge
v-if="modelIsDegraded(p, m)"
:attempts-day="modelRateFor(p, m).attemptsDay"
:failures-day="modelRateFor(p, m).failuresDay"
/>
</span>
<div v-if="visibleSections(p).length" class="flex flex-col gap-3">
<section v-for="sec in visibleSections(p)" :key="sec.title" class="flex flex-col gap-1.5">
<h4 v-if="sec.title" class="text-xs font-medium uppercase tracking-wide text-muted-foreground">{{ sec.title }}</h4>
<div class="flex flex-wrap gap-1.5">
<span v-for="m in sec.models" :key="m" class="inline-flex min-w-0 max-w-full items-center gap-1">
<ModelChip
:id="routableModelId(p.name, m)"
:context-tokens="modelMetaFor(p, m).contextTokens"
:input-per-m-tok-usd="modelMetaFor(p, m).inputPerMTokUsd"
:output-per-m-tok-usd="modelMetaFor(p, m).outputPerMTokUsd"
/>
<EntityLink :label="routableModelId(p.name, m)" kind="model" :id="routableModelId(p.name, m)" class="min-w-0" label-class="truncate" />
<span
v-if="modelMetaFor(p, m).contextTokens !== undefined"
title="context window"
class="text-xs text-muted-foreground tabular-nums"
>
{{ formatContextWindow(modelMetaFor(p, m).contextTokens as number) }}
</span>
<ProviderRateBadge
v-if="modelIsDegraded(p, m)"
:attempts-day="modelRateFor(p, m).attemptsDay"
:failures-day="modelRateFor(p, m).failuresDay"
/>
</span>
<code
v-for="e in sec.endpoints"
:key="e"
title="native passthrough path (not a routable model)"
class="rounded bg-muted px-1.5 py-0.5 text-xs"
>
{{ p.name }}{{ e }}
</code>
</div>
</section>
</div>
<p v-else class="text-sm text-muted-foreground">no models known yet</p>
</AccordionContent>
+31
View File
@@ -0,0 +1,31 @@
import { describe, expect, it } from 'vitest'
import { providerSections } from '@/lib/provider-sections'
describe('providerSections', () => {
it('returns one untitled section when no kinds or endpoints are set', () => {
expect(providerSections({ models: ['a', 'b'] })).toEqual([{ title: '', models: ['a', 'b'], endpoints: [] }])
})
it('groups models and endpoints by kind, plain models first', () => {
const got = providerSections({
models: ['chat', 'rerank', 'embed'],
kinds: { rerank: 'reranking', embed: 'embedding', '/v1/decide': 'decision' },
endpoints: ['/v1/decide'],
})
expect(got).toEqual([
{ title: '', models: ['chat'], endpoints: [] },
{ title: 'decision', models: [], endpoints: ['/v1/decide'] },
{ title: 'embedding', models: ['embed'], endpoints: [] },
{ title: 'reranking', models: ['rerank'], endpoints: [] },
])
})
it('files an endpoint without a kind under "endpoints"', () => {
const got = providerSections({ models: ['chat'], endpoints: ['/v1/other'] })
expect(got).toEqual([
{ title: '', models: ['chat'], endpoints: [] },
{ title: 'endpoints', models: [], endpoints: ['/v1/other'] },
])
})
})
+40
View File
@@ -0,0 +1,40 @@
export interface ProviderSection {
/** Sub-section heading; '' for the untitled plain-model section. */
title: string
models: string[]
endpoints: string[]
}
export interface ProviderSectionInput {
models: string[]
kinds?: Record<string, string>
endpoints?: string[]
}
/** Heading for an endpoint with no configured kind. */
export const ENDPOINT_KIND = 'endpoints'
/**
* providerSections splits one provider's rows into sub-sections by kind:
* the plain (no-kind) models first, then one section per kind, sorted.
* A provider with no kinds and no endpoints yields one untitled section,
* so an unconfigured provider renders exactly as the flat list did.
*/
export function providerSections(p: ProviderSectionInput): ProviderSection[] {
const kinds = p.kinds ?? {}
const endpoints = p.endpoints ?? []
if (endpoints.length === 0 && Object.keys(kinds).length === 0) return [{ title: '', models: p.models, endpoints: [] }]
const byTitle = new Map<string, ProviderSection>()
const section = (title: string): ProviderSection => {
let s = byTitle.get(title)
if (!s) {
s = { title, models: [], endpoints: [] }
byTitle.set(title, s)
}
return s
}
for (const m of p.models) section(kinds[m] ?? '').models.push(m)
for (const e of endpoints) section(kinds[e] ?? ENDPOINT_KIND).endpoints.push(e)
return [...byTitle.values()].sort((a, b) => (a.title === '' ? -1 : b.title === '' ? 1 : a.title.localeCompare(b.title)))
}
+4
View File
@@ -89,6 +89,10 @@ export interface AdminProviderView {
lastErr?: string
/** Sorted explicit∪discovered model ids (admin.go: adminProviderView.Models) — always an array, never omitted, even when empty. */
models: string[]
/** Display labels from the provider's `kinds` config, keyed by model id or endpoint path (admin.go: adminProviderView.Kinds). */
kinds?: Record<string, string>
/** pathBaseUrls keys (admin.go: adminProviderView.Endpoints) — display-only rows, not routable models. */
endpoints?: string[]
modelCount: number
/**
* Resolved metadata (context window, per-token cost — feature v0.23)