debugger: Add an action to rerun the last session (#31442)

This works the same as selecting the first history match in the new
session modal.

Release Notes:

- Debugger Beta: Added the `debugger: rerun last session` action, bound
by default to `alt-f4`.
This commit is contained in:
Cole Miller 2025-05-26 21:21:11 -04:00 committed by GitHub
parent 092be31b2b
commit 03071a9152
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 58 additions and 1 deletions

View file

@ -322,6 +322,45 @@ impl DebugPanel {
.detach_and_log_err(cx);
}
pub(crate) fn rerun_last_session(
&mut self,
workspace: &mut Workspace,
window: &mut Window,
cx: &mut Context<Self>,
) {
let task_store = workspace.project().read(cx).task_store().clone();
let Some(task_inventory) = task_store.read(cx).task_inventory() else {
return;
};
let Some(scenario) = task_inventory.read(cx).last_scheduled_scenario().cloned() else {
return;
};
let workspace = self.workspace.clone();
cx.spawn_in(window, async move |this, cx| {
let task_contexts = workspace
.update_in(cx, |workspace, window, cx| {
tasks_ui::task_contexts(workspace, window, cx)
})?
.await;
let task_context = task_contexts.active_context().cloned().unwrap_or_default();
let worktree_id = task_contexts.worktree();
this.update_in(cx, |this, window, cx| {
this.start_session(
scenario.clone(),
task_context,
None,
worktree_id,
window,
cx,
);
})
})
.detach();
}
pub(crate) async fn register_session(
this: WeakEntity<Self>,
session: Entity<Session>,