Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language_models: Make subscription text exhaustive (#51524)
Neelee8ecfa47c24
diff --git a/Cargo.lock b/Cargo.lockindex cbc83f81168..21646eef97e 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -9444,7 +9444,6 @@ dependencies = ["aws_http_client","base64 0.22.1","bedrock",- "chrono","client","cloud_api_types","cloud_llm_client",diff --git a/crates/language_models/Cargo.toml b/crates/language_models/Cargo.tomlindex b37f783eb92..f9dc4266d69 100644--- a/crates/language_models/Cargo.toml+++ b/crates/language_models/Cargo.toml@@ -20,7 +20,6 @@ aws-credential-types = { workspace = true, features = ["hardcoded-credentials"]aws_http_client.workspace = truebase64.workspace = truebedrock = { workspace = true, features = ["schemars"] }-chrono.workspace = trueclient.workspace = truecloud_api_types.workspace = truecloud_llm_client.workspace = truediff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rsindex b871015826f..8f2b6c10f34 100644--- a/crates/language_models/src/provider/cloud.rs+++ b/crates/language_models/src/provider/cloud.rs@@ -1,7 +1,6 @@use ai_onboarding::YoungAccountBanner;use anthropic::AnthropicModelMode;use anyhow::{Context as _, Result, anyhow};-use chrono::{DateTime, Utc};use client::{Client, UserStore, zed_urls};use cloud_api_types::{OrganizationId, Plan};use cloud_llm_client::{@@ -1091,7 +1090,6 @@ fn response_lines<T: DeserializeOwned>(struct ZedAiConfiguration {is_connected: bool,plan: Option<Plan>,- subscription_period: Option<(DateTime<Utc>, DateTime<Utc>)>,eligible_for_trial: bool,account_too_young: bool,sign_in_callback: Arc<dyn Fn(&mut Window, &mut App) + Send + Sync>,@@ -1099,31 +1097,34 @@ struct ZedAiConfiguration {impl RenderOnce for ZedAiConfiguration {fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {- let is_pro = self.plan.is_some_and(|plan| plan == Plan::ZedPro);- let subscription_text = match (self.plan, self.subscription_period) {- (Some(Plan::ZedPro), Some(_)) => {- "You have access to Zed's hosted models through your Pro subscription."- }- (Some(Plan::ZedProTrial), Some(_)) => {- "You have access to Zed's hosted models through your Pro trial."- }- (Some(Plan::ZedFree), Some(_)) => {- if self.eligible_for_trial {- "Subscribe for access to Zed's hosted models. Start with a 14 day free trial."- } else {- "Subscribe for access to Zed's hosted models."- }- }- _ => {+ let (subscription_text, has_paid_plan) = match self.plan {+ Some(Plan::ZedPro) => (+ "You have access to Zed's hosted models through your Pro subscription.",+ true,+ ),+ Some(Plan::ZedProTrial) => (+ "You have access to Zed's hosted models through your Pro trial.",+ false,+ ),+ Some(Plan::ZedStudent) => (+ "You have access to Zed's hosted models through your Student subscription.",+ true,+ ),+ Some(Plan::ZedBusiness) => (+ "You have access to Zed's hosted models through your Organization.",+ true,+ ),+ Some(Plan::ZedFree) | None => (if self.eligible_for_trial {"Subscribe for access to Zed's hosted models. Start with a 14 day free trial."} else {"Subscribe for access to Zed's hosted models."- }- }+ },+ false,+ ),};- let manage_subscription_buttons = if is_pro {+ let manage_subscription_buttons = if has_paid_plan {Button::new("manage_settings", "Manage Subscription").full_width().label_size(LabelSize::Small)@@ -1207,7 +1208,6 @@ impl Render for ConfigurationView {ZedAiConfiguration {is_connected: !state.is_signed_out(cx),plan: user_store.plan(),- subscription_period: user_store.subscription_period(),eligible_for_trial: user_store.trial_started_at().is_none(),account_too_young: user_store.account_too_young(),sign_in_callback: self.sign_in_callback.clone(),@@ -1238,9 +1238,6 @@ impl Component for ZedAiConfiguration {ZedAiConfiguration {is_connected,plan,- subscription_period: plan- .is_some()- .then(|| (Utc::now(), Utc::now() + chrono::Duration::days(7))),eligible_for_trial,account_too_young,sign_in_callback: Arc::new(|_, _| {}),