agent_ui: Do not show Codex wsl warning on wsl (#42079)

Lukas Wirth created

Release Notes:

- Fixed the codex wsl warning being shown on wsl itself

Change summary

crates/agent_ui/src/acp/thread_view.rs | 21 ++++++++++-----------
crates/remote/src/remote_client.rs     |  4 ++++
2 files changed, 14 insertions(+), 11 deletions(-)

Detailed changes

crates/agent_ui/src/acp/thread_view.rs 🔗

@@ -294,7 +294,6 @@ pub struct AcpThreadView {
     resume_thread_metadata: Option<DbThreadMetadata>,
     _cancel_task: Option<Task<()>>,
     _subscriptions: [Subscription; 5],
-    #[cfg(target_os = "windows")]
     show_codex_windows_warning: bool,
 }
 
@@ -401,7 +400,6 @@ impl AcpThreadView {
             ),
         ];
 
-        #[cfg(target_os = "windows")]
         let show_codex_windows_warning = crate::ExternalAgent::parse_built_in(agent.as_ref())
             == Some(crate::ExternalAgent::Codex);
 
@@ -447,7 +445,6 @@ impl AcpThreadView {
             focus_handle: cx.focus_handle(),
             new_server_version_available: None,
             resume_thread_metadata: resume_thread,
-            #[cfg(target_os = "windows")]
             show_codex_windows_warning,
         }
     }
@@ -5252,7 +5249,6 @@ impl AcpThreadView {
         )
     }
 
-    #[cfg(target_os = "windows")]
     fn render_codex_windows_warning(&self, cx: &mut Context<Self>) -> Option<Callout> {
         if self.show_codex_windows_warning {
             Some(
@@ -5268,8 +5264,9 @@ impl AcpThreadView {
                             .icon_size(IconSize::Small)
                             .icon_color(Color::Muted)
                             .on_click(cx.listener({
-                                move |_, _, window, cx| {
-                                    window.dispatch_action(
+                                move |_, _, _window, cx| {
+                                    #[cfg(windows)]
+                                    _window.dispatch_action(
                                         zed_actions::wsl_actions::OpenWsl::default().boxed_clone(),
                                         cx,
                                     );
@@ -5772,13 +5769,15 @@ impl Render for AcpThreadView {
             })
             .children(self.render_thread_retry_status_callout(window, cx))
             .children({
-                #[cfg(target_os = "windows")]
+                if self
+                    .project
+                    .read(cx)
+                    .remote_connection_options(cx)
+                    .is_some_and(|it| it.is_wsl())
                 {
                     self.render_codex_windows_warning(cx)
-                }
-                #[cfg(not(target_os = "windows"))]
-                {
-                    Vec::<Empty>::new()
+                } else {
+                    None
                 }
             })
             .children(self.render_thread_error(cx))

crates/remote/src/remote_client.rs 🔗

@@ -1077,6 +1077,10 @@ impl RemoteConnectionOptions {
             RemoteConnectionOptions::Wsl(opts) => opts.distro_name.clone(),
         }
     }
+
+    pub fn is_wsl(&self) -> bool {
+        matches!(self, RemoteConnectionOptions::Wsl(_))
+    }
 }
 
 impl From<SshConnectionOptions> for RemoteConnectionOptions {