ZIm/crates/workspace/src
tims 7ed834bd79
terminal: Fix unresponsive buttons on load until center pane is clicked + Auto-focus docked terminal on load if no other item is focused (#23039)
Closes #23006

This PR should have been split into two, but since the changes are
related, I merged them into one.

1. On load, the title bar actions and bottom bar toggles are
unresponsive until the center pane is clicked. This happens because the
terminal captures focus (even if it's closed) long after the workspace
sets focus to itself during loading.

The issue was in the `focus_view` call used in the `new` method of
`TerminalPanel`. Since new terminal views can be created behind the
scenes (i.e., without the terminal being visible to the user), we
shouldn't handle focus for the terminal in this case. Removing
`focus_view` from the `new` method has no impact on the existing
terminal focusing logic. I've tested scenarios such as creating new
terminals, splitting terminals, zooming, etc., and everything works as
expected.

2. Currently, on load, docked terminals do not automatically focus when
they are only visible item to the user. This PR implements it.

Before/After:

1. When only the dock terminal is visible on load. Terminal is focused.

<img
src="https://github.com/user-attachments/assets/af8848aa-ccb5-4a3b-b2c6-486e8d588f09"
alt="image" height="280px" />

<img
src="https://github.com/user-attachments/assets/8f76ca2e-de29-4cc0-979b-749b50a00bbd"
alt="image" height="280px" />

2. When other items are visible along with the dock terminal on load.
Editor is focused.

<img
src="https://github.com/user-attachments/assets/d3248272-a75d-4763-9e99-defb8a369b68"
alt="image" height="280px" />

<img
src="https://github.com/user-attachments/assets/fba5184e-1ab2-406c-9669-b141aaf1c32f"
alt="image" height="280px" />

3. Multiple tabs along with split panes. Last terminal is focused.

<img
src="https://github.com/user-attachments/assets/7a10c3cf-8bb3-4b88-aacc-732b678bee19"
alt="image" height="270px" />

<img
src="https://github.com/user-attachments/assets/4d16e98f-9d7a-45f6-8701-d6652e411d3b"
alt="image" height="270px" />

Future:

When a docked terminal is in a zoomed state and Zed is loaded, we should
prioritize focusing on the terminal over the active item (e.g., an
editor) behind it. This hasn't been implemented in this PR because the
zoomed state during the load function is stale. The correct state is
received later via the workspace. I'm still investigating where exactly
this should be handled, so this will be a separate PR.

cc: @SomeoneToIgnore 

Release Notes:

- Fixed unresponsive buttons on load until the center pane is clicked.  
- Added auto-focus for the docked terminal on load when no other item is
focused.
2025-01-13 15:11:45 +00:00
..
persistence Fix empty title in Recent Projects (#21952) 2025-01-07 03:45:38 +00:00
shared_screen Simplify livekit config so that cargo check Just Works (#21661) 2024-12-06 13:50:59 -08:00
dock.rs Reduce amount of workspace serialization happening (#22730) 2025-01-07 11:00:26 +00:00
item.rs pane: Add ability to use custom tooltip content (#22879) 2025-01-09 15:34:30 +00:00
modal_layer.rs chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
notifications.rs extensions_ui: Show an error toast when a dev extension fails to install (#22914) 2025-01-09 19:38:16 +00:00
pane.rs Improve keymap json schema (#23044) 2025-01-13 02:34:35 +00:00
pane_group.rs Improve keymap json schema (#23044) 2025-01-13 02:34:35 +00:00
persistence.rs Move git status out of Entry (#22224) 2025-01-04 01:00:16 +00:00
searchable.rs Display buffer/project search entries in the outline panel (#16589) 2024-08-25 21:40:02 +03:00
shared_screen.rs Simplify livekit config so that cargo check Just Works (#21661) 2024-12-06 13:50:59 -08:00
status_bar.rs Status bar: Reduce right tools lateral margin (#21329) 2024-11-29 10:56:32 -03:00
tasks.rs Cleanups preparing for WindowContext refactor (#22475) 2024-12-28 21:36:14 +00:00
theme_preview.rs Add the SwitchWithLabel component (#22314) 2024-12-20 23:44:47 +00:00
toolbar.rs Refactor Spacing into DynamicSpacing using proc macro (#20504) 2024-11-11 11:08:55 -05:00
workspace.rs terminal: Fix unresponsive buttons on load until center pane is clicked + Auto-focus docked terminal on load if no other item is focused (#23039) 2025-01-13 15:11:45 +00:00
workspace_settings.rs workspace: Fix doc comments (#22063) 2024-12-16 08:27:14 -05:00