collab: Fix project sharing between Windows and Unix (#23680)

Closes #14258

Windows user(host) sharing a project to a guest(using macOS), and host
follows guest:


https://github.com/user-attachments/assets/ba306b6b-23f7-48b1-8ba8-fdc5992d8f00

macOS user(host) sharing a project to a guest(using Windows), and host
follows guest:



https://github.com/user-attachments/assets/c5ee5e78-870d-49e5-907d-8565977a01ae

macOS user edits files in a windows project through collab:



https://github.com/user-attachments/assets/581057cf-e7df-4e56-a0ce-ced74339906a





Release Notes:

- N/A
This commit is contained in:
张小白
2025-02-10 16:12:01 -08:00
committed by GitHub
parent 929c5e76b4
commit c1f162abc6
14 changed files with 226 additions and 117 deletions
+11 -9
View File
@@ -15,7 +15,7 @@ use futures::{
use gpui::{App, AsyncApp, Context, Entity, EntityId, EventEmitter, Task, WeakEntity};
use postage::oneshot;
use rpc::{
proto::{self, SSH_PROJECT_ID},
proto::{self, FromProto, ToProto, SSH_PROJECT_ID},
AnyProtoClient, ErrorExt, TypedEnvelope,
};
use smol::{
@@ -268,10 +268,11 @@ impl WorktreeStore {
cx.spawn(|this, mut cx| async move {
let this = this.upgrade().context("Dropped worktree store")?;
let path = Path::new(abs_path.as_str());
let response = client
.request(proto::AddWorktree {
project_id: SSH_PROJECT_ID,
path: abs_path.clone(),
path: path.to_proto(),
visible,
})
.await?;
@@ -282,10 +283,11 @@ impl WorktreeStore {
return Ok(existing_worktree);
}
let root_name = PathBuf::from(&response.canonicalized_path)
let root_path_buf = PathBuf::from_proto(response.canonicalized_path.clone());
let root_name = root_path_buf
.file_name()
.map(|n| n.to_string_lossy().to_string())
.unwrap_or(response.canonicalized_path.to_string());
.unwrap_or(root_path_buf.to_string_lossy().to_string());
let worktree = cx.update(|cx| {
Worktree::remote(
@@ -596,7 +598,7 @@ impl WorktreeStore {
id: worktree.id().to_proto(),
root_name: worktree.root_name().into(),
visible: worktree.is_visible(),
abs_path: worktree.abs_path().to_string_lossy().into(),
abs_path: worktree.abs_path().to_proto(),
}
})
.collect()
@@ -923,7 +925,7 @@ impl WorktreeStore {
project_id: remote_worktree.project_id(),
repository: Some(proto::ProjectPath {
worktree_id: project_path.worktree_id.to_proto(),
path: project_path.path.to_string_lossy().to_string(), // Root path
path: project_path.path.to_proto(), // Root path
}),
});
@@ -994,7 +996,7 @@ impl WorktreeStore {
project_id: remote_worktree.project_id(),
repository: Some(proto::ProjectPath {
worktree_id: repository.worktree_id.to_proto(),
path: repository.path.to_string_lossy().to_string(), // Root path
path: repository.path.to_proto(), // Root path
}),
branch_name: new_branch,
});
@@ -1116,7 +1118,7 @@ impl WorktreeStore {
.context("Invalid GitBranches call")?;
let project_path = ProjectPath {
worktree_id: WorktreeId::from_proto(project_path.worktree_id),
path: Path::new(&project_path.path).into(),
path: Arc::<Path>::from_proto(project_path.path),
};
let branches = this
@@ -1147,7 +1149,7 @@ impl WorktreeStore {
.context("Invalid GitBranches call")?;
let project_path = ProjectPath {
worktree_id: WorktreeId::from_proto(project_path.worktree_id),
path: Path::new(&project_path.path).into(),
path: Arc::<Path>::from_proto(project_path.path),
};
let new_branch = update_branch.payload.branch_name;