Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge branch 'main' into reconnections-2
Antonio Scandurra9a62150dce45
diff --cc Cargo.lockindex 30c5054576a,4312b7e830f..17f1eef8a6b--- a/Cargo.lock+++ b/Cargo.lock@@@ -559,24 -562,11 +574,24 @@@ dependencies ="rustc-demangle",]+[[package]]+name = "bae"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a"+dependencies = [+ "heck 0.3.3",+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn",+]+[[package]]name = "base64"- version = "0.13.0"+ version = "0.13.1"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"+ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"[[package]]name = "base64ct"@@@ -657,54 -648,8 +673,53 @@@ dependencies ="atomic-waker","fastrand","futures-lite",- "once_cell",]+[[package]]+name = "borsh"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa"+dependencies = [+ "borsh-derive",+ "hashbrown 0.11.2",+]++[[package]]+name = "borsh-derive"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775"+dependencies = [+ "borsh-derive-internal",+ "borsh-schema-derive-internal",+ "proc-macro-crate",+ "proc-macro2",+ "syn",+]++[[package]]+name = "borsh-derive-internal"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "borsh-schema-derive-internal"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]+[[package]]name = "breadcrumbs"version = "0.1.0"@@@ -744,36 -689,15 +759,36 @@@ dependencies =[[package]]name = "bumpalo"- version = "3.11.0"+ version = "3.11.1"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"+ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"+[[package]]+name = "bytecheck"+version = "0.6.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f"+dependencies = [+ "bytecheck_derive",+ "ptr_meta",+]++[[package]]+name = "bytecheck_derive"+version = "0.6.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]+[[package]]name = "bytemuck"- version = "1.12.1"+ version = "1.12.3"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da"+ checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f"[[package]]name = "byteorder"@@@ -932,8 -850,7 +941,8 @@@ dependencies ="js-sys","num-integer","num-traits",+ "serde",- "time 0.1.44",+ "time 0.1.45","wasm-bindgen","winapi 0.3.9",]@@@ -1631,19 -1546,6 +1640,19 @@@ dependencies ="syn",]+[[package]]+name = "dashmap"+version = "5.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"+dependencies = [+ "cfg-if 1.0.0",+ "hashbrown 0.12.3",+ "lock_api",+ "once_cell",- "parking_lot_core 0.9.4",++ "parking_lot_core 0.9.5",+]+[[package]]name = "data-url"version = "0.1.1"@@@ -3204,9 -3107,9 +3214,9 @@@ dependencies =[[package]]name = "libsqlite3-sys"--version = "0.25.2"++version = "0.24.2"source = "registry+https://github.com/rust-lang/crates.io-index"--checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa"++checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14"dependencies = ["cc","pkg-config",@@@ -3932,33 -3854,10 +3961,33 @@@ dependencies =[[package]]name = "os_str_bytes"- version = "6.3.0"+ version = "6.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"+ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"+[[package]]+name = "ouroboros"+version = "0.15.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dfbb50b356159620db6ac971c6d5c9ab788c9cc38a6f49619fca2a27acb062ca"+dependencies = [+ "aliasable",+ "ouroboros_macro",+]++[[package]]+name = "ouroboros_macro"+version = "0.15.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a0d9d1a6191c4f391f87219d1ea42b23f09ee84d64763cd05ee6ea88d9f384d"+dependencies = [+ "Inflector",+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn",+]+[[package]]name = "outline"version = "0.1.0"@@@ -4313,19 -4212,10 +4342,19 @@@ dependencies =[[package]]name = "ppv-lite86"- version = "0.2.16"+ version = "0.2.17"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"+ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"+[[package]]+name = "proc-macro-crate"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"+dependencies = [+ "toml",+]+[[package]]name = "proc-macro-error"version = "1.0.4"@@@ -4828,23 -4697,14 +4856,23 @@@ dependencies ="winapi 0.3.9",]+[[package]]+name = "rend"+version = "0.3.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95"+dependencies = [+ "bytecheck",+]+[[package]]name = "reqwest"- version = "0.11.12"+ version = "0.11.13"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"+ checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c"dependencies = ["base64",- "bytes 1.2.1",+ "bytes 1.3.0","encoding_rs","futures-core","futures-util",@@@ -5090,24 -4901,6 +5094,24 @@@ dependencies ="walkdir",]+[[package]]+name = "rust_decimal"+version = "1.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33c321ee4e17d2b7abe12b5d20c1231db708dd36185c8a21e9de5fed6da4dbe9"+dependencies = [+ "arrayvec 0.7.2",+ "borsh",+ "bytecheck",+ "byteorder",- "bytes 1.2.1",++ "bytes 1.3.0",+ "num-traits",+ "rand 0.8.5",+ "rkyv",+ "serde",+ "serde_json",+]+[[package]]name = "rustc-demangle"version = "0.1.21"@@@ -5326,109 -5113,6 +5330,109 @@@ dependencies ="untrusted",]+[[package]]+name = "sea-orm"+version = "0.10.5"+source = "git+https://github.com/zed-industries/sea-orm?rev=18f4c691085712ad014a51792af75a9044bacee6#18f4c691085712ad014a51792af75a9044bacee6"+dependencies = [+ "async-stream",+ "async-trait",+ "chrono",- "futures 0.3.24",++ "futures 0.3.25",+ "futures-util",+ "log",+ "ouroboros",+ "rust_decimal",+ "sea-orm-macros",+ "sea-query",+ "sea-query-binder",+ "sea-strum",+ "serde",+ "serde_json",+ "sqlx",+ "thiserror",- "time 0.3.15",++ "time 0.3.17",+ "tracing",+ "url",- "uuid 1.2.1",++ "uuid 1.2.2",+]++[[package]]+name = "sea-orm-macros"+version = "0.10.5"+source = "git+https://github.com/zed-industries/sea-orm?rev=18f4c691085712ad014a51792af75a9044bacee6#18f4c691085712ad014a51792af75a9044bacee6"+dependencies = [+ "bae",+ "heck 0.3.3",+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "sea-query"+version = "0.27.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4f0fc4d8e44e1d51c739a68d336252a18bc59553778075d5e32649be6ec92ed"+dependencies = [+ "chrono",+ "rust_decimal",+ "sea-query-derive",+ "serde_json",- "time 0.3.15",- "uuid 1.2.1",++ "time 0.3.17",++ "uuid 1.2.2",+]++[[package]]+name = "sea-query-binder"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9c2585b89c985cfacfe0ec9fc9e7bb055b776c1a2581c4e3c6185af2b8bf8865"+dependencies = [+ "chrono",+ "rust_decimal",+ "sea-query",+ "serde_json",+ "sqlx",- "time 0.3.15",- "uuid 1.2.1",++ "time 0.3.17",++ "uuid 1.2.2",+]++[[package]]+name = "sea-query-derive"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5"+dependencies = [+ "heck 0.3.3",+ "proc-macro2",+ "quote",+ "syn",+ "thiserror",+]++[[package]]+name = "sea-strum"+version = "0.23.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b"+dependencies = [+ "sea-strum_macros",+]++[[package]]+name = "sea-strum_macros"+version = "0.23.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21"+dependencies = [+ "heck 0.3.3",+ "proc-macro2",+ "quote",+ "rustversion",+ "syn",+]+[[package]]name = "seahash"version = "4.1.0"@@@ -5926,8 -5626,8 +5946,9 @@@ dependencies =[[package]]name = "sqlx"--version = "0.6.2"--source = "git+https://github.com/launchbadge/sqlx?rev=4b7053807c705df312bcb9b6281e184bf7534eb3#4b7053807c705df312bcb9b6281e184bf7534eb3"++version = "0.6.1"++source = "registry+https://github.com/rust-lang/crates.io-index"++checksum = "788841def501aabde58d3666fcea11351ec3962e6ea75dbcd05c84a71d68bcd1"dependencies = ["sqlx-core","sqlx-macros",@@@ -5936,15 -5636,14 +5957,16 @@@[[package]]name = "sqlx-core"version = "0.6.2"--source = "git+https://github.com/launchbadge/sqlx?rev=4b7053807c705df312bcb9b6281e184bf7534eb3#4b7053807c705df312bcb9b6281e184bf7534eb3"++source = "registry+https://github.com/rust-lang/crates.io-index"++checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105"dependencies = ["ahash","atoi","base64","bitflags","byteorder",- "bytes 1.2.1",+ "bytes 1.3.0",+ "chrono","crc","crossbeam-queue","dirs 4.0.0",@@@ -5996,7 -5693,7 +6018,8 @@@[[package]]name = "sqlx-macros"version = "0.6.2"--source = "git+https://github.com/launchbadge/sqlx?rev=4b7053807c705df312bcb9b6281e184bf7534eb3#4b7053807c705df312bcb9b6281e184bf7534eb3"++source = "registry+https://github.com/rust-lang/crates.io-index"++checksum = "b850fa514dc11f2ee85be9d055c512aa866746adfacd1cb42d867d68e6a5b0d9"dependencies = ["dotenvy","either",@@@ -6015,7 -5712,7 +6038,8 @@@[[package]]name = "sqlx-rt"version = "0.6.2"--source = "git+https://github.com/launchbadge/sqlx?rev=4b7053807c705df312bcb9b6281e184bf7534eb3#4b7053807c705df312bcb9b6281e184bf7534eb3"++source = "registry+https://github.com/rust-lang/crates.io-index"++checksum = "24c5b2d25fa654cc5f841750b8e1cdedbe21189bf9a9382ee90bfa9dd3562396"dependencies = ["once_cell","tokio",@@@ -7130,12 -6847,11 +7174,12 @@@ dependencies =[[package]]name = "uuid"- version = "1.2.1"+ version = "1.2.2"source = "registry+https://github.com/rust-lang/crates.io-index"- checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83"+ checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c"dependencies = [- "getrandom 0.2.7",+ "getrandom 0.2.8",+ "serde",][[package]]diff --cc crates/client/src/client.rsindex c75aef3a1ad,f9b3a88545e..5e10f9ea8f4--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@@ -1187,99 -1217,8 +1186,99 @@@ impl Clientself.peer.respond_with_error(receipt, error)}+ fn handle_message(+ self: &Arc<Client>,+ message: Box<dyn AnyTypedEnvelope>,+ cx: &AsyncAppContext,+ ) {+ let mut state = self.state.write();+ let type_name = message.payload_type_name();+ let payload_type_id = message.payload_type_id();+ let sender_id = message.original_sender_id().map(|id| id.0);++ let mut subscriber = None;++ if let Some(message_model) = state+ .models_by_message_type+ .get(&payload_type_id)+ .and_then(|model| model.upgrade(cx))+ {+ subscriber = Some(Subscriber::Model(message_model));+ } else if let Some((extract_entity_id, entity_type_id)) =+ state.entity_id_extractors.get(&payload_type_id).zip(+ state+ .entity_types_by_message_type+ .get(&payload_type_id)+ .copied(),+ )+ {+ let entity_id = (extract_entity_id)(message.as_ref());++ match state+ .entities_by_type_and_remote_id+ .get_mut(&(entity_type_id, entity_id))+ {+ Some(WeakSubscriber::Pending(pending)) => {+ pending.push(message);+ return;+ }+ Some(weak_subscriber @ _) => subscriber = weak_subscriber.upgrade(cx),+ _ => {}+ }+ }++ let subscriber = if let Some(subscriber) = subscriber {+ subscriber+ } else {+ log::info!("unhandled message {}", type_name);+ return;+ };++ let handler = state.message_handlers.get(&payload_type_id).cloned();+ // Dropping the state prevents deadlocks if the handler interacts with rpc::Client.+ // It also ensures we don't hold the lock while yielding back to the executor, as+ // that might cause the executor thread driving this future to block indefinitely.+ drop(state);++ if let Some(handler) = handler {+ let future = handler(subscriber, message, &self, cx.clone());+ let client_id = self.id;+ log::debug!(+ "rpc message received. client_id:{}, sender_id:{:?}, type:{}",+ client_id,+ sender_id,+ type_name+ );+ cx.foreground()+ .spawn(async move {+ match future.await {+ Ok(()) => {+ log::debug!(+ "rpc message handled. client_id:{}, sender_id:{:?}, type:{}",+ client_id,+ sender_id,+ type_name+ );+ }+ Err(error) => {+ log::error!(+ "error handling message. client_id:{}, sender_id:{:?}, type:{}, error:{:?}",+ client_id,+ sender_id,+ type_name,+ error+ );+ }+ }+ })+ .detach();+ } else {+ log::info!("unhandled message {}", type_name);+ }+ }+- pub fn start_telemetry(&self, db: Db) {- self.telemetry.start(db.clone());+ pub fn start_telemetry(&self) {+ self.telemetry.start();}pub fn report_event(&self, kind: &str, properties: Value) {diff --cc crates/sqlez/Cargo.tomlindex 00000000000,c6c018b9244..78bf83dc303mode 000000,100644..100644--- a/crates/sqlez/Cargo.toml+++ b/crates/sqlez/Cargo.toml@@@ -1,0 -1,16 +1,16 @@@+ [package]+ name = "sqlez"+ version = "0.1.0"+ edition = "2021"++ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html++ [dependencies]+ anyhow = { version = "1.0.38", features = ["backtrace"] }+ indoc = "1.0.7"-libsqlite3-sys = { version = "0.25.2", features = ["bundled"] }++libsqlite3-sys = { version = "0.24", features = ["bundled"] }+ smol = "1.2"+ thread_local = "1.1.4"+ lazy_static = "1.4"+ parking_lot = "0.11.1"+ futures = "0.3"diff --cc crates/workspace/src/workspace.rsindex 9021867dfc3,2327c517632..45de94b6030--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@@ -28,13 -40,20 +40,20 @@@ use gpui::MouseButton, MutableAppContext, PathPromptOptions, PromptLevel, RenderContext, Task, View,ViewContext, ViewHandle, WeakViewHandle,};+ use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};use language::LanguageRegistry;+use log::{error, warn};+ use notifications::NotificationHandle;pub use pane::*;pub use pane_group::*;+ use persistence::{model::SerializedItem, DB};+ pub use persistence::{+ model::{ItemId, WorkspaceLocation},+ WorkspaceDb,+ };use postage::prelude::Stream;-use project::{Project, ProjectEntryId, ProjectPath, ProjectStore, Worktree, WorktreeId};+use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};- use searchable::SearchableItemHandle;use serde::Deserialize;use settings::{Autosave, DockAnchor, Settings};use shared_screen::SharedScreen;@@@ -343,189 -379,34 +378,32 @@@ pub struct AppStatepub default_item_factory: DefaultItemFactory,}- #[derive(Eq, PartialEq, Hash)]- pub enum ItemEvent {- CloseItem,- UpdateTab,- UpdateBreadcrumbs,- Edit,- }-- pub trait Item: View {- fn deactivated(&mut self, _: &mut ViewContext<Self>) {}- fn workspace_deactivated(&mut self, _: &mut ViewContext<Self>) {}- fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) -> bool {- false- }- fn tab_description<'a>(&'a self, _: usize, _: &'a AppContext) -> Option<Cow<'a, str>> {- None- }- fn tab_content(&self, detail: Option<usize>, style: &theme::Tab, cx: &AppContext)- -> ElementBox;- fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;- fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;- fn is_singleton(&self, cx: &AppContext) -> bool;- fn set_nav_history(&mut self, _: ItemNavHistory, _: &mut ViewContext<Self>);- fn clone_on_split(&self, _: &mut ViewContext<Self>) -> Option<Self>- where- Self: Sized,- {- None- }- fn is_dirty(&self, _: &AppContext) -> bool {- false- }- fn has_conflict(&self, _: &AppContext) -> bool {- false- }- fn can_save(&self, cx: &AppContext) -> bool;- fn save(- &mut self,- project: ModelHandle<Project>,- cx: &mut ViewContext<Self>,- ) -> Task<Result<()>>;- fn save_as(- &mut self,- project: ModelHandle<Project>,- abs_path: PathBuf,- cx: &mut ViewContext<Self>,- ) -> Task<Result<()>>;- fn reload(- &mut self,- project: ModelHandle<Project>,- cx: &mut ViewContext<Self>,- ) -> Task<Result<()>>;- fn git_diff_recalc(- &mut self,- _project: ModelHandle<Project>,- _cx: &mut ViewContext<Self>,- ) -> Task<Result<()>> {- Task::ready(Ok(()))- }- fn to_item_events(event: &Self::Event) -> Vec<ItemEvent>;- fn should_close_item_on_event(_: &Self::Event) -> bool {- false- }- fn should_update_tab_on_event(_: &Self::Event) -> bool {- false- }- fn is_edit_event(_: &Self::Event) -> bool {- false- }- fn act_as_type(- &self,- type_id: TypeId,- self_handle: &ViewHandle<Self>,- _: &AppContext,- ) -> Option<AnyViewHandle> {- if TypeId::of::<Self>() == type_id {- Some(self_handle.into())- } else {- None- }- }- fn as_searchable(&self, _: &ViewHandle<Self>) -> Option<Box<dyn SearchableItemHandle>> {- None- }-- fn breadcrumb_location(&self) -> ToolbarItemLocation {- ToolbarItemLocation::Hidden- }- fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox>> {- None- }- }-- pub trait ProjectItem: Item {- type Item: project::Item;-- fn for_project_item(- project: ModelHandle<Project>,- item: ModelHandle<Self::Item>,- cx: &mut ViewContext<Self>,- ) -> Self;- }-- pub trait FollowableItem: Item {- fn to_state_proto(&self, cx: &AppContext) -> Option<proto::view::Variant>;- fn from_state_proto(- pane: ViewHandle<Pane>,- project: ModelHandle<Project>,- state: &mut Option<proto::view::Variant>,- cx: &mut MutableAppContext,- ) -> Option<Task<Result<ViewHandle<Self>>>>;- fn add_event_to_update_proto(- &self,- event: &Self::Event,- update: &mut Option<proto::update_view::Variant>,- cx: &AppContext,- ) -> bool;- fn apply_update_proto(- &mut self,- message: proto::update_view::Variant,- cx: &mut ViewContext<Self>,- ) -> Result<()>;-- fn set_leader_replica_id(&mut self, leader_replica_id: Option<u16>, cx: &mut ViewContext<Self>);- fn should_unfollow_on_event(event: &Self::Event, cx: &AppContext) -> bool;- }+ impl AppState {+ #[cfg(any(test, feature = "test-support"))]+ pub fn test(cx: &mut MutableAppContext) -> Arc<Self> {+ use fs::HomeDir;- pub trait FollowableItemHandle: ItemHandle {- fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut MutableAppContext);- fn to_state_proto(&self, cx: &AppContext) -> Option<proto::view::Variant>;- fn add_event_to_update_proto(- &self,- event: &dyn Any,- update: &mut Option<proto::update_view::Variant>,- cx: &AppContext,- ) -> bool;- fn apply_update_proto(- &self,- message: proto::update_view::Variant,- cx: &mut MutableAppContext,- ) -> Result<()>;- fn should_unfollow_on_event(&self, event: &dyn Any, cx: &AppContext) -> bool;- }+ cx.set_global(HomeDir(Path::new("/tmp/").to_path_buf()));+ let settings = Settings::test(cx);+ cx.set_global(settings);- impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {- fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut MutableAppContext) {- self.update(cx, |this, cx| {- this.set_leader_replica_id(leader_replica_id, cx)+ let fs = fs::FakeFs::new(cx.background().clone());+ let languages = Arc::new(LanguageRegistry::test());+ let http_client = client::test::FakeHttpClient::with_404_response();+ let client = Client::new(http_client.clone(), cx);- let project_store = cx.add_model(|_| ProjectStore::new());+ let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));+ let themes = ThemeRegistry::new((), cx.font_cache().clone());+ Arc::new(Self {+ client,+ themes,+ fs,+ languages,+ user_store,- project_store,+ initialize_workspace: |_, _, _| {},+ build_window_options: Default::default,+ default_item_factory: |_, _| unimplemented!(),})}-- fn to_state_proto(&self, cx: &AppContext) -> Option<proto::view::Variant> {- self.read(cx).to_state_proto(cx)- }-- fn add_event_to_update_proto(- &self,- event: &dyn Any,- update: &mut Option<proto::update_view::Variant>,- cx: &AppContext,- ) -> bool {- if let Some(event) = event.downcast_ref() {- self.read(cx).add_event_to_update_proto(event, update, cx)- } else {- false- }- }-- fn apply_update_proto(- &self,- message: proto::update_view::Variant,- cx: &mut MutableAppContext,- ) -> Result<()> {- self.update(cx, |this, cx| this.apply_update_proto(message, cx))- }-- fn should_unfollow_on_event(&self, event: &dyn Any, cx: &AppContext) -> bool {- if let Some(event) = event.downcast_ref() {- T::should_unfollow_on_event(event, cx)- } else {- false- }- }}struct DelayedDebouncedEditAction {@@@ -1200,39 -610,144 +607,143 @@@ impl Workspaceactive_call = Some((call, subscriptions));}- let mut this = Workspace {- modal: None,- weak_self: weak_handle,- center: PaneGroup::new(center_pane.clone()),- dock,- // When removing an item, the last element remaining in this array- // is used to find where focus should fallback to. As such, the order- // of these two variables is important.- panes: vec![dock_pane, center_pane.clone()],- panes_by_item: Default::default(),- active_pane: center_pane.clone(),- last_active_center_pane: Some(center_pane.downgrade()),- status_bar,- titlebar_item: None,- notifications: Default::default(),- client,- remote_entity_subscription: None,- user_store,- fs,- left_sidebar,- right_sidebar,- project,- leader_state: Default::default(),- follower_states_by_leader: Default::default(),- last_leaders_by_pane: Default::default(),- window_edited: false,- active_call,- _observe_current_user,- };- this.project_remote_id_changed(this.project.read(cx).remote_id(), cx);- cx.defer(|this, cx| this.update_window_title(cx));+ let mut this = Workspace {+ modal: None,+ weak_self: weak_handle.clone(),+ center: PaneGroup::new(center_pane.clone()),+ dock,+ // When removing an item, the last element remaining in this array+ // is used to find where focus should fallback to. As such, the order+ // of these two variables is important.+ panes: vec![dock_pane.clone(), center_pane.clone()],+ panes_by_item: Default::default(),+ active_pane: center_pane.clone(),+ last_active_center_pane: Some(center_pane.downgrade()),+ status_bar,+ titlebar_item: None,+ notifications: Default::default(),+ client,+ remote_entity_subscription: None,+ user_store,+ fs,+ left_sidebar,+ right_sidebar,+ project: project.clone(),+ leader_state: Default::default(),+ follower_states_by_leader: Default::default(),+ last_leaders_by_pane: Default::default(),+ window_edited: false,+ active_call,+ database_id: workspace_id,+ _observe_current_user,+ };+ this.project_remote_id_changed(project.read(cx).remote_id(), cx);+ cx.defer(|this, cx| this.update_window_title(cx));++ if let Some(serialized_workspace) = serialized_workspace {+ cx.defer(move |_, cx| {+ Self::load_from_serialized_workspace(weak_handle, serialized_workspace, cx)+ });+ }++ this+ }++ fn new_local(+ abs_paths: Vec<PathBuf>,+ app_state: Arc<AppState>,+ cx: &mut MutableAppContext,+ ) -> Task<(+ ViewHandle<Workspace>,+ Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>,+ )> {+ let project_handle = Project::local(+ app_state.client.clone(),+ app_state.user_store.clone(),- app_state.project_store.clone(),+ app_state.languages.clone(),+ app_state.fs.clone(),+ cx,+ );++ cx.spawn(|mut cx| async move {+ let serialized_workspace = persistence::DB.workspace_for_roots(&abs_paths.as_slice());++ let paths_to_open = serialized_workspace+ .as_ref()+ .map(|workspace| workspace.location.paths())+ .unwrap_or(Arc::new(abs_paths));++ // Get project paths for all of the abs_paths+ let mut worktree_roots: HashSet<Arc<Path>> = Default::default();+ let mut project_paths = Vec::new();+ for path in paths_to_open.iter() {+ if let Some((worktree, project_entry)) = cx+ .update(|cx| {+ Workspace::project_path_for_path(project_handle.clone(), &path, true, cx)+ })+ .await+ .log_err()+ {+ worktree_roots.insert(worktree.read_with(&mut cx, |tree, _| tree.abs_path()));+ project_paths.push(Some(project_entry));+ } else {+ project_paths.push(None);+ }+ }++ let workspace_id = if let Some(serialized_workspace) = serialized_workspace.as_ref() {+ serialized_workspace.id+ } else {+ DB.next_id().await.unwrap_or(0)+ };++ // Use the serialized workspace to construct the new window+ let (_, workspace) = cx.add_window((app_state.build_window_options)(), |cx| {+ let mut workspace = Workspace::new(+ serialized_workspace,+ workspace_id,+ project_handle,+ app_state.default_item_factory,+ cx,+ );+ (app_state.initialize_workspace)(&mut workspace, &app_state, cx);+ workspace+ });++ notify_if_database_failed(&workspace, &mut cx);++ // Call open path for each of the project paths+ // (this will bring them to the front if they were in the serialized workspace)+ debug_assert!(paths_to_open.len() == project_paths.len());+ let tasks = paths_to_open+ .iter()+ .cloned()+ .zip(project_paths.into_iter())+ .map(|(abs_path, project_path)| {+ let workspace = workspace.clone();+ cx.spawn(|mut cx| {+ let fs = app_state.fs.clone();+ async move {+ let project_path = project_path?;+ if fs.is_file(&abs_path).await {+ Some(+ workspace+ .update(&mut cx, |workspace, cx| {+ workspace.open_path(project_path, None, true, cx)+ })+ .await,+ )+ } else {+ None+ }+ }+ })+ });++ let opened_items = futures::future::join_all(tasks.into_iter()).await;- this+ (workspace, opened_items)+ })}pub fn weak_handle(&self) -> WeakViewHandle<Self> {diff --cc crates/zed/src/main.rsindex e6437feb6bb,97a19b6d86f..4163841d455--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@@ -146,8 -139,9 +139,7 @@@ fn main()}).detach();- let db = cx.background().block(db);- client.start_telemetry(db.clone());- let project_store = cx.add_model(|_| ProjectStore::new());-+ client.start_telemetry();client.report_event("start app", Default::default());let app_state = Arc::new(AppState {