Restructure remote client crate, consolidate SSH logic (#36967)
This is a pure refactor that consolidates all SSH remoting logic such that it should be straightforward to add another transport to the remoting system. Release Notes: - N/A --------- Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
co-authored by
Mikayla Maki
parent
d713390366
commit
1eae76e856
@@ -1403,7 +1403,7 @@ impl InputHandler for TerminalInputHandler {
|
||||
window.invalidate_character_coordinates();
|
||||
let project = this.project().read(cx);
|
||||
let telemetry = project.client().telemetry().clone();
|
||||
telemetry.log_edit_event("terminal", project.is_via_ssh());
|
||||
telemetry.log_edit_event("terminal", project.is_via_remote_server());
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
@@ -481,17 +481,28 @@ impl TerminalPanel {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<WeakEntity<Terminal>>> {
|
||||
let Ok((ssh_client, false)) = self.workspace.update(cx, |workspace, cx| {
|
||||
let project = workspace.project().read(cx);
|
||||
(
|
||||
project.ssh_client().and_then(|it| it.read(cx).ssh_info()),
|
||||
project.is_via_collab(),
|
||||
)
|
||||
}) else {
|
||||
return Task::ready(Err(anyhow!("Project is not local")));
|
||||
let remote_client = self
|
||||
.workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
let project = workspace.project().read(cx);
|
||||
if project.is_via_collab() {
|
||||
Err(anyhow!("cannot spawn tasks as a guest"))
|
||||
} else {
|
||||
Ok(project.remote_client())
|
||||
}
|
||||
})
|
||||
.flatten();
|
||||
|
||||
let remote_client = match remote_client {
|
||||
Ok(remote_client) => remote_client,
|
||||
Err(e) => return Task::ready(Err(e)),
|
||||
};
|
||||
|
||||
let builder = ShellBuilder::new(ssh_client.as_ref().map(|info| &*info.shell), &task.shell);
|
||||
let remote_shell = remote_client
|
||||
.as_ref()
|
||||
.and_then(|remote_client| remote_client.read(cx).shell());
|
||||
|
||||
let builder = ShellBuilder::new(remote_shell.as_deref(), &task.shell);
|
||||
let command_label = builder.command_label(&task.command_label);
|
||||
let (command, args) = builder.build(task.command.clone(), &task.args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user