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:
@@ -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