language_models: Make subscription text exhaustive (#51524)

Neel created

Closes CLO-493.

Release Notes:

- N/A

Change summary

Cargo.lock                                   |  1 
crates/language_models/Cargo.toml            |  1 
crates/language_models/src/provider/cloud.rs | 47 ++++++++++-----------
3 files changed, 22 insertions(+), 27 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -9444,7 +9444,6 @@ dependencies = [
  "aws_http_client",
  "base64 0.22.1",
  "bedrock",
- "chrono",
  "client",
  "cloud_api_types",
  "cloud_llm_client",

crates/language_models/Cargo.toml 🔗

@@ -20,7 +20,6 @@ aws-credential-types = { workspace = true, features = ["hardcoded-credentials"]
 aws_http_client.workspace = true
 base64.workspace = true
 bedrock = { workspace = true, features = ["schemars"] }
-chrono.workspace = true
 client.workspace = true
 cloud_api_types.workspace = true
 cloud_llm_client.workspace = true

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(|_, _| {}),