Show edit predictions usage in status bar menu (#29046)

This PR adds an indicator for edit predictions usage in the edit
predictions menu:

| Free | Zed Pro / Trial |
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
| <img width="235" alt="Screenshot 2025-04-18 at 9 53 47 AM"
src="https://github.com/user-attachments/assets/6da001d2-ef9c-49df-86be-03d4c615d45c"
/> | <img width="237" alt="Screenshot 2025-04-18 at 9 54 33 AM"
src="https://github.com/user-attachments/assets/31f5df04-a8e1-43ec-8af7-ebe501516abe"
/> |

Only visible to users on the new billing.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-18 10:15:19 -04:00 committed by GitHub
parent 62b8ef980b
commit 0dc0701967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 111 additions and 43 deletions

View file

@ -29,10 +29,11 @@ settings.workspace = true
supermaven.workspace = true
telemetry.workspace = true
ui.workspace = true
workspace-hack.workspace = true
workspace.workspace = true
zed_actions.workspace = true
zed_llm_client.workspace = true
zeta.workspace = true
workspace-hack.workspace = true
[dev-dependencies]
copilot = { workspace = true, features = ["test-support"] }

View file

@ -1,5 +1,5 @@
use anyhow::Result;
use client::UserStore;
use client::{UserStore, zed_urls};
use copilot::{Copilot, Status};
use editor::{
Editor,
@ -27,13 +27,14 @@ use std::{
use supermaven::{AccountStatus, Supermaven};
use ui::{
Clickable, ContextMenu, ContextMenuEntry, IconButton, IconButtonShape, Indicator, PopoverMenu,
PopoverMenuHandle, Tooltip, prelude::*,
PopoverMenuHandle, ProgressBar, Tooltip, prelude::*,
};
use workspace::{
StatusItemView, Toast, Workspace, create_and_open_local_file, item::ItemHandle,
notifications::NotificationId,
};
use zed_actions::OpenBrowser;
use zed_llm_client::{Plan, UsageLimit};
use zeta::RateCompletions;
actions!(edit_prediction, [ToggleMenu]);
@ -402,6 +403,45 @@ impl InlineCompletionButton {
let fs = self.fs.clone();
let line_height = window.line_height();
if let Some(provider) = self.edit_prediction_provider.as_ref() {
if let Some(usage) = provider.usage(cx) {
menu = menu.header("Usage");
menu = menu.custom_entry(
move |_window, cx| {
let plan = Plan::ZedProTrial;
let edit_predictions_limit = plan.edit_predictions_limit();
let used_percentage = match edit_predictions_limit {
UsageLimit::Limited(limit) => {
Some((usage.amount as f32 / limit as f32) * 100.)
}
UsageLimit::Unlimited => None,
};
h_flex()
.flex_1()
.gap_1p5()
.children(
used_percentage
.map(|percent| ProgressBar::new("usage", percent, 100., cx)),
)
.child(
Label::new(match edit_predictions_limit {
UsageLimit::Limited(limit) => {
format!("{} / {limit}", usage.amount)
}
UsageLimit::Unlimited => format!("{} / ∞", usage.amount),
})
.size(LabelSize::Small)
.color(Color::Muted),
)
.into_any_element()
},
move |_, cx| cx.open_url(&zed_urls::account_url(cx)),
);
}
}
menu = menu.header("Show Edit Predictions For");
let language_state = self.language.as_ref().map(|language| {