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