language_models: Improve subscription states in the Agent configuration view (#30252)
This PR improves the subscription states in the Agent configuration view to the new billing system. Zed Free (legacy): <img width="638" alt="Screenshot 2025-05-08 at 8 42 59 AM" src="https://github.com/user-attachments/assets/7b62d4c1-2a9c-4c6a-aa8f-060730b6d7b3" /> Zed Free (new): <img width="640" alt="Screenshot 2025-05-08 at 8 43 56 AM" src="https://github.com/user-attachments/assets/8a48448e-813e-4633-955d-623d3e6d603c" /> Zed Pro trial: <img width="641" alt="Screenshot 2025-05-08 at 8 45 52 AM" src="https://github.com/user-attachments/assets/1ec7ee62-e954-48e7-8447-4584527307c9" /> Zed Pro: <img width="636" alt="Screenshot 2025-05-08 at 8 47 21 AM" src="https://github.com/user-attachments/assets/f934b2e3-0943-4b78-b8dc-0a31e731d8fb" /> Release Notes: - agent: Improved the subscription-related information in the configuration view.
This commit is contained in:
parent
3a3d3c05e8
commit
b343a8aa22
4 changed files with 75 additions and 40 deletions
|
@ -2709,7 +2709,7 @@ async fn update_user_plan(user_id: UserId, session: &Session) -> Result<()> {
|
|||
let billing_customer = db.get_billing_customer_by_user_id(user_id).await?;
|
||||
let billing_preferences = db.get_billing_preferences(user_id).await?;
|
||||
|
||||
let usage = if let Some(llm_db) = session.app_state.llm_db.clone() {
|
||||
let (subscription_period, usage) = if let Some(llm_db) = session.app_state.llm_db.clone() {
|
||||
let subscription = db.get_active_billing_subscription(user_id).await?;
|
||||
|
||||
let subscription_period = crate::db::billing_subscription::Model::current_period(
|
||||
|
@ -2717,15 +2717,17 @@ async fn update_user_plan(user_id: UserId, session: &Session) -> Result<()> {
|
|||
session.is_staff(),
|
||||
);
|
||||
|
||||
if let Some((period_start_at, period_end_at)) = subscription_period {
|
||||
let usage = if let Some((period_start_at, period_end_at)) = subscription_period {
|
||||
llm_db
|
||||
.get_subscription_usage_for_period(user_id, period_start_at, period_end_at)
|
||||
.await?
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
(subscription_period, usage)
|
||||
} else {
|
||||
None
|
||||
(None, None)
|
||||
};
|
||||
|
||||
session
|
||||
|
@ -2743,6 +2745,12 @@ async fn update_user_plan(user_id: UserId, session: &Session) -> Result<()> {
|
|||
billing_preferences
|
||||
.map(|preferences| preferences.model_request_overages_enabled)
|
||||
},
|
||||
subscription_period: subscription_period.map(|(started_at, ended_at)| {
|
||||
proto::SubscriptionPeriod {
|
||||
started_at: started_at.timestamp() as u64,
|
||||
ended_at: ended_at.timestamp() as u64,
|
||||
}
|
||||
}),
|
||||
usage: usage.map(|usage| {
|
||||
let plan = match plan {
|
||||
proto::Plan::Free => zed_llm_client::Plan::Free,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue