mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-12-04 00:00:59 +00:00
fix(admin): show upstream errors and retry waits in request popovers
Localize interrupted requests, align quota badges, and update the icon picker to the responsive UI revision. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
"build:source": "vue-tsc -p tsconfig.source.json --noEmit && vite build --mode source"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#5f38c8bacd53e4669c0cfa57b961c8d97085ff9f",
|
||||
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#09de193d1f1ff785b07713e0ccea98d35ebb0222",
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||
"@lobehub/icons-vue": "1.2.0",
|
||||
|
||||
Generated
+5
-5
@@ -192,8 +192,8 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
'@codex-proxy/ui':
|
||||
specifier: github:zyycn/codex-proxy-ui#5f38c8bacd53e4669c0cfa57b961c8d97085ff9f
|
||||
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)
|
||||
specifier: github:zyycn/codex-proxy-ui#09de193d1f1ff785b07713e0ccea98d35ebb0222
|
||||
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/09de193d1f1ff785b07713e0ccea98d35ebb0222(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)
|
||||
'@fontsource-variable/inter':
|
||||
specifier: ^5.3.0
|
||||
version: 5.3.0
|
||||
@@ -451,8 +451,8 @@ packages:
|
||||
resolution: {integrity: sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==}
|
||||
engines: {node: '>= 20.12.0'}
|
||||
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f':
|
||||
resolution: {gitHosted: true, integrity: sha512-mwiaZaxYlA2MeAErOGCr5MlsLmxJSTySEA9fUErfaAFl0AZoaIsfTo+Bd6L+x8/kTL5xRIK8VVfju2MQXqNPrA==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f}
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/09de193d1f1ff785b07713e0ccea98d35ebb0222':
|
||||
resolution: {gitHosted: true, integrity: sha512-LQmVPnJgE6dHwQcKRpcJ3lS5uzyEVvugcfr4+kwbBU2VnoMcMII27oi/ukYXMUil73gvjX42OFwwCA16Y1HMyg==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/09de193d1f1ff785b07713e0ccea98d35ebb0222}
|
||||
version: 0.14.0
|
||||
engines: {node: '>=24'}
|
||||
peerDependencies:
|
||||
@@ -3559,7 +3559,7 @@ snapshots:
|
||||
fast-wrap-ansi: 0.2.2
|
||||
sisteransi: 1.0.5
|
||||
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/5f38c8bacd53e4669c0cfa57b961c8d97085ff9f(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)':
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/09de193d1f1ff785b07713e0ccea98d35ebb0222(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.4.0(@types/node@26.6.11)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.46(typescript@6.0.3))(yaml@2.9.0)':
|
||||
dependencies:
|
||||
'@ant-design/colors': 8.0.1
|
||||
'@ant-design/fast-color': 3.0.1
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import type { UsageListRecord } from '@/api'
|
||||
import type { UsageListRecord, UsageRecord } from '@/api'
|
||||
import { ZPopover, ZScrollbar } from '@codex-proxy/ui'
|
||||
import { CheckCheck, CircleHelp, Network, Server, Unplug } from '@lucide/vue'
|
||||
import { computed } from 'vue'
|
||||
import { computed, shallowRef, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { usageErrorOrigin, usageErrorSummary, usageErrorTitle } from './errors'
|
||||
import { getUsageRecordDetail } from '@/api'
|
||||
import { useRequestState } from '@/composables/useRequestState'
|
||||
import { formatDuration } from '@/utils/format'
|
||||
import { usageErrorMessage, usageErrorOrigin, usageErrorSummary, usageErrorTitle } from './errors'
|
||||
|
||||
const props = defineProps<{ record: UsageListRecord }>()
|
||||
|
||||
@@ -16,11 +19,42 @@ const originIcons = {
|
||||
}
|
||||
|
||||
const { t } = useI18n({ useScope: 'global' })
|
||||
const code = computed(() => props.record.errorCode || props.record.errorKind)
|
||||
const errorType = computed(() => props.record.errorKind || props.record.errorCode)
|
||||
const origin = computed(() => usageErrorOrigin(props.record))
|
||||
const outcome = computed(() => usageErrorTitle(props.record))
|
||||
const summary = computed(() => usageErrorSummary(props.record))
|
||||
|
||||
const popoverOpen = shallowRef(false)
|
||||
const detail = shallowRef<Pick<UsageRecord, 'message' | 'upstreamError' | 'retryAfterMs'> | null>(null)
|
||||
const request = useRequestState()
|
||||
const message = computed(() => usageErrorMessage(props.record, detail.value?.message ?? props.record.errorMessage, detail.value?.upstreamError))
|
||||
|
||||
watch([
|
||||
popoverOpen,
|
||||
() => props.record,
|
||||
], async ([open, record], [, previous]) => {
|
||||
if (record !== previous)
|
||||
detail.value = null
|
||||
if (!open) {
|
||||
request.invalidate()
|
||||
return
|
||||
}
|
||||
if (detail.value)
|
||||
return
|
||||
|
||||
const sequence = request.start()
|
||||
try {
|
||||
const { message, upstreamError, retryAfterMs } = await getUsageRecordDetail({ id: record.id }, { signal: request.signal, silent: true })
|
||||
if (request.isCurrent(sequence))
|
||||
detail.value = { message, upstreamError, retryAfterMs }
|
||||
}
|
||||
catch (cause) {
|
||||
request.fail(sequence, cause)
|
||||
}
|
||||
finally {
|
||||
request.finish(sequence)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -47,7 +81,7 @@ const summary = computed(() => usageErrorSummary(props.record))
|
||||
<CheckCheck class="size-4" :stroke-width="2.25" aria-hidden="true" />
|
||||
</span>
|
||||
</div>
|
||||
<ZPopover class="mt-1 flex!" trigger="hover-click" placement="top-start" role="tooltip">
|
||||
<ZPopover v-model="popoverOpen" class="mt-1 flex!" trigger="hover-click" placement="top-start" role="tooltip">
|
||||
<template #reference="{ id, open }">
|
||||
<button
|
||||
type="button"
|
||||
@@ -65,14 +99,21 @@ const summary = computed(() => usageErrorSummary(props.record))
|
||||
</template>
|
||||
<ZScrollbar class="w-max max-w-[min(26rem,calc(100vw-2rem))]" max-height="min(18rem, 60dvh)">
|
||||
<div class="grid gap-1 px-3 py-2 text-z-sm leading-relaxed whitespace-pre-wrap select-text wrap-anywhere" translate="no">
|
||||
<code v-if="code" class="font-mono font-emphasis">{{ code }}</code>
|
||||
<span v-if="record.errorKind && record.errorKind !== code">
|
||||
{{ t('usage.error.failureClassification') }} · <code>{{ record.errorKind }}</code>
|
||||
<span v-if="record.errorKind">
|
||||
{{ t('usage.error.failureClassification') }} · <code class="font-emphasis">{{ record.errorKind }}</code>
|
||||
</span>
|
||||
<span v-if="record.errorCode && record.errorCode !== record.errorKind">
|
||||
{{ t('usage.error.errorCode') }} · <code>{{ record.errorCode }}</code>
|
||||
</span>
|
||||
<span v-if="record.websocketCloseCode != null">
|
||||
{{ t('usage.error.websocketCloseCode') }} · <code>{{ record.websocketCloseCode }}</code>
|
||||
</span>
|
||||
<span>{{ record.errorMessage || t('usage.error.noDetails') }}</span>
|
||||
<span v-if="detail?.retryAfterMs != null">
|
||||
{{ t('usage.error.retryAfter') }} · <code>{{ formatDuration(detail.retryAfterMs) }}</code>
|
||||
</span>
|
||||
<span v-if="request.loading.value" role="status" class="text-z-xs text-z-text-secondary">{{ t('usage.request.loadingDetails') }}</span>
|
||||
<span v-else-if="request.error.value" role="status" class="text-z-xs text-z-text-secondary">{{ request.error.value }}</span>
|
||||
<span>{{ t('usage.error.errorMessage') }} · {{ message }}</span>
|
||||
</div>
|
||||
</ZScrollbar>
|
||||
</ZPopover>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UsageErrorFacts, UsageListRecord } from '@/api'
|
||||
import type { UsageErrorFacts, UsageListRecord, UsageRecord } from '@/api'
|
||||
import { t } from '@/i18n'
|
||||
|
||||
export type UsageErrorRecord = UsageErrorFacts & {
|
||||
@@ -56,6 +56,30 @@ export function usageSendStateText(state: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function gatewayErrorMessage(kind: string | null, message: string | null) {
|
||||
if (kind === 'process_interrupted') {
|
||||
if (message === 'request did not reach a terminal state')
|
||||
return t('usage.error.processInterrupted')
|
||||
if (message === 'request recovery lease is missing')
|
||||
return t('usage.error.requestTrackingLost')
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
export function usageErrorMessage(
|
||||
record: Pick<UsageRecord, 'errorKind' | 'logicalOutcome'>,
|
||||
message: string | null,
|
||||
upstream?: UsageRecord['upstreamError'],
|
||||
) {
|
||||
const original = upstream?.message || upstream?.closeReason
|
||||
if (original)
|
||||
return original
|
||||
const saved = message?.trim()
|
||||
return saved && saved !== record.logicalOutcome
|
||||
? gatewayErrorMessage(record.errorKind, saved.replace(/^OpenAI upstream failure: /, ''))
|
||||
: t('usage.error.noDetails')
|
||||
}
|
||||
|
||||
export function usageErrorSummary(record: UsageListRecord): string {
|
||||
const reason = usageErrorReason(record.errorKind) || usageErrorReason(record.errorCode)
|
||||
if (reason)
|
||||
@@ -71,7 +95,7 @@ export function usageErrorSummary(record: UsageListRecord): string {
|
||||
if (record.errorKind === 'upstream_unavailable' && upstreamClosed)
|
||||
return t('usage.error.upstreamConnectionClosed')
|
||||
|
||||
return record.errorMessage || record.errorCode || record.errorKind
|
||||
return gatewayErrorMessage(record.errorKind, record.errorMessage) || record.errorCode || record.errorKind
|
||||
|| (record.websocketCloseCode != null
|
||||
? `WS ${record.websocketCloseCode}`
|
||||
: t('usage.error.noDetails'))
|
||||
|
||||
@@ -257,6 +257,8 @@
|
||||
"error": {
|
||||
"noDetails": "No detailed error message was recorded",
|
||||
"noAvailableProvider": "No upstream provider is available for this request.",
|
||||
"processInterrupted": "The gateway did not record how the request ended",
|
||||
"requestTrackingLost": "The gateway lost track of the request before its outcome was recorded",
|
||||
"requestLimited": "Request limited",
|
||||
"upstreamCapacityUnavailable": "Upstream model is at capacity",
|
||||
"upstreamConnectionClosed": "Upstream connection closed",
|
||||
@@ -273,6 +275,7 @@
|
||||
"responseId": "Response ID",
|
||||
"clientKeyId": "Client key ID",
|
||||
"errorCode": "Error code",
|
||||
"errorMessage": "Error message",
|
||||
"failureClassification": "Failure classification",
|
||||
"duration": "Duration",
|
||||
"triggerMode": "Trigger mode",
|
||||
|
||||
@@ -257,6 +257,8 @@
|
||||
"error": {
|
||||
"noDetails": "未记录具体错误消息",
|
||||
"noAvailableProvider": "此请求没有可用的上游服务",
|
||||
"processInterrupted": "网关未记录到请求结束",
|
||||
"requestTrackingLost": "网关已失去对这次请求的跟踪,最终结果未知",
|
||||
"requestLimited": "请求受限",
|
||||
"upstreamCapacityUnavailable": "上游模型容量不足",
|
||||
"upstreamConnectionClosed": "上游连接已关闭",
|
||||
@@ -273,6 +275,7 @@
|
||||
"responseId": "响应 ID",
|
||||
"clientKeyId": "API密钥 ID",
|
||||
"errorCode": "错误码",
|
||||
"errorMessage": "错误信息",
|
||||
"failureClassification": "失败分类",
|
||||
"duration": "耗时",
|
||||
"triggerMode": "触发方式",
|
||||
|
||||
@@ -257,6 +257,8 @@
|
||||
"error": {
|
||||
"noDetails": "未記錄具體錯誤消息",
|
||||
"noAvailableProvider": "此請求沒有可用的上游服務",
|
||||
"processInterrupted": "閘道未記錄到請求結束",
|
||||
"requestTrackingLost": "閘道已失去對這次請求的追蹤,最終結果未知",
|
||||
"requestLimited": "請求受限",
|
||||
"upstreamCapacityUnavailable": "上游模型容量不足",
|
||||
"upstreamConnectionClosed": "上游連線已關閉",
|
||||
@@ -273,6 +275,7 @@
|
||||
"responseId": "響應 ID",
|
||||
"clientKeyId": "API密鑰 ID",
|
||||
"errorCode": "錯誤碼",
|
||||
"errorMessage": "錯誤訊息",
|
||||
"failureClassification": "失敗分類",
|
||||
"duration": "耗時",
|
||||
"triggerMode": "觸發方式",
|
||||
|
||||
@@ -85,7 +85,7 @@ watch(hasPersonalInfo, (available) => {
|
||||
v-if="(account.capabilities.quota || quotaEntries.length > 0 || account.upstream?.discovered) && (hasPlanBadge || lastRefreshed)"
|
||||
class="col-span-2 row-start-2 m-0 flex min-w-0 items-center gap-1.5 text-z-xs font-emphasis text-z-text-secondary"
|
||||
>
|
||||
<AccountPlanBadge v-if="hasPlanBadge" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="sm" class="shrink-0" />
|
||||
<AccountPlanBadge v-if="hasPlanBadge" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="sm" class="shrink-0 rounded-md!" />
|
||||
<span v-if="lastRefreshed" class="min-w-0 truncate">{{ lastRefreshed }}</span>
|
||||
</p>
|
||||
<div v-if="hasActions" class="col-start-2 row-start-1 flex items-center gap-0.5 [&_svg]:size-3.5 [&_svg]:stroke-2">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { UsageRecordDetail } from '@/api'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { usageErrorOrigin, usageErrorTitle } from '@/components/usage-records-table/errors'
|
||||
import { usageErrorMessage, usageErrorOrigin, usageErrorTitle } from '@/components/usage-records-table/errors'
|
||||
import { usageTransportType } from '@/components/usage-records-table/presenter'
|
||||
import { formatDuration } from '@/utils/format'
|
||||
import UsageDetailFieldGrid from './UsageDetailFieldGrid.vue'
|
||||
@@ -12,15 +12,7 @@ const props = defineProps<{ record: UsageRecordDetail }>()
|
||||
const { t } = useI18n({ useScope: 'global' })
|
||||
const origin = computed(() => usageErrorOrigin(props.record))
|
||||
const title = computed(() => usageErrorTitle(props.record))
|
||||
const errorMessage = computed(() => {
|
||||
const upstream = props.record.upstreamError
|
||||
if (upstream?.message || upstream?.closeReason)
|
||||
return upstream.message || upstream.closeReason
|
||||
const message = props.record.message.trim()
|
||||
return message && message !== props.record.logicalOutcome
|
||||
? message.replace(/^OpenAI upstream failure: /, '')
|
||||
: t('usage.error.noDetails')
|
||||
})
|
||||
const errorMessage = computed(() => usageErrorMessage(props.record, props.record.message, props.record.upstreamError))
|
||||
const errorItems = computed(() => [
|
||||
{ label: 'Code', value: props.record.upstreamError?.code ?? props.record.errorCode },
|
||||
{ label: 'Type', value: props.record.upstreamError?.errorType },
|
||||
|
||||
+1
-1
Submodule modules/ui updated: 5f38c8bacd...09de193d1f
Reference in New Issue
Block a user