Expose local scheduling failures in usage UI

This commit is contained in:
MMEXA
2026-05-18 16:28:37 +00:00
parent d51b44d642
commit 4317ff78b1
15 changed files with 620 additions and 24 deletions
@@ -536,15 +536,18 @@
>
<div class="flex min-w-0 items-center gap-1">
<div class="flex min-w-0 flex-col text-xs gap-0.5">
<span class="truncate">{{ record.provider }}</span>
<span
v-if="record.provider_key_name"
class="truncate"
:title="getRecordProviderTitle(record)"
>{{ getRecordProviderDisplay(record) }}</span>
<span
v-if="getRecordProviderSecondaryText(record)"
class="text-muted-foreground truncate"
:title="record.provider_key_name"
:title="getRecordProviderSecondaryTitle(record)"
>
{{ record.provider_key_name }}
{{ getRecordProviderSecondaryText(record) }}
<span
v-if="record.rate_multiplier && record.rate_multiplier !== 1.0"
v-if="record.provider_key_name && record.rate_multiplier && record.rate_multiplier !== 1.0"
class="text-foreground/60"
>({{ record.rate_multiplier }}x)</span>
</span>
@@ -938,6 +941,57 @@ function getDisplayStatus(record: UsageRecord) {
return resolveDisplayRequestStatus(record)
}
function nonEmptyDisplayString(value: string | null | undefined): string | null {
const trimmed = value?.trim()
return trimmed ? trimmed : null
}
function isUnknownProvider(value: string | null | undefined): boolean {
const normalized = value?.trim().toLowerCase()
return !normalized || ['unknown', 'unknow', 'pending'].includes(normalized)
}
function getRecordSchedulingProviderHint(record: UsageRecord): string | null {
const name = nonEmptyDisplayString(record.scheduling_failure?.provider_hint?.name)
if (name && !isUnknownProvider(name)) return name
const id = nonEmptyDisplayString(record.scheduling_failure?.provider_hint?.id)
if (id && !isUnknownProvider(id)) return id
return null
}
function getRecordProviderDisplay(record: UsageRecord): string {
const provider = nonEmptyDisplayString(record.provider)
if (provider && !isUnknownProvider(provider)) return provider
const providerHint = getRecordSchedulingProviderHint(record)
if (providerHint) return providerHint
if (record.scheduling_failure) return '未选定提供商'
return provider ?? 'unknown'
}
function getRecordProviderTitle(record: UsageRecord): string {
const schedulingMessage = nonEmptyDisplayString(record.scheduling_failure?.message)
const providerDisplay = getRecordProviderDisplay(record)
return schedulingMessage ? `${providerDisplay}\n${schedulingMessage}` : providerDisplay
}
function getRecordProviderSecondaryText(record: UsageRecord): string | null {
return nonEmptyDisplayString(record.provider_key_name)
?? nonEmptyDisplayString(record.scheduling_failure?.reason_label)
?? nonEmptyDisplayString(record.scheduling_failure?.reason_summary)
?? nonEmptyDisplayString(record.scheduling_failure?.reason)
}
function getRecordProviderSecondaryTitle(record: UsageRecord): string | undefined {
return nonEmptyDisplayString(record.provider_key_name)
?? nonEmptyDisplayString(record.scheduling_failure?.message)
?? getRecordProviderSecondaryText(record)
?? undefined
}
function getStreamModeLabel(record: UsageRecord): string {
return formatUsageStreamLabel(record)
}