Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add buffer integration test Rearrange channel crate structure Get channel buffer from database
Mikaylaa7a4e2e36996
diff --git a/Cargo.lock b/Cargo.lockindex b10d8730fb4..a40aa7d89ce 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1063,6 +1063,7 @@ dependencies = ["anyhow","async-broadcast","audio",+ "channel","client","collections","fs",@@ -1190,6 +1191,41 @@ version = "1.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"+[[package]]+name = "channel"+version = "0.1.0"+dependencies = [+ "anyhow",+ "client",+ "collections",+ "db",+ "futures 0.3.28",+ "gpui",+ "image",+ "language",+ "lazy_static",+ "log",+ "parking_lot 0.11.2",+ "postage",+ "rand 0.8.5",+ "rpc",+ "schemars",+ "serde",+ "serde_derive",+ "settings",+ "smol",+ "staff_mode",+ "sum_tree",+ "tempfile",+ "text",+ "thiserror",+ "time 0.3.24",+ "tiny_http",+ "url",+ "util",+ "uuid 1.4.1",+]+[[package]]name = "chrono"version = "0.4.26"@@ -1354,6 +1390,7 @@ dependencies = ["staff_mode","sum_tree","tempfile",+ "text","thiserror","time 0.3.24","tiny_http",@@ -1418,6 +1455,7 @@ dependencies = ["axum-extra","base64 0.13.1","call",+ "channel","clap 3.2.25","client","collections",@@ -1480,6 +1518,7 @@ dependencies = ["anyhow","auto_update","call",+ "channel","client","clock","collections",@@ -9536,6 +9575,7 @@ dependencies = ["async-recursion 1.0.4","bincode","call",+ "channel","client","collections","context_menu",@@ -9661,6 +9701,7 @@ dependencies = ["backtrace","breadcrumbs","call",+ "channel","chrono","cli","client",diff --git a/Cargo.toml b/Cargo.tomlindex a35b3eea234..0fb8f0b6b71 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -6,6 +6,7 @@ members = ["crates/auto_update","crates/breadcrumbs","crates/call",+ "crates/channel","crates/cli","crates/client","crates/clock",diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.tomlindex eb448d8d8d0..b4e94fe56c3 100644--- a/crates/call/Cargo.toml+++ b/crates/call/Cargo.toml@@ -20,6 +20,7 @@ test-support = [[dependencies]audio = { path = "../audio" }+channel = { path = "../channel" }client = { path = "../client" }collections = { path = "../collections" }gpui = { path = "../gpui" }diff --git a/crates/call/src/call.rs b/crates/call/src/call.rsindex 5fef53fa814..5af094df059 100644--- a/crates/call/src/call.rs+++ b/crates/call/src/call.rs@@ -7,9 +7,8 @@ use std::sync::Arc;use anyhow::{anyhow, Result};use audio::Audio;use call_settings::CallSettings;-use client::{- proto, ChannelId, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore,-};+use channel::ChannelId;+use client::{proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore};use collections::HashSet;use futures::{future::Shared, FutureExt};use postage::watch;diff --git a/crates/channel/Cargo.toml b/crates/channel/Cargo.tomlnew file mode 100644index 00000000000..0978462a1a8--- /dev/null+++ b/crates/channel/Cargo.toml@@ -0,0 +1,51 @@+[package]+name = "channel"+version = "0.1.0"+edition = "2021"+publish = false++[lib]+path = "src/channel.rs"+doctest = false++[features]+test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]++[dependencies]+client = { path = "../client" }+collections = { path = "../collections" }+db = { path = "../db" }+gpui = { path = "../gpui" }+util = { path = "../util" }+rpc = { path = "../rpc" }+text = { path = "../text" }+language = { path = "../language" }+settings = { path = "../settings" }+staff_mode = { path = "../staff_mode" }+sum_tree = { path = "../sum_tree" }++anyhow.workspace = true+futures.workspace = true+image = "0.23"+lazy_static.workspace = true+log.workspace = true+parking_lot.workspace = true+postage.workspace = true+rand.workspace = true+schemars.workspace = true+smol.workspace = true+thiserror.workspace = true+time.workspace = true+tiny_http = "0.8"+uuid = { version = "1.1.2", features = ["v4"] }+url = "2.2"+serde.workspace = true+serde_derive.workspace = true+tempfile = "3"++[dev-dependencies]+collections = { path = "../collections", features = ["test-support"] }+gpui = { path = "../gpui", features = ["test-support"] }+rpc = { path = "../rpc", features = ["test-support"] }+settings = { path = "../settings", features = ["test-support"] }+util = { path = "../util", features = ["test-support"] }diff --git a/crates/channel/src/channel.rs b/crates/channel/src/channel.rsnew file mode 100644index 00000000000..67c560a1fca--- /dev/null+++ b/crates/channel/src/channel.rs@@ -0,0 +1,7 @@+mod channel_store;++pub mod channel_buffer;+pub use channel_store::*;++#[cfg(test)]+mod channel_store_tests;diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rsnew file mode 100644index 00000000000..10f59bce46c--- /dev/null+++ b/crates/channel/src/channel_buffer.rs@@ -0,0 +1,80 @@+use crate::ChannelId;+use anyhow::Result;+use client::Client;+use gpui::{Entity, ModelContext, ModelHandle, Task};+use rpc::proto::GetChannelBuffer;+use std::sync::Arc;++// Open the channel document+// ChannelDocumentView { ChannelDocument, Editor } -> On clone, clones internal ChannelDocument handle, instantiates new editor+// Produces a view which is: (ChannelDocument, Editor), ChannelDocument manages subscriptions+// ChannelDocuments -> Buffers -> Editor with that buffer++// ChannelDocuments {+// ChannleBuffers: HashMap<bufferId, ModelHandle<language::Buffer>>+// }++pub struct ChannelBuffer {+ channel_id: ChannelId,+ buffer: Option<ModelHandle<language::Buffer>>,+ client: Arc<Client>,+}++impl Entity for ChannelBuffer {+ type Event = ();+}++impl ChannelBuffer {+ pub fn for_channel(+ channel_id: ChannelId,+ client: Arc<Client>,+ cx: &mut ModelContext<Self>,+ ) -> Self {+ Self {+ channel_id,+ client,+ buffer: None,+ }+ }++ fn on_buffer_update(+ &mut self,+ buffer: ModelHandle<language::Buffer>,+ event: &language::Event,+ cx: &mut ModelContext<Self>,+ ) {+ //+ }++ pub fn buffer(+ &mut self,+ cx: &mut ModelContext<Self>,+ ) -> Task<Result<ModelHandle<language::Buffer>>> {+ if let Some(buffer) = &self.buffer {+ Task::ready(Ok(buffer.clone()))+ } else {+ let channel_id = self.channel_id;+ let client = self.client.clone();+ cx.spawn(|this, mut cx| async move {+ let response = client.request(GetChannelBuffer { channel_id }).await?;++ let base_text = response.base_text;+ let operations = response+ .operations+ .into_iter()+ .map(language::proto::deserialize_operation)+ .collect::<Result<Vec<_>, _>>()?;++ this.update(&mut cx, |this, cx| {+ let buffer = cx.add_model(|cx| language::Buffer::new(0, base_text, cx));+ buffer.update(cx, |buffer, cx| buffer.apply_ops(operations, cx))?;++ cx.subscribe(&buffer, Self::on_buffer_update).detach();++ this.buffer = Some(buffer.clone());+ anyhow::Ok(buffer)+ })+ })+ }+ }+}diff --git a/crates/client/src/channel_store.rs b/crates/channel/src/channel_store.rssimilarity index 99%rename from crates/client/src/channel_store.rsrename to crates/channel/src/channel_store.rsindex 6352ac791ed..b9b2c98acd3 100644--- a/crates/client/src/channel_store.rs+++ b/crates/channel/src/channel_store.rs@@ -1,7 +1,8 @@-use crate::Status;-use crate::{Client, Subscription, User, UserStore};use anyhow::anyhow;use anyhow::Result;+use client::Status;+use client::UserId;+use client::{Client, Subscription, User, UserStore};use collections::HashMap;use collections::HashSet;use futures::channel::mpsc;@@ -13,7 +14,6 @@ use std::sync::Arc;use util::ResultExt;pub type ChannelId = u64;-pub type UserId = u64;pub struct ChannelStore {channels_by_id: HashMap<ChannelId, Arc<Channel>>,diff --git a/crates/client/src/channel_store_tests.rs b/crates/channel/src/channel_store_tests.rssimilarity index 98%rename from crates/client/src/channel_store_tests.rsrename to crates/channel/src/channel_store_tests.rsindex 51e819349e7..18894b1f472 100644--- a/crates/client/src/channel_store_tests.rs+++ b/crates/channel/src/channel_store_tests.rs@@ -1,4 +1,7 @@use super::*;+use client::{Client, UserStore};+use gpui::{AppContext, ModelHandle};+use rpc::proto;use util::http::FakeHttpClient;#[gpui::test]diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.tomlindex 3ecc5159869..64d8f02c8ae 100644--- a/crates/client/Cargo.toml+++ b/crates/client/Cargo.toml@@ -17,6 +17,7 @@ db = { path = "../db" }gpui = { path = "../gpui" }util = { path = "../util" }rpc = { path = "../rpc" }+text = { path = "../text" }settings = { path = "../settings" }staff_mode = { path = "../staff_mode" }sum_tree = { path = "../sum_tree" }diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex 8ef3e32ea8f..a32c415f7e9 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -1,10 +1,6 @@#[cfg(any(test, feature = "test-support"))]pub mod test;-#[cfg(test)]-mod channel_store_tests;--pub mod channel_store;pub mod telemetry;pub mod user;@@ -48,7 +44,6 @@ use util::channel::ReleaseChannel;use util::http::HttpClient;use util::{ResultExt, TryFutureExt};-pub use channel_store::*;pub use rpc::*;pub use telemetry::ClickhouseEvent;pub use user::*;diff --git a/crates/client/src/user.rs b/crates/client/src/user.rsindex be11d1fb442..1dc384da172 100644--- a/crates/client/src/user.rs+++ b/crates/client/src/user.rs@@ -10,9 +10,11 @@ use std::sync::{Arc, Weak};use util::http::HttpClient;use util::TryFutureExt as _;+pub type UserId = u64;+#[derive(Default, Debug)]pub struct User {- pub id: u64,+ pub id: UserId,pub github_login: String,pub avatar: Option<Arc<ImageData>>,}diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.tomlindex 49d17bdc638..fc78a03f677 100644--- a/crates/collab/Cargo.toml+++ b/crates/collab/Cargo.toml@@ -64,6 +64,7 @@ collections = { path = "../collections", features = ["test-support"] }gpui = { path = "../gpui", features = ["test-support"] }call = { path = "../call", features = ["test-support"] }client = { path = "../client", features = ["test-support"] }+channel = { path = "../channel" }editor = { path = "../editor", features = ["test-support"] }language = { path = "../language", features = ["test-support"] }fs = { path = "../fs", features = ["test-support"] }diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rsindex 19915777dc7..9c759f79a8d 100644--- a/crates/collab/src/db.rs+++ b/crates/collab/src/db.rs@@ -1,7 +1,8 @@#[cfg(test)]-mod db_tests;+pub mod tests;+#[cfg(test)]-pub mod test_db;+pub use tests::TestDb;mod ids;mod queries;diff --git a/crates/collab/src/db/queries.rs b/crates/collab/src/db/queries.rsindex c4a1d57eb44..09a8f073b46 100644--- a/crates/collab/src/db/queries.rs+++ b/crates/collab/src/db/queries.rs@@ -9,6 +9,3 @@ pub mod rooms;pub mod servers;pub mod signups;pub mod users;--#[cfg(test)]-pub mod buffer_tests;diff --git a/crates/collab/src/db/queries/channels.rs b/crates/collab/src/db/queries/channels.rsindex e3d3643a61f..85a9304a2ec 100644--- a/crates/collab/src/db/queries/channels.rs+++ b/crates/collab/src/db/queries/channels.rs@@ -689,6 +689,34 @@ impl Database {}).await}++ pub async fn get_or_create_buffer_for_channel(+ &self,+ channel_id: ChannelId,+ ) -> Result<BufferId> {+ self.transaction(|tx| async move {+ let tx = tx;+ let channel = channel::Entity::find_by_id(channel_id)+ .one(&*tx)+ .await?+ .ok_or_else(|| anyhow!("invalid channel"))?;++ if let Some(id) = channel.main_buffer_id {+ return Ok(id);+ } else {+ let buffer = buffer::ActiveModel::new().insert(&*tx).await?;+ channel::ActiveModel {+ id: ActiveValue::Unchanged(channel_id),+ main_buffer_id: ActiveValue::Set(Some(buffer.id)),+ ..Default::default()+ }+ .update(&*tx)+ .await?;+ Ok(buffer.id)+ }+ })+ .await+ }}#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]diff --git a/crates/collab/src/db/tables/channel.rs b/crates/collab/src/db/tables/channel.rsindex f00b4ced627..444d5fa6d92 100644--- a/crates/collab/src/db/tables/channel.rs+++ b/crates/collab/src/db/tables/channel.rs@@ -1,4 +1,4 @@-use crate::db::ChannelId;+use crate::db::{BufferId, ChannelId};use sea_orm::entity::prelude::*;#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]@@ -7,6 +7,7 @@ pub struct Model {#[sea_orm(primary_key)]pub id: ChannelId,pub name: String,+ pub main_buffer_id: Option<BufferId>,}impl ActiveModelBehavior for ActiveModel {}diff --git a/crates/collab/src/db/test_db.rs b/crates/collab/src/db/tests.rssimilarity index 95%rename from crates/collab/src/db/test_db.rsrename to crates/collab/src/db/tests.rsindex 71e352eb864..36a0888a62e 100644--- a/crates/collab/src/db/test_db.rs+++ b/crates/collab/src/db/tests.rs@@ -1,3 +1,6 @@+mod buffer_tests;+mod db_tests;+use super::*;use gpui::executor::Background;use parking_lot::Mutex;@@ -96,7 +99,7 @@ macro_rules! test_both_dbs {($test_name:ident, $postgres_test_name:ident, $sqlite_test_name:ident) => {#[gpui::test]async fn $postgres_test_name() {- let test_db = crate::db::test_db::TestDb::postgres(+ let test_db = crate::db::TestDb::postgres(gpui::executor::Deterministic::new(0).build_background(),);$test_name(test_db.db()).await;@@ -104,9 +107,8 @@ macro_rules! test_both_dbs {#[gpui::test]async fn $sqlite_test_name() {- let test_db = crate::db::test_db::TestDb::sqlite(- gpui::executor::Deterministic::new(0).build_background(),- );+ let test_db =+ crate::db::TestDb::sqlite(gpui::executor::Deterministic::new(0).build_background());$test_name(test_db.db()).await;}};diff --git a/crates/collab/src/db/queries/buffer_tests.rs b/crates/collab/src/db/tests/buffer_tests.rssimilarity index 100%rename from crates/collab/src/db/queries/buffer_tests.rsrename to crates/collab/src/db/tests/buffer_tests.rsdiff --git a/crates/collab/src/db/db_tests.rs b/crates/collab/src/db/tests/db_tests.rssimilarity index 98%rename from crates/collab/src/db/db_tests.rsrename to crates/collab/src/db/tests/db_tests.rsindex 8c5dab77bd7..0fffabc7c43 100644--- a/crates/collab/src/db/db_tests.rs+++ b/crates/collab/src/db/tests/db_tests.rs@@ -3,7 +3,7 @@ use crate::test_both_dbs;use gpui::executor::{Background, Deterministic};use pretty_assertions::{assert_eq, assert_ne};use std::sync::Arc;-use test_db::TestDb;+use tests::TestDb;test_both_dbs!(test_get_users,@@ -1329,6 +1329,35 @@ async fn test_channel_renames(db: &Arc<Database>) {assert!(bad_name_rename.is_err())}+test_both_dbs!(+ test_get_or_create_channel_buffer,+ test_get_or_create_channel_buffer_postgres,+ test_get_or_create_channel_buffer_sqlite+);++async fn test_get_or_create_channel_buffer(db: &Arc<Database>) {+ let a_id = db+ .create_user(+ "[email protected]",+ false,+ NewUserParams {+ github_login: "user1".into(),+ github_user_id: 5,+ invite_count: 0,+ },+ )+ .await+ .unwrap()+ .user_id;++ let zed_id = db.create_root_channel("zed", "1", a_id).await.unwrap();++ let first_buffer_id = db.get_or_create_buffer_for_channel(zed_id).await.unwrap();+ let second_buffer_id = db.get_or_create_buffer_for_channel(zed_id).await.unwrap();++ assert_eq!(first_buffer_id, second_buffer_id);+}+#[gpui::test]async fn test_multiple_signup_overwrite() {let test_db = TestDb::postgres(build_background_executor());diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 521aa3e7b45..22eb23ce8e1 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -35,8 +35,8 @@ use lazy_static::lazy_static;use prometheus::{register_int_gauge, IntGauge};use rpc::{proto::{- self, AnyTypedEnvelope, EntityMessage, EnvelopedMessage, LiveKitConnectionInfo,- RequestMessage,+ self, AnyTypedEnvelope, EntityMessage, EnvelopedMessage, GetChannelBufferResponse,+ LiveKitConnectionInfo, RequestMessage,},Connection, ConnectionId, Peer, Receipt, TypedEnvelope,};@@ -248,6 +248,7 @@ impl Server {.add_request_handler(remove_channel_member).add_request_handler(set_channel_member_admin).add_request_handler(rename_channel)+ .add_request_handler(get_channel_buffer).add_request_handler(get_channel_members).add_request_handler(respond_to_channel_invite).add_request_handler(join_channel)@@ -2478,6 +2479,26 @@ async fn join_channel(Ok(())}+async fn get_channel_buffer(+ request: proto::GetChannelBuffer,+ response: Response<proto::GetChannelBuffer>,+ session: Session,+) -> Result<()> {+ let db = session.db().await;+ let channel_id = ChannelId::from_proto(request.channel_id);++ let buffer_id = db.get_or_create_buffer_for_channel(channel_id).await?;++ let buffer = db.get_buffer(buffer_id).await?;++ response.send(GetChannelBufferResponse {+ base_text: buffer.base_text,+ operations: buffer.operations,+ })?;++ Ok(())+}+async fn update_diff_base(request: proto::UpdateDiffBase, session: Session) -> Result<()> {let project_id = ProjectId::from_proto(request.project_id);let project_connection_ids = sessiondiff --git a/crates/collab/src/tests.rs b/crates/collab/src/tests.rsindex c9f358ca5bb..831bccbb724 100644--- a/crates/collab/src/tests.rs+++ b/crates/collab/src/tests.rs@@ -1,14 +1,14 @@use crate::{- db::{test_db::TestDb, NewUserParams, UserId},+ db::{tests::TestDb, NewUserParams, UserId},executor::Executor,rpc::{Server, CLEANUP_TIMEOUT},AppState,};use anyhow::anyhow;use call::{ActiveCall, Room};+use channel::ChannelStore;use client::{- self, proto::PeerId, ChannelStore, Client, Connection, Credentials, EstablishConnectionError,- UserStore,+ self, proto::PeerId, Client, Connection, Credentials, EstablishConnectionError, UserStore,};use collections::{HashMap, HashSet};use fs::FakeFs;@@ -31,6 +31,7 @@ use std::{use util::http::FakeHttpClient;use workspace::Workspace;+mod channel_buffer_tests;mod channel_tests;mod integration_tests;mod randomized_integration_tests;diff --git a/crates/collab/src/tests/channel_buffer_tests.rs b/crates/collab/src/tests/channel_buffer_tests.rsnew file mode 100644index 00000000000..e7f662523e5--- /dev/null+++ b/crates/collab/src/tests/channel_buffer_tests.rs@@ -0,0 +1,84 @@+use crate::tests::TestServer;++use channel::channel_buffer::ChannelBuffer;+use gpui::{executor::Deterministic, ModelHandle, TestAppContext};+use std::{ops::Range, sync::Arc};++#[gpui::test]+async fn test_channel_buffers(+ deterministic: Arc<Deterministic>,+ cx_a: &mut TestAppContext,+ cx_b: &mut TestAppContext,+) {+ deterministic.forbid_parking();+ let mut server = TestServer::start(&deterministic).await;+ let client_a = server.create_client(cx_a, "user_a").await;+ let client_b = server.create_client(cx_b, "user_b").await;++ let zed_id = server+ .make_channel("zed", (&client_a, cx_a), &mut [(&client_b, cx_b)])+ .await;++ let a_document =+ cx_a.add_model(|cx| ChannelBuffer::for_channel(zed_id, client_a.client().to_owned(), cx));+ let channel_buffer_a = a_document+ .update(cx_a, |doc, cx| doc.buffer(cx))+ .await+ .unwrap();++ edit_channel_buffer(&channel_buffer_a, cx_a, [(0..0, "hello world")]);+ edit_channel_buffer(&channel_buffer_a, cx_a, [(5..5, ", cruel")]);+ edit_channel_buffer(&channel_buffer_a, cx_a, [(0..5, "goodbye")]);+ undo_channel_buffer(&channel_buffer_a, cx_a);++ assert_eq!(+ channel_buffer_text(&channel_buffer_a, cx_a),+ "hello, cruel world"+ );++ let b_document =+ cx_b.add_model(|cx| ChannelBuffer::for_channel(zed_id, client_b.client().to_owned(), cx));+ let channel_buffer_b = b_document+ .update(cx_b, |doc, cx| doc.buffer(cx))+ .await+ .unwrap();++ assert_eq!(+ channel_buffer_text(&channel_buffer_b, cx_b),+ "hello, cruel world"+ );++ edit_channel_buffer(&channel_buffer_b, cx_b, [(7..12, "beautiful")]);++ deterministic.run_until_parked();++ assert_eq!(+ channel_buffer_text(&channel_buffer_a, cx_a),+ "hello, beautiful world"+ );+ assert_eq!(+ channel_buffer_text(&channel_buffer_b, cx_b),+ "hello, beautiful world"+ );+}++fn edit_channel_buffer<I>(+ channel_buffer: &ModelHandle<language::Buffer>,+ cx: &mut TestAppContext,+ edits: I,+) where+ I: IntoIterator<Item = (Range<usize>, &'static str)>,+{+ channel_buffer.update(cx, |buffer, cx| buffer.edit(edits, None, cx));+}++fn undo_channel_buffer(channel_buffer: &ModelHandle<language::Buffer>, cx: &mut TestAppContext) {+ channel_buffer.update(cx, |buffer, cx| buffer.undo(cx));+}++fn channel_buffer_text(+ channel_buffer: &ModelHandle<language::Buffer>,+ cx: &mut TestAppContext,+) -> String {+ channel_buffer.read_with(cx, |buffer, _| buffer.text())+}diff --git a/crates/collab/src/tests/channel_tests.rs b/crates/collab/src/tests/channel_tests.rsindex 06cf3607c05..41d22867722 100644--- a/crates/collab/src/tests/channel_tests.rs+++ b/crates/collab/src/tests/channel_tests.rs@@ -3,7 +3,8 @@ use crate::{tests::{room_participants, RoomParticipants, TestServer},};use call::ActiveCall;-use client::{ChannelId, ChannelMembership, ChannelStore, User};+use channel::{ChannelId, ChannelMembership, ChannelStore};+use client::User;use gpui::{executor::Deterministic, ModelHandle, TestAppContext};use rpc::{proto, RECEIVE_TIMEOUT};use std::sync::Arc;diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.tomlindex 471608c43ec..e0177f66090 100644--- a/crates/collab_ui/Cargo.toml+++ b/crates/collab_ui/Cargo.toml@@ -26,6 +26,7 @@ auto_update = { path = "../auto_update" }db = { path = "../db" }call = { path = "../call" }client = { path = "../client" }+channel = { path = "../channel" }clock = { path = "../clock" }collections = { path = "../collections" }context_menu = { path = "../context_menu" }diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex 5623ada42dc..ab692dd1667 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -4,10 +4,8 @@ mod panel_settings;use anyhow::Result;use call::ActiveCall;-use client::{- proto::PeerId, Channel, ChannelEvent, ChannelId, ChannelStore, Client, Contact, User, UserStore,-};-+use channel::{Channel, ChannelEvent, ChannelId, ChannelStore};+use client::{proto::PeerId, Client, Contact, User, UserStore};use context_menu::{ContextMenu, ContextMenuItem};use db::kvp::KEY_VALUE_STORE;use editor::{Cancel, Editor};diff --git a/crates/collab_ui/src/collab_panel/channel_modal.rs b/crates/collab_ui/src/collab_panel/channel_modal.rsindex 75ab40be85a..0adf2806d72 100644--- a/crates/collab_ui/src/collab_panel/channel_modal.rs+++ b/crates/collab_ui/src/collab_panel/channel_modal.rs@@ -1,4 +1,5 @@-use client::{proto, ChannelId, ChannelMembership, ChannelStore, User, UserId, UserStore};+use channel::{ChannelId, ChannelMembership, ChannelStore};+use client::{proto, User, UserId, UserStore};use context_menu::{ContextMenu, ContextMenuItem};use fuzzy::{match_strings, StringMatchCandidate};use gpui::{diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.protoindex caa5efd2cb1..baeaae18762 100644--- a/crates/rpc/proto/zed.proto+++ b/crates/rpc/proto/zed.proto@@ -142,6 +142,9 @@ message Envelope {GetChannelMembersResponse get_channel_members_response = 128;SetChannelMemberAdmin set_channel_member_admin = 129;RenameChannel rename_channel = 130;++ GetChannelBuffer get_channel_buffer = 131;+ GetChannelBufferResponse get_channel_buffer_response = 132;}}@@ -948,6 +951,15 @@ message RenameChannel {string name = 2;}+message GetChannelBuffer {+ uint64 channel_id = 1;+}++message GetChannelBufferResponse {+ string base_text = 1;+ repeated Operation operations = 2;+}+message RespondToChannelInvite {uint64 channel_id = 1;bool accept = 2;diff --git a/crates/rpc/src/proto.rs b/crates/rpc/src/proto.rsindex 92732b00b5d..21a491b9342 100644--- a/crates/rpc/src/proto.rs+++ b/crates/rpc/src/proto.rs@@ -248,7 +248,9 @@ messages!((GetPrivateUserInfo, Foreground),(GetPrivateUserInfoResponse, Foreground),(GetChannelMembers, Foreground),- (GetChannelMembersResponse, Foreground)+ (GetChannelMembersResponse, Foreground),+ (GetChannelBuffer, Foreground),+ (GetChannelBufferResponse, Foreground));request_messages!(@@ -315,6 +317,7 @@ request_messages!((UpdateParticipantLocation, Ack),(UpdateProject, Ack),(UpdateWorktree, Ack),+ (GetChannelBuffer, GetChannelBufferResponse));entity_messages!(diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.tomlindex 8606be49448..e2dae07b8c9 100644--- a/crates/workspace/Cargo.toml+++ b/crates/workspace/Cargo.toml@@ -22,6 +22,7 @@ test-support = [db = { path = "../db" }call = { path = "../call" }client = { path = "../client" }+channel = { path = "../channel" }collections = { path = "../collections" }context_menu = { path = "../context_menu" }drag_and_drop = { path = "../drag_and_drop" }diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 79b701e015e..a8354472aa5 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -12,9 +12,10 @@ mod workspace_settings;use anyhow::{anyhow, Context, Result};use call::ActiveCall;+use channel::ChannelStore;use client::{proto::{self, PeerId},- ChannelStore, Client, TypedEnvelope, UserStore,+ Client, TypedEnvelope, UserStore,};use collections::{hash_map, HashMap, HashSet};use drag_and_drop::DragAndDrop;diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex faa3ae69530..92900f84cb5 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -21,6 +21,7 @@ activity_indicator = { path = "../activity_indicator" }auto_update = { path = "../auto_update" }breadcrumbs = { path = "../breadcrumbs" }call = { path = "../call" }+channel = { path = "../channel" }cli = { path = "../cli" }collab_ui = { path = "../collab_ui" }collections = { path = "../collections" }diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex caeaecededf..b905c1d37bc 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -3,13 +3,12 @@use anyhow::{anyhow, Context, Result};use backtrace::Backtrace;+use channel::ChannelStore;use cli::{ipc::{self, IpcSender},CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,};-use client::{- self, ChannelStore, TelemetrySettings, UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN,-};+use client::{self, TelemetrySettings, UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN};use db::kvp::KEY_VALUE_STORE;use editor::{scroll::autoscroll::Autoscroll, Editor};use futures::{