Skip to repository content57 lines · 2.0 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:48:12.022Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
test.rs
1#![expect(clippy::result_large_err)]
2use std::{path::Path, sync::Arc};
3
4use dap::client::DebugAdapterClient;
5use gpui::{App, Subscription};
6
7use super::session::{Session, SessionStateEvent};
8
9pub fn intercept_debug_sessions<T: Fn(&Arc<DebugAdapterClient>) + 'static>(
10 cx: &mut gpui::TestAppContext,
11 configure: T,
12) -> Subscription {
13 cx.update(|cx| {
14 let configure = Arc::new(configure);
15 cx.observe_new::<Session>(move |_, _, cx| {
16 let configure = configure.clone();
17 cx.subscribe_self(move |session, event, cx| {
18 let configure = configure.clone();
19 if matches!(event, SessionStateEvent::Running) {
20 let client = session.adapter_client().unwrap();
21 register_default_handlers(session, &client, cx);
22 configure(&client);
23 }
24 })
25 .detach();
26 })
27 })
28}
29
30fn register_default_handlers(session: &Session, client: &Arc<DebugAdapterClient>, cx: &mut App) {
31 client.on_request::<dap::requests::Initialize, _>(move |_, _| Ok(Default::default()));
32 let paths = session.breakpoint_store.read(cx).breakpoint_paths();
33
34 client.on_request::<dap::requests::SetBreakpoints, _>(move |_, args| {
35 let p = Arc::from(Path::new(&args.source.path.unwrap()));
36 if !paths.contains(&p) {
37 panic!("Sent breakpoints for path without any")
38 }
39
40 Ok(dap::SetBreakpointsResponse {
41 breakpoints: Vec::default(),
42 })
43 });
44
45 client.on_request::<dap::requests::Launch, _>(move |_, _| Ok(()));
46
47 client.on_request::<dap::requests::SetExceptionBreakpoints, _>(move |_, _| {
48 Ok(dap::SetExceptionBreakpointsResponse { breakpoints: None })
49 });
50
51 client.on_request::<dap::requests::Disconnect, _>(move |_, _| Ok(()));
52
53 client.on_request::<dap::requests::Threads, _>(move |_, _| {
54 Ok(dap::ThreadsResponse { threads: vec![] })
55 });
56}
57