clock: Cleanup ReplicaId, Lamport and Global (#40600)

- Notable change is the use of a newtype for `ReplicaId`
- Fixes `WorktreeStore::create_remote_worktree` creating a remote
worktree with the local replica id, though this is not currently used
- Fixes observing the `Agent` (that is following the agent) causing
global clocks to allocate 65535 elements
- Shrinks the size of `Global` a bit. In a local or non-collab remote
session it won't ever allocate still.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-20 13:26:20 +02:00
committed by GitHub
parent 37e264ab99
commit 43a9368dff
33 changed files with 427 additions and 284 deletions
+3 -3
View File
@@ -1560,7 +1560,7 @@ impl Project {
})?;
let agent_server_store = cx.new(|cx| AgentServerStore::collab(cx))?;
let replica_id = response.payload.replica_id as ReplicaId;
let replica_id = ReplicaId::new(response.payload.replica_id as u16);
let project = cx.new(|cx| {
let snippets = SnippetProvider::new(fs.clone(), BTreeSet::from_iter([]), cx);
@@ -1975,9 +1975,9 @@ impl Project {
ProjectClientState::Remote { replica_id, .. } => replica_id,
_ => {
if self.remote_client.is_some() {
1
ReplicaId::REMOTE_SERVER
} else {
0
ReplicaId::LOCAL
}
}
}