Update edit prediction messaging for the Free plan (#65258)

Starting Oct 7th, the free plan will no longer include Zed's hosted edit
predictions.

## Testing

- Added `test_free_plan_edit_predictions_ended_for_zed_provider`. It
covers:
- the Free vs Pro plan rule, with Cloud still reporting a 2,000
allowance
  - the default vs explicitly chosen provider
  - the Ollama exclusion
  - the notice only firing when the user accepted predictions
- All `edit_prediction` tests pass.
- Clippy with `--deny warnings` passes on the touched crates.
- The docs pass prettier.
- Screenshots of an earlier revision were captured with the visual test
runner. The latest copy and the Copilot removal haven't been checked in
a running build.


Release Notes:

- N/A
This commit is contained in:
Katie Geer
2026-10-07 16:40:00 +00:00
committed by GitHub
parent 4882254fae
commit a34a062bb7
10 changed files with 257 additions and 90 deletions
@@ -1,8 +1,7 @@
use std::sync::Arc;
use client::{Client, UserStore};
use cloud_api_types::Plan;
use gpui::{Entity, IntoElement, ParentElement};
use gpui::{Entity, IntoElement};
use ui::prelude::*;
use crate::ZedAiOnboarding;
@@ -10,72 +9,31 @@ use crate::ZedAiOnboarding;
pub struct EditPredictionOnboarding {
user_store: Entity<UserStore>,
client: Arc<Client>,
copilot_is_configured: bool,
continue_with_zed_ai: Arc<dyn Fn(&mut Window, &mut App)>,
continue_with_copilot: Arc<dyn Fn(&mut Window, &mut App)>,
}
impl EditPredictionOnboarding {
pub fn new(
user_store: Entity<UserStore>,
client: Arc<Client>,
copilot_is_configured: bool,
continue_with_zed_ai: Arc<dyn Fn(&mut Window, &mut App)>,
continue_with_copilot: Arc<dyn Fn(&mut Window, &mut App)>,
_cx: &mut Context<Self>,
) -> Self {
Self {
user_store,
copilot_is_configured,
client,
continue_with_zed_ai,
continue_with_copilot,
}
}
}
impl Render for EditPredictionOnboarding {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let is_free_plan = self
.user_store
.read(cx)
.plan()
.is_some_and(|plan| plan == Plan::ZedFree);
let github_copilot = v_flex()
.gap_1()
.child(Label::new(if self.copilot_is_configured {
"Alternatively, you can continue to use GitHub Copilot as that's already set up."
} else {
"Alternatively, you can use GitHub Copilot as your edit prediction provider."
}))
.child(
Button::new(
"configure-copilot",
if self.copilot_is_configured {
"Use Copilot"
} else {
"Configure Copilot"
},
)
.full_width()
.style(ButtonStyle::Outlined)
.on_click({
let callback = self.continue_with_copilot.clone();
move |_, window, cx| callback(window, cx)
}),
);
v_flex()
.gap_2()
.child(ZedAiOnboarding::new(
self.client.clone(),
&self.user_store,
self.continue_with_zed_ai.clone(),
cx,
))
.when(is_free_plan, |this| {
this.child(ui::Divider::horizontal()).child(github_copilot)
})
ZedAiOnboarding::new(
self.client.clone(),
&self.user_store,
self.continue_with_zed_ai.clone(),
cx,
)
}
}
@@ -7,7 +7,6 @@ pub struct PlanDefinitions;
impl PlanDefinitions {
pub fn free_plan(&self) -> impl IntoElement {
List::new()
.child(ListBulletItem::new("2,000 accepted edit predictions"))
.child(ListBulletItem::new(
"Unlimited prompts with your AI API keys",
))
+16
View File
@@ -762,6 +762,15 @@ impl UserStore {
cx.notify();
}
#[cfg(any(test, feature = "test-support"))]
pub fn set_current_organization_plan_for_test(&mut self, plan: Plan, cx: &mut Context<Self>) {
if let Some(organization) = &self.current_organization {
self.plans_by_organization
.insert(organization.id.clone(), plan);
}
cx.notify();
}
pub fn plan(&self) -> Option<Plan> {
#[cfg(debug_assertions)]
if let Ok(plan) = std::env::var("ZED_SIMULATE_PLAN").as_ref() {
@@ -832,6 +841,13 @@ impl UserStore {
self.edit_prediction_usage
}
/// Returns whether the current plan doesn't include Zed's hosted edit predictions. This is
/// decided by plan rather than by the usage limit Cloud reports, because Cloud may still
/// report a nonzero Free allowance while it denies requests.
pub fn edit_predictions_excluded_from_plan(&self) -> bool {
self.plan() == Some(Plan::ZedFree)
}
pub fn update_edit_prediction_usage(
&mut self,
usage: EditPredictionUsage,
+94 -2
View File
@@ -1,6 +1,6 @@
use anyhow::{Context as _, Result, anyhow};
use buffer_diff::BufferDiff;
use client::{Client, EditPredictionUsage, UserStore, global_llm_token};
use client::{Client, EditPredictionUsage, UserStore, global_llm_token, zed_urls};
use cloud_api_client::LlmApiToken;
use cloud_api_types::{
EditPredictionRecentFile, EditPredictionSettledKeptChars,
@@ -52,12 +52,16 @@ use release_channel::AppVersion;
use semver::Version;
use serde::de::DeserializeOwned;
use settings::{
EditPredictionDataCollectionChoice, EditPredictionProvider, Settings as _, update_settings_file,
EditPredictionDataCollectionChoice, EditPredictionProvider, Settings as _, SettingsStore,
update_settings_file,
};
use std::collections::{VecDeque, hash_map};
use std::env;
use std::rc::Rc;
use text::{AnchorRangeExt, Edit};
use workspace::notifications::{
NotificationId, show_app_notification, simple_message_notification::MessageNotification,
};
use workspace::{AppState, Workspace};
use zeta_prompt::ContextSource;
use zeta_prompt::{Zeta2PromptInput, Zeta3PromptInput, ZetaFormat};
@@ -166,6 +170,7 @@ pub struct EditPredictionStore {
user_store: Entity<UserStore>,
llm_token: LlmApiToken,
_fetch_experiments_task: Task<()>,
_user_store_subscription: gpui::Subscription,
projects: HashMap<EntityId, ProjectState>,
update_required: bool,
edit_prediction_model: EditPredictionModel,
@@ -1030,6 +1035,12 @@ impl EditPredictionStore {
.log_err();
});
let user_store_subscription = cx.subscribe(&user_store, |_, user_store, event, cx| {
if let client::user::Event::PrivateUserInfoUpdated = event {
show_free_plan_edit_predictions_ended_notice_once(&user_store, cx);
}
});
let credentials_provider = zed_credentials_provider::global(cx);
let this = Self {
@@ -1038,6 +1049,7 @@ impl EditPredictionStore {
user_store,
llm_token,
_fetch_experiments_task: fetch_experiments_task,
_user_store_subscription: user_store_subscription,
update_required: false,
edit_prediction_model: EditPredictionModel::Zeta,
zeta2_raw_config: Self::zeta2_raw_config_from_env(),
@@ -3519,6 +3531,86 @@ pub fn should_show_upsell_modal(cx: &App) -> bool {
!is_upsell_dismissed(cx)
}
/// Returns whether the user is set up to use Zed's hosted edit predictions but their plan
/// doesn't include them. Other providers, including Ollama and OpenAI-compatible servers that
/// run Zeta, don't go through Zed's servers and are unaffected.
pub fn zed_edit_predictions_excluded_from_plan(user_store: &UserStore, cx: &App) -> bool {
all_language_settings(None, cx).edit_predictions.provider == EditPredictionProvider::Zed
&& user_store.edit_predictions_excluded_from_plan()
}
/// Returns whether Zed's edit predictions should be treated as turned off: the user's plan
/// doesn't include them and Zed is only their provider by default. Users who explicitly chose
/// Zed keep the status bar button, which explains why predictions aren't available.
pub fn zed_edit_predictions_off_for_plan(user_store: &UserStore, cx: &App) -> bool {
let provider_explicitly_chosen = cx
.global::<SettingsStore>()
.raw_user_settings()
.and_then(|settings| {
settings
.content
.project
.all_languages
.edit_predictions
.as_ref()?
.provider
})
.is_some();
!provider_explicitly_chosen && zed_edit_predictions_excluded_from_plan(user_store, cx)
}
struct FreePlanEditPredictionsEndedNotice;
impl Dismissable for FreePlanEditPredictionsEndedNotice {
const KEY: &'static str = "free-plan-edit-predictions-ended-notice";
}
fn show_free_plan_edit_predictions_ended_notice_once(user_store: &Entity<UserStore>, cx: &mut App) {
// Accepted predictions are metered per billing period, so a nonzero count identifies users
// who were actually relying on edit predictions rather than just having the default provider.
let has_accepted_predictions = user_store
.read(cx)
.edit_prediction_usage()
.is_some_and(|usage| usage.amount > 0);
if DisableAiSettings::get_global(cx).disable_ai
|| !has_accepted_predictions
|| !zed_edit_predictions_excluded_from_plan(user_store.read(cx), cx)
|| FreePlanEditPredictionsEndedNotice::dismissed(cx)
{
return;
}
// Recorded when shown rather than when dismissed, so users see this once even if they
// never interact with it.
FreePlanEditPredictionsEndedNotice::set_dismissed(true, cx);
telemetry::event!("Free Plan Edit Predictions Ended Notice Shown");
show_app_notification(
NotificationId::unique::<FreePlanEditPredictionsEndedNotice>(),
cx,
|cx| {
cx.new(|cx| {
MessageNotification::new(
"Edit predictions are no longer included in the Free plan. \
Upgrade to Pro for unlimited edit predictions.",
cx,
)
.primary_message("Upgrade")
.primary_on_click(|_window, cx| {
telemetry::event!(
"Upgrade To Pro Clicked",
state = "free-plan-edit-predictions-ended"
);
cx.open_url(&zed_urls::upgrade_to_zed_pro_url(cx));
})
.show_suppress_button(false)
})
},
);
}
pub fn init(cx: &mut App) {
cx.observe_new(move |workspace: &mut Workspace, _, _cx| {
workspace.register_action(
@@ -3,12 +3,12 @@ use clock::FakeSystemClock;
use clock::ReplicaId;
use cloud_api_types::{
CreateLlmTokenResponse, LlmToken, Organization, OrganizationConfiguration,
OrganizationEditPredictionConfiguration, OrganizationId, SettledEditPrediction,
OrganizationEditPredictionConfiguration, OrganizationId, Plan, SettledEditPrediction,
SubmitEditPredictionSettledBatchBody, SubmitEditPredictionSettledResponse,
};
use cloud_llm_client::{
EditPredictionRejectReason, EditPredictionRejection, PredictEditsRequestTrigger,
RejectEditPredictionsBody,
RejectEditPredictionsBody, UsageLimit,
predict_edits_v3::{
PredictEditsV3Request, PredictEditsV3Response, RawCompletionChoice, RawCompletionRequest,
RawCompletionResponse, RawCompletionUsage,
@@ -2861,6 +2861,77 @@ fn set_test_organization(user_store: &Entity<UserStore>, cx: &mut TestAppContext
});
}
#[gpui::test]
async fn test_free_plan_edit_predictions_ended_for_zed_provider(cx: &mut TestAppContext) {
let (ep_store, _requests) = init_test_with_fake_client(cx);
let user_store = ep_store.read_with(cx, |ep_store, _| ep_store.user_store.clone());
// Cloud reports a 2,000 allowance for Free, which must not keep predictions on.
let set_plan_and_usage = |plan, amount, cx: &mut TestAppContext| {
user_store.update(cx, |user_store, cx| {
user_store.set_current_organization_plan_for_test(plan, cx);
user_store.update_edit_prediction_usage(
EditPredictionUsage(client::RequestUsage {
limit: UsageLimit::Limited(2_000),
amount,
}),
cx,
);
cx.emit(client::user::Event::PrivateUserInfoUpdated);
});
cx.run_until_parked();
};
let set_provider = |provider: Option<EditPredictionProvider>, cx: &mut TestAppContext| {
cx.update(|cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings(cx, |settings| {
settings
.project
.all_languages
.edit_predictions
.get_or_insert_default()
.provider = provider;
});
});
});
};
let excluded_from_plan = |cx: &mut TestAppContext| {
cx.read(|cx| zed_edit_predictions_excluded_from_plan(user_store.read(cx), cx))
};
let off_for_plan = |cx: &mut TestAppContext| {
cx.read(|cx| zed_edit_predictions_off_for_plan(user_store.read(cx), cx))
};
let notice_shown =
|cx: &mut TestAppContext| cx.read(|cx| FreePlanEditPredictionsEndedNotice::dismissed(cx));
set_provider(None, cx);
set_plan_and_usage(Plan::ZedPro, 250, cx);
assert!(!excluded_from_plan(cx));
assert!(!off_for_plan(cx));
assert!(!notice_shown(cx));
// Local Zeta models don't go through Zed's servers.
set_provider(Some(EditPredictionProvider::Ollama), cx);
set_plan_and_usage(Plan::ZedFree, 250, cx);
assert!(!excluded_from_plan(cx));
assert!(!notice_shown(cx));
// Free users who never accepted a prediction this period don't need to be told.
set_provider(None, cx);
set_plan_and_usage(Plan::ZedFree, 0, cx);
assert!(excluded_from_plan(cx));
assert!(off_for_plan(cx));
assert!(!notice_shown(cx));
// Explicitly choosing Zed keeps it on, so the status bar can explain why it isn't working.
set_provider(Some(EditPredictionProvider::Zed), cx);
assert!(excluded_from_plan(cx));
assert!(!off_for_plan(cx));
set_plan_and_usage(Plan::ZedFree, 250, cx);
assert!(notice_shown(cx));
}
#[gpui::test]
async fn test_edit_prediction_basic_interpolation(cx: &mut TestAppContext) {
let buffer = cx.new(|cx| Buffer::local("Lorem ipsum dolor", cx));
+1 -18
View File
@@ -1,6 +1,6 @@
use std::sync::Arc;
use crate::{EditPredictionStore, ZedPredictUpsell};
use crate::ZedPredictUpsell;
use ai_onboarding::EditPredictionOnboarding;
use client::{Client, UserStore};
use db::kvp::Dismissable;
@@ -50,19 +50,13 @@ impl ZedPredictModal {
window: &mut Window,
cx: &mut Context<Workspace>,
) {
let project = workspace.project().clone();
workspace.toggle_modal(window, cx, |_window, cx| {
let weak_entity = cx.weak_entity();
let copilot = EditPredictionStore::try_global(cx)
.and_then(|store| store.read(cx).copilot_for_project(&project));
Self {
onboarding: cx.new(|cx| {
EditPredictionOnboarding::new(
user_store.clone(),
client.clone(),
copilot
.as_ref()
.is_some_and(|copilot| copilot.read(cx).status().is_configured()),
Arc::new({
let this = weak_entity.clone();
move |_window, cx| {
@@ -71,17 +65,6 @@ impl ZedPredictModal {
this.update(cx, |_, cx| cx.emit(DismissEvent)).ok();
}
}),
Arc::new({
let this = weak_entity.clone();
move |window, cx| {
ZedPredictUpsell::set_dismissed(true, cx);
set_edit_prediction_provider(EditPredictionProvider::Copilot, cx);
this.update(cx, |_, cx| cx.emit(DismissEvent)).ok();
if let Some(copilot) = copilot.clone() {
copilot_ui::initiate_sign_in(copilot, window, cx);
}
}
}),
cx,
)
}),
@@ -148,8 +148,10 @@ impl EditPredictionDelegate for ZedEditPredictionDelegate {
) {
let store = self.store.read(cx);
if store.user_store.read_with(cx, |user_store, _cx| {
user_store.account_too_young() || user_store.has_overdue_invoices()
if store.user_store.read_with(cx, |user_store, cx| {
user_store.account_too_young()
|| user_store.has_overdue_invoices()
|| crate::zed_edit_predictions_excluded_from_plan(user_store, cx)
}) {
return;
}
@@ -343,6 +343,11 @@ impl Render for EditPredictionButton {
)
}
provider @ (EditPredictionProvider::Zed | EditPredictionProvider::Mercury) => {
if edit_prediction::zed_edit_predictions_off_for_plan(self.user_store.read(cx), cx)
{
return div().hidden();
}
let enabled = self.editor_enabled.unwrap_or(true);
let file = self.file.clone();
let language = self.language.clone();
@@ -428,6 +433,10 @@ impl Render for EditPredictionButton {
let show_editor_predictions = self.editor_show_predictions;
let user = self.user_store.read(cx).current_user();
let excluded_from_plan = edit_prediction::zed_edit_predictions_excluded_from_plan(
self.user_store.read(cx),
cx,
);
let mercury_has_error = matches!(provider, EditPredictionProvider::Mercury)
&& edit_prediction::EditPredictionStore::try_global(cx).is_some_and(
@@ -436,6 +445,8 @@ impl Render for EditPredictionButton {
let indicator_color = if missing_token || mercury_has_error {
Some(Color::Error)
} else if excluded_from_plan {
Some(Color::Muted)
} else if enabled && (!show_editor_predictions || over_limit) {
Some(if over_limit {
Color::Error
@@ -465,6 +476,8 @@ impl Render for EditPredictionButton {
"Disabled For This File"
} else if zed_cloud_needs_sign_in {
"Sign In Or Configure a Provider"
} else if excluded_from_plan {
"Configure a Provider"
} else if provider_unavailable || show_editor_predictions {
tooltip_meta
} else {
@@ -600,6 +613,9 @@ impl EditPredictionButton {
let is_zed_provider_disabled = organization_configuration
.is_some_and(|configuration| !configuration.edit_prediction.is_enabled);
let user_store = self.user_store.read(cx);
let is_zed_provider_unavailable = user_store.current_user().is_none()
|| edit_prediction::zed_edit_predictions_excluded_from_plan(user_store, cx);
let available_providers = get_available_providers(cx);
@@ -618,11 +634,18 @@ impl EditPredictionButton {
let is_current = provider == current_provider;
let is_disabled_zed_provider =
provider == EditPredictionProvider::Zed && is_zed_provider_disabled;
// Zed stays selected in settings, but checking it would imply predictions are
// working when the user still needs to sign in or upgrade.
let is_unavailable_zed_provider =
provider == EditPredictionProvider::Zed && is_zed_provider_unavailable;
let fs = self.fs.clone();
menu = menu.item(
ContextMenuEntry::new(name)
.toggleable(IconPosition::Start, is_current && !is_disabled_zed_provider)
.toggleable(
IconPosition::Start,
is_current && !is_disabled_zed_provider && !is_unavailable_zed_provider,
)
.disabled(is_disabled_zed_provider)
.when(is_disabled_zed_provider, |item| {
item.documentation_aside(DocumentationSide::Left, move |_cx| {
@@ -1118,8 +1141,8 @@ impl EditPredictionButton {
menu = menu
.custom_row(move |_window, cx| {
let description = indoc! {
"You get 2,000 accepted suggestions at every keystroke for free, \
powered by Zeta, our open-source, open-data model"
"Suggestions at every keystroke, powered by Zeta, our open-source, \
open-data model. Included with Zed Pro and the Pro trial."
};
v_flex()
@@ -1135,7 +1158,7 @@ impl EditPredictionButton {
.into_any_element()
})
.separator()
.entry("Sign In & Start Using", None, |window, cx| {
.entry("Sign In", None, |window, cx| {
telemetry::event!(
"Edit Prediction Menu Action",
action = "sign_in",
@@ -1185,7 +1208,30 @@ impl EditPredictionButton {
.separator();
}
if let Some(usage) = self
if edit_prediction::zed_edit_predictions_excluded_from_plan(
self.user_store.read(cx),
cx,
) {
menu = menu
.custom_entry(
|_window, _cx| {
Label::new("Zed's edit predictions not included in the Free plan.")
.size(LabelSize::Small)
.color(Color::Muted)
.into_any_element()
},
|_window, cx| cx.open_url(&zed_urls::upgrade_to_zed_pro_url(cx)),
)
.entry("Upgrade to Pro", None, |_window, cx| {
telemetry::event!(
"Edit Prediction Menu Action",
action = "upsell_clicked",
reason = "excluded_from_plan",
);
cx.open_url(&zed_urls::upgrade_to_zed_pro_url(cx))
})
.separator();
} else if let Some(usage) = self
.edit_prediction_provider
.as_ref()
.and_then(|provider| provider.usage(cx))
+10 -10
View File
@@ -11,19 +11,19 @@ Zed works without AI features or a subscription. No [authentication](../authenti
## Plans {#plans}
| | Free | Pro | Student | Business |
| -------------------------------------------------------- | ------- | --------- | --------- | --------- |
| Zed-hosted AI models | — | ✓ | ✓ | ✓ |
| [AI via own API keys](../ai/use-api-access.md) | ✓ | ✓ | ✓ | ✓ |
| [External Agents](../ai/external-agents.md) | ✓ | ✓ | ✓ | ✓ |
| Edit Predictions | Limited | Unlimited | Unlimited | Unlimited |
| [Org-wide admin controls](../business/admin-controls.md) | — | — | — | ✓ |
| Roles & permissions | — | — | — | ✓ |
| Consolidated billing | — | — | — | ✓ |
| | Free | Pro | Student | Business |
| -------------------------------------------------------- | ---- | --------- | --------- | --------- |
| Zed-hosted AI models | — | ✓ | ✓ | ✓ |
| [AI via own API keys](../ai/use-api-access.md) | ✓ | ✓ | ✓ | ✓ |
| [External Agents](../ai/external-agents.md) | ✓ | ✓ | ✓ | ✓ |
| Edit Predictions | — | Unlimited | Unlimited | Unlimited |
| [Org-wide admin controls](../business/admin-controls.md) | — | — | — | ✓ |
| Roles & permissions | — | — | — | ✓ |
| Consolidated billing | — | — | — | ✓ |
### Zed Free {#free}
Zed is free to use. You can configure AI agents with your own API keys via [Use API Access](../ai/use-api-access.md). [Edit Predictions](../ai/edit-prediction.md) are available on a limited basis. Zed's hosted models require a Pro subscription.
Zed is free to use. You can configure AI agents with your own API keys via [Use API Access](../ai/use-api-access.md). Zed's hosted models and [Edit Predictions](../ai/edit-prediction.md) require a Pro subscription. You can still use edit predictions from [other providers](../ai/edit-prediction.md#other-providers), like GitHub Copilot or a local model.
### Zed Pro {#pro}
+1 -1
View File
@@ -35,7 +35,7 @@ The Z icon in the status bar also indicates Zeta is active.
### Pricing and Plans
The free plan includes 2,000 Zeta predictions per month. The [Pro plan](../account/plans-and-pricing.md) removes this limit. See [Zed's pricing page](https://zed.dev/pricing) for details.
Zeta predictions are included with [Zed Pro](../account/plans-and-pricing.md#pro), the [Pro trial](../account/plans-and-pricing.md#trials), and the [Student](../account/plans-and-pricing.md#student) and [Business](../account/plans-and-pricing.md#business) plans. On the Free plan, you can use [other providers](#other-providers), like GitHub Copilot or a [local model](#local-and-self-hosted-models). See [Zed's pricing page](https://zed.dev/pricing) for details.
### Switching Modes {#switching-modes}