ssh-remoting: Tidy up the code a bit after #18094 (#18102)

Stanislav Alekseev created

Release Notes:

- N/A

Change summary

crates/client/src/client.rs          | 2 +-
crates/project/src/worktree_store.rs | 7 ++++---
crates/remote/src/ssh_session.rs     | 2 +-
crates/rpc/src/proto_client.rs       | 6 +++---
4 files changed, 9 insertions(+), 8 deletions(-)

Detailed changes

crates/client/src/client.rs 🔗

@@ -1622,7 +1622,7 @@ impl ProtoClient for Client {
         &self.handler_set
     }
 
-    fn goes_via_collab(&self) -> bool {
+    fn is_via_collab(&self) -> bool {
         true
     }
 }

crates/project/src/worktree_store.rs 🔗

@@ -313,9 +313,10 @@ impl WorktreeStore {
         })
     }
 
+    #[track_caller]
     pub fn add(&mut self, worktree: &Model<Worktree>, cx: &mut ModelContext<Self>) {
         let worktree_id = worktree.read(cx).id();
-        debug_assert!(!self.worktrees().any(|w| w.read(cx).id() == worktree_id));
+        debug_assert!(self.worktrees().all(|w| w.read(cx).id() != worktree_id));
 
         let push_strong_handle = self.retain_worktrees || worktree.read(cx).is_visible();
         let handle = if push_strong_handle {
@@ -487,7 +488,7 @@ impl WorktreeStore {
         };
 
         // collab has bad concurrency guarantees, so we send requests in serial.
-        let update_project = if downstream_client.goes_via_collab() {
+        let update_project = if downstream_client.is_via_collab() {
             Some(downstream_client.request(update))
         } else {
             downstream_client.send(update).log_err();
@@ -508,7 +509,7 @@ impl WorktreeStore {
                             move |update| {
                                 let client = client.clone();
                                 async move {
-                                    if client.goes_via_collab() {
+                                    if client.is_via_collab() {
                                         client.request(update).map(|result| result.is_ok()).await
                                     } else {
                                         client.send(update).is_ok()

crates/remote/src/ssh_session.rs 🔗

@@ -471,7 +471,7 @@ impl ProtoClient for SshSession {
         &self.state
     }
 
-    fn goes_via_collab(&self) -> bool {
+    fn is_via_collab(&self) -> bool {
         false
     }
 }

crates/rpc/src/proto_client.rs 🔗

@@ -28,7 +28,7 @@ pub trait ProtoClient: Send + Sync {
 
     fn message_handler_set(&self) -> &parking_lot::Mutex<ProtoMessageHandlerSet>;
 
-    fn goes_via_collab(&self) -> bool;
+    fn is_via_collab(&self) -> bool;
 }
 
 #[derive(Default)]
@@ -141,8 +141,8 @@ impl AnyProtoClient {
         Self(client)
     }
 
-    pub fn goes_via_collab(&self) -> bool {
-        self.0.goes_via_collab()
+    pub fn is_via_collab(&self) -> bool {
+        self.0.is_via_collab()
     }
 
     pub fn request<T: RequestMessage>(