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

@ -10,7 +10,8 @@ use gpui::{
use picker::{highlighted_match_with_paths::HighlightedMatch, Picker, PickerDelegate};
use project::{task_store::TaskStore, TaskSourceKind};
use task::{
DebugRequestType, ResolvedTask, RevealTarget, TaskContext, TaskModal, TaskTemplate, TaskType,
DebugRequestType, DebugTaskDefinition, ResolvedTask, RevealTarget, TaskContext, TaskModal,
TaskTemplate, TaskType,
};
use ui::{
div, h_flex, v_flex, ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color,
@ -320,15 +321,11 @@ impl PickerDelegate for TasksModalDelegate {
self.workspace
.update(cx, |workspace, cx| {
match task.task_type() {
TaskType::Script => schedule_resolved_task(
workspace,
task_source_kind,
task,
omit_history_entry,
cx,
),
TaskType::Debug(_) => {
let Some(config) = task.resolved_debug_adapter_config() else {
TaskType::Debug(config) if config.locator.is_none() => {
let Some(config): Option<DebugTaskDefinition> = task
.resolved_debug_adapter_config()
.and_then(|config| config.try_into().ok())
else {
return;
};
let project = workspace.project().clone();
@ -355,6 +352,13 @@ impl PickerDelegate for TasksModalDelegate {
}
}
}
_ => schedule_resolved_task(
workspace,
task_source_kind,
task,
omit_history_entry,
cx,
),
};
})
.ok();
@ -517,16 +521,30 @@ impl PickerDelegate for TasksModalDelegate {
omit_history_entry,
cx,
),
// TODO: Should create a schedule_resolved_debug_task function
// todo(debugger): Should create a schedule_resolved_debug_task function
// This would allow users to access to debug history and other issues
TaskType::Debug(_) => workspace.project().update(cx, |project, cx| {
project
.start_debug_session(
task.resolved_debug_adapter_config().unwrap().into(),
TaskType::Debug(debug_args) => {
let Some(debug_config) = task.resolved_debug_adapter_config() else {
// todo(debugger) log an error, this should never happen
return;
};
if debug_args.locator.is_some() {
schedule_resolved_task(
workspace,
task_source_kind,
task,
omit_history_entry,
cx,
)
.detach_and_log_err(cx);
}),
);
} else {
workspace.project().update(cx, |project, cx| {
project
.start_debug_session(debug_config, cx)
.detach_and_log_err(cx);
});
}
}
};
})
.ok();