debugger: Debug sessions rerun build tasks by default when restarting (#33724)

We reworked the debug modal spawning to use the task context from past
debug sessions when spawning a debug scenario based on task inventory
history.

We changed restart session keybinding to rerun session too.

Closes #31369

Release Notes:

- Restarting a debug session now reruns build tasks that are associated
with the session

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Anthony Eid 2025-07-01 15:43:58 -04:00 committed by GitHub
parent 6b06685723
commit 0e2e5b8b0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 213 additions and 82 deletions

View file

@ -33,7 +33,7 @@ use language::Buffer;
use loaded_source_list::LoadedSourceList;
use module_list::ModuleList;
use project::{
Project, WorktreeId,
DebugScenarioContext, Project, WorktreeId,
debugger::session::{Session, SessionEvent, ThreadId, ThreadStatus},
terminals::TerminalKind,
};
@ -79,6 +79,8 @@ pub struct RunningState {
pane_close_subscriptions: HashMap<EntityId, Subscription>,
dock_axis: Axis,
_schedule_serialize: Option<Task<()>>,
pub(crate) scenario: Option<DebugScenario>,
pub(crate) scenario_context: Option<DebugScenarioContext>,
}
impl RunningState {
@ -831,6 +833,8 @@ impl RunningState {
debug_terminal,
dock_axis,
_schedule_serialize: None,
scenario: None,
scenario_context: None,
}
}
@ -1039,7 +1043,7 @@ impl RunningState {
let scenario = dap_registry
.adapter(&adapter)
.with_context(|| anyhow!("{}: is not a valid adapter name", &adapter))?.config_from_zed_format(zed_config)
.await?;
.await?;
config = scenario.config;
util::merge_non_null_json_value_into(extra_config, &mut config);
@ -1525,6 +1529,34 @@ impl RunningState {
});
}
pub fn rerun_session(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if let Some((scenario, context)) = self.scenario.take().zip(self.scenario_context.take())
&& scenario.build.is_some()
{
let DebugScenarioContext {
task_context,
active_buffer,
worktree_id,
} = context;
let active_buffer = active_buffer.and_then(|buffer| buffer.upgrade());
self.workspace
.update(cx, |workspace, cx| {
workspace.start_debug_session(
scenario,
task_context,
active_buffer,
worktree_id,
window,
cx,
)
})
.ok();
} else {
self.restart_session(cx);
}
}
pub fn restart_session(&self, cx: &mut Context<Self>) {
self.session().update(cx, |state, cx| {
state.restart(None, cx);