debugger: More tidy up for SSH (#28993)

Split `locator` out of DebugTaskDefinition to make it clearer when
location needs to happen.

Release Notes:

- N/A

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Cole Miller <m@cole-miller.net>
This commit is contained in:
Conrad Irwin 2025-04-21 10:00:03 -06:00 committed by GitHub
parent d13cd007a2
commit 9d35f0389d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 1146 additions and 884 deletions

View file

@ -15,7 +15,6 @@ mod toast_layer;
mod toolbar;
mod workspace_settings;
use dap::DapRegistry;
pub use toast_layer::{RunAction, ToastAction, ToastLayer, ToastView};
use anyhow::{Context as _, Result, anyhow};
@ -92,11 +91,12 @@ use std::{
env,
hash::{Hash, Hasher},
path::{Path, PathBuf},
process::ExitStatus,
rc::Rc,
sync::{Arc, LazyLock, Weak, atomic::AtomicUsize},
time::Duration,
};
use task::{DebugTaskDefinition, SpawnInTerminal, TaskId};
use task::SpawnInTerminal;
use theme::{ActiveTheme, SystemAppearance, ThemeSettings};
pub use toolbar::{Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
pub use ui;
@ -130,6 +130,15 @@ static ZED_WINDOW_POSITION: LazyLock<Option<Point<Pixels>>> = LazyLock::new(|| {
.and_then(parse_pixel_position_env_var)
});
pub trait TerminalProvider {
fn spawn(
&self,
task: SpawnInTerminal,
window: &mut Window,
cx: &mut App,
) -> Task<Result<ExitStatus>>;
}
actions!(
workspace,
[
@ -626,7 +635,6 @@ pub fn register_serializable_item<I: SerializableItem>(cx: &mut App) {
pub struct AppState {
pub languages: Arc<LanguageRegistry>,
pub debug_adapters: Arc<DapRegistry>,
pub client: Arc<Client>,
pub user_store: Entity<UserStore>,
pub workspace_store: Entity<WorkspaceStore>,
@ -678,7 +686,6 @@ impl AppState {
let fs = fs::FakeFs::new(cx.background_executor().clone());
let languages = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
let debug_adapters = Arc::new(DapRegistry::fake());
let clock = Arc::new(clock::FakeSystemClock::new());
let http_client = http_client::FakeHttpClient::with_404_response();
let client = Client::new(clock, http_client.clone(), cx);
@ -694,7 +701,6 @@ impl AppState {
client,
fs,
languages,
debug_adapters,
user_store,
workspace_store,
node_runtime: NodeRuntime::unavailable(),
@ -772,9 +778,6 @@ pub enum Event {
},
ContactRequestedJoin(u64),
WorkspaceCreated(WeakEntity<Workspace>),
SpawnTask {
action: Box<SpawnInTerminal>,
},
OpenBundledFile {
text: Cow<'static, str>,
title: &'static str,
@ -856,11 +859,11 @@ pub struct Workspace {
bounds_save_task_queued: Option<Task<()>>,
on_prompt_for_new_path: Option<PromptForNewPath>,
on_prompt_for_open_path: Option<PromptForOpenPath>,
terminal_provider: Option<Box<dyn TerminalProvider>>,
serializable_items_tx: UnboundedSender<Box<dyn SerializableItemHandle>>,
serialized_ssh_project: Option<SerializedSshProject>,
_items_serializer: Task<Result<()>>,
session_id: Option<String>,
debug_task_queue: HashMap<task::TaskId, DebugTaskDefinition>,
}
impl EventEmitter<Event> for Workspace {}
@ -1182,11 +1185,11 @@ impl Workspace {
bounds_save_task_queued: None,
on_prompt_for_new_path: None,
on_prompt_for_open_path: None,
terminal_provider: None,
serializable_items_tx,
_items_serializer,
session_id: Some(session_id),
serialized_ssh_project: None,
debug_task_queue: Default::default(),
}
}
@ -1207,7 +1210,6 @@ impl Workspace {
app_state.node_runtime.clone(),
app_state.user_store.clone(),
app_state.languages.clone(),
app_state.debug_adapters.clone(),
app_state.fs.clone(),
env,
cx,
@ -1699,6 +1701,10 @@ impl Workspace {
self.on_prompt_for_open_path = Some(prompt)
}
pub fn set_terminal_provider(&mut self, provider: impl TerminalProvider + 'static) {
self.terminal_provider = Some(Box::new(provider));
}
pub fn serialized_ssh_project(&self) -> Option<SerializedSshProject> {
self.serialized_ssh_project.clone()
}
@ -5082,7 +5088,6 @@ impl Workspace {
window.activate_window();
let app_state = Arc::new(AppState {
languages: project.read(cx).languages().clone(),
debug_adapters: project.read(cx).debug_adapters().clone(),
workspace_store,
client,
user_store,
@ -5238,16 +5243,6 @@ impl Workspace {
.update(cx, |_, window, _| window.activate_window())
.ok();
}
pub fn debug_task_ready(&mut self, task_id: &TaskId, cx: &mut App) {
if let Some(debug_config) = self.debug_task_queue.remove(task_id) {
self.project.update(cx, |project, cx| {
project
.start_debug_session(debug_config, cx)
.detach_and_log_err(cx);
})
}
}
}
fn leader_border_for_pane(