Skip to content

Commit 56abc60

Browse files
Collab - Toggle Ignore Breakpoints (#93)
* Create collab ignore breakpoint integration test * Add collab ignore breakpoints message handlers Still need to enable remote dap_stores the ability to store/manage ignore breakpoint state * Refactor session to have remote and local modes This was done to allow remote clients access to some session details they need such as ignore breakpoints. Co-authored-by: Remco Smits <[email protected]> * DapStore so both local & remote modes have access to DebugSessions * Add remote sessions when creating new debug panel items * Finish implementing collab breakpoints ignore * Clippy & clean up * Clean up session information when sessions end on remote clients * Rename proto message * Add ignore breakpoints state to collab db --------- Co-authored-by: Remco Smits <[email protected]>
1 parent a89e295 commit 56abc60

File tree

15 files changed

+974
-89
lines changed

15 files changed

+974
-89
lines changed

crates/collab/migrations.sqlite/20221109000000_test_schema.sql

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ CREATE TABLE IF NOT EXISTS "debug_clients" (
474474
project_id INTEGER NOT NULL,
475475
session_id BIGINT NOT NULL,
476476
capabilities INTEGER NOT NULL,
477+
ignore_breakpoints BOOLEAN NOT NULL DEFAULT FALSE,
477478
PRIMARY KEY (id, project_id, session_id),
478479
FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
479480
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
ALTER TABLE debug_clients ADD COLUMN ignore_breakpoints BOOLEAN NOT NULL DEFAULT FALSE;

crates/collab/src/db/queries/projects.rs

+39
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,40 @@ impl Database {
556556
.await
557557
}
558558

559+
pub async fn ignore_breakpoint_state(
560+
&self,
561+
connection_id: ConnectionId,
562+
update: &proto::IgnoreBreakpointState,
563+
) -> Result<TransactionGuard<HashSet<ConnectionId>>> {
564+
let project_id = ProjectId::from_proto(update.project_id);
565+
self.project_transaction(project_id, |tx| async move {
566+
let debug_clients = debug_clients::Entity::find()
567+
.filter(
568+
Condition::all()
569+
.add(debug_clients::Column::ProjectId.eq(project_id))
570+
.add(debug_clients::Column::SessionId.eq(update.session_id)),
571+
)
572+
.all(&*tx)
573+
.await?;
574+
575+
for debug_client in debug_clients {
576+
debug_clients::Entity::update(debug_clients::ActiveModel {
577+
id: ActiveValue::Unchanged(debug_client.id),
578+
project_id: ActiveValue::Unchanged(debug_client.project_id),
579+
session_id: ActiveValue::Unchanged(debug_client.session_id),
580+
capabilities: ActiveValue::Unchanged(debug_client.capabilities),
581+
ignore_breakpoints: ActiveValue::Set(update.ignore),
582+
})
583+
.exec(&*tx)
584+
.await?;
585+
}
586+
587+
self.internal_project_connection_ids(project_id, connection_id, true, &tx)
588+
.await
589+
})
590+
.await
591+
}
592+
559593
pub async fn update_debug_adapter(
560594
&self,
561595
connection_id: ConnectionId,
@@ -647,6 +681,7 @@ impl Database {
647681
project_id: ActiveValue::Set(project_id),
648682
session_id: ActiveValue::Set(update.session_id as i64),
649683
capabilities: ActiveValue::Set(0),
684+
ignore_breakpoints: ActiveValue::Set(false),
650685
};
651686
new_debug_client.insert(&*tx).await?;
652687
}
@@ -729,6 +764,7 @@ impl Database {
729764
project_id: ActiveValue::Set(project_id),
730765
session_id: ActiveValue::Set(update.session_id as i64),
731766
capabilities: ActiveValue::Set(0),
767+
ignore_breakpoints: ActiveValue::Set(false),
732768
};
733769
debug_client = Some(new_debug_client.insert(&*tx).await?);
734770
}
@@ -742,6 +778,7 @@ impl Database {
742778
project_id: ActiveValue::Unchanged(debug_client.project_id),
743779
session_id: ActiveValue::Unchanged(debug_client.session_id),
744780
capabilities: ActiveValue::Set(debug_client.capabilities),
781+
ignore_breakpoints: ActiveValue::Set(debug_client.ignore_breakpoints),
745782
})
746783
.exec(&*tx)
747784
.await?;
@@ -1086,6 +1123,7 @@ impl Database {
10861123

10871124
for (session_id, clients) in debug_sessions.into_iter() {
10881125
let mut debug_clients = Vec::default();
1126+
let ignore_breakpoints = clients.iter().any(|debug| debug.ignore_breakpoints); // Temp solution until client -> session change
10891127

10901128
for debug_client in clients.into_iter() {
10911129
let debug_panel_items = debug_client
@@ -1108,6 +1146,7 @@ impl Database {
11081146
project_id,
11091147
session_id: session_id as u64,
11101148
clients: debug_clients,
1149+
ignore_breakpoints,
11111150
});
11121151
}
11131152

crates/collab/src/db/tables/debug_clients.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct Model {
2525
pub session_id: i64,
2626
#[sea_orm(column_type = "Integer")]
2727
pub capabilities: i32,
28+
pub ignore_breakpoints: bool,
2829
}
2930

3031
impl Model {

crates/collab/src/rpc.rs

+29
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,13 @@ impl Server {
438438
.add_request_handler(forward_mutating_project_request::<proto::VariablesRequest>)
439439
.add_message_handler(
440440
broadcast_project_message_from_host::<proto::DapRestartStackFrameRequest>,
441+
)
442+
.add_message_handler(
443+
broadcast_project_message_from_host::<proto::ToggleIgnoreBreakpoints>,
444+
)
445+
.add_message_handler(ignore_breakpoint_state)
446+
.add_message_handler(
447+
broadcast_project_message_from_host::<proto::DebuggerSessionEnded>,
441448
);
442449

443450
Arc::new(server)
@@ -2155,6 +2162,28 @@ async fn shutdown_debug_client(
21552162
Ok(())
21562163
}
21572164

2165+
async fn ignore_breakpoint_state(
2166+
request: proto::IgnoreBreakpointState,
2167+
session: Session,
2168+
) -> Result<()> {
2169+
let guest_connection_ids = session
2170+
.db()
2171+
.await
2172+
.ignore_breakpoint_state(session.connection_id, &request)
2173+
.await?;
2174+
2175+
broadcast(
2176+
Some(session.connection_id),
2177+
guest_connection_ids.iter().copied(),
2178+
|connection_id| {
2179+
session
2180+
.peer
2181+
.forward_send(session.connection_id, connection_id, request.clone())
2182+
},
2183+
);
2184+
Ok(())
2185+
}
2186+
21582187
/// Notify other participants that a debug panel item has been updated
21592188
async fn update_debug_adapter(request: proto::UpdateDebugAdapter, session: Session) -> Result<()> {
21602189
let guest_connection_ids = session

0 commit comments

Comments
 (0)