mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-27 08:01:04 +00:00
fix(antigravity): display the subscription description from Google (#781)
* fix(antigravity): show subscription tier labels Co-authored-by: OpenAI <support@openai.com> * fix(accounts): keep model IDs visible on one line Co-authored-by: OpenAI <support@openai.com> * fix(accounts): separate tunnel latency from the address Co-authored-by: OpenAI <support@openai.com> * fix(antigravity): display the subscription description from Google Align account plan labels with Antigravity Desktop and preserve raw tier IDs for scheduling. Keep the existing model column and tunnel field layouts. Co-authored-by: Codex <noreply@openai.com> --------- Co-authored-by: OpenAI <support@openai.com> Co-authored-by: Zyy <zyycn@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
OpenAI
Codex
Zyy
parent
8c36215899
commit
f46b2be957
@@ -894,6 +894,8 @@ pub struct ProviderQuota {
|
||||
pub upstream: Option<super::upstream_info::ProviderUpstreamInfo>,
|
||||
/// 上游额度响应明确提供的套餐,可用于补全账号展示
|
||||
pub plan_type: Option<String>,
|
||||
/// 与同一观测中的套餐配套的展示文本
|
||||
pub plan_type_display: Option<String>,
|
||||
pub observed_at: Option<DateTime<Utc>>,
|
||||
pub refresh_token_expires_at: Option<DateTime<Utc>>,
|
||||
pub windows: Vec<ProviderQuotaWindow>,
|
||||
|
||||
@@ -280,9 +280,9 @@ pub trait ProviderAdmin: Send + Sync {
|
||||
Ok(update.map_or_else(|| current.cloned(), Clone::clone))
|
||||
}
|
||||
|
||||
/// 提供最终套餐展示名称;未覆盖时采用通用的大驼峰格式
|
||||
fn plan_type_display(&self, plan_type: &str) -> String {
|
||||
default_plan_type_display(plan_type)
|
||||
/// 仅根据 ID 能确定的展示名称;依赖上游描述的 Provider 返回空值
|
||||
fn plan_type_display(&self, plan_type: &str) -> Option<String> {
|
||||
Some(default_plan_type_display(plan_type))
|
||||
}
|
||||
|
||||
/// 账号已经由控制面提交为不可调度状态,释放 Provider 持有的账号级运行时资源
|
||||
@@ -560,6 +560,13 @@ impl ProviderAdminRegistry {
|
||||
) -> Option<String> {
|
||||
if let Some(quota) = quota {
|
||||
quota.fill_missing_plan_type(plan_type);
|
||||
// 保留账号已知的套餐,不能给它配上另一档快照的描述
|
||||
let quota_id = explicit_plan_type(quota.plan_type.as_deref()).map(str::trim);
|
||||
if let Some(display) = "a.plan_type_display
|
||||
&& quota_id.is_none_or(|id| Some(id) == plan_type.as_deref().map(str::trim))
|
||||
{
|
||||
return Some(display.clone());
|
||||
}
|
||||
}
|
||||
self.plan_type_display(provider_kind, plan_type.as_deref())
|
||||
}
|
||||
@@ -574,10 +581,10 @@ impl ProviderAdminRegistry {
|
||||
let provider = ProviderKind::new(provider_kind.to_owned())
|
||||
.ok()
|
||||
.and_then(|kind| self.require(&kind).ok());
|
||||
Some(provider.map_or_else(
|
||||
|| default_plan_type_display(plan_type),
|
||||
provider.map_or_else(
|
||||
|| Some(default_plan_type_display(plan_type)),
|
||||
|provider| provider.plan_type_display(plan_type),
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
/// 返回所有已注册 Provider 的 Dashboard 上游身份画像
|
||||
|
||||
@@ -128,11 +128,6 @@ impl DefaultObservabilityService {
|
||||
.await;
|
||||
self.enrich_dashboard_quotas(&mut observation.account_usage)
|
||||
.await;
|
||||
for account in &mut observation.account_usage {
|
||||
account.plan_type_display = self
|
||||
.providers
|
||||
.plan_type_display(&account.provider_kind, account.plan_type.as_deref());
|
||||
}
|
||||
let today = dashboard_period_metrics(
|
||||
observation
|
||||
.trend
|
||||
@@ -513,8 +508,12 @@ impl DefaultObservabilityService {
|
||||
});
|
||||
let quotas = futures::future::join_all(quota_reads).await;
|
||||
for (account, quota) in accounts.iter_mut().zip(quotas) {
|
||||
account.plan_type_display = self.providers.resolve_account_plan(
|
||||
&account.provider_kind,
|
||||
&mut account.plan_type,
|
||||
quota.as_ref(),
|
||||
);
|
||||
if let Some(mut quota) = quota {
|
||||
quota.fill_missing_plan_type(&mut account.plan_type);
|
||||
quota.apply_limit_reached_display();
|
||||
account.quota_used_percent = quota.representative_used_percent();
|
||||
account.quota_window = quota.representative_window().cloned();
|
||||
|
||||
@@ -217,6 +217,7 @@ impl PeerInfoService {
|
||||
paused_windows: Vec::new(),
|
||||
upstream: Some(info),
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at,
|
||||
refresh_token_expires_at: None,
|
||||
windows,
|
||||
|
||||
@@ -18,8 +18,7 @@ use super::{map_store_error, publish_committed};
|
||||
use crate::{
|
||||
model::{
|
||||
AdminError, AdminErrorKind, MutationContext, Revision,
|
||||
provider_credentials::{ProviderQuotaRequest, explicit_plan_type},
|
||||
proxies::*,
|
||||
provider_credentials::ProviderQuotaRequest, proxies::*,
|
||||
},
|
||||
ports::{
|
||||
provider::ProviderAdminRegistry,
|
||||
@@ -267,8 +266,9 @@ impl ProxiesService for DefaultProxiesService {
|
||||
.map_err(|error| map_store_error(error, "proxy"))?;
|
||||
page.items = stream::iter(page.items)
|
||||
.map(|mut account| async {
|
||||
// 与账号目录一致,缺失套餐时读取已有额度快照;限制并发且不触发上游刷新
|
||||
let mut cached_quota = None;
|
||||
account.plan_type_display = self
|
||||
.providers
|
||||
.plan_type_display(&account.provider_kind, account.plan_type.as_deref());
|
||||
if let Ok(kind) = ProviderKind::new(account.provider_kind.clone())
|
||||
&& let Ok(provider) = self.providers.require(&kind)
|
||||
&& let Ok(account_id) = ProviderAccountId::new(account.id.clone())
|
||||
@@ -283,8 +283,8 @@ impl ProxiesService for DefaultProxiesService {
|
||||
.flatten()
|
||||
.and_then(|quota| quota.upstream);
|
||||
}
|
||||
if explicit_plan_type(account.plan_type.as_deref()).is_none() {
|
||||
cached_quota = provider
|
||||
if account.plan_type_display.is_none() {
|
||||
let cached_quota = provider
|
||||
.quota(ProviderQuotaRequest {
|
||||
account_id,
|
||||
refresh: false,
|
||||
@@ -292,13 +292,13 @@ impl ProxiesService for DefaultProxiesService {
|
||||
})
|
||||
.await
|
||||
.ok();
|
||||
account.plan_type_display = self.providers.resolve_account_plan(
|
||||
&account.provider_kind,
|
||||
&mut account.plan_type,
|
||||
cached_quota.as_ref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
account.plan_type_display = self.providers.resolve_account_plan(
|
||||
&account.provider_kind,
|
||||
&mut account.plan_type,
|
||||
cached_quota.as_ref(),
|
||||
);
|
||||
account
|
||||
})
|
||||
.buffered(8)
|
||||
|
||||
@@ -110,6 +110,7 @@ fn representative_quota_should_prefer_short_window_and_highest_usage() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![
|
||||
@@ -134,6 +135,7 @@ fn representative_quota_should_prefer_account_wide_window_over_model_specific_wi
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![
|
||||
@@ -154,6 +156,7 @@ fn account_exhaustion_preserves_measured_and_unknown_window_usage() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![
|
||||
@@ -184,6 +187,7 @@ fn exhausted_quota_should_preserve_the_provider_identified_reached_window() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![reached, quota_window("shortTerm", Some(18_000), Some(95.0))],
|
||||
|
||||
@@ -120,6 +120,7 @@ fn usage_quota(windows: Vec<ProviderQuotaWindow>) -> ProviderQuota {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows,
|
||||
@@ -173,6 +174,7 @@ fn dashboard_quota_should_preserve_unknown_and_actual_window_facts() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: Vec::new(),
|
||||
|
||||
@@ -63,6 +63,7 @@ fn quota(windows: Vec<ProviderQuotaWindow>) -> ProviderQuota {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows,
|
||||
|
||||
@@ -330,13 +330,16 @@ impl ProviderAdmin for FakeProviderAdmin {
|
||||
.map_err(ProviderAdminError::new)
|
||||
}
|
||||
|
||||
fn plan_type_display(&self, plan_type: &str) -> String {
|
||||
match plan_type {
|
||||
fn plan_type_display(&self, plan_type: &str) -> Option<String> {
|
||||
if self.kind.as_str() == "antigravity" {
|
||||
return None;
|
||||
}
|
||||
Some(match plan_type {
|
||||
"prolite" => "ProLite".to_owned(),
|
||||
"pro" => "Pro".to_owned(),
|
||||
"promax" => "ProMax".to_owned(),
|
||||
_ => format!("{} display: {plan_type}", self.kind),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn account_unavailable(&self, _: &ProviderAccountId) {
|
||||
@@ -2067,23 +2070,18 @@ async fn accounts_list_should_return_complete_directory_semantics() {
|
||||
#[tokio::test]
|
||||
async fn accounts_should_fill_missing_plan_from_quota_without_overriding_known_subtypes() {
|
||||
for (stored_plan, quota_plan, expected, expected_display) in [
|
||||
(
|
||||
None,
|
||||
Some("free"),
|
||||
Some("free"),
|
||||
Some("openai display: free"),
|
||||
),
|
||||
(None, Some("free"), Some("free"), Some("Plan from quota")),
|
||||
(
|
||||
Some(" "),
|
||||
Some("free"),
|
||||
Some("free"),
|
||||
Some("openai display: free"),
|
||||
Some("Plan from quota"),
|
||||
),
|
||||
(
|
||||
Some("unknown"),
|
||||
Some("free"),
|
||||
Some("free"),
|
||||
Some("openai display: free"),
|
||||
Some("Plan from quota"),
|
||||
),
|
||||
(
|
||||
Some("self_serve_business_prolite"),
|
||||
@@ -2100,6 +2098,7 @@ async fn accounts_should_fill_missing_plan_from_quota_without_overriding_known_s
|
||||
provider.set_quota(ProviderQuota {
|
||||
upstream: None,
|
||||
plan_type: quota_plan.map(str::to_owned),
|
||||
plan_type_display: quota_plan.map(|_| "Plan from quota".to_owned()),
|
||||
..empty_quota()
|
||||
});
|
||||
let mut stored = account_record("openai");
|
||||
@@ -2146,6 +2145,7 @@ async fn accounts_list_should_degrade_quota_failure_to_empty_window_without_drop
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(Utc::now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
@@ -2307,6 +2307,7 @@ async fn accounts_list_should_not_derive_rate_limited_from_provider_quota_view()
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(Utc::now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
@@ -2359,6 +2360,7 @@ async fn accounts_list_should_not_derive_exhaustion_from_provider_quota_view() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(Utc::now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
@@ -3124,6 +3126,7 @@ async fn accounts_list_should_attach_local_usage_to_quota_windows() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(Utc::now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
@@ -3289,6 +3292,7 @@ async fn account_windows_attach_only_the_usage_allowed_by_the_provider() {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: Some(Utc::now()),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![
|
||||
@@ -3611,6 +3615,7 @@ fn empty_quota() -> ProviderQuota {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: Vec::new(),
|
||||
|
||||
@@ -273,18 +273,56 @@ async fn linked_accounts_share_plan_resolution_and_only_read_cached_quota() {
|
||||
use gateway_admin::model::{PageSize, provider_credentials::ProviderQuota};
|
||||
use std::sync::Arc;
|
||||
|
||||
for (stored, cached, expected) in [
|
||||
(None, Some("free"), Some("free")),
|
||||
(Some("unknown"), Some("free"), Some("free")),
|
||||
(Some("plus"), Some("free"), Some("plus")),
|
||||
(None, None, None),
|
||||
for (kind, stored, cached, description, expected, display) in [
|
||||
(
|
||||
"openai",
|
||||
None,
|
||||
Some("free"),
|
||||
None,
|
||||
Some("free"),
|
||||
Some("openai display: free"),
|
||||
),
|
||||
(
|
||||
"openai",
|
||||
Some("unknown"),
|
||||
Some("free"),
|
||||
None,
|
||||
Some("free"),
|
||||
Some("openai display: free"),
|
||||
),
|
||||
(
|
||||
"openai",
|
||||
Some("plus"),
|
||||
Some("free"),
|
||||
None,
|
||||
Some("plus"),
|
||||
Some("openai display: plus"),
|
||||
),
|
||||
("openai", None, None, None, None, None),
|
||||
(
|
||||
"antigravity",
|
||||
Some("g1-ultra-tier"),
|
||||
Some("g1-ultra-tier"),
|
||||
Some("Ultra subscription"),
|
||||
Some("g1-ultra-tier"),
|
||||
Some("Ultra subscription"),
|
||||
),
|
||||
(
|
||||
"antigravity",
|
||||
None,
|
||||
None,
|
||||
Some("Subscription without an ID"),
|
||||
None,
|
||||
Some("Subscription without an ID"),
|
||||
),
|
||||
] {
|
||||
let provider = FakeProviderAdmin::new("openai", events());
|
||||
let provider = FakeProviderAdmin::new(kind, events());
|
||||
provider.set_quota(ProviderQuota {
|
||||
paused_windows: Vec::new(),
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: cached.map(str::to_owned),
|
||||
plan_type_display: description.map(str::to_owned),
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![],
|
||||
@@ -299,7 +337,7 @@ async fn linked_accounts_share_plan_resolution_and_only_read_cached_quota() {
|
||||
id: "acct_plan".to_owned(),
|
||||
name: "套餐测试".to_owned(),
|
||||
email: None,
|
||||
provider_kind: "openai".to_owned(),
|
||||
provider_kind: kind.to_owned(),
|
||||
authentication_kind: "oauth".to_owned(),
|
||||
plan_type: stored.map(str::to_owned),
|
||||
plan_type_display: None,
|
||||
@@ -321,14 +359,7 @@ async fn linked_accounts_share_plan_resolution_and_only_read_cached_quota() {
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(result.items[0].plan_type.as_deref(), expected);
|
||||
assert_eq!(
|
||||
result.items[0].plan_type_display.as_deref(),
|
||||
match expected {
|
||||
Some("free") => Some("openai display: free"),
|
||||
Some("plus") => Some("openai display: plus"),
|
||||
_ => None,
|
||||
}
|
||||
);
|
||||
assert_eq!(result.items[0].plan_type_display.as_deref(), display);
|
||||
let requests = provider.quota_requests();
|
||||
assert_eq!(requests.len(), usize::from(stored != Some("plus")));
|
||||
assert!(requests.iter().all(|request| !request.refresh));
|
||||
|
||||
@@ -364,6 +364,7 @@ async fn account_quota_refresh_time_uses_server_clock_and_deployment_timezone()
|
||||
paused_windows: Vec::new(),
|
||||
upstream: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at,
|
||||
refresh_token_expires_at: None,
|
||||
windows: Vec::new(),
|
||||
|
||||
@@ -135,6 +135,7 @@ async fn fixture(sharing: ClientPeerSharing, plaintext: &str) -> (AdminTestFixtu
|
||||
paused_windows: Vec::new(),
|
||||
upstream: None,
|
||||
plan_type: Some("pro".into()),
|
||||
plan_type_display: None,
|
||||
observed_at: Some(now),
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
|
||||
@@ -166,6 +166,7 @@ impl PluginAccountAccess for Facts {
|
||||
balance: Some("123456789.123456789".into()),
|
||||
}),
|
||||
plan_type: Some("private plan".into()),
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: vec![ProviderQuotaWindow {
|
||||
|
||||
@@ -76,13 +76,8 @@ impl ProviderAdmin for AntigravityAdmin {
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
fn plan_type_display(&self, plan: &str) -> String {
|
||||
match plan {
|
||||
"g1-pro-tier" => "Google AI Pro",
|
||||
"free-tier" => "Antigravity",
|
||||
_ => plan,
|
||||
}
|
||||
.to_owned()
|
||||
fn plan_type_display(&self, _plan: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn supported_pricing_bands(&self) -> &'static [&'static str] {
|
||||
crate::billing::SUPPORTED_PRICING_BANDS
|
||||
|
||||
@@ -18,6 +18,8 @@ use std::{
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(super) struct Document {
|
||||
pub(super) tier: Option<Tier>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(super) plan_description: Option<String>,
|
||||
pub(super) summary: QuotaSummary,
|
||||
pub(super) models: BTreeMap<String, ModelQuota>,
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
@@ -252,6 +254,11 @@ impl Document {
|
||||
}),
|
||||
limit_reached: self.access(observed).is_exhausted(),
|
||||
plan_type: self.plan_type(),
|
||||
plan_type_display: self
|
||||
.plan_description
|
||||
.as_ref()
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.cloned(),
|
||||
observed_at: Some(DateTime::<Utc>::from(observed)),
|
||||
windows,
|
||||
..Default::default()
|
||||
|
||||
@@ -171,8 +171,13 @@ impl QuotaService {
|
||||
client.quota_summary(&material.access_token, &info.project),
|
||||
)
|
||||
.map_err(upstream)?;
|
||||
let (tier, plan_description) = match info.paid_tier {
|
||||
Some(paid) => (Some(paid.tier), paid.description),
|
||||
None => (info.current_tier, None),
|
||||
};
|
||||
let doc = Document {
|
||||
tier: info.paid_tier.or(info.current_tier),
|
||||
tier,
|
||||
plan_description,
|
||||
bucket_models: super::document::bucket_models(&summary, &catalog),
|
||||
summary,
|
||||
models: catalog
|
||||
|
||||
@@ -10,12 +10,21 @@ use serde_json::json;
|
||||
pub(crate) struct AccountInfo {
|
||||
#[serde(rename = "cloudaicompanionProject")]
|
||||
pub(crate) project: String,
|
||||
pub(crate) paid_tier: Option<Tier>,
|
||||
pub(crate) paid_tier: Option<PaidTier>,
|
||||
pub(crate) current_tier: Option<Tier>,
|
||||
}
|
||||
|
||||
// Desktop 将 paidTier 投影为 userStatus.userTier,显示其中的 description
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct PaidTier {
|
||||
#[serde(flatten)]
|
||||
pub(crate) tier: Tier,
|
||||
pub(crate) description: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub(crate) struct Tier {
|
||||
#[serde(default)]
|
||||
pub(crate) id: String,
|
||||
#[serde(default)]
|
||||
pub(crate) name: String,
|
||||
|
||||
@@ -194,6 +194,43 @@ async fn quota_and_catalog_refresh_use_current_global_identity() {
|
||||
assert_eq!(server.received_requests().await.unwrap().len(), 10);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn account_plan_uses_the_desktop_description_for_every_tier() {
|
||||
let server = MockServer::start().await;
|
||||
upstream(&server, json!(1.0), Duration::ZERO).await;
|
||||
let f = Fixture::new(&server.uri());
|
||||
let account = f.store.primary().loaded.lock().unwrap().account.clone();
|
||||
for (paid_id, description) in [
|
||||
(Some("free-tier"), Some("Google's free plan")),
|
||||
(Some("g1-pro-tier"), Some("Pro subscription")),
|
||||
(Some("g1-ultra-tier"), Some("Ultra subscription")),
|
||||
(Some("future-tier"), Some("A future plan")),
|
||||
(Some("future-tier"), Some("Updated description")),
|
||||
(Some("future-tier"), None),
|
||||
(None, None),
|
||||
] {
|
||||
let paid = paid_id.map(|id| {
|
||||
json!({
|
||||
"id": id, "name": "Different Google name", "description": description
|
||||
})
|
||||
});
|
||||
Mock::given(path("/v1internal:loadCodeAssist"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
|
||||
"cloudaicompanionProject": "p",
|
||||
"paidTier": paid,
|
||||
"currentTier": {"id":"free-tier","description":"Current tier only"}
|
||||
})))
|
||||
.with_priority(1)
|
||||
.up_to_n_times(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
f.quota.refresh(account.id()).await.unwrap();
|
||||
let view = f.quota.read(account.id()).await.unwrap();
|
||||
assert_eq!(view.plan_type.as_deref(), paid_id.or(Some("free-tier")));
|
||||
assert_eq!(view.plan_type_display.as_deref(), description);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn quota_refresh_projects_paid_plan_without_exhausting_other_models() {
|
||||
let server = MockServer::start().await;
|
||||
|
||||
@@ -267,9 +267,9 @@ impl ProviderAdmin for OpenAiAdminProvider {
|
||||
&self.provider_kind
|
||||
}
|
||||
|
||||
fn plan_type_display(&self, plan_type: &str) -> String {
|
||||
fn plan_type_display(&self, plan_type: &str) -> Option<String> {
|
||||
// Pro 三档沿用管理端短名,其余已知套餐使用 Codex /status 的名称
|
||||
match plan_type.to_ascii_lowercase().as_str() {
|
||||
let display = match plan_type.to_ascii_lowercase().as_str() {
|
||||
"free" => "Free",
|
||||
"go" => "Go",
|
||||
"plus" => "Plus",
|
||||
@@ -288,8 +288,8 @@ impl ProviderAdmin for OpenAiAdminProvider {
|
||||
"sci" => "Academic Researchers",
|
||||
"sci_plus" => "Academic Researchers Plus",
|
||||
_ => plan_type,
|
||||
}
|
||||
.to_owned()
|
||||
};
|
||||
Some(display.to_owned())
|
||||
}
|
||||
|
||||
async fn account_unavailable(&self, account_id: &ProviderAccountId) {
|
||||
|
||||
@@ -17,6 +17,7 @@ pub(super) fn empty_quota() -> ProviderQuota {
|
||||
upstream: None,
|
||||
credits: None,
|
||||
plan_type: None,
|
||||
plan_type_display: None,
|
||||
observed_at: None,
|
||||
refresh_token_expires_at: None,
|
||||
windows: Vec::new(),
|
||||
@@ -89,6 +90,7 @@ fn project_quota_snapshot(
|
||||
.collect(),
|
||||
upstream: None,
|
||||
plan_type: snapshot.plan_type().map(str::to_owned),
|
||||
plan_type_display: None,
|
||||
observed_at: Some(DateTime::<Utc>::from(snapshot.observed_at())),
|
||||
refresh_token_expires_at: None,
|
||||
windows,
|
||||
|
||||
@@ -38,7 +38,11 @@ async fn plan_display_uses_pro_short_names_and_codex_status_labels_for_other_kno
|
||||
("SCI_PLUS", "Academic Researchers Plus"),
|
||||
("Future_Plan", "Future_Plan"),
|
||||
] {
|
||||
assert_eq!(admin.plan_type_display(raw), display, "{raw}");
|
||||
assert_eq!(
|
||||
admin.plan_type_display(raw).as_deref(),
|
||||
Some(display),
|
||||
"{raw}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1456,8 +1460,10 @@ async fn openai_admin_projects_free_plan_from_cached_quota_when_account_claims_o
|
||||
.expect("read cached free quota");
|
||||
assert_eq!(quota.plan_type.as_deref(), Some("free"));
|
||||
assert_eq!(
|
||||
admin.plan_type_display(quota.plan_type.as_deref().expect("plan")),
|
||||
"Free"
|
||||
admin
|
||||
.plan_type_display(quota.plan_type.as_deref().expect("plan"))
|
||||
.as_deref(),
|
||||
Some("Free")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ pub(super) fn project_quota(
|
||||
plan_type: billing
|
||||
.and_then(|billing| billing.plan_type())
|
||||
.map(str::to_owned),
|
||||
plan_type_display: None,
|
||||
observed_at: snapshot.as_ref().map(GrokQuotaSnapshot::observed_at),
|
||||
refresh_token_expires_at,
|
||||
windows: vec![window],
|
||||
|
||||
+3
-2
@@ -1379,7 +1379,7 @@ Antigravity OAuth 账号开启后,生成请求携带 `enabledCreditTypes: ["GO
|
||||
OpenAI 主动额度刷新和正常响应携带的明确套餐会同步到账号,支持升级与降级;
|
||||
空值或 `unknown` 不覆盖已有套餐,同族泛化值(如 `team`)保留已知的具体套餐子类型。
|
||||
账号套餐为空或 `unknown` 时,后端优先用已保存的上游额度响应
|
||||
中的明确套餐值补全 `planType` 和 `planTypeDisplay`;两处均无套餐信息时才显示“未知套餐”
|
||||
中的明确套餐值补全 `planType`。账号页缺少可展示的名称时显示“未知套餐”
|
||||
|
||||
`outboundProxyId` 绑定已保存的代理,无需出口测试成功。
|
||||
编辑时省略或 `null` 表示保持原配置,空字符串表示清除绑定并使用部署默认出口。列表和详情返回绑定的
|
||||
@@ -1855,7 +1855,7 @@ Google 授权后,将浏览器中的完整 `http://localhost:8085/auth/callback
|
||||
|
||||
其余字段记录导出时已保存的凭据和账号观测,未知值省略;`createdAt`、`updatedAt` 是本地账号时间,`accessTokenExpiresAt` 是当前 AT 的有效期。导出不触发上游刷新,已过期 AT 也按原值记录。导入使用 RT 换取新 AT 并重新验证 Google 身份与权限,套餐由上游重新发现,文件中的历史观测不覆盖验证结果。出站代理通过导入请求的 `outboundProxyId` 指定
|
||||
|
||||
Antigravity 主动额度刷新同时读取套餐与上游模型组额度,优先采用明确的付费套餐。`g1-pro-tier`、`g1-ultra-tier` 分别显示为 `Google AI Pro`、`Google AI Ultra`,缺少套餐不推断为免费账号
|
||||
Antigravity 的 `planType` 取自 `paidTier.id`,没有 `paidTier` 时使用 `currentTier.id`。所有档位的展示名均取自 Google 返回的 `paidTier.description`。缺少描述时,账号页显示“未知套餐”。刷新额度后会更新描述
|
||||
|
||||
`quota.windows` 返回上游模型组的 5 小时与周额度、已用百分比及重置时间,同组窗口共享 `limitId`,`accountWide` 为 `false`。缺失的上游百分比保持未知。网关从额度分组的成员名单与同次模型目录确定模型 ID,按各窗口重置时间与时长汇总本地请求的 `localUsage`。无匹配请求时总 Token 为 0,成员或窗口边界无法确认时 `localUsage` 为空。账号 `usage` 单独返回近一周的本地用量,分组窗口不参与整号周/月容量预测
|
||||
|
||||
@@ -3058,6 +3058,7 @@ HTTP SSE 请求可能在返回 HTTP 200 后流内失败;WebSocket 已升级时
|
||||
`retryCount` 为额外执行尝试次数之和,`retryRate` 为发生过重试的请求数占该组请求数的比例,同一请求多次重试只计一次
|
||||
|
||||
使用记录列表和错误排查列表的 `accountPlanType` / `accountPlanTypeDisplay` 来自记录保存的账号订阅快照。
|
||||
Antigravity 请求快照只保存套餐 ID,历史记录的展示名为空。
|
||||
账号维度诊断使用该账号最近请求的订阅快照,并通过 `authenticationKind` 返回同一请求的认证类型快照;未保存的字段为 `null`,非账号维度的认证类型为 `null`
|
||||
|
||||
管理端请求列表及 Dashboard 最近请求中的 `accountNotes` 来自请求保存的账号备注快照,未保存时为 `null`
|
||||
|
||||
@@ -81,7 +81,7 @@ const { t } = useI18n({ useScope: 'global' })
|
||||
|
||||
<template #accountPlanType="{ row }">
|
||||
<div
|
||||
v-if="row.accountUpstreamPeer || row.authenticationKind === 'api_key' || row.accountPlanType"
|
||||
v-if="row.accountUpstreamPeer || row.authenticationKind === 'api_key' || row.accountPlanTypeDisplay"
|
||||
class="-mx-3 flex min-w-0 justify-center"
|
||||
>
|
||||
<AccountPlanBadge
|
||||
@@ -89,7 +89,7 @@ const { t } = useI18n({ useScope: 'global' })
|
||||
:authentication-kind="row.authenticationKind ?? undefined"
|
||||
:upstream-peer="row.accountUpstreamPeer"
|
||||
:plan-type="row.accountPlanType"
|
||||
:plan-type-display="row.accountPlanTypeDisplay || row.accountPlanType || ''"
|
||||
:plan-type-display="row.accountPlanTypeDisplay || ''"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -199,11 +199,11 @@ function diagnosticNameDisplay(name: string) {
|
||||
|
||||
<template #accountPlanType="{ row }">
|
||||
<AccountPlanBadge
|
||||
v-if="row.accountUpstreamPeer || row.authenticationKind === 'api_key' || row.accountPlanType"
|
||||
v-if="row.accountUpstreamPeer || row.authenticationKind === 'api_key' || row.accountPlanTypeDisplay"
|
||||
:authentication-kind="row.authenticationKind ?? undefined"
|
||||
:upstream-peer="row.accountUpstreamPeer"
|
||||
:plan-type="row.accountPlanType"
|
||||
:plan-type-display="row.accountPlanTypeDisplay || row.accountPlanType || ''"
|
||||
:plan-type-display="row.accountPlanTypeDisplay || ''"
|
||||
size="sm"
|
||||
/>
|
||||
<span v-else class="text-z-text-quaternary">—</span>
|
||||
|
||||
Reference in New Issue
Block a user