fix: 三端联调测试 2 P1 + 2 P2 + 4 P3 修复

P1-07: billing get_or_create_usage 同步 max_* 列到当前计划限额
P1-08: relay handler 增加直接配额检查 (relay_requests/input/output_tokens)
P2-09: relay failover 成功后记录 tokens 并标记 completed
P2-10: Tauri agentStore saas-relay 模式下从 SaaS API 获取真实用量
P2-14: super_admin 合成 subscription + check_quota 放行
P3-19: 新建 ApiKeys.tsx 页面替代 ModelServices 路由
P3-15: antd destroyOnClose → destroyOnHidden (3处)
P3-16: ProTable onSearch → onSubmit (2处)
This commit is contained in:
iven
2026-04-14 17:48:22 +08:00
parent 45fd9fee7b
commit dd854479eb
11 changed files with 259 additions and 12 deletions

View File

@@ -591,6 +591,17 @@ pub async fn execute_relay_with_failover(
candidate.model_id
);
}
// P2-09 修复: 非 SSE 响应在 failover 成功后记录 tokens 并标记 completed
if let RelayResponse::Json(ref body) = response {
let (input_tokens, output_tokens) = extract_token_usage(body);
if input_tokens > 0 || output_tokens > 0 {
if let Err(e) = update_task_status(db, task_id, "completed",
Some(input_tokens), Some(output_tokens), None).await {
tracing::warn!("Failed to update task {} tokens after failover: {}", task_id, e);
}
}
}
// SSE 响应由 StreamBridge 后台任务处理,无需在此更新
return Ok((response, candidate.provider_id.clone(), candidate.model_id.clone()));
}
Err(SaasError::RateLimited(msg)) => {