# Fixed the zoomed agent panel closing unexpectedly on rewind \(\#62711\) · gitcafe/zed

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

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

Visibility: public

Requested revision: b2d9c2e122fbc408d42276b4456243ba4f90f181

Requested commit: b2d9c2e122fbc408d42276b4456243ba4f90f181

Commit: b2d9c2e122fbc408d42276b4456243ba4f90f181

Tree: 9fcffd66a77b105a2617f510386c4d9b89917bb6

Author: Kirill Bulatov

Committer: GitHub

## Message

```
Fixed the zoomed agent panel closing unexpectedly on rewind (#62711)

`ThreadView::regenerate` does `thread.rewind()` which de-focused the
message editor mid-flight causing the zoomed panel to disappear.

* workspace: Keep zoomed panels open when window focus is lost

Commit adds a test + tweaks a default, generic, fallback to be more
lenient: instead of focusing the workspace (and hiding all panels right
away), try to fall back to whatever panel open

* gpui: Restore focus to nearest surviving ancestor when focus is lost

Commit tries to push it down to a library level and add a way to fall
back to closest ancestor that's still visible with the focus instead.


Release Notes:

- Fixed the zoomed agent panel closing unexpectedly on rewind
```

## Parents

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

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