zeta: Do not show usage for copilot/supermaven (#30563)
Follow up to #29952 Release Notes: - Fix an issue where zeta usage would show up when using Copilot as an edit prediction provider
This commit is contained in:
parent
8e39281699
commit
19b6c4444e
4 changed files with 64 additions and 64 deletions
|
@ -48,7 +48,7 @@ use std::{
|
|||
};
|
||||
use telemetry_events::InlineCompletionRating;
|
||||
use thiserror::Error;
|
||||
use util::ResultExt;
|
||||
use util::{ResultExt, maybe};
|
||||
use uuid::Uuid;
|
||||
use workspace::Workspace;
|
||||
use workspace::notifications::{ErrorMessagePrompt, NotificationId};
|
||||
|
@ -193,6 +193,7 @@ pub struct Zeta {
|
|||
tos_accepted: bool,
|
||||
/// Whether an update to a newer version of Zed is required to continue using Zeta.
|
||||
update_required: bool,
|
||||
user_store: Entity<UserStore>,
|
||||
_user_store_subscription: Subscription,
|
||||
license_detection_watchers: HashMap<WorktreeId, Rc<LicenseDetectionWatcher>>,
|
||||
}
|
||||
|
@ -232,6 +233,28 @@ impl Zeta {
|
|||
self.events.clear();
|
||||
}
|
||||
|
||||
pub fn usage(&self, cx: &App) -> Option<EditPredictionUsage> {
|
||||
self.last_usage.or_else(|| {
|
||||
let user_store = self.user_store.read(cx);
|
||||
maybe!({
|
||||
let amount = user_store.edit_predictions_usage_amount()?;
|
||||
let limit = user_store.edit_predictions_usage_limit()?.variant?;
|
||||
|
||||
Some(EditPredictionUsage {
|
||||
amount: amount as i32,
|
||||
limit: match limit {
|
||||
proto::usage_limit::Variant::Limited(limited) => {
|
||||
zed_llm_client::UsageLimit::Limited(limited.limit as i32)
|
||||
}
|
||||
proto::usage_limit::Variant::Unlimited(_) => {
|
||||
zed_llm_client::UsageLimit::Unlimited
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn new(
|
||||
workspace: Option<WeakEntity<Workspace>>,
|
||||
client: Arc<Client>,
|
||||
|
@ -282,6 +305,7 @@ impl Zeta {
|
|||
}
|
||||
}),
|
||||
license_detection_watchers: HashMap::default(),
|
||||
user_store,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1441,7 @@ impl inline_completion::EditPredictionProvider for ZetaInlineCompletionProvider
|
|||
}
|
||||
|
||||
fn usage(&self, cx: &App) -> Option<EditPredictionUsage> {
|
||||
self.zeta.read(cx).last_usage
|
||||
self.zeta.read(cx).usage(cx)
|
||||
}
|
||||
|
||||
fn is_enabled(
|
||||
|
@ -1891,6 +1915,7 @@ mod tests {
|
|||
zeta.request_completion(None, &buffer, cursor, false, cx)
|
||||
});
|
||||
|
||||
server.receive::<proto::GetUsers>().await.unwrap();
|
||||
let token_request = server.receive::<proto::GetLlmToken>().await.unwrap();
|
||||
server.respond(
|
||||
token_request.receipt(),
|
||||
|
@ -1945,6 +1970,7 @@ mod tests {
|
|||
zeta.request_completion(None, &buffer, cursor, false, cx)
|
||||
});
|
||||
|
||||
server.receive::<proto::GetUsers>().await.unwrap();
|
||||
let token_request = server.receive::<proto::GetLlmToken>().await.unwrap();
|
||||
server.respond(
|
||||
token_request.receipt(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue