Require accepting ToS when enabling zeta (#23255)
Note: Design hasn't been reviewed yet, but the logic is done When the user switches the inline completion provider to `zed`, we'll show a modal prompting them to accept terms if they haven't done so: https://github.com/user-attachments/assets/3fc6d368-c00a-4dcb-9484-fbbbb5eb859e If they dismiss the modal, they'll be able to get to it again from the inline completion button: https://github.com/user-attachments/assets/cf842778-5538-4e06-9ed8-21579981cc47 This also stops zeta sending requests that will fail immediately when ToS are not accepted. Release Notes: - N/A --------- Co-authored-by: Richard <richard@zed.dev> Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Co-authored-by: Joao <joao@zed.dev>
This commit is contained in:
parent
5bb696e6d7
commit
919803a4f4
19 changed files with 427 additions and 23 deletions
|
@ -70,6 +70,7 @@ pub use element::{
|
|||
};
|
||||
use futures::{future, FutureExt};
|
||||
use fuzzy::StringMatchCandidate;
|
||||
use zed_predict_tos::ZedPredictTos;
|
||||
|
||||
use code_context_menus::{
|
||||
AvailableCodeAction, CodeActionContents, CodeActionsItem, CodeActionsMenu, CodeContextMenu,
|
||||
|
@ -459,6 +460,7 @@ type CompletionId = usize;
|
|||
enum InlineCompletionMenuHint {
|
||||
Loading,
|
||||
Loaded { text: InlineCompletionText },
|
||||
PendingTermsAcceptance,
|
||||
None,
|
||||
}
|
||||
|
||||
|
@ -468,6 +470,7 @@ impl InlineCompletionMenuHint {
|
|||
InlineCompletionMenuHint::Loading | InlineCompletionMenuHint::Loaded { .. } => {
|
||||
"Edit Prediction"
|
||||
}
|
||||
InlineCompletionMenuHint::PendingTermsAcceptance => "Accept Terms of Service",
|
||||
InlineCompletionMenuHint::None => "No Prediction",
|
||||
}
|
||||
}
|
||||
|
@ -3828,6 +3831,14 @@ impl Editor {
|
|||
self.do_completion(action.item_ix, CompletionIntent::Compose, cx)
|
||||
}
|
||||
|
||||
fn toggle_zed_predict_tos(&mut self, cx: &mut ViewContext<Self>) {
|
||||
let (Some(workspace), Some(project)) = (self.workspace(), self.project.as_ref()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
ZedPredictTos::toggle(workspace, project.read(cx).user_store().clone(), cx);
|
||||
}
|
||||
|
||||
fn do_completion(
|
||||
&mut self,
|
||||
item_ix: Option<usize>,
|
||||
|
@ -3851,6 +3862,14 @@ impl Editor {
|
|||
self.context_menu_next(&Default::default(), cx);
|
||||
return Some(Task::ready(Ok(())));
|
||||
}
|
||||
Some(CompletionEntry::InlineCompletionHint(
|
||||
InlineCompletionMenuHint::PendingTermsAcceptance,
|
||||
)) => {
|
||||
drop(entries);
|
||||
drop(context_menu);
|
||||
self.toggle_zed_predict_tos(cx);
|
||||
return Some(Task::ready(Ok(())));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -4974,6 +4993,8 @@ impl Editor {
|
|||
Some(InlineCompletionMenuHint::Loaded { text })
|
||||
} else if provider.is_refreshing(cx) {
|
||||
Some(InlineCompletionMenuHint::Loading)
|
||||
} else if provider.needs_terms_acceptance(cx) {
|
||||
Some(InlineCompletionMenuHint::PendingTermsAcceptance)
|
||||
} else {
|
||||
Some(InlineCompletionMenuHint::None)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue