diff --git a/Cargo.lock b/Cargo.lock index a6d351099b9351affed9203f9c465a8ca82785f8..d0af85057d251a2e8e5c44990fdbacc6d55ce7c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -418,6 +418,7 @@ dependencies = [ "regex", "release_channel", "rope", + "rpc", "schemars", "search", "semantic_index", @@ -8553,9 +8554,6 @@ version = "0.1.0" dependencies = [ "anyhow", "collections", - "futures 0.3.30", - "gpui", - "parking_lot", "prost", "prost-build", "serde", diff --git a/crates/assistant/Cargo.toml b/crates/assistant/Cargo.toml index d2b5aed9bd8bba4e0365bd07f6422ed959ce36bf..b700702062c0a7c6e35b31da03fce6c125eab548 100644 --- a/crates/assistant/Cargo.toml +++ b/crates/assistant/Cargo.toml @@ -65,6 +65,7 @@ proto.workspace = true regex.workspace = true release_channel.workspace = true rope.workspace = true +rpc.workspace = true schemars.workspace = true search.workspace = true semantic_index.workspace = true diff --git a/crates/assistant/src/context_store.rs b/crates/assistant/src/context_store.rs index b6e1650c41dbf80c36f3c927fbc8bb6d33add2f6..867d90679148541410a616a639e9c67ff41d1089 100644 --- a/crates/assistant/src/context_store.rs +++ b/crates/assistant/src/context_store.rs @@ -2,7 +2,6 @@ use crate::{ prompts::PromptBuilder, Context, ContextEvent, ContextId, ContextOperation, ContextVersion, SavedContext, SavedContextMetadata, }; -use ::proto::AnyProtoClient; use anyhow::{anyhow, Context as _, Result}; use client::{proto, telemetry::Telemetry, Client, TypedEnvelope}; use clock::ReplicaId; @@ -16,6 +15,7 @@ use language::LanguageRegistry; use paths::contexts_dir; use project::Project; use regex::Regex; +use rpc::AnyProtoClient; use std::{ cmp::Reverse, ffi::OsStr, diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rs index bf32185b22043e4a8ee7ad6f6c3a3df9918865e9..2041b16a6da12b19649fc3b5b0a1dcce2ccdaf16 100644 --- a/crates/channel/src/channel_buffer.rs +++ b/crates/channel/src/channel_buffer.rs @@ -5,8 +5,8 @@ use collections::HashMap; use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task}; use language::proto::serialize_version; use rpc::{ - proto::{self, AnyProtoClient, PeerId}, - TypedEnvelope, + proto::{self, PeerId}, + AnyProtoClient, TypedEnvelope, }; use std::{sync::Arc, time::Duration}; use text::BufferId; diff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rs index 7cbc362ff3500bfa20919d5f2ff9ad0835a2edbe..286eb46a91600467c999aa0c1ff46b3ba207635b 100644 --- a/crates/channel/src/channel_chat.rs +++ b/crates/channel/src/channel_chat.rs @@ -11,7 +11,7 @@ use gpui::{ AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel, }; use rand::prelude::*; -use rpc::proto::AnyProtoClient; +use rpc::AnyProtoClient; use std::{ ops::{ControlFlow, Range}, sync::Arc, diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 72ca8ffc2478fdd2143a049d6496ff8a3fc0458d..82237ebaa5abbdd2b27fdf036c38c5c2c2de148d 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -34,7 +34,7 @@ parking_lot.workspace = true postage.workspace = true rand.workspace = true release_channel.workspace = true -rpc.workspace = true +rpc = { workspace = true, features = ["gpui"] } schemars.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 8787e2ed9675fe89c4e244fef362cc734282dc2a..6e1362c43e16fbe72f1a6ca7fdb16705e8614e3a 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -22,7 +22,6 @@ use gpui::{actions, AppContext, AsyncAppContext, Global, Model, Task, WeakModel} use http_client::{AsyncBody, HttpClient, HttpClientWithUrl}; use parking_lot::RwLock; use postage::watch; -use proto::{AnyProtoClient, EntityMessageSubscriber, ProtoClient, ProtoMessageHandlerSet}; use rand::prelude::*; use release_channel::{AppVersion, ReleaseChannel}; use rpc::proto::{AnyTypedEnvelope, EnvelopedMessage, PeerId, RequestMessage}; diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index 9bbc2f435892296f4fe9feb25caa04f47211d2cc..403b53745a51e90a7c25e2f08c6bb078e2f9003f 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -17,10 +17,7 @@ use language::{ proto::{deserialize_line_ending, deserialize_version, serialize_version, split_operations}, Buffer, Capability, Event as BufferEvent, File as _, Language, Operation, }; -use rpc::{ - proto::{self, AnyProtoClient}, - ErrorExt as _, TypedEnvelope, -}; +use rpc::{proto, AnyProtoClient, ErrorExt as _, TypedEnvelope}; use smol::channel::Receiver; use std::{io, path::Path, str::FromStr as _, sync::Arc, time::Instant}; use text::BufferId; diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 668bdae4dc735bc639c6a6e4d733d3fe4623d95c..854915e82d66fc6c449e988a25b06b1a5c781fdb 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -49,7 +49,7 @@ use parking_lot::{Mutex, RwLock}; use postage::watch; use rand::prelude::*; -use rpc::proto::AnyProtoClient; +use rpc::AnyProtoClient; use serde::Serialize; use settings::{Settings, SettingsLocation, SettingsStore}; use sha2::{Digest, Sha256}; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index f67423b07385143931d4db2cc3681b9c4b7268d7..8fca2ea686354669e52f32f235b878e54cc730d1 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -62,10 +62,7 @@ use paths::{local_tasks_file_relative_path, local_vscode_tasks_file_relative_pat use prettier_support::{DefaultPrettier, PrettierInstance}; use project_settings::{LspSettings, ProjectSettings, SettingsObserver}; use remote::SshSession; -use rpc::{ - proto::{AnyProtoClient, SSH_PROJECT_ID}, - ErrorCode, -}; +use rpc::{proto::SSH_PROJECT_ID, AnyProtoClient, ErrorCode}; use search::{SearchInputKind, SearchQuery, SearchResult}; use search_history::SearchHistory; use settings::{watch_config_file, Settings, SettingsLocation, SettingsStore}; diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 70b2eccf237c622f4cab33e7b7699cfe13508a7b..2eeb8408961186d948412d5ba21be11604bd19c2 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -2,10 +2,7 @@ use collections::HashMap; use fs::Fs; use gpui::{AppContext, AsyncAppContext, BorrowAppContext, Model, ModelContext}; use paths::local_settings_file_relative_path; -use rpc::{ - proto::{self, AnyProtoClient}, - TypedEnvelope, -}; +use rpc::{proto, AnyProtoClient, TypedEnvelope}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsSources, SettingsStore}; diff --git a/crates/project/src/worktree_store.rs b/crates/project/src/worktree_store.rs index 6e03e614da84b7c0b8e59e479e15f06928a75039..8b620de43e08385144157f635630f3737d82b7ce 100644 --- a/crates/project/src/worktree_store.rs +++ b/crates/project/src/worktree_store.rs @@ -17,8 +17,8 @@ use gpui::{ }; use postage::oneshot; use rpc::{ - proto::{self, AnyProtoClient, SSH_PROJECT_ID}, - TypedEnvelope, + proto::{self, SSH_PROJECT_ID}, + AnyProtoClient, TypedEnvelope, }; use smol::{ channel::{Receiver, Sender}, diff --git a/crates/proto/Cargo.toml b/crates/proto/Cargo.toml index e1d111366c9986cb6b4be64d476d86f9847907d0..eca020a92ddc9de3659aea80ce3a55dcb43c78fd 100644 --- a/crates/proto/Cargo.toml +++ b/crates/proto/Cargo.toml @@ -19,11 +19,8 @@ doctest = false [dependencies] anyhow.workspace = true collections.workspace = true -futures.workspace = true -parking_lot.workspace = true prost.workspace = true serde.workspace = true -gpui.workspace = true [build-dependencies] prost-build.workspace = true diff --git a/crates/proto/src/proto.rs b/crates/proto/src/proto.rs index 7af66a6a6be093c3498bc13c8cb1714162a1da20..a1853ed4a3bb5b8ce629b890d6994c9db38354e0 100644 --- a/crates/proto/src/proto.rs +++ b/crates/proto/src/proto.rs @@ -2,11 +2,9 @@ pub mod error; mod macros; -mod proto_client; mod typed_envelope; pub use error::*; -pub use proto_client::*; pub use typed_envelope::*; use collections::HashMap; diff --git a/crates/remote/Cargo.toml b/crates/remote/Cargo.toml index 2e96d8062e6f4423fdb0930a083225c008e0c4a5..5c291b59d344e785564a2e094da3e374d1600202 100644 --- a/crates/remote/Cargo.toml +++ b/crates/remote/Cargo.toml @@ -26,7 +26,7 @@ gpui.workspace = true log.workspace = true parking_lot.workspace = true prost.workspace = true -rpc.workspace = true +rpc = { workspace = true, features = ["gpui"] } serde.workspace = true serde_json.workspace = true smol.workspace = true diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rs index 5ff11fe09931c954484708f9b33f4c6494687d4d..4762a785dbdcd2179831a2691779b0479d2e00d5 100644 --- a/crates/remote/src/ssh_session.rs +++ b/crates/remote/src/ssh_session.rs @@ -13,9 +13,9 @@ use futures::{ }; use gpui::{AppContext, AsyncAppContext, Model, SemanticVersion}; use parking_lot::Mutex; -use rpc::proto::{ - self, build_typed_envelope, EntityMessageSubscriber, Envelope, EnvelopedMessage, PeerId, - ProtoClient, ProtoMessageHandlerSet, RequestMessage, +use rpc::{ + proto::{self, build_typed_envelope, Envelope, EnvelopedMessage, PeerId, RequestMessage}, + EntityMessageSubscriber, ProtoClient, ProtoMessageHandlerSet, }; use smol::{ fs, diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index c8ec49cc1e286003ff5ac7f7a68932df5e6d7745..08723daa01d0634f6694016b6b96460c497e4e18 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -8,8 +8,8 @@ use project::{ }; use remote::SshSession; use rpc::{ - proto::{self, AnyProtoClient, SSH_PEER_ID, SSH_PROJECT_ID}, - TypedEnvelope, + proto::{self, SSH_PEER_ID, SSH_PROJECT_ID}, + AnyProtoClient, TypedEnvelope, }; use smol::stream::StreamExt; use std::{ diff --git a/crates/rpc/Cargo.toml b/crates/rpc/Cargo.toml index 79cb811afa5bae62f968bbac930358dd50d98e97..f664085f04c239afd48c10d895f9ff57c3f9a723 100644 --- a/crates/rpc/Cargo.toml +++ b/crates/rpc/Cargo.toml @@ -14,6 +14,7 @@ path = "src/rpc.rs" doctest = false [features] +gpui = ["dep:gpui"] test-support = ["collections/test-support", "gpui/test-support", "proto/test-support"] [dependencies] @@ -39,7 +40,6 @@ zstd = "0.11" [target.'cfg(target_os = "linux")'.dependencies] zstd = { version = "0.11", features = [ "pkg-config" ] } - [dev-dependencies] collections = { workspace = true, features = ["test-support"] } env_logger.workspace = true diff --git a/crates/proto/src/proto_client.rs b/crates/rpc/src/proto_client.rs similarity index 99% rename from crates/proto/src/proto_client.rs rename to crates/rpc/src/proto_client.rs index edcb6417d8fc9867367239f02974e437e59666f2..4a990a84336dfd37e7a63a6ec4153087d2feaf0d 100644 --- a/crates/proto/src/proto_client.rs +++ b/crates/rpc/src/proto_client.rs @@ -1,7 +1,3 @@ -use crate::{ - error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage, - RequestMessage, TypedEnvelope, -}; use anyhow::anyhow; use collections::HashMap; use futures::{ @@ -9,7 +5,11 @@ use futures::{ Future, FutureExt as _, }; use gpui::{AnyModel, AnyWeakModel, AsyncAppContext, Model}; -pub use prost::Message; +// pub use prost::Message; +use proto::{ + error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage, + RequestMessage, TypedEnvelope, +}; use std::{any::TypeId, sync::Arc}; #[derive(Clone)] diff --git a/crates/rpc/src/rpc.rs b/crates/rpc/src/rpc.rs index 2e8b1ef6b7a0f644b33c9d201e462cc790f4088a..9c62238733215f9bcda3b5ad2186d6a291a69392 100644 --- a/crates/rpc/src/rpc.rs +++ b/crates/rpc/src/rpc.rs @@ -14,4 +14,9 @@ pub use peer::*; pub use proto::{error::*, Receipt, TypedEnvelope}; mod macros; +#[cfg(feature = "gpui")] +mod proto_client; +#[cfg(feature = "gpui")] +pub use proto_client::*; + pub const PROTOCOL_VERSION: u32 = 68; diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 584524a1d7b6fef4a1b82db640f2852c71688c13..776c01c49c28685c2db5a57acc07302c28a9d628 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -36,7 +36,7 @@ use postage::{ prelude::{Sink as _, Stream as _}, watch, }; -use rpc::proto::{self, AnyProtoClient}; +use rpc::{proto, AnyProtoClient}; pub use settings::WorktreeId; use settings::{Settings, SettingsLocation, SettingsStore}; use smallvec::{smallvec, SmallVec};