Make plans backwards compatible (#37941)
This PR fixes the backwards compatibility of the new `Plan` variants. We can't add new variants to the wire representation, as old clients won't be able to understand them. Release Notes: - N/A
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{Client, Connection, Credentials, EstablishConnectionError, UserStore};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use cloud_api_client::{AuthenticatedUser, GetAuthenticatedUserResponse, PlanInfo};
|
||||
use cloud_llm_client::{CurrentUsage, Plan, UsageData, UsageLimit};
|
||||
use cloud_llm_client::{CurrentUsage, PlanV1, UsageData, UsageLimit};
|
||||
use futures::{StreamExt, stream::BoxStream};
|
||||
use gpui::{AppContext as _, BackgroundExecutor, Entity, TestAppContext};
|
||||
use http_client::{AsyncBody, Method, Request, http};
|
||||
@@ -269,7 +269,8 @@ pub fn make_get_authenticated_user_response(
|
||||
},
|
||||
feature_flags: vec![],
|
||||
plan: PlanInfo {
|
||||
plan: Plan::ZedPro,
|
||||
plan: PlanV1::ZedPro,
|
||||
plan_v2: None,
|
||||
subscription_period: None,
|
||||
usage: CurrentUsage {
|
||||
model_requests: UsageData {
|
||||
|
||||
@@ -5,7 +5,8 @@ use cloud_api_client::websocket_protocol::MessageToClient;
|
||||
use cloud_api_client::{GetAuthenticatedUserResponse, PlanInfo};
|
||||
use cloud_llm_client::{
|
||||
EDIT_PREDICTIONS_USAGE_AMOUNT_HEADER_NAME, EDIT_PREDICTIONS_USAGE_LIMIT_HEADER_NAME,
|
||||
MODEL_REQUESTS_USAGE_AMOUNT_HEADER_NAME, MODEL_REQUESTS_USAGE_LIMIT_HEADER_NAME, UsageLimit,
|
||||
MODEL_REQUESTS_USAGE_AMOUNT_HEADER_NAME, MODEL_REQUESTS_USAGE_LIMIT_HEADER_NAME, Plan,
|
||||
UsageLimit,
|
||||
};
|
||||
use collections::{HashMap, HashSet, hash_map::Entry};
|
||||
use derive_more::Deref;
|
||||
@@ -692,20 +693,22 @@ impl UserStore {
|
||||
self.current_user.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn plan(&self) -> Option<cloud_llm_client::Plan> {
|
||||
pub fn plan(&self) -> Option<Plan> {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Ok(plan) = std::env::var("ZED_SIMULATE_PLAN").as_ref() {
|
||||
use cloud_llm_client::PlanV1;
|
||||
|
||||
return match plan.as_str() {
|
||||
"free" => Some(cloud_llm_client::Plan::ZedFree),
|
||||
"trial" => Some(cloud_llm_client::Plan::ZedProTrial),
|
||||
"pro" => Some(cloud_llm_client::Plan::ZedPro),
|
||||
"free" => Some(Plan::V1(PlanV1::ZedFree)),
|
||||
"trial" => Some(Plan::V1(PlanV1::ZedProTrial)),
|
||||
"pro" => Some(Plan::V1(PlanV1::ZedPro)),
|
||||
_ => {
|
||||
panic!("ZED_SIMULATE_PLAN must be one of 'free', 'trial', or 'pro'");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
self.plan_info.as_ref().map(|info| info.plan)
|
||||
self.plan_info.as_ref().map(|info| info.plan())
|
||||
}
|
||||
|
||||
pub fn subscription_period(&self) -> Option<(DateTime<Utc>, DateTime<Utc>)> {
|
||||
|
||||
Reference in New Issue
Block a user