Reconnect button for remote projects (#12669)
Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev>
This commit is contained in:
@@ -1816,6 +1816,9 @@ impl Project {
|
||||
}
|
||||
|
||||
pub fn disconnected_from_host(&mut self, cx: &mut ModelContext<Self>) {
|
||||
if self.is_disconnected() {
|
||||
return;
|
||||
}
|
||||
self.disconnected_from_host_internal(cx);
|
||||
cx.emit(Event::DisconnectedFromHost);
|
||||
cx.notify();
|
||||
@@ -1863,7 +1866,10 @@ impl Project {
|
||||
for open_buffer in self.opened_buffers.values_mut() {
|
||||
// Wake up any tasks waiting for peers' edits to this buffer.
|
||||
if let Some(buffer) = open_buffer.upgrade() {
|
||||
buffer.update(cx, |buffer, _| buffer.give_up_waiting());
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.give_up_waiting();
|
||||
buffer.set_capability(Capability::ReadOnly, cx)
|
||||
});
|
||||
}
|
||||
|
||||
if let OpenBuffer::Strong(buffer) = open_buffer {
|
||||
@@ -2127,6 +2133,9 @@ impl Project {
|
||||
let remote_worktree_id = worktree.read(cx).id();
|
||||
let path = path.clone();
|
||||
let path_string = path.to_string_lossy().to_string();
|
||||
if self.is_disconnected() {
|
||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||
}
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
let response = rpc
|
||||
.request(proto::OpenBufferByPath {
|
||||
|
||||
@@ -337,22 +337,10 @@ fn prepare_ssh_shell(
|
||||
"exec $SHELL -l".to_string()
|
||||
};
|
||||
|
||||
let (port_forward, local_dev_env) =
|
||||
if env::var("ZED_RPC_URL").as_deref() == Ok("http://localhost:8080/rpc") {
|
||||
(
|
||||
"-R 8080:localhost:8080",
|
||||
"export ZED_RPC_URL=http://localhost:8080/rpc;",
|
||||
)
|
||||
} else {
|
||||
("", "")
|
||||
};
|
||||
|
||||
let commands = if let Some(path) = path {
|
||||
// I've found that `ssh -t dev sh -c 'cd; cd /tmp; pwd'` gives /tmp
|
||||
// but `ssh -t dev sh -c 'cd /tmp; pwd'` gives /root
|
||||
format!("cd {path}; {local_dev_env} {to_run}")
|
||||
format!("cd {path}; {to_run}")
|
||||
} else {
|
||||
format!("cd; {local_dev_env} {to_run}")
|
||||
format!("cd; {to_run}")
|
||||
};
|
||||
let shell_invocation = &format!("sh -c {}", shlex::try_quote(&commands)?);
|
||||
|
||||
@@ -361,10 +349,9 @@ fn prepare_ssh_shell(
|
||||
// be run instead.
|
||||
write!(
|
||||
&mut ssh_file,
|
||||
"#!/bin/sh\nexec {} \"$@\" {} {} {}",
|
||||
"#!/bin/sh\nexec {} \"$@\" {} {}",
|
||||
real_ssh.to_string_lossy(),
|
||||
if spawn_task.is_none() { "-t" } else { "" },
|
||||
port_forward,
|
||||
shlex::try_quote(shell_invocation)?,
|
||||
)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user