Skip to content

Commit

Permalink
Remove dev servers (zed-industries#19638)
Browse files Browse the repository at this point in the history
TODO:

- [ ] Check that workspace migration worked
- [ ] Add server migrations and make sure SeaORM files are in sync
(maybe?)

Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent b5f816d commit 0271828
Show file tree
Hide file tree
Showing 55 changed files with 397 additions and 5,030 deletions.
45 changes: 0 additions & 45 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ members = [
"crates/context_servers",
"crates/copilot",
"crates/db",
"crates/dev_server_projects",
"crates/diagnostics",
"crates/docs_preprocessor",
"crates/editor",
Expand All @@ -45,7 +44,6 @@ members = [
"crates/google_ai",
"crates/gpui",
"crates/gpui_macros",
"crates/headless",
"crates/html_to_markdown",
"crates/http_client",
"crates/image_viewer",
Expand Down Expand Up @@ -201,7 +199,6 @@ command_palette_hooks = { path = "crates/command_palette_hooks" }
context_servers = { path = "crates/context_servers" }
copilot = { path = "crates/copilot" }
db = { path = "crates/db" }
dev_server_projects = { path = "crates/dev_server_projects" }
diagnostics = { path = "crates/diagnostics" }
editor = { path = "crates/editor" }
extension = { path = "crates/extension" }
Expand All @@ -219,7 +216,6 @@ go_to_line = { path = "crates/go_to_line" }
google_ai = { path = "crates/google_ai" }
gpui = { path = "crates/gpui", default-features = false, features = ["http_client"]}
gpui_macros = { path = "crates/gpui_macros" }
headless = { path = "crates/headless" }
html_to_markdown = { path = "crates/html_to_markdown" }
http_client = { path = "crates/http_client" }
image_viewer = { path = "crates/image_viewer" }
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant/src/assistant_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ impl AssistantPanel {

fn new_context(&mut self, cx: &mut ViewContext<Self>) -> Option<View<ContextEditor>> {
let project = self.project.read(cx);
if project.is_via_collab() && project.dev_server_project_id().is_none() {
if project.is_via_collab() {
let task = self
.context_store
.update(cx, |store, cx| store.create_remote_context(cx));
Expand Down
27 changes: 8 additions & 19 deletions crates/call/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,26 +1194,15 @@ impl Room {
project: Model<Project>,
cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> {
let request = if let Some(dev_server_project_id) = project.read(cx).dev_server_project_id()
{
self.client.request(proto::ShareProject {
room_id: self.id(),
worktrees: vec![],
dev_server_project_id: Some(dev_server_project_id.0),
is_ssh_project: false,
})
} else {
if let Some(project_id) = project.read(cx).remote_id() {
return Task::ready(Ok(project_id));
}
if let Some(project_id) = project.read(cx).remote_id() {
return Task::ready(Ok(project_id));
}

self.client.request(proto::ShareProject {
room_id: self.id(),
worktrees: project.read(cx).worktree_metadata_protos(cx),
dev_server_project_id: None,
is_ssh_project: project.read(cx).is_via_ssh(),
})
};
let request = self.client.request(proto::ShareProject {
room_id: self.id(),
worktrees: project.read(cx).worktree_metadata_protos(cx),
is_ssh_project: project.read(cx).is_via_ssh(),
});

cx.spawn(|this, mut cx| async move {
let response = request.await?;
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub enum CliRequest {
urls: Vec<String>,
wait: bool,
open_new_workspace: Option<bool>,
dev_server_token: Option<String>,
env: Option<HashMap<String, String>>,
},
}
Expand Down
7 changes: 6 additions & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ fn main() -> Result<()> {
}
}

if let Some(_) = args.dev_server_token {
return Err(anyhow::anyhow!(
"Dev servers were removed in v0.157.x please upgrade to SSH remoting: https://zed.dev/docs/remote-development"
))?;
}

let sender: JoinHandle<anyhow::Result<()>> = thread::spawn({
let exit_status = exit_status.clone();
move || {
Expand All @@ -162,7 +168,6 @@ fn main() -> Result<()> {
urls,
wait: args.wait,
open_new_workspace,
dev_server_token: args.dev_server_token,
env,
})?;

Expand Down
58 changes: 17 additions & 41 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
use socks::connect_socks_proxy_stream;
use std::fmt;
use std::pin::Pin;
use std::{
any::TypeId,
Expand All @@ -54,15 +53,6 @@ pub use rpc::*;
pub use telemetry_events::Event;
pub use user::*;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct DevServerToken(pub String);

impl fmt::Display for DevServerToken {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}

static ZED_SERVER_URL: LazyLock<Option<String>> =
LazyLock::new(|| std::env::var("ZED_SERVER_URL").ok());
static ZED_RPC_URL: LazyLock<Option<String>> = LazyLock::new(|| std::env::var("ZED_RPC_URL").ok());
Expand Down Expand Up @@ -304,20 +294,14 @@ struct ClientState {
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Credentials {
DevServer { token: DevServerToken },
User { user_id: u64, access_token: String },
pub struct Credentials {
pub user_id: u64,
pub access_token: String,
}

impl Credentials {
pub fn authorization_header(&self) -> String {
match self {
Credentials::DevServer { token } => format!("dev-server-token {}", token),
Credentials::User {
user_id,
access_token,
} => format!("{} {}", user_id, access_token),
}
format!("{} {}", self.user_id, self.access_token)
}
}

Expand Down Expand Up @@ -600,11 +584,11 @@ impl Client {
}

pub fn user_id(&self) -> Option<u64> {
if let Some(Credentials::User { user_id, .. }) = self.state.read().credentials.as_ref() {
Some(*user_id)
} else {
None
}
self.state
.read()
.credentials
.as_ref()
.map(|credentials| credentials.user_id)
}

pub fn peer_id(&self) -> Option<PeerId> {
Expand Down Expand Up @@ -793,11 +777,6 @@ impl Client {
.is_some()
}

pub fn set_dev_server_token(&self, token: DevServerToken) -> &Self {
self.state.write().credentials = Some(Credentials::DevServer { token });
self
}

#[async_recursion(?Send)]
pub async fn authenticate_and_connect(
self: &Arc<Self>,
Expand Down Expand Up @@ -848,9 +827,7 @@ impl Client {
}
}
let credentials = credentials.unwrap();
if let Credentials::User { user_id, .. } = &credentials {
self.set_id(*user_id);
}
self.set_id(credentials.user_id);

if was_disconnected {
self.set_status(Status::Connecting, cx);
Expand All @@ -866,9 +843,8 @@ impl Client {
Ok(conn) => {
self.state.write().credentials = Some(credentials.clone());
if !read_from_provider && IMPERSONATE_LOGIN.is_none() {
if let Credentials::User{user_id, access_token} = credentials {
self.credentials_provider.write_credentials(user_id, access_token, cx).await.log_err();
}
self.credentials_provider.write_credentials(credentials.user_id, credentials.access_token, cx).await.log_err();

}

futures::select_biased! {
Expand Down Expand Up @@ -1301,7 +1277,7 @@ impl Client {
.decrypt_string(&access_token)
.context("failed to decrypt access token")?;

Ok(Credentials::User {
Ok(Credentials {
user_id: user_id.parse()?,
access_token,
})
Expand Down Expand Up @@ -1422,7 +1398,7 @@ impl Client {

// Use the admin API token to authenticate as the impersonated user.
api_token.insert_str(0, "ADMIN_TOKEN:");
Ok(Credentials::User {
Ok(Credentials {
user_id: response.user.id,
access_token: api_token,
})
Expand Down Expand Up @@ -1667,7 +1643,7 @@ impl CredentialsProvider for DevelopmentCredentialsProvider {

let credentials: DevelopmentCredentials = serde_json::from_slice(&json).log_err()?;

Some(Credentials::User {
Some(Credentials {
user_id: credentials.user_id,
access_token: credentials.access_token,
})
Expand Down Expand Up @@ -1721,7 +1697,7 @@ impl CredentialsProvider for KeychainCredentialsProvider {
.await
.log_err()??;

Some(Credentials::User {
Some(Credentials {
user_id: user_id.parse().ok()?,
access_token: String::from_utf8(access_token).ok()?,
})
Expand Down Expand Up @@ -1855,7 +1831,7 @@ mod tests {
// Time out when client tries to connect.
client.override_authenticate(move |cx| {
cx.background_executor().spawn(async move {
Ok(Credentials::User {
Ok(Credentials {
user_id,
access_token: "token".into(),
})
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl FakeServer {
let mut state = state.lock();
state.auth_count += 1;
let access_token = state.access_token.to_string();
Ok(Credentials::User {
Ok(Credentials {
user_id: client_user_id,
access_token,
})
Expand All @@ -73,7 +73,7 @@ impl FakeServer {
}

if credentials
!= (Credentials::User {
!= (Credentials {
user_id: client_user_id,
access_token: state.lock().access_token.to_string(),
})
Expand Down
Loading

0 comments on commit 0271828

Please sign in to comment.