Debugger UI: Dynamic session contents (#28033)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Piotr Osiewicz
2025-04-07 23:22:09 +02:00
committed by GitHub
co-authored by Anthony Eid Anthony
parent fdaf2a27bf
commit 22b937f27f
14 changed files with 663 additions and 537 deletions
+3 -8
View File
@@ -101,10 +101,6 @@ async fn test_handle_output_event(executor: BackgroundExecutor, cx: &mut TestApp
.clone()
});
running_state.update(cx, |state, cx| {
state.set_thread_item(session::ThreadItem::Console, cx);
cx.refresh_windows();
});
cx.run_until_parked();
// assert we have output from before the thread stopped
@@ -112,7 +108,7 @@ async fn test_handle_output_event(executor: BackgroundExecutor, cx: &mut TestApp
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_debug_session_panel = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
assert_eq!(
@@ -151,8 +147,7 @@ async fn test_handle_output_event(executor: BackgroundExecutor, cx: &mut TestApp
.await;
cx.run_until_parked();
running_state.update(cx, |state, cx| {
state.set_thread_item(session::ThreadItem::Console, cx);
running_state.update(cx, |_, cx| {
cx.refresh_windows();
});
cx.run_until_parked();
@@ -162,7 +157,7 @@ async fn test_handle_output_event(executor: BackgroundExecutor, cx: &mut TestApp
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session_panel = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
assert_eq!(
+12 -34
View File
@@ -85,9 +85,8 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
workspace
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel.update(cx, |debug_panel, cx| {
debug_panel.active_session(cx).unwrap()
});
let active_session =
debug_panel.update(cx, |debug_panel, _| debug_panel.active_session().unwrap());
let running_state = active_session.update(cx, |active_session, _| {
active_session
@@ -98,9 +97,7 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
});
debug_panel.update(cx, |this, cx| {
assert!(this.active_session(cx).is_some());
// we have one active session
assert_eq!(1, this.pane().unwrap().read(cx).items_len());
assert!(this.active_session().is_some());
assert!(running_state.read(cx).selected_thread_id().is_none());
});
})
@@ -124,7 +121,7 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
let running_state = active_session.update(cx, |active_session, _| {
@@ -135,11 +132,6 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
.clone()
});
// we have one active session
assert_eq!(
1,
debug_panel.update(cx, |this, cx| this.pane().unwrap().read(cx).items_len())
);
assert_eq!(client.id(), running_state.read(cx).session_id());
assert_eq!(
ThreadId(1),
@@ -162,7 +154,7 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
let running_state = active_session.update(cx, |active_session, _| {
@@ -174,8 +166,7 @@ async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut Test
});
debug_panel.update(cx, |this, cx| {
assert!(this.active_session(cx).is_some());
assert_eq!(1, this.pane().unwrap().read(cx).items_len());
assert!(this.active_session().is_some());
assert_eq!(
ThreadId(1),
running_state.read(cx).selected_thread_id().unwrap()
@@ -243,10 +234,8 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
debug_panel.update(cx, |this, cx| {
assert!(this.active_session(cx).is_some());
// we have one active session
assert_eq!(1, this.pane().unwrap().read(cx).items_len());
debug_panel.update(cx, |this, _| {
assert!(this.active_session().is_some());
});
})
.unwrap();
@@ -270,7 +259,7 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
let running_state = active_session.update(cx, |active_session, _| {
@@ -281,11 +270,6 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.clone()
});
// we have one active session
assert_eq!(
1,
debug_panel.update(cx, |this, cx| this.pane().unwrap().read(cx).items_len())
);
assert_eq!(client.id(), active_session.read(cx).session_id(cx).unwrap());
assert_eq!(
ThreadId(1),
@@ -312,7 +296,7 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
let running_state = active_session.update(cx, |active_session, _| {
@@ -323,11 +307,6 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.clone()
});
// we have one active session
assert_eq!(
1,
debug_panel.update(cx, |this, cx| this.pane().unwrap().read(cx).items_len())
);
assert_eq!(client.id(), active_session.read(cx).session_id(cx).unwrap());
assert_eq!(
ThreadId(1),
@@ -349,7 +328,7 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_session = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
let running_state = active_session.update(cx, |active_session, _| {
@@ -361,8 +340,7 @@ async fn test_we_can_only_have_one_panel_per_debug_session(
});
debug_panel.update(cx, |this, cx| {
assert!(this.active_session(cx).is_some());
assert_eq!(1, this.pane().unwrap().read(cx).items_len());
assert!(this.active_session().is_some());
assert_eq!(
ThreadId(1),
running_state.read(cx).selected_thread_id().unwrap()
+1 -11
View File
@@ -1,6 +1,5 @@
use crate::{
debugger_panel::DebugPanel,
session::ThreadItem,
tests::{active_debug_session_panel, init_test, init_test_workspace},
};
use dap::{
@@ -139,13 +138,7 @@ async fn test_module_list(executor: BackgroundExecutor, cx: &mut TestAppContext)
.clone()
});
assert!(
!called_modules.load(std::sync::atomic::Ordering::SeqCst),
"Request Modules shouldn't be called before it's needed"
);
running_state.update(cx, |state, cx| {
state.set_thread_item(ThreadItem::Modules, cx);
running_state.update(cx, |_, cx| {
cx.refresh_windows();
});
@@ -157,9 +150,6 @@ async fn test_module_list(executor: BackgroundExecutor, cx: &mut TestAppContext)
);
active_debug_session_panel(workspace, cx).update(cx, |_, cx| {
running_state.update(cx, |state, cx| {
state.set_thread_item(ThreadItem::Modules, cx)
});
let actual_modules = running_state.update(cx, |state, cx| {
state.module_list().update(cx, |list, cx| list.modules(cx))
});
@@ -410,7 +410,7 @@ async fn test_select_stack_frame(executor: BackgroundExecutor, cx: &mut TestAppC
.update(cx, |workspace, _window, cx| {
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
let active_debug_panel_item = debug_panel
.update(cx, |this, cx| this.active_session(cx))
.update(cx, |this, _| this.active_session())
.unwrap();
active_debug_panel_item
+18 -11
View File
@@ -207,7 +207,9 @@ async fn test_basic_fetch_initial_scope_and_variables(
.expect("Session should be running by this point")
.clone()
});
running_state.update_in(cx, |this, window, cx| {
this.activate_variable_list(window, cx);
});
cx.run_until_parked();
running_state.update(cx, |running_state, cx| {
@@ -222,7 +224,6 @@ async fn test_basic_fetch_initial_scope_and_variables(
running_state
.variable_list()
.update(cx, |variable_list, _| {
assert_eq!(1, variable_list.scopes().len());
assert_eq!(scopes, variable_list.scopes());
assert_eq!(
vec![variables[0].clone(), variables[1].clone(),],
@@ -480,7 +481,9 @@ async fn test_fetch_variables_for_multiple_scopes(
.expect("Session should be running by this point")
.clone()
});
running_state.update_in(cx, |this, window, cx| {
this.activate_variable_list(window, cx);
});
cx.run_until_parked();
running_state.update(cx, |running_state, cx| {
@@ -797,7 +800,11 @@ async fn test_keyboard_navigation(executor: BackgroundExecutor, cx: &mut TestApp
variable_list.update(cx, |_, cx| cx.focus_self(window));
running
});
running_state.update_in(cx, |this, window, cx| {
this.activate_variable_list(window, cx);
});
cx.run_until_parked();
cx.dispatch_action(SelectFirst);
cx.dispatch_action(SelectFirst);
cx.run_until_parked();
@@ -1541,16 +1548,13 @@ async fn test_variable_list_only_sends_requests_when_rendering(
})
.await;
let running_state = active_debug_session_panel(workspace, cx).update_in(cx, |item, _, cx| {
let running_state = active_debug_session_panel(workspace, cx).update_in(cx, |item, _, _| {
let state = item
.mode()
.as_running()
.expect("Session should be running by this point")
.clone();
state.update(cx, |state, cx| {
state.set_thread_item(crate::session::ThreadItem::Modules, cx)
});
state
});
@@ -1577,9 +1581,10 @@ async fn test_variable_list_only_sends_requests_when_rendering(
assert!(!made_scopes_request.load(Ordering::SeqCst));
cx.focus_self(window);
running_state.set_thread_item(crate::session::ThreadItem::Variables, cx);
});
running_state.update_in(cx, |this, window, cx| {
this.activate_variable_list(window, cx);
});
cx.run_until_parked();
running_state.update(cx, |running_state, cx| {
@@ -1893,7 +1898,9 @@ async fn test_it_fetches_scopes_variables_when_you_select_a_stack_frame(
.expect("Session should be running by this point")
.clone()
});
running_state.update_in(cx, |this, window, cx| {
this.activate_variable_list(window, cx);
});
cx.run_until_parked();
running_state.update(cx, |running_state, cx| {