zeta: Fix update required notification not showing (#25588)

This PR fixes an issue introduced in #25530 that broke the notifications
that inform the user that a Zed update is required to continue using
edit prediction.

The issue is that the `Workspace` stored on the `Editor` is set _after_
the point we initialize Zeta, so capturing the `Workspace` at
construction time leads to it being `None`.

@ConradIrwin suggested that we could obtain the `Workspace` from the
`Window`, which does indeed do the trick.

I tested it both with and without this change by mocking the error
response, like so:

```rs
let response: Result<PredictEditsResponse, anyhow::Error> =
    Err(anyhow!(ZedUpdateRequiredError {
        minimum_version: SemanticVersion::new(0, 1, 0),
    }));
```

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-02-25 15:02:43 -05:00 committed by GitHub
parent 23f61d5954
commit e5b6194914
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -9,6 +9,7 @@ use settings::SettingsStore;
use std::{cell::RefCell, rc::Rc, sync::Arc};
use supermaven::{Supermaven, SupermavenCompletionProvider};
use ui::Window;
use workspace::Workspace;
use zeta::{ProviderDataCollection, ZetaInlineCompletionProvider};
pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
@ -266,13 +267,13 @@ fn assign_edit_prediction_provider(
}
}
let zeta = zeta::Zeta::register(
editor.workspace().map(|w| w.downgrade()),
worktree,
client.clone(),
user_store,
cx,
);
let workspace = window
.root::<Workspace>()
.flatten()
.map(|workspace| workspace.downgrade());
let zeta =
zeta::Zeta::register(workspace, worktree, client.clone(), user_store, cx);
if let Some(buffer) = &singleton_buffer {
if buffer.read(cx).file().is_some() {

View file

@ -704,7 +704,10 @@ and then another
can_collect_data: bool,
cx: &mut Context<Self>,
) -> Task<Result<Option<InlineCompletion>>> {
let workspace = self.workspace.as_ref().and_then(|w| w.upgrade());
let workspace = self
.workspace
.as_ref()
.and_then(|workspace| workspace.upgrade());
self.request_completion_impl(
workspace,
project,