SSH remoting: terminal & tasks (#15321)

This also rolls back the `TerminalWorkDir` abstraction I added for the
original remoting, and tidies up the terminal creation code to be clear
about whether we're creating a task *or* a terminal. The previous logic
was a little muddy because it assumed we could be doing both at the same
time (which was not true).

Release Notes:

- remoting alpha: Removed the ability to specify `gh cs ssh` or `gcloud
compute ssh` etc. See https://zed.dev/docs/remote-development for
alternatives.
- remoting alpha: Added support for terminal and tasks to new
experimental ssh remoting
This commit is contained in:
Conrad Irwin 2024-07-28 22:45:00 -06:00 committed by GitHub
parent 26d0a33e79
commit 583b6235fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 404 additions and 454 deletions

View file

@ -8,7 +8,7 @@ use sha2::{Digest, Sha256};
use util::{truncate_and_remove_front, ResultExt};
use crate::{
ResolvedTask, Shell, SpawnInTerminal, TaskContext, TaskId, TerminalWorkDir, VariableName,
ResolvedTask, Shell, SpawnInTerminal, TaskContext, TaskId, VariableName,
ZED_VARIABLE_NAME_PREFIX,
};
@ -134,14 +134,11 @@ impl TaskTemplate {
&variable_names,
&mut substituted_variables,
)?;
Some(TerminalWorkDir::Local(PathBuf::from(substitured_cwd)))
Some(PathBuf::from(substitured_cwd))
}
None => None,
}
.or(cx
.cwd
.as_ref()
.map(|cwd| TerminalWorkDir::Local(cwd.clone())));
.or(cx.cwd.clone());
let human_readable_label = substitute_all_template_variables_in_str(
&self.label,
&truncated_variables,
@ -421,11 +418,8 @@ mod tests {
project_env: HashMap::default(),
};
assert_eq!(
resolved_task(&task_without_cwd, &cx)
.cwd
.as_ref()
.and_then(|cwd| cwd.local_path()),
Some(context_cwd.as_path()),
resolved_task(&task_without_cwd, &cx).cwd,
Some(context_cwd.clone()),
"TaskContext's cwd should be taken on resolve if task's cwd is None"
);
@ -440,11 +434,8 @@ mod tests {
project_env: HashMap::default(),
};
assert_eq!(
resolved_task(&task_with_cwd, &cx)
.cwd
.as_ref()
.and_then(|cwd| cwd.local_path()),
Some(task_cwd.as_path()),
resolved_task(&task_with_cwd, &cx).cwd,
Some(task_cwd.clone()),
"TaskTemplate's cwd should be taken on resolve if TaskContext's cwd is None"
);
@ -454,11 +445,8 @@ mod tests {
project_env: HashMap::default(),
};
assert_eq!(
resolved_task(&task_with_cwd, &cx)
.cwd
.as_ref()
.and_then(|cwd| cwd.local_path()),
Some(task_cwd.as_path()),
resolved_task(&task_with_cwd, &cx).cwd,
Some(task_cwd),
"TaskTemplate's cwd should be taken on resolve if TaskContext's cwd is not None"
);
}