Set up Rust debugger code runner tasks (#27571)

## Summary 
This PR starts the process of adding debug task locators to Zed's
debugger system. A task locator is a secondary resolution phase that
allows a debug task to run a command before starting a debug session and
then uses the output of the run command to configure itself.

Locators are most applicable when debugging a compiled language but will
be helpful for any language as well.

## Architecture

At a high level, this works by adding a debug task queue to `Workspace`.
Which add's a debug configuration associated with a `TaskId` whenever a
resolved task with a debug config is added to `TaskInventory`'s queue.
Then, when the `SpawnInTerminal` task finishes running, it emits its
task_id and the result of the ran task.

When a ran task exits successfully, `Workspace` tells `Project` to start
a debug session using its stored debug config, then `DapStore` queries
the `LocatorStore` to configure the debug configuration if it has a
valid locator argument.

Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-03-29 02:10:40 -04:00 committed by GitHub
parent 141a6c3915
commit 8add90d7cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 441 additions and 168 deletions

View file

@ -46,7 +46,15 @@ pub fn schedule_resolved_task(
omit_history: bool,
cx: &mut Context<Workspace>,
) {
let debug_config = resolved_task.resolved_debug_adapter_config();
if let Some(spawn_in_terminal) = resolved_task.resolved.take() {
if let Some(debug_config) = debug_config {
workspace
.debug_task_queue
.insert(resolved_task.id.clone(), debug_config);
}
if !omit_history {
resolved_task.resolved = Some(spawn_in_terminal.clone());
workspace.project().update(cx, |project, cx| {

View file

@ -94,7 +94,7 @@ use std::{
sync::{atomic::AtomicUsize, Arc, LazyLock, Weak},
time::Duration,
};
use task::SpawnInTerminal;
use task::{DebugAdapterConfig, SpawnInTerminal, TaskId};
use theme::{ActiveTheme, SystemAppearance, ThemeSettings};
pub use toolbar::{Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
pub use ui;
@ -874,6 +874,7 @@ pub struct Workspace {
serialized_ssh_project: Option<SerializedSshProject>,
_items_serializer: Task<Result<()>>,
session_id: Option<String>,
debug_task_queue: HashMap<task::TaskId, DebugAdapterConfig>,
}
impl EventEmitter<Event> for Workspace {}
@ -1185,6 +1186,7 @@ impl Workspace {
_items_serializer,
session_id: Some(session_id),
serialized_ssh_project: None,
debug_task_queue: Default::default(),
}
}
@ -5191,6 +5193,16 @@ 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(