From 4577e1bf8fb42ec96d6054f2da4de89df2d822cd Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 6 Dec 2025 21:34:19 +0100 Subject: [PATCH] debugger: Get stack frame list working with historic snapshot feature (#44303) This PR fixes an issue where the stack frame list would not update when viewing a historic snapshot. We now also show the right active debug line based on the currently selected history. https://github.com/user-attachments/assets/baccd078-23ed-4db3-9959-f83dc2be8309 Release Notes: - N/A --------- Co-authored-by: Anthony Eid --- .../src/session/running/loaded_source_list.rs | 4 +++- .../src/session/running/module_list.rs | 4 +++- .../src/session/running/stack_frame_list.rs | 4 +++- .../src/session/running/variable_list.rs | 7 ++++++- crates/project/src/debugger/session.rs | 19 +++++++------------ 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crates/debugger_ui/src/session/running/loaded_source_list.rs b/crates/debugger_ui/src/session/running/loaded_source_list.rs index 921ebd8b5f5bdfe8a3c8a8f7bb1625bd1ffad7fb..e55fad336b5ee6dfbee1cb0c90ea3d19f561a2ba 100644 --- a/crates/debugger_ui/src/session/running/loaded_source_list.rs +++ b/crates/debugger_ui/src/session/running/loaded_source_list.rs @@ -17,7 +17,9 @@ impl LoadedSourceList { let list = ListState::new(0, gpui::ListAlignment::Top, px(1000.)); let _subscription = cx.subscribe(&session, |this, _, event, cx| match event { - SessionEvent::Stopped(_) | SessionEvent::LoadedSources => { + SessionEvent::Stopped(_) + | SessionEvent::HistoricSnapshotSelected + | SessionEvent::LoadedSources => { this.invalidate = true; cx.notify(); } diff --git a/crates/debugger_ui/src/session/running/module_list.rs b/crates/debugger_ui/src/session/running/module_list.rs index 19f407eb23f8acf0aa665f5119ecfd2156eb685f..7d0228fc6851185d10a3a237257d6244d5a90c76 100644 --- a/crates/debugger_ui/src/session/running/module_list.rs +++ b/crates/debugger_ui/src/session/running/module_list.rs @@ -32,7 +32,9 @@ impl ModuleList { let focus_handle = cx.focus_handle(); let _subscription = cx.subscribe(&session, |this, _, event, cx| match event { - SessionEvent::Stopped(_) | SessionEvent::Modules => { + SessionEvent::Stopped(_) + | SessionEvent::HistoricSnapshotSelected + | SessionEvent::Modules => { if this._rebuild_task.is_some() { this.schedule_rebuild(cx); } diff --git a/crates/debugger_ui/src/session/running/stack_frame_list.rs b/crates/debugger_ui/src/session/running/stack_frame_list.rs index 96a910af4dd0ac901c6802c139ddd5b8b3d728bc..5ecdc0f74be97c01ace933fd3513535040599bac 100644 --- a/crates/debugger_ui/src/session/running/stack_frame_list.rs +++ b/crates/debugger_ui/src/session/running/stack_frame_list.rs @@ -97,7 +97,9 @@ impl StackFrameList { SessionEvent::Threads => { this.schedule_refresh(false, window, cx); } - SessionEvent::Stopped(..) | SessionEvent::StackTrace => { + SessionEvent::Stopped(..) + | SessionEvent::StackTrace + | SessionEvent::HistoricSnapshotSelected => { this.schedule_refresh(true, window, cx); } _ => {} diff --git a/crates/debugger_ui/src/session/running/variable_list.rs b/crates/debugger_ui/src/session/running/variable_list.rs index 1b455b59d7d12712a3d4adc713a6ed15e8166c6e..7b23cd685d93e6353d68dc57cd3998099ea56ad7 100644 --- a/crates/debugger_ui/src/session/running/variable_list.rs +++ b/crates/debugger_ui/src/session/running/variable_list.rs @@ -217,6 +217,12 @@ impl VariableList { let _subscriptions = vec![ cx.subscribe(&stack_frame_list, Self::handle_stack_frame_list_events), cx.subscribe(&session, |this, _, event, cx| match event { + SessionEvent::HistoricSnapshotSelected => { + this.selection.take(); + this.edited_path.take(); + this.selected_stack_frame_id.take(); + this.build_entries(cx); + } SessionEvent::Stopped(_) => { this.selection.take(); this.edited_path.take(); @@ -225,7 +231,6 @@ impl VariableList { SessionEvent::Variables | SessionEvent::Watchers => { this.build_entries(cx); } - _ => {} }), cx.on_focus_out(&focus_handle, window, |this, _, _, cx| { diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index a63e9066c9a30233ee1edb15aac13da145cb76b2..9d4d307f990bfc5f00190f74ce3f1f957e71bacc 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -808,6 +808,7 @@ pub enum SessionEvent { }, DataBreakpointInfo, ConsoleOutput, + HistoricSnapshotSelected, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -1447,7 +1448,7 @@ impl Session { self.selected_snapshot_index = ix; if ix.is_some() { - cx.emit(SessionEvent::Stopped(None)); + cx.emit(SessionEvent::HistoricSnapshotSelected); } cx.notify(); @@ -1668,16 +1669,10 @@ impl Session { ); } - if self.selected_snapshot_index.is_some() { - return; - } - - if self.is_session_terminated { - return; - } - - if !self.active_snapshot.thread_states.any_stopped_thread() - && request.type_id() != TypeId::of::() + if (!self.active_snapshot.thread_states.any_stopped_thread() + && request.type_id() != TypeId::of::()) + || self.selected_snapshot_index.is_some() + || self.is_session_terminated { return; } @@ -2505,7 +2500,7 @@ impl Session { ); } - match self.active_snapshot.threads.get(&thread_id) { + match self.session_state().threads.get(&thread_id) { Some(thread) => { if let Some(error) = &thread.stack_frames_error { Err(anyhow!(error.to_string()))