From f07305ba71d644c7e5cfea7266119778a65279d6 Mon Sep 17 00:00:00 2001 From: KyleBarton Date: Tue, 3 Feb 2026 11:36:37 -0800 Subject: [PATCH] Remove duplicated logic to unify code paths (#48291) Small fix for a bug introduced in #47411 In-progress dev container creation didn't show up in modal because of a duplicated code path. This unifies the logic and ensures that "creating dev container" shows up while creation in progress. Release Notes: - Fixed modal for creating dev container --- crates/recent_projects/src/recent_projects.rs | 77 +++---------------- 1 file changed, 9 insertions(+), 68 deletions(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 2693266b927b4dd1c2cdeab594a801b37df0079f..f3660a6e3fe5404296c24fbd7daa5e04aa8db92a 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -9,7 +9,6 @@ use std::path::PathBuf; #[cfg(target_os = "windows")] mod wsl_picker; -use dev_container::{find_devcontainer_configs, start_dev_container_with_config}; use remote::RemoteConnectionOptions; pub use remote_connection::{RemoteConnectionModal, connect}; pub use remote_connections::open_remote_project; @@ -38,8 +37,6 @@ use workspace::{ }; use zed_actions::{OpenDevContainer, OpenRecent, OpenRemote}; -use crate::remote_connections::Connection; - #[derive(Clone, Debug)] pub struct RecentProjectEntry { pub name: SharedString, @@ -235,8 +232,6 @@ pub fn init(cx: &mut App) { cx.on_action(|_: &OpenDevContainer, cx| { with_active_or_new_workspace(cx, move |workspace, window, cx| { - let app_state = workspace.app_state().clone(); - let replace_window = window.window_handle().downcast::(); let is_local = workspace.project().read(cx).is_local(); cx.spawn_in(window, async move |_, cx| { @@ -252,70 +247,16 @@ pub fn init(cx: &mut App) { return; } - let configs = find_devcontainer_configs(cx); - - if configs.len() > 1 { - // Multiple configs found - show modal for selection - cx.update(|_, cx| { - with_active_or_new_workspace(cx, move |workspace, window, cx| { - let fs = workspace.project().read(cx).fs().clone(); - let handle = cx.entity().downgrade(); - workspace.toggle_modal(window, cx, |window, cx| { - RemoteServerProjects::new_dev_container(fs, window, handle, cx) - }); + cx.update(|_, cx| { + with_active_or_new_workspace(cx, move |workspace, window, cx| { + let fs = workspace.project().read(cx).fs().clone(); + let handle = cx.entity().downgrade(); + workspace.toggle_modal(window, cx, |window, cx| { + RemoteServerProjects::new_dev_container(fs, window, handle, cx) }); - }) - .log_err(); - return; - } - - // Single or no config - proceed with opening directly - let config = configs.into_iter().next(); - let (connection, starting_dir) = match start_dev_container_with_config( - cx, - app_state.node_runtime.clone(), - config, - ) - .await - { - Ok((c, s)) => (Connection::DevContainer(c), s), - Err(e) => { - log::error!("Failed to start Dev Container: {:?}", e); - cx.prompt( - gpui::PromptLevel::Critical, - "Failed to start Dev Container", - Some(&format!("{:?}", e)), - &["Ok"], - ) - .await - .ok(); - return; - } - }; - - let result = open_remote_project( - connection.into(), - vec![starting_dir].into_iter().map(PathBuf::from).collect(), - app_state, - OpenOptions { - replace_window, - ..OpenOptions::default() - }, - cx, - ) - .await; - - if let Err(e) = result { - log::error!("Failed to connect: {e:#}"); - cx.prompt( - gpui::PromptLevel::Critical, - "Failed to connect", - Some(&e.to_string()), - &["Ok"], - ) - .await - .ok(); - } + }); + }) + .log_err(); }) .detach(); });