Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal support for remote development #11108

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
154 changes: 140 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions crates/collab/src/db/queries/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,27 @@ impl Database {
.await
}

pub async fn update_remote_terminal(
&self,
update: &proto::UpdateRemoteTerminal,
connection: ConnectionId,
) -> Result<TransactionGuard<Vec<ConnectionId>>> {
let project_id = ProjectId::from_proto(update.project_id);
self.project_transaction(project_id, |tx| async move {
// Ensure the update comes from the host.
let project = project::Entity::find_by_id(project_id)
.one(&*tx)
.await?
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection()? != connection {
return Err(anyhow!("can't update a project hosted by someone else"))?;
}
let connection_ids = self.project_guest_connection_ids(project_id, &tx).await?;
Ok(connection_ids)
})
.await
}

/// Starts the language server for the given connection.
pub async fn start_language_server(
&self,
Expand Down
31 changes: 31 additions & 0 deletions crates/collab/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ impl Server {
.add_message_handler(update_language_server)
.add_message_handler(update_diagnostic_summary)
.add_message_handler(update_worktree_settings)
.add_request_handler(user_handler(
forward_read_only_project_request::<proto::CreateRemoteTerminal>,
))
.add_request_handler(user_handler(
forward_read_only_project_request::<proto::InputRemoteTerminal>,
))
.add_message_handler(update_remote_terminal)
.add_request_handler(user_handler(
forward_read_only_project_request::<proto::GetHover>,
))
Expand Down Expand Up @@ -2572,6 +2579,30 @@ async fn update_diagnostic_summary(
Ok(())
}

/// Updates other participants with changes to the diagnostics
async fn update_remote_terminal(
message: proto::UpdateRemoteTerminal,
session: Session,
) -> Result<()> {
let guest_connection_ids = session
.db()
.await
.update_remote_terminal(&message, session.connection_id)
.await?;

broadcast(
Some(session.connection_id),
guest_connection_ids.iter().copied(),
|connection_id| {
session
.peer
.forward_send(session.connection_id, connection_id, message.clone())
},
);

Ok(())
}

/// Updates other participants with changes to the worktree settings
async fn update_worktree_settings(
message: proto::UpdateWorktreeSettings,
Expand Down