# terminal_view: Don't steal focus from an open modal when terminals appear \(\#63097\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 93f07f6d17217e70cc475ecc7cd0f66476cc0f5a

Requested commit: 93f07f6d17217e70cc475ecc7cd0f66476cc0f5a

Commit: 93f07f6d17217e70cc475ecc7cd0f66476cc0f5a

Tree: d3774b3b7b1d4cf355ba6f5a31622596d70594de

Author: Mikhail Butvin

Committer: GitHub

## Message

```
terminal_view: Don't steal focus from an open modal when terminals appear (#63097)

# Objective

Pressing the recent projects shortcut right after launching Zed opens
the picker, which then dismisses itself a moment later. The terminal
panel takes focus after the keystroke, and the picker cancels on blur.

## Solution

Two paths focused the panel unconditionally at the end of async startup
work: the tail of `TerminalPanel::restore_serialized_state`, and
`RevealStrategy::Always` in `add_terminal_shell` (which
`finish_restoration` uses to spawn the default shell). Both now check
`has_active_modal`, as `add_center_terminal` already did. For the shell
path the check is at reveal time, because the spawn is itself async.

## Testing

Three tests in `terminal_panel.rs`. Two of them fail with the source
change reverted. Manually tested on Linux.

## Before:



https://github.com/user-attachments/assets/66ab9860-b381-46da-8f85-f7a58c5157e6


## After:



https://github.com/user-attachments/assets/57583fe2-3c8a-40e0-9130-bbb612c1e158


Release Notes:

- Fixed the terminal panel dismissing an open modal when terminals
finish restoring during startup
```

## Parents

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

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