1#![allow(non_snake_case)]
2
3pub mod error;
4mod macros;
5mod typed_envelope;
6
7pub use error::*;
8pub use prost::{DecodeError, Message};
9use std::{
10 cmp,
11 fmt::Debug,
12 iter, mem,
13 time::{Duration, SystemTime, UNIX_EPOCH},
14};
15pub use typed_envelope::*;
16
17include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
18
19pub const REMOTE_SERVER_PEER_ID: PeerId = PeerId { owner_id: 0, id: 0 };
20pub const REMOTE_SERVER_PROJECT_ID: u64 = 0;
21
22messages!(
23 (Ack, Foreground),
24 (AckBufferOperation, Background),
25 (AckChannelMessage, Background),
26 (ActivateToolchain, Foreground),
27 (ActiveToolchain, Foreground),
28 (ActiveToolchainResponse, Foreground),
29 (ResolveToolchain, Background),
30 (ResolveToolchainResponse, Background),
31 (AddNotification, Foreground),
32 (AddProjectCollaborator, Foreground),
33 (AddWorktree, Foreground),
34 (AddWorktreeResponse, Foreground),
35 (AllocateWorktreeId, Foreground),
36 (AllocateWorktreeIdResponse, Foreground),
37 (ApplyCodeAction, Background),
38 (ApplyCodeActionResponse, Background),
39 (ApplyCompletionAdditionalEdits, Background),
40 (ApplyCompletionAdditionalEditsResponse, Background),
41 (BlameBuffer, Foreground),
42 (BlameBufferResponse, Foreground),
43 (BufferReloaded, Foreground),
44 (BufferSaved, Foreground),
45 (Call, Foreground),
46 (CallCanceled, Foreground),
47 (CancelCall, Foreground),
48 (CancelLanguageServerWork, Foreground),
49 (ChannelMessageSent, Foreground),
50 (ChannelMessageUpdate, Foreground),
51 (CloseBuffer, Foreground),
52 (Commit, Background),
53 (RunGitHook, Background),
54 (CopyProjectEntry, Foreground),
55 (CreateBufferForPeer, Foreground),
56 (CreateImageForPeer, Foreground),
57 (CreateFileForPeer, Foreground),
58 (CreateChannel, Foreground),
59 (CreateChannelResponse, Foreground),
60 (CreateProjectEntry, Foreground),
61 (CreateRoom, Foreground),
62 (CreateRoomResponse, Foreground),
63 (DeclineCall, Foreground),
64 (DeleteChannel, Foreground),
65 (DeleteNotification, Foreground),
66 (DeleteProjectEntry, Foreground),
67 (DownloadFileByPath, Background),
68 (DownloadFileResponse, Background),
69 (EndStream, Foreground),
70 (Error, Foreground),
71 (ExpandProjectEntry, Foreground),
72 (ExpandProjectEntryResponse, Foreground),
73 (FindSearchCandidates, Background),
74 (FlushBufferedMessages, Foreground),
75 (ExpandAllForProjectEntry, Foreground),
76 (ExpandAllForProjectEntryResponse, Foreground),
77 (Follow, Foreground),
78 (FollowResponse, Foreground),
79 (ApplyCodeActionKind, Foreground),
80 (ApplyCodeActionKindResponse, Foreground),
81 (FormatBuffers, Foreground),
82 (FormatBuffersResponse, Foreground),
83 (FuzzySearchUsers, Foreground),
84 (GetChannelMembers, Foreground),
85 (GetChannelMembersResponse, Foreground),
86 (GetChannelMessages, Background),
87 (GetChannelMessagesById, Background),
88 (GetChannelMessagesResponse, Background),
89 (GetCodeActions, Background),
90 (GetCodeActionsResponse, Background),
91 (GetCompletions, Background),
92 (GetCompletionsResponse, Background),
93 (GetDeclaration, Background),
94 (GetDeclarationResponse, Background),
95 (GetDefinition, Background),
96 (GetDefinitionResponse, Background),
97 (GetDocumentHighlights, Background),
98 (GetDocumentHighlightsResponse, Background),
99 (GetDocumentSymbols, Background),
100 (GetDocumentSymbolsResponse, Background),
101 (GetHover, Background),
102 (GetHoverResponse, Background),
103 (GetNotifications, Foreground),
104 (GetNotificationsResponse, Foreground),
105 (GetCrashFiles, Background),
106 (GetCrashFilesResponse, Background),
107 (GetPathMetadata, Background),
108 (GetPathMetadataResponse, Background),
109 (GetPermalinkToLine, Foreground),
110 (GetProcesses, Background),
111 (GetProcessesResponse, Background),
112 (GetPermalinkToLineResponse, Foreground),
113 (GetProjectSymbols, Background),
114 (GetProjectSymbolsResponse, Background),
115 (GetReferences, Background),
116 (GetReferencesResponse, Background),
117 (GetSignatureHelp, Background),
118 (GetSignatureHelpResponse, Background),
119 (GetTypeDefinition, Background),
120 (GetTypeDefinitionResponse, Background),
121 (GetImplementation, Background),
122 (GetImplementationResponse, Background),
123 (OpenUnstagedDiff, Foreground),
124 (OpenUnstagedDiffResponse, Foreground),
125 (OpenUncommittedDiff, Foreground),
126 (OpenUncommittedDiffResponse, Foreground),
127 (GetUsers, Foreground),
128 (GitGetBranches, Background),
129 (GitBranchesResponse, Background),
130 (Hello, Foreground),
131 (HideToast, Background),
132 (IncomingCall, Foreground),
133 (InlayHints, Background),
134 (InlayHintsResponse, Background),
135 (SemanticTokens, Background),
136 (SemanticTokensResponse, Background),
137 (InstallExtension, Background),
138 (InviteChannelMember, Foreground),
139 (JoinChannel, Foreground),
140 (JoinChannelBuffer, Foreground),
141 (JoinChannelBufferResponse, Foreground),
142 (JoinChannelChat, Foreground),
143 (JoinChannelChatResponse, Foreground),
144 (JoinProject, Foreground),
145 (JoinProjectResponse, Foreground),
146 (JoinRoom, Foreground),
147 (JoinRoomResponse, Foreground),
148 (LanguageServerLog, Foreground),
149 (LanguageServerPromptRequest, Foreground),
150 (LanguageServerPromptResponse, Foreground),
151 (LeaveChannelBuffer, Background),
152 (LeaveChannelChat, Foreground),
153 (LeaveProject, Foreground),
154 (LeaveRoom, Foreground),
155 (LinkedEditingRange, Background),
156 (LinkedEditingRangeResponse, Background),
157 (ListRemoteDirectory, Background),
158 (ListRemoteDirectoryResponse, Background),
159 (ListToolchains, Foreground),
160 (ListToolchainsResponse, Foreground),
161 (LoadCommitDiff, Foreground),
162 (LoadCommitDiffResponse, Foreground),
163 (LspExtExpandMacro, Background),
164 (LspExtExpandMacroResponse, Background),
165 (LspExtOpenDocs, Background),
166 (LspExtOpenDocsResponse, Background),
167 (LspExtRunnables, Background),
168 (LspExtRunnablesResponse, Background),
169 (LspExtSwitchSourceHeader, Background),
170 (LspExtSwitchSourceHeaderResponse, Background),
171 (LspExtGoToParentModule, Background),
172 (LspExtGoToParentModuleResponse, Background),
173 (LspExtCancelFlycheck, Background),
174 (LspExtRunFlycheck, Background),
175 (LspExtClearFlycheck, Background),
176 (MarkNotificationRead, Foreground),
177 (MoveChannel, Foreground),
178 (ReorderChannel, Foreground),
179 (LspQuery, Background),
180 (LspQueryResponse, Background),
181 (OnTypeFormatting, Background),
182 (OnTypeFormattingResponse, Background),
183 (OpenBufferById, Background),
184 (OpenBufferByPath, Background),
185 (OpenImageByPath, Background),
186 (OpenBufferForSymbol, Background),
187 (OpenBufferForSymbolResponse, Background),
188 (OpenBufferResponse, Background),
189 (OpenImageResponse, Background),
190 (OpenCommitMessageBuffer, Background),
191 (OpenNewBuffer, Foreground),
192 (OpenServerSettings, Foreground),
193 (PerformRename, Background),
194 (PerformRenameResponse, Background),
195 (Ping, Foreground),
196 (PrepareRename, Background),
197 (PrepareRenameResponse, Background),
198 (ProjectEntryResponse, Foreground),
199 (RefreshInlayHints, Background),
200 (RefreshSemanticTokens, Background),
201 (RegisterBufferWithLanguageServers, Background),
202 (RejoinChannelBuffers, Foreground),
203 (RejoinChannelBuffersResponse, Foreground),
204 (RejoinRemoteProjects, Foreground),
205 (RejoinRemoteProjectsResponse, Foreground),
206 (RejoinRoom, Foreground),
207 (RejoinRoomResponse, Foreground),
208 (ReloadBuffers, Foreground),
209 (ReloadBuffersResponse, Foreground),
210 (RemoveChannelMember, Foreground),
211 (RemoveChannelMessage, Foreground),
212 (RemoveContact, Foreground),
213 (RemoveProjectCollaborator, Foreground),
214 (RemoveWorktree, Foreground),
215 (RenameChannel, Foreground),
216 (RenameChannelResponse, Foreground),
217 (RenameProjectEntry, Foreground),
218 (RequestContact, Foreground),
219 (ResolveCompletionDocumentation, Background),
220 (ResolveCompletionDocumentationResponse, Background),
221 (ResolveInlayHint, Background),
222 (ResolveInlayHintResponse, Background),
223 (GetDocumentColor, Background),
224 (GetDocumentColorResponse, Background),
225 (GetColorPresentation, Background),
226 (GetColorPresentationResponse, Background),
227 (GetFoldingRanges, Background),
228 (GetFoldingRangesResponse, Background),
229 (RefreshCodeLens, Background),
230 (GetCodeLens, Background),
231 (GetCodeLensResponse, Background),
232 (RespondToChannelInvite, Foreground),
233 (RespondToContactRequest, Foreground),
234 (RestartLanguageServers, Foreground),
235 (StopLanguageServers, Background),
236 (RoomUpdated, Foreground),
237 (SaveBuffer, Foreground),
238 (SendChannelMessage, Background),
239 (SendChannelMessageResponse, Background),
240 (SetChannelMemberRole, Foreground),
241 (SetChannelVisibility, Foreground),
242 (SetRoomParticipantRole, Foreground),
243 (ShareProject, Foreground),
244 (ShareProjectResponse, Foreground),
245 (ShowContacts, Foreground),
246 (ShutdownRemoteServer, Foreground),
247 (Stage, Background),
248 (StartLanguageServer, Foreground),
249 (SubscribeToChannels, Foreground),
250 (SyncExtensions, Background),
251 (SyncExtensionsResponse, Background),
252 (BreakpointsForFile, Background),
253 (ToggleBreakpoint, Foreground),
254 (SynchronizeBuffers, Foreground),
255 (SynchronizeBuffersResponse, Foreground),
256 (TaskContext, Background),
257 (TaskContextForLocation, Background),
258 (Test, Foreground),
259 (Toast, Background),
260 (Unfollow, Foreground),
261 (UnshareProject, Foreground),
262 (Unstage, Background),
263 (Stash, Background),
264 (StashPop, Background),
265 (StashApply, Background),
266 (StashDrop, Background),
267 (UpdateBuffer, Foreground),
268 (UpdateBufferFile, Foreground),
269 (UpdateChannelBuffer, Foreground),
270 (UpdateChannelBufferCollaborators, Foreground),
271 (UpdateChannelMessage, Foreground),
272 (UpdateChannels, Foreground),
273 (UpdateContacts, Foreground),
274 (UpdateDiagnosticSummary, Foreground),
275 (UpdateDiffBases, Foreground),
276 (UpdateFollowers, Foreground),
277 (UpdateGitBranch, Background),
278 (UpdateLanguageServer, Foreground),
279 (UpdateNotification, Foreground),
280 (UpdateParticipantLocation, Foreground),
281 (UpdateProject, Foreground),
282 (UpdateProjectCollaborator, Foreground),
283 (UpdateUserChannels, Foreground),
284 (UpdateWorktree, Foreground),
285 (UpdateWorktreeSettings, Foreground),
286 (UpdateUserSettings, Background),
287 (UpdateRepository, Foreground),
288 (RemoveRepository, Foreground),
289 (UsersResponse, Foreground),
290 (GitReset, Background),
291 (GitDeleteBranch, Background),
292 (GitCheckoutFiles, Background),
293 (GitShow, Background),
294 (GitCommitDetails, Background),
295 (GitFileHistory, Background),
296 (GitFileHistoryResponse, Background),
297 (GitCreateCheckpoint, Background),
298 (GitCreateCheckpointResponse, Background),
299 (GitCreateArchiveCheckpoint, Background),
300 (GitCreateArchiveCheckpointResponse, Background),
301 (GitRestoreCheckpoint, Background),
302 (GitRestoreArchiveCheckpoint, Background),
303 (GitCompareCheckpoints, Background),
304 (GitCompareCheckpointsResponse, Background),
305 (GitDiffCheckpoints, Background),
306 (GitDiffCheckpointsResponse, Background),
307 (SetIndexText, Background),
308 (Push, Background),
309 (Fetch, Background),
310 (GetRemotes, Background),
311 (GetRemotesResponse, Background),
312 (Pull, Background),
313 (RemoteMessageResponse, Background),
314 (AskPassRequest, Background),
315 (AskPassResponse, Background),
316 (GitCreateRemote, Background),
317 (GitRemoveRemote, Background),
318 (GitCreateBranch, Background),
319 (GitChangeBranch, Background),
320 (GitRenameBranch, Background),
321 (TrustWorktrees, Background),
322 (RestrictWorktrees, Background),
323 (CheckForPushedCommits, Background),
324 (CheckForPushedCommitsResponse, Background),
325 (GitDiff, Background),
326 (GitDiffResponse, Background),
327 (GitInit, Background),
328 (GetDebugAdapterBinary, Background),
329 (DebugAdapterBinary, Background),
330 (RunDebugLocators, Background),
331 (DebugRequest, Background),
332 (LogToDebugConsole, Background),
333 (GetDocumentDiagnostics, Background),
334 (GetDocumentDiagnosticsResponse, Background),
335 (PullWorkspaceDiagnostics, Background),
336 (GetDefaultBranch, Background),
337 (GetDefaultBranchResponse, Background),
338 (GetTreeDiff, Background),
339 (GetTreeDiffResponse, Background),
340 (GetBlobContent, Background),
341 (GetBlobContentResponse, Background),
342 (GitClone, Background),
343 (GitCloneResponse, Background),
344 (ToggleLspLogs, Background),
345 (GetDirectoryEnvironment, Background),
346 (DirectoryEnvironment, Background),
347 (GetAgentServerCommand, Background),
348 (AgentServerCommand, Background),
349 (GetContextServerCommand, Background),
350 (ContextServerCommand, Background),
351 (ExternalAgentsUpdated, Background),
352 (ExternalExtensionAgentsUpdated, Background),
353 (ExternalAgentLoadingStatusUpdated, Background),
354 (NewExternalAgentVersionAvailable, Background),
355 (RemoteStarted, Background),
356 (GitGetWorktrees, Background),
357 (GitGetHeadSha, Background),
358 (GitGetHeadShaResponse, Background),
359 (GitEditRef, Background),
360 (GitRepairWorktrees, Background),
361 (GitWorktreesResponse, Background),
362 (GitCreateWorktree, Background),
363 (GitRemoveWorktree, Background),
364 (GitRenameWorktree, Background),
365 (ShareAgentThread, Foreground),
366 (GetSharedAgentThread, Foreground),
367 (GetSharedAgentThreadResponse, Foreground),
368 (FindSearchCandidatesChunk, Background),
369 (FindSearchCandidatesCancelled, Background),
370 (SpawnKernel, Background),
371 (SpawnKernelResponse, Background),
372 (KillKernel, Background),
373 (GetRemoteProfilingData, Background),
374 (GetRemoteProfilingDataResponse, Background),
375);
376
377request_messages!(
378 (AllocateWorktreeId, AllocateWorktreeIdResponse),
379 (ApplyCodeAction, ApplyCodeActionResponse),
380 (
381 ApplyCompletionAdditionalEdits,
382 ApplyCompletionAdditionalEditsResponse
383 ),
384 (Call, Ack),
385 (CancelCall, Ack),
386 (Commit, Ack),
387 (RunGitHook, Ack),
388 (CopyProjectEntry, ProjectEntryResponse),
389 (CreateChannel, CreateChannelResponse),
390 (CreateProjectEntry, ProjectEntryResponse),
391 (CreateRoom, CreateRoomResponse),
392 (DeclineCall, Ack),
393 (DeleteChannel, Ack),
394 (DeleteProjectEntry, ProjectEntryResponse),
395 (DownloadFileByPath, DownloadFileResponse),
396 (ExpandProjectEntry, ExpandProjectEntryResponse),
397 (ExpandAllForProjectEntry, ExpandAllForProjectEntryResponse),
398 (Follow, FollowResponse),
399 (ApplyCodeActionKind, ApplyCodeActionKindResponse),
400 (FormatBuffers, FormatBuffersResponse),
401 (FuzzySearchUsers, UsersResponse),
402 (GetChannelMembers, GetChannelMembersResponse),
403 (GetChannelMessages, GetChannelMessagesResponse),
404 (GetChannelMessagesById, GetChannelMessagesResponse),
405 (GetCodeActions, GetCodeActionsResponse),
406 (GetCompletions, GetCompletionsResponse),
407 (GetDefinition, GetDefinitionResponse),
408 (GetDeclaration, GetDeclarationResponse),
409 (GetImplementation, GetImplementationResponse),
410 (GetDocumentHighlights, GetDocumentHighlightsResponse),
411 (GetDocumentSymbols, GetDocumentSymbolsResponse),
412 (GetHover, GetHoverResponse),
413 (GetNotifications, GetNotificationsResponse),
414 (GetProjectSymbols, GetProjectSymbolsResponse),
415 (GetReferences, GetReferencesResponse),
416 (GetSignatureHelp, GetSignatureHelpResponse),
417 (OpenUnstagedDiff, OpenUnstagedDiffResponse),
418 (OpenUncommittedDiff, OpenUncommittedDiffResponse),
419 (GetTypeDefinition, GetTypeDefinitionResponse),
420 (LinkedEditingRange, LinkedEditingRangeResponse),
421 (ListRemoteDirectory, ListRemoteDirectoryResponse),
422 (GetUsers, UsersResponse),
423 (IncomingCall, Ack),
424 (InlayHints, InlayHintsResponse),
425 (SemanticTokens, SemanticTokensResponse),
426 (GetCodeLens, GetCodeLensResponse),
427 (InviteChannelMember, Ack),
428 (JoinChannel, JoinRoomResponse),
429 (JoinChannelBuffer, JoinChannelBufferResponse),
430 (JoinChannelChat, JoinChannelChatResponse),
431 (JoinProject, JoinProjectResponse),
432 (JoinRoom, JoinRoomResponse),
433 (LeaveChannelBuffer, Ack),
434 (LeaveRoom, Ack),
435 (LoadCommitDiff, LoadCommitDiffResponse),
436 (MarkNotificationRead, Ack),
437 (MoveChannel, Ack),
438 (OnTypeFormatting, OnTypeFormattingResponse),
439 (OpenBufferById, OpenBufferResponse),
440 (OpenBufferByPath, OpenBufferResponse),
441 (OpenImageByPath, OpenImageResponse),
442 (OpenBufferForSymbol, OpenBufferForSymbolResponse),
443 (OpenCommitMessageBuffer, OpenBufferResponse),
444 (OpenNewBuffer, OpenBufferResponse),
445 (PerformRename, PerformRenameResponse),
446 (Ping, Ack),
447 (PrepareRename, PrepareRenameResponse),
448 (RefreshInlayHints, Ack),
449 (RefreshSemanticTokens, Ack),
450 (RefreshCodeLens, Ack),
451 (RejoinChannelBuffers, RejoinChannelBuffersResponse),
452 (RejoinRoom, RejoinRoomResponse),
453 (ReloadBuffers, ReloadBuffersResponse),
454 (RemoveChannelMember, Ack),
455 (RemoveChannelMessage, Ack),
456 (UpdateChannelMessage, Ack),
457 (RemoveContact, Ack),
458 (RenameChannel, RenameChannelResponse),
459 (RenameProjectEntry, ProjectEntryResponse),
460 (ReorderChannel, Ack),
461 (RequestContact, Ack),
462 (
463 ResolveCompletionDocumentation,
464 ResolveCompletionDocumentationResponse
465 ),
466 (ResolveInlayHint, ResolveInlayHintResponse),
467 (GetDocumentColor, GetDocumentColorResponse),
468 (GetFoldingRanges, GetFoldingRangesResponse),
469 (GetColorPresentation, GetColorPresentationResponse),
470 (RespondToChannelInvite, Ack),
471 (RespondToContactRequest, Ack),
472 (SaveBuffer, BufferSaved),
473 (Stage, Ack),
474 (FindSearchCandidates, Ack),
475 (SendChannelMessage, SendChannelMessageResponse),
476 (SetChannelMemberRole, Ack),
477 (SetChannelVisibility, Ack),
478 (ShareAgentThread, Ack),
479 (GetSharedAgentThread, GetSharedAgentThreadResponse),
480 (ShareProject, ShareProjectResponse),
481 (SynchronizeBuffers, SynchronizeBuffersResponse),
482 (TaskContextForLocation, TaskContext),
483 (Test, Test),
484 (Unstage, Ack),
485 (Stash, Ack),
486 (StashPop, Ack),
487 (StashApply, Ack),
488 (StashDrop, Ack),
489 (UpdateBuffer, Ack),
490 (UpdateParticipantLocation, Ack),
491 (UpdateProject, Ack),
492 (UpdateWorktree, Ack),
493 (UpdateRepository, Ack),
494 (RemoveRepository, Ack),
495 (LspExtExpandMacro, LspExtExpandMacroResponse),
496 (LspExtOpenDocs, LspExtOpenDocsResponse),
497 (LspExtRunnables, LspExtRunnablesResponse),
498 (SetRoomParticipantRole, Ack),
499 (BlameBuffer, BlameBufferResponse),
500 (RejoinRemoteProjects, RejoinRemoteProjectsResponse),
501 (LspQuery, Ack),
502 (LspQueryResponse, Ack),
503 (RestartLanguageServers, Ack),
504 (StopLanguageServers, Ack),
505 (LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
506 (LspExtGoToParentModule, LspExtGoToParentModuleResponse),
507 (LspExtCancelFlycheck, Ack),
508 (LspExtRunFlycheck, Ack),
509 (LspExtClearFlycheck, Ack),
510 (AddWorktree, AddWorktreeResponse),
511 (ShutdownRemoteServer, Ack),
512 (RemoveWorktree, Ack),
513 (OpenServerSettings, OpenBufferResponse),
514 (GetPermalinkToLine, GetPermalinkToLineResponse),
515 (FlushBufferedMessages, Ack),
516 (LanguageServerPromptRequest, LanguageServerPromptResponse),
517 (GitGetBranches, GitBranchesResponse),
518 (UpdateGitBranch, Ack),
519 (ListToolchains, ListToolchainsResponse),
520 (ActivateToolchain, Ack),
521 (ActiveToolchain, ActiveToolchainResponse),
522 (ResolveToolchain, ResolveToolchainResponse),
523 (GetPathMetadata, GetPathMetadataResponse),
524 (GetCrashFiles, GetCrashFilesResponse),
525 (CancelLanguageServerWork, Ack),
526 (SyncExtensions, SyncExtensionsResponse),
527 (InstallExtension, Ack),
528 (RegisterBufferWithLanguageServers, Ack),
529 (GitShow, GitCommitDetails),
530 (GitFileHistory, GitFileHistoryResponse),
531 (GitCreateCheckpoint, GitCreateCheckpointResponse),
532 (
533 GitCreateArchiveCheckpoint,
534 GitCreateArchiveCheckpointResponse
535 ),
536 (GitRestoreCheckpoint, Ack),
537 (GitRestoreArchiveCheckpoint, Ack),
538 (GitCompareCheckpoints, GitCompareCheckpointsResponse),
539 (GitDiffCheckpoints, GitDiffCheckpointsResponse),
540 (GitReset, Ack),
541 (GitDeleteBranch, Ack),
542 (GitCheckoutFiles, Ack),
543 (SetIndexText, Ack),
544 (Push, RemoteMessageResponse),
545 (Fetch, RemoteMessageResponse),
546 (GetRemotes, GetRemotesResponse),
547 (Pull, RemoteMessageResponse),
548 (AskPassRequest, AskPassResponse),
549 (GitCreateRemote, Ack),
550 (GitRemoveRemote, Ack),
551 (GitCreateBranch, Ack),
552 (GitChangeBranch, Ack),
553 (GitRenameBranch, Ack),
554 (CheckForPushedCommits, CheckForPushedCommitsResponse),
555 (GitDiff, GitDiffResponse),
556 (GitInit, Ack),
557 (ToggleBreakpoint, Ack),
558 (GetDebugAdapterBinary, DebugAdapterBinary),
559 (RunDebugLocators, DebugRequest),
560 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
561 (PullWorkspaceDiagnostics, Ack),
562 (GetDefaultBranch, GetDefaultBranchResponse),
563 (GetBlobContent, GetBlobContentResponse),
564 (GetTreeDiff, GetTreeDiffResponse),
565 (GitClone, GitCloneResponse),
566 (ToggleLspLogs, Ack),
567 (GetDirectoryEnvironment, DirectoryEnvironment),
568 (GetProcesses, GetProcessesResponse),
569 (GetAgentServerCommand, AgentServerCommand),
570 (GetContextServerCommand, ContextServerCommand),
571 (RemoteStarted, Ack),
572 (GitGetWorktrees, GitWorktreesResponse),
573 (GitGetHeadSha, GitGetHeadShaResponse),
574 (GitEditRef, Ack),
575 (GitRepairWorktrees, Ack),
576 (GitCreateWorktree, Ack),
577 (GitRemoveWorktree, Ack),
578 (GitRenameWorktree, Ack),
579 (TrustWorktrees, Ack),
580 (RestrictWorktrees, Ack),
581 (FindSearchCandidatesChunk, Ack),
582 (SpawnKernel, SpawnKernelResponse),
583 (KillKernel, Ack),
584 (GetRemoteProfilingData, GetRemoteProfilingDataResponse),
585);
586
587lsp_messages!(
588 (GetReferences, GetReferencesResponse, true),
589 (GetDocumentColor, GetDocumentColorResponse, true),
590 (GetFoldingRanges, GetFoldingRangesResponse, true),
591 (GetDocumentSymbols, GetDocumentSymbolsResponse, true),
592 (GetHover, GetHoverResponse, true),
593 (GetCodeActions, GetCodeActionsResponse, true),
594 (GetSignatureHelp, GetSignatureHelpResponse, true),
595 (GetCodeLens, GetCodeLensResponse, true),
596 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse, true),
597 (GetDefinition, GetDefinitionResponse, true),
598 (GetDeclaration, GetDeclarationResponse, true),
599 (GetTypeDefinition, GetTypeDefinitionResponse, true),
600 (GetImplementation, GetImplementationResponse, true),
601 (InlayHints, InlayHintsResponse, false),
602 (SemanticTokens, SemanticTokensResponse, true)
603);
604
605entity_messages!(
606 {project_id, ShareProject},
607 AddProjectCollaborator,
608 AddWorktree,
609 AllocateWorktreeId,
610 ApplyCodeAction,
611 ApplyCompletionAdditionalEdits,
612 BlameBuffer,
613 BufferReloaded,
614 BufferSaved,
615 CloseBuffer,
616 Commit,
617 RunGitHook,
618 GetColorPresentation,
619 CopyProjectEntry,
620 CreateBufferForPeer,
621 CreateFileForPeer,
622 CreateImageForPeer,
623 CreateProjectEntry,
624 GetDocumentColor,
625 GetFoldingRanges,
626 DeleteProjectEntry,
627 ExpandProjectEntry,
628 ExpandAllForProjectEntry,
629 FindSearchCandidates,
630 ApplyCodeActionKind,
631 FormatBuffers,
632 GetCodeActions,
633 GetCodeLens,
634 GetCompletions,
635 GetDefinition,
636 GetDeclaration,
637 GetImplementation,
638 GetDocumentHighlights,
639 GetDocumentSymbols,
640 GetHover,
641 GetProjectSymbols,
642 GetReferences,
643 GetSignatureHelp,
644 OpenUnstagedDiff,
645 OpenUncommittedDiff,
646 GetTypeDefinition,
647 InlayHints,
648 SemanticTokens,
649 JoinProject,
650 LeaveProject,
651 SpawnKernel,
652 KillKernel,
653 LinkedEditingRange,
654 LoadCommitDiff,
655 LspQuery,
656 LspQueryResponse,
657 RestartLanguageServers,
658 StopLanguageServers,
659 OnTypeFormatting,
660 OpenNewBuffer,
661 OpenBufferById,
662 OpenBufferByPath,
663 OpenImageByPath,
664 OpenBufferForSymbol,
665 OpenCommitMessageBuffer,
666 PerformRename,
667 PrepareRename,
668 RefreshInlayHints,
669 RefreshSemanticTokens,
670 RefreshCodeLens,
671 ReloadBuffers,
672 RemoveProjectCollaborator,
673 RenameProjectEntry,
674 ResolveCompletionDocumentation,
675 ResolveInlayHint,
676 SaveBuffer,
677 Stage,
678 StartLanguageServer,
679 SynchronizeBuffers,
680 TaskContextForLocation,
681 UnshareProject,
682 Unstage,
683 Stash,
684 StashPop,
685 StashApply,
686 StashDrop,
687 UpdateBuffer,
688 UpdateBufferFile,
689 UpdateDiagnosticSummary,
690 UpdateDiffBases,
691 UpdateLanguageServer,
692 UpdateProject,
693 UpdateProjectCollaborator,
694 UpdateWorktree,
695 UpdateRepository,
696 RemoveRepository,
697 UpdateWorktreeSettings,
698 UpdateUserSettings,
699 LspExtExpandMacro,
700 LspExtOpenDocs,
701 LspExtRunnables,
702 LspExtSwitchSourceHeader,
703 LspExtGoToParentModule,
704 LspExtCancelFlycheck,
705 LspExtRunFlycheck,
706 LspExtClearFlycheck,
707 LanguageServerLog,
708 Toast,
709 HideToast,
710 OpenServerSettings,
711 GetPermalinkToLine,
712 LanguageServerPromptRequest,
713 GitGetBranches,
714 UpdateGitBranch,
715 ListToolchains,
716 ActivateToolchain,
717 ActiveToolchain,
718 ResolveToolchain,
719 GetPathMetadata,
720 GetProcesses,
721 CancelLanguageServerWork,
722 RegisterBufferWithLanguageServers,
723 GitShow,
724 GitFileHistory,
725 GitCreateCheckpoint,
726 GitRestoreCheckpoint,
727 GitCompareCheckpoints,
728 GitDiffCheckpoints,
729 GitReset,
730 GitDeleteBranch,
731 GitCheckoutFiles,
732 SetIndexText,
733 ToggleLspLogs,
734 GetDirectoryEnvironment,
735
736 Push,
737 Fetch,
738 GetRemotes,
739 Pull,
740 AskPassRequest,
741 GitChangeBranch,
742 GitRenameBranch,
743 GitCreateBranch,
744 GitCreateRemote,
745 GitRemoveRemote,
746 CheckForPushedCommits,
747 GitDiff,
748 GitInit,
749 BreakpointsForFile,
750 ToggleBreakpoint,
751 RunDebugLocators,
752 GetDebugAdapterBinary,
753 LogToDebugConsole,
754 GetDocumentDiagnostics,
755 PullWorkspaceDiagnostics,
756 GetDefaultBranch,
757 GetTreeDiff,
758 GetBlobContent,
759 GitClone,
760 GetAgentServerCommand,
761 GetContextServerCommand,
762 ExternalAgentsUpdated,
763 ExternalExtensionAgentsUpdated,
764 ExternalAgentLoadingStatusUpdated,
765 NewExternalAgentVersionAvailable,
766 GitGetWorktrees,
767 GitGetHeadSha,
768 GitEditRef,
769 GitRepairWorktrees,
770 GitCreateArchiveCheckpoint,
771 GitRestoreArchiveCheckpoint,
772 GitCreateWorktree,
773 GitRemoveWorktree,
774 GitRenameWorktree,
775 TrustWorktrees,
776 RestrictWorktrees,
777 FindSearchCandidatesChunk,
778 FindSearchCandidatesCancelled,
779 DownloadFileByPath,
780 GetRemoteProfilingData
781);
782
783entity_messages!(
784 {channel_id, Channel},
785 ChannelMessageSent,
786 ChannelMessageUpdate,
787 RemoveChannelMessage,
788 UpdateChannelMessage,
789 UpdateChannelBuffer,
790 UpdateChannelBufferCollaborators,
791);
792
793impl From<Timestamp> for SystemTime {
794 fn from(val: Timestamp) -> Self {
795 UNIX_EPOCH
796 .checked_add(Duration::new(val.seconds, val.nanos))
797 .unwrap()
798 }
799}
800
801impl From<SystemTime> for Timestamp {
802 fn from(time: SystemTime) -> Self {
803 let duration = time.duration_since(UNIX_EPOCH).unwrap_or_default();
804 Self {
805 seconds: duration.as_secs(),
806 nanos: duration.subsec_nanos(),
807 }
808 }
809}
810
811impl From<u128> for Nonce {
812 fn from(nonce: u128) -> Self {
813 let upper_half = (nonce >> 64) as u64;
814 let lower_half = nonce as u64;
815 Self {
816 upper_half,
817 lower_half,
818 }
819 }
820}
821
822impl From<Nonce> for u128 {
823 fn from(nonce: Nonce) -> Self {
824 let upper_half = (nonce.upper_half as u128) << 64;
825 let lower_half = nonce.lower_half as u128;
826 upper_half | lower_half
827 }
828}
829
830#[cfg(any(test, feature = "test-support"))]
831pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
832#[cfg(not(any(test, feature = "test-support")))]
833pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
834
835pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
836 let mut done = false;
837
838 iter::from_fn(move || {
839 if done {
840 return None;
841 }
842
843 let updated_entries_chunk_size = cmp::min(
844 message.updated_entries.len(),
845 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
846 );
847 let updated_entries: Vec<_> = message
848 .updated_entries
849 .drain(..updated_entries_chunk_size)
850 .collect();
851
852 let removed_entries_chunk_size = cmp::min(
853 message.removed_entries.len(),
854 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
855 );
856 let removed_entries = message
857 .removed_entries
858 .drain(..removed_entries_chunk_size)
859 .collect();
860
861 let mut updated_repositories = Vec::new();
862 let mut limit = MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE;
863 while let Some(repo) = message.updated_repositories.first_mut() {
864 let updated_statuses_limit = cmp::min(repo.updated_statuses.len(), limit);
865 let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
866
867 updated_repositories.push(RepositoryEntry {
868 repository_id: repo.repository_id,
869 branch_summary: repo.branch_summary.clone(),
870 updated_statuses: repo
871 .updated_statuses
872 .drain(..updated_statuses_limit)
873 .collect(),
874 removed_statuses: repo
875 .removed_statuses
876 .drain(..removed_statuses_limit)
877 .collect(),
878 current_merge_conflicts: repo.current_merge_conflicts.clone(),
879 });
880 if repo.removed_statuses.is_empty() && repo.updated_statuses.is_empty() {
881 message.updated_repositories.remove(0);
882 }
883 limit = limit.saturating_sub(removed_statuses_limit + updated_statuses_limit);
884 if limit == 0 {
885 break;
886 }
887 }
888
889 done = message.updated_entries.is_empty()
890 && message.removed_entries.is_empty()
891 && message.updated_repositories.is_empty();
892
893 let removed_repositories = if done {
894 mem::take(&mut message.removed_repositories)
895 } else {
896 Default::default()
897 };
898
899 Some(UpdateWorktree {
900 project_id: message.project_id,
901 worktree_id: message.worktree_id,
902 root_name: message.root_name.clone(),
903 abs_path: message.abs_path.clone(),
904 root_repo_common_dir: message.root_repo_common_dir.clone(),
905 updated_entries,
906 removed_entries,
907 scan_id: message.scan_id,
908 is_last_update: done && message.is_last_update,
909 updated_repositories,
910 removed_repositories,
911 })
912 })
913}
914
915pub fn split_repository_update(
916 mut update: UpdateRepository,
917) -> impl Iterator<Item = UpdateRepository> {
918 let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
919 let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
920 std::iter::from_fn({
921 let update = update.clone();
922 move || {
923 let updated_statuses = updated_statuses_iter
924 .by_ref()
925 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
926 .collect::<Vec<_>>();
927 let removed_statuses = removed_statuses_iter
928 .by_ref()
929 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
930 .collect::<Vec<_>>();
931 if updated_statuses.is_empty() && removed_statuses.is_empty() {
932 return None;
933 }
934 Some(UpdateRepository {
935 updated_statuses,
936 removed_statuses,
937 is_last_update: false,
938 ..update.clone()
939 })
940 }
941 })
942 .chain([UpdateRepository {
943 updated_statuses: Vec::new(),
944 removed_statuses: Vec::new(),
945 is_last_update: true,
946 ..update
947 }])
948}
949
950impl LspQuery {
951 pub fn query_name_and_write_permissions(&self) -> (&str, bool) {
952 match self.request {
953 Some(lsp_query::Request::GetHover(_)) => ("GetHover", false),
954 Some(lsp_query::Request::GetCodeActions(_)) => ("GetCodeActions", true),
955 Some(lsp_query::Request::GetSignatureHelp(_)) => ("GetSignatureHelp", false),
956 Some(lsp_query::Request::GetCodeLens(_)) => ("GetCodeLens", true),
957 Some(lsp_query::Request::GetDocumentDiagnostics(_)) => {
958 ("GetDocumentDiagnostics", false)
959 }
960 Some(lsp_query::Request::GetDefinition(_)) => ("GetDefinition", false),
961 Some(lsp_query::Request::GetDeclaration(_)) => ("GetDeclaration", false),
962 Some(lsp_query::Request::GetTypeDefinition(_)) => ("GetTypeDefinition", false),
963 Some(lsp_query::Request::GetImplementation(_)) => ("GetImplementation", false),
964 Some(lsp_query::Request::GetReferences(_)) => ("GetReferences", false),
965 Some(lsp_query::Request::GetDocumentColor(_)) => ("GetDocumentColor", false),
966 Some(lsp_query::Request::GetFoldingRanges(_)) => ("GetFoldingRanges", false),
967 Some(lsp_query::Request::GetDocumentSymbols(_)) => ("GetDocumentSymbols", false),
968 Some(lsp_query::Request::InlayHints(_)) => ("InlayHints", false),
969 Some(lsp_query::Request::SemanticTokens(_)) => ("SemanticTokens", false),
970 None => ("<unknown>", true),
971 }
972 }
973}
974
975#[cfg(test)]
976mod tests {
977 use super::*;
978
979 #[test]
980 fn test_converting_peer_id_from_and_to_u64() {
981 let peer_id = PeerId {
982 owner_id: 10,
983 id: 3,
984 };
985 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
986 let peer_id = PeerId {
987 owner_id: u32::MAX,
988 id: 3,
989 };
990 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
991 let peer_id = PeerId {
992 owner_id: 10,
993 id: u32::MAX,
994 };
995 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
996 let peer_id = PeerId {
997 owner_id: u32::MAX,
998 id: u32::MAX,
999 };
1000 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
1001 }
1002}