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:
Agus Zubiaga 2025-01-20 11:48:49 -03:00 committed by GitHub
parent 5bb696e6d7
commit 919803a4f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 427 additions and 23 deletions

View file

@ -36,6 +36,9 @@ pub trait InlineCompletionProvider: 'static + Sized {
debounce: bool,
cx: &mut ModelContext<Self>,
);
fn needs_terms_acceptance(&self, _cx: &AppContext) -> bool {
false
}
fn cycle(
&mut self,
buffer: Model<Buffer>,
@ -64,6 +67,7 @@ pub trait InlineCompletionProviderHandle {
) -> bool;
fn show_completions_in_menu(&self) -> bool;
fn show_completions_in_normal_mode(&self) -> bool;
fn needs_terms_acceptance(&self, cx: &AppContext) -> bool;
fn is_refreshing(&self, cx: &AppContext) -> bool;
fn refresh(
&self,
@ -118,6 +122,10 @@ where
self.read(cx).is_enabled(buffer, cursor_position, cx)
}
fn needs_terms_acceptance(&self, cx: &AppContext) -> bool {
self.read(cx).needs_terms_acceptance(cx)
}
fn is_refreshing(&self, cx: &AppContext) -> bool {
self.read(cx).is_refreshing()
}