assistant panel: Fix panic when opening panel with zed.dev provider (#15538)

There was/is some race condition that gets triggered only with the
zed.dev provider when opening the provider that would cause a
double-borrow on workspace.

This PR fixes the issue by cloning the workspace weakly. Turns out we
can go very far with just the weak reference.

We're still a bit unsure why exactly the race condition happened, since
it's hard to reproduce, but we're working on configuration
view/management in #15490 anyway.

Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-07-31 16:57:24 +02:00 committed by GitHub
parent 64bfec533e
commit 874fedd717
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 24 deletions

View file

@ -84,8 +84,10 @@ impl CloudLanguageModelProvider {
while let Some(status) = status_rx.next().await {
if let Some(this) = state_ref.upgrade() {
_ = this.update(&mut cx, |this, cx| {
this.status = status;
cx.notify();
if this.status != status {
this.status = status;
cx.notify();
}
});
} else {
break;