From 2d6f697a6e72213358debd2a3e1787d096dbb75a Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Fri, 13 Mar 2026 12:06:11 -0700 Subject: [PATCH] Make icon_tooltip not optional Co-authored-by: Max Brunsfeld --- crates/agent_ui/src/agent_panel.rs | 4 ++-- crates/collab_ui/src/collab_panel.rs | 4 ++-- crates/collab_ui/src/notification_panel.rs | 4 ++-- crates/debugger_ui/src/debugger_panel.rs | 8 ++----- crates/git_ui/src/git_panel.rs | 4 ++-- crates/outline_panel/src/outline_panel.rs | 4 ++-- crates/project_panel/src/project_panel.rs | 4 ++-- crates/terminal_view/src/terminal_panel.rs | 4 ++-- crates/workspace/src/dock.rs | 28 +++++++++------------- 9 files changed, 27 insertions(+), 37 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index d5c2942cf3528b94ad7d93271ef75e976bcbea56..75e61c3a8f19ce4b9ed137df69fedb679cff6049 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -3234,8 +3234,8 @@ impl Panel for AgentPanel { (self.enabled(cx) && AgentSettings::get_global(cx).button).then_some(IconName::ZedAssistant) } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Agent Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Agent Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 9aeeeeb4233a7e5486ef49da8b0aeaaddd846d17..8d48370a27c7a50323d2dfa1ad95a8284491d81d 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -3197,8 +3197,8 @@ impl Panel for CollabPanel { .then_some(ui::IconName::UserGroup) } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Collab Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Collab Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index fd70163896113f0a20b66c5181749d58385b4c34..93300f55d862f710d576a18152424830ce9746f2 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -672,8 +672,8 @@ impl Panel for NotificationPanel { Some(IconName::BellDot) } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Notification Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Notification Panel" } fn icon_label(&self, _window: &Window, cx: &App) -> Option { diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 7e11fe4e19f9acafdb9e2d0be30069f3d5457e5c..9750fd360f564a3b74b7f868a7e5e02f675a5bc9 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -1585,12 +1585,8 @@ impl Panel for DebugPanel { .then_some(IconName::Debug) } - fn icon_tooltip(&self, _window: &Window, cx: &App) -> Option<&'static str> { - if DebuggerSettings::get_global(cx).button { - Some("Debug Panel") - } else { - None - } + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Debug Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 8205f5ee7b6a9966a37a8406331d171d8ca57f1d..8a8a900df1ddff361d144c0b71c4637205f9ef0d 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -5734,8 +5734,8 @@ impl Panel for GitPanel { Some(ui::IconName::GitBranchAlt).filter(|_| GitPanelSettings::get_global(cx).button) } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Git Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Git Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index ec85fc14a2eefe280afd0d44ed92b4b8502f460c..eca4d92ed6a762d68506d752cd0aacc241eb9b67 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -5023,8 +5023,8 @@ impl Panel for OutlinePanel { .then_some(IconName::ListTree) } - fn icon_tooltip(&self, _window: &Window, _: &App) -> Option<&'static str> { - Some("Outline Panel") + fn icon_tooltip(&self, _window: &Window, _: &App) -> &'static str { + "Outline Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 96e680c0d1648bd4cf337cbc55e321e3948c217a..2a72a58db828f6caec66a1b114e4baba84f44e34 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -7063,8 +7063,8 @@ impl Panel for ProjectPanel { .then_some(IconName::FileTree) } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Project Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Project Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 93b9e651191e791da8bbda35600c3db001b46d90..27d532c3d67c04bbe09830b79da6b5abaef5cc29 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -1637,8 +1637,8 @@ impl Panel for TerminalPanel { } } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - Some("Terminal Panel") + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Terminal Panel" } fn toggle_action(&self) -> Box { diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 439c6df5ee45938368895a67834d57df695fde89..62c63a664dae08fbda3291dd9b63d2c94a518efb 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -36,7 +36,7 @@ pub trait Panel: Focusable + EventEmitter + Render + Sized { fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&mut self, size: Option, window: &mut Window, cx: &mut Context); fn icon(&self, window: &Window, cx: &App) -> Option; - fn icon_tooltip(&self, window: &Window, cx: &App) -> Option<&'static str>; + fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str; fn toggle_action(&self) -> Box; fn icon_label(&self, _window: &Window, _: &App) -> Option { None @@ -76,7 +76,7 @@ pub trait PanelHandle: Send + Sync { fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&self, size: Option, window: &mut Window, cx: &mut App); fn icon(&self, window: &Window, cx: &App) -> Option; - fn icon_tooltip(&self, window: &Window, cx: &App) -> Option<&'static str>; + fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str; fn toggle_action(&self, window: &Window, cx: &App) -> Box; fn icon_label(&self, window: &Window, cx: &App) -> Option; fn panel_focus_handle(&self, cx: &App) -> FocusHandle; @@ -160,7 +160,7 @@ where self.read(cx).icon(window, cx) } - fn icon_tooltip(&self, window: &Window, cx: &App) -> Option<&'static str> { + fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str { self.read(cx).icon_tooltip(window, cx) } @@ -265,11 +265,6 @@ struct PanelEntry { _subscriptions: [Subscription; 3], } -pub struct PanelButtons { - dock: Entity, - _settings_subscription: Subscription, -} - impl Dock { pub fn new( position: DockPosition, @@ -886,6 +881,11 @@ impl Render for Dock { } } +pub struct PanelButtons { + dock: Entity, + _settings_subscription: Subscription, +} + impl PanelButtons { pub fn new(dock: Entity, cx: &mut Context) -> Self { cx.observe(&dock, |_, _, cx| cx.notify()).detach(); @@ -915,13 +915,7 @@ impl Render for PanelButtons { .enumerate() .filter_map(|(i, entry)| { let icon = entry.panel.icon(window, cx)?; - let icon_tooltip = entry - .panel - .icon_tooltip(window, cx) - .ok_or_else(|| { - anyhow::anyhow!("can't render a panel button without an icon tooltip") - }) - .log_err()?; + let icon_tooltip = entry.panel.icon_tooltip(window, cx); let name = entry.panel.persistent_name(); let panel = entry.panel.clone(); @@ -1089,8 +1083,8 @@ pub mod test { None } - fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { - None + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { + "Test Panel" } fn toggle_action(&self) -> Box {