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:
parent
26d0a33e79
commit
583b6235fb
10 changed files with 404 additions and 454 deletions
|
@ -9,9 +9,9 @@ use collections::{hash_map, HashMap, HashSet};
|
|||
use gpui::SharedString;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::{borrow::Cow, path::Path};
|
||||
|
||||
pub use task_template::{HideStrategy, RevealStrategy, TaskTemplate, TaskTemplates};
|
||||
pub use vscode_format::VsCodeTaskFile;
|
||||
|
@ -21,38 +21,6 @@ pub use vscode_format::VsCodeTaskFile;
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize)]
|
||||
pub struct TaskId(pub String);
|
||||
|
||||
/// TerminalWorkDir describes where a task should be run
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum TerminalWorkDir {
|
||||
/// Local is on this machine
|
||||
Local(PathBuf),
|
||||
/// SSH runs the terminal over ssh
|
||||
Ssh {
|
||||
/// The command to run to connect
|
||||
ssh_command: String,
|
||||
/// The path on the remote server
|
||||
path: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl TerminalWorkDir {
|
||||
/// Returns whether the terminal task is supposed to be spawned on a local machine or not.
|
||||
pub fn is_local(&self) -> bool {
|
||||
match self {
|
||||
Self::Local(_) => true,
|
||||
Self::Ssh { .. } => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a local CWD if the terminal is local, None otherwise.
|
||||
pub fn local_path(&self) -> Option<&Path> {
|
||||
match self {
|
||||
Self::Local(path) => Some(path),
|
||||
Self::Ssh { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains all information needed by Zed to spawn a new terminal tab for the given task.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SpawnInTerminal {
|
||||
|
@ -70,7 +38,7 @@ pub struct SpawnInTerminal {
|
|||
/// A human-readable label, containing command and all of its arguments, joined and substituted.
|
||||
pub command_label: String,
|
||||
/// Current working directory to spawn the command into.
|
||||
pub cwd: Option<TerminalWorkDir>,
|
||||
pub cwd: Option<PathBuf>,
|
||||
/// Env overrides for the command, will be appended to the terminal's environment from the settings.
|
||||
pub env: HashMap<String, String>,
|
||||
/// Whether to use a new terminal tab or reuse the existing one to spawn the process.
|
||||
|
@ -265,7 +233,7 @@ impl IntoIterator for TaskVariables {
|
|||
|
||||
/// Keeps track of the file associated with a task and context of tasks execution (i.e. current file or current function).
|
||||
/// Keeps all Zed-related state inside, used to produce a resolved task out of its template.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct TaskContext {
|
||||
/// A path to a directory in which the task should be executed.
|
||||
pub cwd: Option<PathBuf>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue