Fix terminal rename not working from context menu on inactive tabs (#50031)

Mohammad Razeghi created

Closes #49939

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing

<img width="485" height="58" alt="Screenshot 2026-02-24 at 11 53 57 PM"
src="https://github.com/user-attachments/assets/651db04a-fc52-46ed-b017-ad586c817bdc"
/>

- [x] Done a self-review taking into account security and performance
aspects
- [x] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Fix terminal rename not working from context menu on inactive tabs

Change summary

crates/terminal_view/src/terminal_view.rs | 7 +++++++
1 file changed, 7 insertions(+)

Detailed changes

crates/terminal_view/src/terminal_view.rs 🔗

@@ -1350,9 +1350,16 @@ impl Item for TerminalView {
             None => (IconName::Terminal, Color::Muted, None),
         };
 
+        let self_handle = self.self_handle.clone();
         h_flex()
             .gap_1()
             .group("term-tab-icon")
+            .track_focus(&self.focus_handle)
+            .on_action(move |action: &RenameTerminal, window, cx| {
+                self_handle
+                    .update(cx, |this, cx| this.rename_terminal(action, window, cx))
+                    .ok();
+            })
             .child(
                 h_flex()
                     .group("term-tab-icon")