Skip to content

Commit ee8ecfa

Browse files
authored
language_models: Make subscription text exhaustive (zed-industries#51524)
Closes CLO-493. Release Notes: - N/A
1 parent 8fc880e commit ee8ecfa

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/language_models/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ aws-credential-types = { workspace = true, features = ["hardcoded-credentials"]
2020
aws_http_client.workspace = true
2121
base64.workspace = true
2222
bedrock = { workspace = true, features = ["schemars"] }
23-
chrono.workspace = true
2423
client.workspace = true
2524
cloud_api_types.workspace = true
2625
cloud_llm_client.workspace = true

crates/language_models/src/provider/cloud.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use ai_onboarding::YoungAccountBanner;
22
use anthropic::AnthropicModelMode;
33
use anyhow::{Context as _, Result, anyhow};
4-
use chrono::{DateTime, Utc};
54
use client::{Client, UserStore, zed_urls};
65
use cloud_api_types::{OrganizationId, Plan};
76
use cloud_llm_client::{
@@ -1091,39 +1090,41 @@ fn response_lines<T: DeserializeOwned>(
10911090
struct ZedAiConfiguration {
10921091
is_connected: bool,
10931092
plan: Option<Plan>,
1094-
subscription_period: Option<(DateTime<Utc>, DateTime<Utc>)>,
10951093
eligible_for_trial: bool,
10961094
account_too_young: bool,
10971095
sign_in_callback: Arc<dyn Fn(&mut Window, &mut App) + Send + Sync>,
10981096
}
10991097

11001098
impl RenderOnce for ZedAiConfiguration {
11011099
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
1102-
let is_pro = self.plan.is_some_and(|plan| plan == Plan::ZedPro);
1103-
let subscription_text = match (self.plan, self.subscription_period) {
1104-
(Some(Plan::ZedPro), Some(_)) => {
1105-
"You have access to Zed's hosted models through your Pro subscription."
1106-
}
1107-
(Some(Plan::ZedProTrial), Some(_)) => {
1108-
"You have access to Zed's hosted models through your Pro trial."
1109-
}
1110-
(Some(Plan::ZedFree), Some(_)) => {
1111-
if self.eligible_for_trial {
1112-
"Subscribe for access to Zed's hosted models. Start with a 14 day free trial."
1113-
} else {
1114-
"Subscribe for access to Zed's hosted models."
1115-
}
1116-
}
1117-
_ => {
1100+
let (subscription_text, has_paid_plan) = match self.plan {
1101+
Some(Plan::ZedPro) => (
1102+
"You have access to Zed's hosted models through your Pro subscription.",
1103+
true,
1104+
),
1105+
Some(Plan::ZedProTrial) => (
1106+
"You have access to Zed's hosted models through your Pro trial.",
1107+
false,
1108+
),
1109+
Some(Plan::ZedStudent) => (
1110+
"You have access to Zed's hosted models through your Student subscription.",
1111+
true,
1112+
),
1113+
Some(Plan::ZedBusiness) => (
1114+
"You have access to Zed's hosted models through your Organization.",
1115+
true,
1116+
),
1117+
Some(Plan::ZedFree) | None => (
11181118
if self.eligible_for_trial {
11191119
"Subscribe for access to Zed's hosted models. Start with a 14 day free trial."
11201120
} else {
11211121
"Subscribe for access to Zed's hosted models."
1122-
}
1123-
}
1122+
},
1123+
false,
1124+
),
11241125
};
11251126

1126-
let manage_subscription_buttons = if is_pro {
1127+
let manage_subscription_buttons = if has_paid_plan {
11271128
Button::new("manage_settings", "Manage Subscription")
11281129
.full_width()
11291130
.label_size(LabelSize::Small)
@@ -1207,7 +1208,6 @@ impl Render for ConfigurationView {
12071208
ZedAiConfiguration {
12081209
is_connected: !state.is_signed_out(cx),
12091210
plan: user_store.plan(),
1210-
subscription_period: user_store.subscription_period(),
12111211
eligible_for_trial: user_store.trial_started_at().is_none(),
12121212
account_too_young: user_store.account_too_young(),
12131213
sign_in_callback: self.sign_in_callback.clone(),
@@ -1238,9 +1238,6 @@ impl Component for ZedAiConfiguration {
12381238
ZedAiConfiguration {
12391239
is_connected,
12401240
plan,
1241-
subscription_period: plan
1242-
.is_some()
1243-
.then(|| (Utc::now(), Utc::now() + chrono::Duration::days(7))),
12441241
eligible_for_trial,
12451242
account_too_young,
12461243
sign_in_callback: Arc::new(|_, _| {}),

0 commit comments

Comments
 (0)