Start separating authentication from connection to collab (#35471)

This pull request should be idempotent, but lays the groundwork for
avoiding to connect to collab in order to interact with AI features
provided by Zed.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
Antonio Scandurra 2025-08-01 19:37:38 +02:00 committed by GitHub
parent b01d1872cc
commit f888f3fc0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 653 additions and 855 deletions

View file

@ -1,5 +1,5 @@
use anyhow::Result;
use client::{CloudUserStore, DisableAiSettings, zed_urls};
use client::{DisableAiSettings, UserStore, zed_urls};
use cloud_llm_client::UsageLimit;
use copilot::{Copilot, Status};
use editor::{
@ -59,7 +59,7 @@ pub struct InlineCompletionButton {
file: Option<Arc<dyn File>>,
edit_prediction_provider: Option<Arc<dyn inline_completion::InlineCompletionProviderHandle>>,
fs: Arc<dyn Fs>,
cloud_user_store: Entity<CloudUserStore>,
user_store: Entity<UserStore>,
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
}
@ -245,9 +245,9 @@ impl Render for InlineCompletionButton {
IconName::ZedPredictDisabled
};
if zeta::should_show_upsell_modal(&self.cloud_user_store, cx) {
let tooltip_meta = if self.cloud_user_store.read(cx).is_authenticated() {
if self.cloud_user_store.read(cx).has_accepted_tos() {
if zeta::should_show_upsell_modal(&self.user_store, cx) {
let tooltip_meta = if self.user_store.read(cx).current_user().is_some() {
if self.user_store.read(cx).has_accepted_terms_of_service() {
"Choose a Plan"
} else {
"Accept the Terms of Service"
@ -371,7 +371,7 @@ impl Render for InlineCompletionButton {
impl InlineCompletionButton {
pub fn new(
fs: Arc<dyn Fs>,
cloud_user_store: Entity<CloudUserStore>,
user_store: Entity<UserStore>,
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
cx: &mut Context<Self>,
) -> Self {
@ -390,9 +390,9 @@ impl InlineCompletionButton {
language: None,
file: None,
edit_prediction_provider: None,
user_store,
popover_menu_handle,
fs,
cloud_user_store,
}
}
@ -763,7 +763,7 @@ impl InlineCompletionButton {
})
})
.separator();
} else if self.cloud_user_store.read(cx).account_too_young() {
} else if self.user_store.read(cx).account_too_young() {
menu = menu
.custom_entry(
|_window, _cx| {
@ -778,7 +778,7 @@ impl InlineCompletionButton {
cx.open_url(&zed_urls::account_url(cx))
})
.separator();
} else if self.cloud_user_store.read(cx).has_overdue_invoices() {
} else if self.user_store.read(cx).has_overdue_invoices() {
menu = menu
.custom_entry(
|_window, _cx| {