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 (SetIndexText, Background),
298 (Push, Background),
299 (Fetch, Background),
300 (GetRemotes, Background),
301 (GetRemotesResponse, Background),
302 (Pull, Background),
303 (RemoteMessageResponse, Background),
304 (AskPassRequest, Background),
305 (AskPassResponse, Background),
306 (GitCreateRemote, Background),
307 (GitRemoveRemote, Background),
308 (GitCreateBranch, Background),
309 (GitChangeBranch, Background),
310 (GitRenameBranch, Background),
311 (TrustWorktrees, Background),
312 (RestrictWorktrees, Background),
313 (CheckForPushedCommits, Background),
314 (CheckForPushedCommitsResponse, Background),
315 (GitDiff, Background),
316 (GitDiffResponse, Background),
317 (GitInit, Background),
318 (GetDebugAdapterBinary, Background),
319 (DebugAdapterBinary, Background),
320 (RunDebugLocators, Background),
321 (DebugRequest, Background),
322 (LogToDebugConsole, Background),
323 (GetDocumentDiagnostics, Background),
324 (GetDocumentDiagnosticsResponse, Background),
325 (PullWorkspaceDiagnostics, Background),
326 (GetDefaultBranch, Background),
327 (GetDefaultBranchResponse, Background),
328 (GetTreeDiff, Background),
329 (GetTreeDiffResponse, Background),
330 (GetBlobContent, Background),
331 (GetBlobContentResponse, Background),
332 (GitClone, Background),
333 (GitCloneResponse, Background),
334 (ToggleLspLogs, Background),
335 (GetDirectoryEnvironment, Background),
336 (DirectoryEnvironment, Background),
337 (GetAgentServerCommand, Background),
338 (AgentServerCommand, Background),
339 (GetContextServerCommand, Background),
340 (ContextServerCommand, Background),
341 (ExternalAgentsUpdated, Background),
342 (ExternalExtensionAgentsUpdated, Background),
343 (ExternalAgentLoadingStatusUpdated, Background),
344 (NewExternalAgentVersionAvailable, Background),
345 (RemoteStarted, Background),
346 (GitGetWorktrees, Background),
347 (GitWorktreesResponse, Background),
348 (GitCreateWorktree, Background),
349 (GitRemoveWorktree, Background),
350 (GitRenameWorktree, Background),
351 (ShareAgentThread, Foreground),
352 (GetSharedAgentThread, Foreground),
353 (GetSharedAgentThreadResponse, Foreground),
354 (FindSearchCandidatesChunk, Background),
355 (FindSearchCandidatesCancelled, Background),
356 (SpawnKernel, Background),
357 (SpawnKernelResponse, Background),
358 (KillKernel, Background),
359 (GetRemoteProfilingData, Background),
360 (GetRemoteProfilingDataResponse, Background),
361);
362
363request_messages!(
364 (AllocateWorktreeId, AllocateWorktreeIdResponse),
365 (ApplyCodeAction, ApplyCodeActionResponse),
366 (
367 ApplyCompletionAdditionalEdits,
368 ApplyCompletionAdditionalEditsResponse
369 ),
370 (Call, Ack),
371 (CancelCall, Ack),
372 (Commit, Ack),
373 (RunGitHook, Ack),
374 (CopyProjectEntry, ProjectEntryResponse),
375 (CreateChannel, CreateChannelResponse),
376 (CreateProjectEntry, ProjectEntryResponse),
377 (CreateRoom, CreateRoomResponse),
378 (DeclineCall, Ack),
379 (DeleteChannel, Ack),
380 (DeleteProjectEntry, ProjectEntryResponse),
381 (DownloadFileByPath, DownloadFileResponse),
382 (ExpandProjectEntry, ExpandProjectEntryResponse),
383 (ExpandAllForProjectEntry, ExpandAllForProjectEntryResponse),
384 (Follow, FollowResponse),
385 (ApplyCodeActionKind, ApplyCodeActionKindResponse),
386 (FormatBuffers, FormatBuffersResponse),
387 (FuzzySearchUsers, UsersResponse),
388 (GetChannelMembers, GetChannelMembersResponse),
389 (GetChannelMessages, GetChannelMessagesResponse),
390 (GetChannelMessagesById, GetChannelMessagesResponse),
391 (GetCodeActions, GetCodeActionsResponse),
392 (GetCompletions, GetCompletionsResponse),
393 (GetDefinition, GetDefinitionResponse),
394 (GetDeclaration, GetDeclarationResponse),
395 (GetImplementation, GetImplementationResponse),
396 (GetDocumentHighlights, GetDocumentHighlightsResponse),
397 (GetDocumentSymbols, GetDocumentSymbolsResponse),
398 (GetHover, GetHoverResponse),
399 (GetNotifications, GetNotificationsResponse),
400 (GetProjectSymbols, GetProjectSymbolsResponse),
401 (GetReferences, GetReferencesResponse),
402 (GetSignatureHelp, GetSignatureHelpResponse),
403 (OpenUnstagedDiff, OpenUnstagedDiffResponse),
404 (OpenUncommittedDiff, OpenUncommittedDiffResponse),
405 (GetTypeDefinition, GetTypeDefinitionResponse),
406 (LinkedEditingRange, LinkedEditingRangeResponse),
407 (ListRemoteDirectory, ListRemoteDirectoryResponse),
408 (GetUsers, UsersResponse),
409 (IncomingCall, Ack),
410 (InlayHints, InlayHintsResponse),
411 (SemanticTokens, SemanticTokensResponse),
412 (GetCodeLens, GetCodeLensResponse),
413 (InviteChannelMember, Ack),
414 (JoinChannel, JoinRoomResponse),
415 (JoinChannelBuffer, JoinChannelBufferResponse),
416 (JoinChannelChat, JoinChannelChatResponse),
417 (JoinProject, JoinProjectResponse),
418 (JoinRoom, JoinRoomResponse),
419 (LeaveChannelBuffer, Ack),
420 (LeaveRoom, Ack),
421 (LoadCommitDiff, LoadCommitDiffResponse),
422 (MarkNotificationRead, Ack),
423 (MoveChannel, Ack),
424 (OnTypeFormatting, OnTypeFormattingResponse),
425 (OpenBufferById, OpenBufferResponse),
426 (OpenBufferByPath, OpenBufferResponse),
427 (OpenImageByPath, OpenImageResponse),
428 (OpenBufferForSymbol, OpenBufferForSymbolResponse),
429 (OpenCommitMessageBuffer, OpenBufferResponse),
430 (OpenNewBuffer, OpenBufferResponse),
431 (PerformRename, PerformRenameResponse),
432 (Ping, Ack),
433 (PrepareRename, PrepareRenameResponse),
434 (RefreshInlayHints, Ack),
435 (RefreshSemanticTokens, Ack),
436 (RefreshCodeLens, Ack),
437 (RejoinChannelBuffers, RejoinChannelBuffersResponse),
438 (RejoinRoom, RejoinRoomResponse),
439 (ReloadBuffers, ReloadBuffersResponse),
440 (RemoveChannelMember, Ack),
441 (RemoveChannelMessage, Ack),
442 (UpdateChannelMessage, Ack),
443 (RemoveContact, Ack),
444 (RenameChannel, RenameChannelResponse),
445 (RenameProjectEntry, ProjectEntryResponse),
446 (ReorderChannel, Ack),
447 (RequestContact, Ack),
448 (
449 ResolveCompletionDocumentation,
450 ResolveCompletionDocumentationResponse
451 ),
452 (ResolveInlayHint, ResolveInlayHintResponse),
453 (GetDocumentColor, GetDocumentColorResponse),
454 (GetFoldingRanges, GetFoldingRangesResponse),
455 (GetColorPresentation, GetColorPresentationResponse),
456 (RespondToChannelInvite, Ack),
457 (RespondToContactRequest, Ack),
458 (SaveBuffer, BufferSaved),
459 (Stage, Ack),
460 (FindSearchCandidates, Ack),
461 (SendChannelMessage, SendChannelMessageResponse),
462 (SetChannelMemberRole, Ack),
463 (SetChannelVisibility, Ack),
464 (ShareAgentThread, Ack),
465 (GetSharedAgentThread, GetSharedAgentThreadResponse),
466 (ShareProject, ShareProjectResponse),
467 (SynchronizeBuffers, SynchronizeBuffersResponse),
468 (TaskContextForLocation, TaskContext),
469 (Test, Test),
470 (Unstage, Ack),
471 (Stash, Ack),
472 (StashPop, Ack),
473 (StashApply, Ack),
474 (StashDrop, Ack),
475 (UpdateBuffer, Ack),
476 (UpdateParticipantLocation, Ack),
477 (UpdateProject, Ack),
478 (UpdateWorktree, Ack),
479 (UpdateRepository, Ack),
480 (RemoveRepository, Ack),
481 (LspExtExpandMacro, LspExtExpandMacroResponse),
482 (LspExtOpenDocs, LspExtOpenDocsResponse),
483 (LspExtRunnables, LspExtRunnablesResponse),
484 (SetRoomParticipantRole, Ack),
485 (BlameBuffer, BlameBufferResponse),
486 (RejoinRemoteProjects, RejoinRemoteProjectsResponse),
487 (LspQuery, Ack),
488 (LspQueryResponse, Ack),
489 (RestartLanguageServers, Ack),
490 (StopLanguageServers, Ack),
491 (LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
492 (LspExtGoToParentModule, LspExtGoToParentModuleResponse),
493 (LspExtCancelFlycheck, Ack),
494 (LspExtRunFlycheck, Ack),
495 (LspExtClearFlycheck, Ack),
496 (AddWorktree, AddWorktreeResponse),
497 (ShutdownRemoteServer, Ack),
498 (RemoveWorktree, Ack),
499 (OpenServerSettings, OpenBufferResponse),
500 (GetPermalinkToLine, GetPermalinkToLineResponse),
501 (FlushBufferedMessages, Ack),
502 (LanguageServerPromptRequest, LanguageServerPromptResponse),
503 (GitGetBranches, GitBranchesResponse),
504 (UpdateGitBranch, Ack),
505 (ListToolchains, ListToolchainsResponse),
506 (ActivateToolchain, Ack),
507 (ActiveToolchain, ActiveToolchainResponse),
508 (ResolveToolchain, ResolveToolchainResponse),
509 (GetPathMetadata, GetPathMetadataResponse),
510 (GetCrashFiles, GetCrashFilesResponse),
511 (CancelLanguageServerWork, Ack),
512 (SyncExtensions, SyncExtensionsResponse),
513 (InstallExtension, Ack),
514 (RegisterBufferWithLanguageServers, Ack),
515 (GitShow, GitCommitDetails),
516 (GitFileHistory, GitFileHistoryResponse),
517 (GitReset, Ack),
518 (GitDeleteBranch, Ack),
519 (GitCheckoutFiles, Ack),
520 (SetIndexText, Ack),
521 (Push, RemoteMessageResponse),
522 (Fetch, RemoteMessageResponse),
523 (GetRemotes, GetRemotesResponse),
524 (Pull, RemoteMessageResponse),
525 (AskPassRequest, AskPassResponse),
526 (GitCreateRemote, Ack),
527 (GitRemoveRemote, Ack),
528 (GitCreateBranch, Ack),
529 (GitChangeBranch, Ack),
530 (GitRenameBranch, Ack),
531 (CheckForPushedCommits, CheckForPushedCommitsResponse),
532 (GitDiff, GitDiffResponse),
533 (GitInit, Ack),
534 (ToggleBreakpoint, Ack),
535 (GetDebugAdapterBinary, DebugAdapterBinary),
536 (RunDebugLocators, DebugRequest),
537 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
538 (PullWorkspaceDiagnostics, Ack),
539 (GetDefaultBranch, GetDefaultBranchResponse),
540 (GetBlobContent, GetBlobContentResponse),
541 (GetTreeDiff, GetTreeDiffResponse),
542 (GitClone, GitCloneResponse),
543 (ToggleLspLogs, Ack),
544 (GetDirectoryEnvironment, DirectoryEnvironment),
545 (GetProcesses, GetProcessesResponse),
546 (GetAgentServerCommand, AgentServerCommand),
547 (GetContextServerCommand, ContextServerCommand),
548 (RemoteStarted, Ack),
549 (GitGetWorktrees, GitWorktreesResponse),
550 (GitCreateWorktree, Ack),
551 (GitRemoveWorktree, Ack),
552 (GitRenameWorktree, Ack),
553 (TrustWorktrees, Ack),
554 (RestrictWorktrees, Ack),
555 (FindSearchCandidatesChunk, Ack),
556 (SpawnKernel, SpawnKernelResponse),
557 (KillKernel, Ack),
558 (GetRemoteProfilingData, GetRemoteProfilingDataResponse),
559);
560
561lsp_messages!(
562 (GetReferences, GetReferencesResponse, true),
563 (GetDocumentColor, GetDocumentColorResponse, true),
564 (GetFoldingRanges, GetFoldingRangesResponse, true),
565 (GetDocumentSymbols, GetDocumentSymbolsResponse, true),
566 (GetHover, GetHoverResponse, true),
567 (GetCodeActions, GetCodeActionsResponse, true),
568 (GetSignatureHelp, GetSignatureHelpResponse, true),
569 (GetCodeLens, GetCodeLensResponse, true),
570 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse, true),
571 (GetDefinition, GetDefinitionResponse, true),
572 (GetDeclaration, GetDeclarationResponse, true),
573 (GetTypeDefinition, GetTypeDefinitionResponse, true),
574 (GetImplementation, GetImplementationResponse, true),
575 (InlayHints, InlayHintsResponse, false),
576 (SemanticTokens, SemanticTokensResponse, true)
577);
578
579entity_messages!(
580 {project_id, ShareProject},
581 AddProjectCollaborator,
582 AddWorktree,
583 AllocateWorktreeId,
584 ApplyCodeAction,
585 ApplyCompletionAdditionalEdits,
586 BlameBuffer,
587 BufferReloaded,
588 BufferSaved,
589 CloseBuffer,
590 Commit,
591 RunGitHook,
592 GetColorPresentation,
593 CopyProjectEntry,
594 CreateBufferForPeer,
595 CreateFileForPeer,
596 CreateImageForPeer,
597 CreateProjectEntry,
598 GetDocumentColor,
599 GetFoldingRanges,
600 DeleteProjectEntry,
601 ExpandProjectEntry,
602 ExpandAllForProjectEntry,
603 FindSearchCandidates,
604 ApplyCodeActionKind,
605 FormatBuffers,
606 GetCodeActions,
607 GetCodeLens,
608 GetCompletions,
609 GetDefinition,
610 GetDeclaration,
611 GetImplementation,
612 GetDocumentHighlights,
613 GetDocumentSymbols,
614 GetHover,
615 GetProjectSymbols,
616 GetReferences,
617 GetSignatureHelp,
618 OpenUnstagedDiff,
619 OpenUncommittedDiff,
620 GetTypeDefinition,
621 InlayHints,
622 SemanticTokens,
623 JoinProject,
624 LeaveProject,
625 SpawnKernel,
626 KillKernel,
627 LinkedEditingRange,
628 LoadCommitDiff,
629 LspQuery,
630 LspQueryResponse,
631 RestartLanguageServers,
632 StopLanguageServers,
633 OnTypeFormatting,
634 OpenNewBuffer,
635 OpenBufferById,
636 OpenBufferByPath,
637 OpenImageByPath,
638 OpenBufferForSymbol,
639 OpenCommitMessageBuffer,
640 PerformRename,
641 PrepareRename,
642 RefreshInlayHints,
643 RefreshSemanticTokens,
644 RefreshCodeLens,
645 ReloadBuffers,
646 RemoveProjectCollaborator,
647 RenameProjectEntry,
648 ResolveCompletionDocumentation,
649 ResolveInlayHint,
650 SaveBuffer,
651 Stage,
652 StartLanguageServer,
653 SynchronizeBuffers,
654 TaskContextForLocation,
655 UnshareProject,
656 Unstage,
657 Stash,
658 StashPop,
659 StashApply,
660 StashDrop,
661 UpdateBuffer,
662 UpdateBufferFile,
663 UpdateDiagnosticSummary,
664 UpdateDiffBases,
665 UpdateLanguageServer,
666 UpdateProject,
667 UpdateProjectCollaborator,
668 UpdateWorktree,
669 UpdateRepository,
670 RemoveRepository,
671 UpdateWorktreeSettings,
672 UpdateUserSettings,
673 LspExtExpandMacro,
674 LspExtOpenDocs,
675 LspExtRunnables,
676 LspExtSwitchSourceHeader,
677 LspExtGoToParentModule,
678 LspExtCancelFlycheck,
679 LspExtRunFlycheck,
680 LspExtClearFlycheck,
681 LanguageServerLog,
682 Toast,
683 HideToast,
684 OpenServerSettings,
685 GetPermalinkToLine,
686 LanguageServerPromptRequest,
687 GitGetBranches,
688 UpdateGitBranch,
689 ListToolchains,
690 ActivateToolchain,
691 ActiveToolchain,
692 ResolveToolchain,
693 GetPathMetadata,
694 GetProcesses,
695 CancelLanguageServerWork,
696 RegisterBufferWithLanguageServers,
697 GitShow,
698 GitFileHistory,
699 GitReset,
700 GitDeleteBranch,
701 GitCheckoutFiles,
702 SetIndexText,
703 ToggleLspLogs,
704 GetDirectoryEnvironment,
705
706 Push,
707 Fetch,
708 GetRemotes,
709 Pull,
710 AskPassRequest,
711 GitChangeBranch,
712 GitRenameBranch,
713 GitCreateBranch,
714 GitCreateRemote,
715 GitRemoveRemote,
716 CheckForPushedCommits,
717 GitDiff,
718 GitInit,
719 BreakpointsForFile,
720 ToggleBreakpoint,
721 RunDebugLocators,
722 GetDebugAdapterBinary,
723 LogToDebugConsole,
724 GetDocumentDiagnostics,
725 PullWorkspaceDiagnostics,
726 GetDefaultBranch,
727 GetTreeDiff,
728 GetBlobContent,
729 GitClone,
730 GetAgentServerCommand,
731 GetContextServerCommand,
732 ExternalAgentsUpdated,
733 ExternalExtensionAgentsUpdated,
734 ExternalAgentLoadingStatusUpdated,
735 NewExternalAgentVersionAvailable,
736 GitGetWorktrees,
737 GitCreateWorktree,
738 GitRemoveWorktree,
739 GitRenameWorktree,
740 TrustWorktrees,
741 RestrictWorktrees,
742 FindSearchCandidatesChunk,
743 FindSearchCandidatesCancelled,
744 DownloadFileByPath,
745 GetRemoteProfilingData
746);
747
748entity_messages!(
749 {channel_id, Channel},
750 ChannelMessageSent,
751 ChannelMessageUpdate,
752 RemoveChannelMessage,
753 UpdateChannelMessage,
754 UpdateChannelBuffer,
755 UpdateChannelBufferCollaborators,
756);
757
758impl From<Timestamp> for SystemTime {
759 fn from(val: Timestamp) -> Self {
760 UNIX_EPOCH
761 .checked_add(Duration::new(val.seconds, val.nanos))
762 .unwrap()
763 }
764}
765
766impl From<SystemTime> for Timestamp {
767 fn from(time: SystemTime) -> Self {
768 let duration = time.duration_since(UNIX_EPOCH).unwrap_or_default();
769 Self {
770 seconds: duration.as_secs(),
771 nanos: duration.subsec_nanos(),
772 }
773 }
774}
775
776impl From<u128> for Nonce {
777 fn from(nonce: u128) -> Self {
778 let upper_half = (nonce >> 64) as u64;
779 let lower_half = nonce as u64;
780 Self {
781 upper_half,
782 lower_half,
783 }
784 }
785}
786
787impl From<Nonce> for u128 {
788 fn from(nonce: Nonce) -> Self {
789 let upper_half = (nonce.upper_half as u128) << 64;
790 let lower_half = nonce.lower_half as u128;
791 upper_half | lower_half
792 }
793}
794
795#[cfg(any(test, feature = "test-support"))]
796pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
797#[cfg(not(any(test, feature = "test-support")))]
798pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
799
800pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
801 let mut done = false;
802
803 iter::from_fn(move || {
804 if done {
805 return None;
806 }
807
808 let updated_entries_chunk_size = cmp::min(
809 message.updated_entries.len(),
810 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
811 );
812 let updated_entries: Vec<_> = message
813 .updated_entries
814 .drain(..updated_entries_chunk_size)
815 .collect();
816
817 let removed_entries_chunk_size = cmp::min(
818 message.removed_entries.len(),
819 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
820 );
821 let removed_entries = message
822 .removed_entries
823 .drain(..removed_entries_chunk_size)
824 .collect();
825
826 let mut updated_repositories = Vec::new();
827 let mut limit = MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE;
828 while let Some(repo) = message.updated_repositories.first_mut() {
829 let updated_statuses_limit = cmp::min(repo.updated_statuses.len(), limit);
830 let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
831
832 updated_repositories.push(RepositoryEntry {
833 repository_id: repo.repository_id,
834 branch_summary: repo.branch_summary.clone(),
835 updated_statuses: repo
836 .updated_statuses
837 .drain(..updated_statuses_limit)
838 .collect(),
839 removed_statuses: repo
840 .removed_statuses
841 .drain(..removed_statuses_limit)
842 .collect(),
843 current_merge_conflicts: repo.current_merge_conflicts.clone(),
844 });
845 if repo.removed_statuses.is_empty() && repo.updated_statuses.is_empty() {
846 message.updated_repositories.remove(0);
847 }
848 limit = limit.saturating_sub(removed_statuses_limit + updated_statuses_limit);
849 if limit == 0 {
850 break;
851 }
852 }
853
854 done = message.updated_entries.is_empty()
855 && message.removed_entries.is_empty()
856 && message.updated_repositories.is_empty();
857
858 let removed_repositories = if done {
859 mem::take(&mut message.removed_repositories)
860 } else {
861 Default::default()
862 };
863
864 Some(UpdateWorktree {
865 project_id: message.project_id,
866 worktree_id: message.worktree_id,
867 root_name: message.root_name.clone(),
868 abs_path: message.abs_path.clone(),
869 updated_entries,
870 removed_entries,
871 scan_id: message.scan_id,
872 is_last_update: done && message.is_last_update,
873 updated_repositories,
874 removed_repositories,
875 })
876 })
877}
878
879pub fn split_repository_update(
880 mut update: UpdateRepository,
881) -> impl Iterator<Item = UpdateRepository> {
882 let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
883 let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
884 std::iter::from_fn({
885 let update = update.clone();
886 move || {
887 let updated_statuses = updated_statuses_iter
888 .by_ref()
889 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
890 .collect::<Vec<_>>();
891 let removed_statuses = removed_statuses_iter
892 .by_ref()
893 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
894 .collect::<Vec<_>>();
895 if updated_statuses.is_empty() && removed_statuses.is_empty() {
896 return None;
897 }
898 Some(UpdateRepository {
899 updated_statuses,
900 removed_statuses,
901 is_last_update: false,
902 ..update.clone()
903 })
904 }
905 })
906 .chain([UpdateRepository {
907 updated_statuses: Vec::new(),
908 removed_statuses: Vec::new(),
909 is_last_update: true,
910 ..update
911 }])
912}
913
914impl LspQuery {
915 pub fn query_name_and_write_permissions(&self) -> (&str, bool) {
916 match self.request {
917 Some(lsp_query::Request::GetHover(_)) => ("GetHover", false),
918 Some(lsp_query::Request::GetCodeActions(_)) => ("GetCodeActions", true),
919 Some(lsp_query::Request::GetSignatureHelp(_)) => ("GetSignatureHelp", false),
920 Some(lsp_query::Request::GetCodeLens(_)) => ("GetCodeLens", true),
921 Some(lsp_query::Request::GetDocumentDiagnostics(_)) => {
922 ("GetDocumentDiagnostics", false)
923 }
924 Some(lsp_query::Request::GetDefinition(_)) => ("GetDefinition", false),
925 Some(lsp_query::Request::GetDeclaration(_)) => ("GetDeclaration", false),
926 Some(lsp_query::Request::GetTypeDefinition(_)) => ("GetTypeDefinition", false),
927 Some(lsp_query::Request::GetImplementation(_)) => ("GetImplementation", false),
928 Some(lsp_query::Request::GetReferences(_)) => ("GetReferences", false),
929 Some(lsp_query::Request::GetDocumentColor(_)) => ("GetDocumentColor", false),
930 Some(lsp_query::Request::GetFoldingRanges(_)) => ("GetFoldingRanges", false),
931 Some(lsp_query::Request::GetDocumentSymbols(_)) => ("GetDocumentSymbols", false),
932 Some(lsp_query::Request::InlayHints(_)) => ("InlayHints", false),
933 Some(lsp_query::Request::SemanticTokens(_)) => ("SemanticTokens", false),
934 None => ("<unknown>", true),
935 }
936 }
937}
938
939#[cfg(test)]
940mod tests {
941 use super::*;
942
943 #[test]
944 fn test_converting_peer_id_from_and_to_u64() {
945 let peer_id = PeerId {
946 owner_id: 10,
947 id: 3,
948 };
949 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
950 let peer_id = PeerId {
951 owner_id: u32::MAX,
952 id: 3,
953 };
954 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
955 let peer_id = PeerId {
956 owner_id: 10,
957 id: u32::MAX,
958 };
959 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
960 let peer_id = PeerId {
961 owner_id: u32::MAX,
962 id: u32::MAX,
963 };
964 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
965 }
966}