# Fix circular reference issue between EditPredictionButton and PopoverMenuHandle \(\#42351\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/42ed032f129fbb65e1e9ddb42ac9dcf9ae71eba6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 42ed032f129fbb65e1e9ddb42ac9dcf9ae71eba6

Requested commit: 42ed032f129fbb65e1e9ddb42ac9dcf9ae71eba6

Commit: 42ed032f129fbb65e1e9ddb42ac9dcf9ae71eba6

Tree: 0e9c3924529dd0fc81826e005d8bb2a4ac3614d3

Author: feeiyu

Committer: GitHub

## Message

```
Fix circular reference issue between EditPredictionButton and PopoverMenuHandle (#42351)

Closes #ISSUE

While working on issue #40906, I discovered that RemoteClient was not
being released after the remote project closed.
Analysis revealed a circular reference between EditPredictionButton and
PopoverMenuHandle.

Dependency Chain: RemoteClient → Project → ZetaEditPredictionProvider →
EditPredictionButton ↔ PopoverMenuHandle

<img width="400" height="300" alt="image"
src="https://github.com/user-attachments/assets/6b716c9b-6938-471a-b044-397314b729d4"
/>

a) EditPredictionButton hold the reference of PopoverMenuHandle 

https://github.com/zed-industries/zed/blob/5f8226457ee6e1346a224ae6b0329f014ea883f7/crates/zed/src/zed.rs#L386-L394

b) PopoverMenuHandle hold the reference of Fn which capture
`Entity<EditPredictionButton>`

https://github.com/zed-industries/zed/blob/5fc54986c72f2863645302c5e6a99277f8c38cab/crates/edit_prediction_button/src/edit_prediction_button.rs#L382-L389


https://github.com/zed-industries/zed/blob/a9bc890497f1edaf4f177385cf96785de60e910c/crates/ui/src/components/popover_menu.rs#L376-L384


Release Notes:

- N/A
```

## Parents

- [2d84af91bf3e272770c07ddb4056618cb5e5e9a8](https://git.cafe/gitcafe/zed/commit/2d84af91bf3e272770c07ddb4056618cb5e5e9a8?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/42ed032f129fbb65e1e9ddb42ac9dcf9ae71eba6?format=markdown)
