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:
@@ -7,8 +7,9 @@ use cloud_llm_client::{
|
||||
CLIENT_SUPPORTS_STATUS_MESSAGES_HEADER_NAME, CURRENT_PLAN_HEADER_NAME, CompletionBody,
|
||||
CompletionEvent, CompletionRequestStatus, CountTokensBody, CountTokensResponse,
|
||||
EXPIRED_LLM_TOKEN_HEADER_NAME, ListModelsResponse, MODEL_REQUESTS_RESOURCE_HEADER_VALUE, Plan,
|
||||
SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME, SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME,
|
||||
TOOL_USE_LIMIT_REACHED_HEADER_NAME, ZED_VERSION_HEADER_NAME,
|
||||
PlanV1, PlanV2, SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME,
|
||||
SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME, TOOL_USE_LIMIT_REACHED_HEADER_NAME,
|
||||
ZED_VERSION_HEADER_NAME,
|
||||
};
|
||||
use futures::{
|
||||
AsyncBufReadExt, FutureExt, Stream, StreamExt, future::BoxFuture, stream::BoxStream,
|
||||
@@ -480,7 +481,8 @@ impl CloudLanguageModel {
|
||||
.headers()
|
||||
.get(CURRENT_PLAN_HEADER_NAME)
|
||||
.and_then(|plan| plan.to_str().ok())
|
||||
.and_then(|plan| cloud_llm_client::Plan::from_str(plan).ok())
|
||||
.and_then(|plan| cloud_llm_client::PlanV1::from_str(plan).ok())
|
||||
.map(Plan::V1)
|
||||
{
|
||||
return Err(anyhow!(ModelRequestLimitReachedError { plan }));
|
||||
}
|
||||
@@ -994,15 +996,17 @@ impl RenderOnce for ZedAiConfiguration {
|
||||
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
|
||||
let young_account_banner = YoungAccountBanner;
|
||||
|
||||
let is_pro = self.plan == Some(Plan::ZedPro);
|
||||
let is_pro = self.plan.is_some_and(|plan| {
|
||||
matches!(plan, Plan::V1(PlanV1::ZedPro) | Plan::V2(PlanV2::ZedPro))
|
||||
});
|
||||
let subscription_text = match (self.plan, self.subscription_period) {
|
||||
(Some(Plan::ZedPro), Some(_)) => {
|
||||
(Some(Plan::V1(PlanV1::ZedPro) | Plan::V2(PlanV2::ZedPro)), Some(_)) => {
|
||||
"You have access to Zed's hosted models through your Pro subscription."
|
||||
}
|
||||
(Some(Plan::ZedProTrial), Some(_)) => {
|
||||
(Some(Plan::V1(PlanV1::ZedProTrial) | Plan::V2(PlanV2::ZedProTrial)), Some(_)) => {
|
||||
"You have access to Zed's hosted models through your Pro trial."
|
||||
}
|
||||
(Some(Plan::ZedFree), Some(_)) => {
|
||||
(Some(Plan::V1(PlanV1::ZedFree) | Plan::V2(PlanV2::ZedFree)), Some(_)) => {
|
||||
"You have basic access to Zed's hosted models through the Free plan."
|
||||
}
|
||||
_ => {
|
||||
@@ -1161,15 +1165,15 @@ impl Component for ZedAiConfiguration {
|
||||
),
|
||||
single_example(
|
||||
"Free Plan",
|
||||
configuration(true, Some(Plan::ZedFree), true, false),
|
||||
configuration(true, Some(Plan::V1(PlanV1::ZedFree)), true, false),
|
||||
),
|
||||
single_example(
|
||||
"Zed Pro Trial Plan",
|
||||
configuration(true, Some(Plan::ZedProTrial), true, false),
|
||||
configuration(true, Some(Plan::V1(PlanV1::ZedProTrial)), true, false),
|
||||
),
|
||||
single_example(
|
||||
"Zed Pro Plan",
|
||||
configuration(true, Some(Plan::ZedPro), true, false),
|
||||
configuration(true, Some(Plan::V1(PlanV1::ZedPro)), true, false),
|
||||
),
|
||||
])
|
||||
.into_any_element(),
|
||||
|
||||
Reference in New Issue
Block a user