fix: retain async holds for unknown provider outcomes

This commit is contained in:
xpp committed 2026-10-21 18:57:35 +08:00
1 parent 76265845dc
commit 5be06a97c1
18 files changed
+574 -108

No files matched your search

+2 -2
View File
@@ -202,8 +202,8 @@ function formatUsagePayload(value: unknown) {
const queueGroups = computed(() => (adminSummary.value?.capacityGroups || []).map((group) => ({
...group,
type: `${group.providerName || '未知渠道'} · ${group.sourceLabel || '模型分组'}`,
status: group.running === null ? '未读取' : group.routeEnabled === false ? '已停用,仍有任务' : group.queued ? '排队中' : group.running ? '执行中' : '空闲',
warning: group.running === null || group.routeEnabled === false || !!group.queued,
status: group.reconciling ? `待核账 ${group.reconciling} 笔(额度仍冻结)` : group.running === null ? '未读取' : group.routeEnabled === false ? '已停用,仍有任务' : group.queued ? '排队中' : group.running ? '执行中' : '空闲',
warning: group.running === null || group.routeEnabled === false || !!group.queued || !!group.reconciling,
})))
const { page: capacityPage, pageSize: capacityPageSize, pagedItems: capacityPageGroups } = usePagination(queueGroups)
const configuredCapacityGroups = computed(() => adminSummary.value?.capacityGroups.filter(group => group.routeEnabled !== false) || [])
+7 -6
View File
@@ -235,6 +235,7 @@ function normalizeOverview(value: unknown): PlatformOverview {
tasks: {
queued: asNumber(rawTasks.queued),
running: asNumber(rawTasks.running),
reconciling: asNumber(rawTasks.reconciling),
succeeded: asNumber(rawTasks.succeeded),
failed: asNumber(rawTasks.failed),
},
@@ -504,6 +505,7 @@ function mapAsyncTask(task: AsyncTaskResult, model: ModelItem, taskPrompt?: stri
const statusMap: Record<AsyncTaskResult['status'], TaskStatus> = {
queued: '排队中',
running: '执行中',
reconciling: '待核账',
succeeded: '已完成',
failed: '失败',
cancelled: '失败',
@@ -516,7 +518,7 @@ function mapAsyncTask(task: AsyncTaskResult, model: ModelItem, taskPrompt?: stri
status: statusMap[task.status],
progress: task.status === 'succeeded' ? 100 : Math.round(task.progress || 0),
createdAt: createdAt ? formatTaskTime(createdAt) : '刚刚',
duration: task.completedAt ? '已完成' : '计算中',
duration: task.completedAt ? '已完成' : task.status === 'reconciling' ? '等待核账' : '计算中',
result: task.error?.message || (videoUrl ? '视频已生成' : imageUrl ? '图片已生成' : audioUrl ? '音频已生成' : modelUrl ? 'GLB 模型已生成' : resultUrl ? '文件已生成' : task.status === 'succeeded' ? '异步任务已完成' : task.status === 'running' ? `正在生成 · ${Math.round(task.progress || 0)}%` : '等待平台调度'),
provider: task.provider,
prompt: taskPrompt,
@@ -557,13 +559,11 @@ async function pollTask(taskId: string, apiKey: string) {
scheduleTaskPoll(taskId, apiKey, 2500)
} else {
taskPollers.delete(taskId)
// The async endpoint settles or releases the wallet only when the
// provider task reaches a terminal state. Refresh the overview here so
// the balance card and usage counters reflect that settlement immediately
// instead of waiting for a full page reload.
// Reconciliation stops automatic polling, but it is NOT a failure or a refund.
// Refresh financial state without encouraging another generation request.
await refreshOverview()
historyRevision.value++
emit('notify', latest.status === 'succeeded' ? `${previous.name}完成,可以查看和保存结果` : `${previous.name}未能完成,请查看错误说明`)
emit('notify', latest.status === 'reconciling' ? `${previous.name}结果尚未确认,额度仍冻结,请联系管理员核账,勿重复提交` : latest.status === 'succeeded' ? `${previous.name}完成,可以查看和保存结果` : `${previous.name}未能完成,请查看错误说明`)
}
} catch (error) {
taskPollers.delete(taskId)
@@ -1010,6 +1010,7 @@ $env:OPENAI_API_KEY="你的 MOYI 用户 API Key"
.token-limit { display: grid; gap: 8px; }
.response-result > p, .response-content { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.response-result .status-chip.failed { color: #b42318; background: #fee4e2; }
.status-chip.待核账 { color: #b54708; background: #fffaeb; }
.response-result p[role="alert"] { color: #b42318; }
.playground-selectors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.playground-selectors label { display: grid; gap: 8px; font-size: 13px; min-width: 0; }