zed.proto

   1syntax = "proto3";
   2package zed.messages;
   3
   4message PeerId {
   5    uint32 owner_id = 1;
   6    uint32 id = 2;
   7}
   8
   9message Envelope {
  10    uint32 id = 1;
  11    optional uint32 responding_to = 2;
  12    optional PeerId original_sender_id = 3;
  13    oneof payload {
  14        Hello hello = 4;
  15        Ack ack = 5;
  16        Error error = 6;
  17        Ping ping = 7;
  18        Test test = 8;
  19
  20        CreateRoom create_room = 9;
  21        CreateRoomResponse create_room_response = 10;
  22        JoinRoom join_room = 11;
  23        JoinRoomResponse join_room_response = 12;
  24        RejoinRoom rejoin_room = 108;
  25        RejoinRoomResponse rejoin_room_response = 109;
  26        LeaveRoom leave_room = 13;
  27        Call call = 14;
  28        IncomingCall incoming_call = 15;
  29        CallCanceled call_canceled = 16;
  30        CancelCall cancel_call = 17;
  31        DeclineCall decline_call = 18;
  32        UpdateParticipantLocation update_participant_location = 19;
  33        RoomUpdated room_updated = 20;
  34
  35        ShareProject share_project = 21;
  36        ShareProjectResponse share_project_response = 22;
  37        UnshareProject unshare_project = 23;
  38        JoinProject join_project = 24;
  39        JoinProjectResponse join_project_response = 25;
  40        LeaveProject leave_project = 26;
  41        AddProjectCollaborator add_project_collaborator = 27;
  42        UpdateProjectCollaborator update_project_collaborator = 110;
  43        RemoveProjectCollaborator remove_project_collaborator = 28;
  44
  45        GetDefinition get_definition = 29;
  46        GetDefinitionResponse get_definition_response = 30;
  47        GetTypeDefinition get_type_definition = 31;
  48        GetTypeDefinitionResponse get_type_definition_response = 32;
  49        GetReferences get_references = 33;
  50        GetReferencesResponse get_references_response = 34;
  51        GetDocumentHighlights get_document_highlights = 35;
  52        GetDocumentHighlightsResponse get_document_highlights_response = 36;
  53        GetProjectSymbols get_project_symbols = 37;
  54        GetProjectSymbolsResponse get_project_symbols_response = 38;
  55        OpenBufferForSymbol open_buffer_for_symbol = 39;
  56        OpenBufferForSymbolResponse open_buffer_for_symbol_response = 40;
  57
  58        UpdateProject update_project = 41;
  59        UpdateWorktree update_worktree = 43;
  60
  61        CreateProjectEntry create_project_entry = 45;
  62        RenameProjectEntry rename_project_entry = 46;
  63        CopyProjectEntry copy_project_entry = 47;
  64        DeleteProjectEntry delete_project_entry = 48;
  65        ProjectEntryResponse project_entry_response = 49;
  66
  67        UpdateDiagnosticSummary update_diagnostic_summary = 50;
  68        StartLanguageServer start_language_server = 51;
  69        UpdateLanguageServer update_language_server = 52;
  70
  71        OpenBufferById open_buffer_by_id = 53;
  72        OpenBufferByPath open_buffer_by_path = 54;
  73        OpenBufferResponse open_buffer_response = 55;
  74        CreateBufferForPeer create_buffer_for_peer = 56;
  75        UpdateBuffer update_buffer = 57;
  76        UpdateBufferFile update_buffer_file = 58;
  77        SaveBuffer save_buffer = 59;
  78        BufferSaved buffer_saved = 60;
  79        BufferReloaded buffer_reloaded = 61;
  80        ReloadBuffers reload_buffers = 62;
  81        ReloadBuffersResponse reload_buffers_response = 63;
  82        SynchronizeBuffers synchronize_buffers = 200;
  83        SynchronizeBuffersResponse synchronize_buffers_response = 201;
  84        FormatBuffers format_buffers = 64;
  85        FormatBuffersResponse format_buffers_response = 65;
  86        GetCompletions get_completions = 66;
  87        GetCompletionsResponse get_completions_response = 67;
  88        ApplyCompletionAdditionalEdits apply_completion_additional_edits = 68;
  89        ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 69;
  90        GetCodeActions get_code_actions = 70;
  91        GetCodeActionsResponse get_code_actions_response = 71;
  92        GetHover get_hover = 72;
  93        GetHoverResponse get_hover_response = 73;
  94        ApplyCodeAction apply_code_action = 74;
  95        ApplyCodeActionResponse apply_code_action_response = 75;
  96        PrepareRename prepare_rename = 76;
  97        PrepareRenameResponse prepare_rename_response = 77;
  98        PerformRename perform_rename = 78;
  99        PerformRenameResponse perform_rename_response = 79;
 100        SearchProject search_project = 80;
 101        SearchProjectResponse search_project_response = 81;
 102
 103        GetChannels get_channels = 82;
 104        GetChannelsResponse get_channels_response = 83;
 105        JoinChannel join_channel = 84;
 106        JoinChannelResponse join_channel_response = 85;
 107        LeaveChannel leave_channel = 86;
 108        SendChannelMessage send_channel_message = 87;
 109        SendChannelMessageResponse send_channel_message_response = 88;
 110        ChannelMessageSent channel_message_sent = 89;
 111        GetChannelMessages get_channel_messages = 90;
 112        GetChannelMessagesResponse get_channel_messages_response = 91;
 113
 114        UpdateContacts update_contacts = 92;
 115        UpdateInviteInfo update_invite_info = 93;
 116        ShowContacts show_contacts = 94;
 117
 118        GetUsers get_users = 95;
 119        FuzzySearchUsers fuzzy_search_users = 96;
 120        UsersResponse users_response = 97;
 121        RequestContact request_contact = 98;
 122        RespondToContactRequest respond_to_contact_request = 99;
 123        RemoveContact remove_contact = 100;
 124
 125        Follow follow = 101;
 126        FollowResponse follow_response = 102;
 127        UpdateFollowers update_followers = 103;
 128        Unfollow unfollow = 104;
 129        GetPrivateUserInfo get_private_user_info = 105;
 130        GetPrivateUserInfoResponse get_private_user_info_response = 106;
 131        UpdateDiffBase update_diff_base = 107;
 132    }
 133}
 134
 135// Messages
 136
 137message Hello {
 138    PeerId peer_id = 1;
 139}
 140
 141message Ping {}
 142
 143message Ack {}
 144
 145message Error {
 146    string message = 1;
 147}
 148
 149message Test {
 150    uint64 id = 1;
 151}
 152
 153message CreateRoom {}
 154
 155message CreateRoomResponse {
 156    Room room = 1;
 157    optional LiveKitConnectionInfo live_kit_connection_info = 2;
 158}
 159
 160message JoinRoom {
 161    uint64 id = 1;
 162}
 163
 164message JoinRoomResponse {
 165    Room room = 1;
 166    optional LiveKitConnectionInfo live_kit_connection_info = 2;
 167}
 168
 169message RejoinRoom {
 170    uint64 id = 1;
 171    repeated UpdateProject reshared_projects = 2;
 172    repeated RejoinProject rejoined_projects = 3;
 173}
 174
 175message RejoinProject {
 176    uint64 id = 1;
 177    repeated RejoinWorktree worktrees = 2;
 178}
 179
 180message RejoinWorktree {
 181    uint64 id = 1;
 182    uint64 scan_id = 2;
 183}
 184
 185message RejoinRoomResponse {
 186    Room room = 1;
 187    repeated ResharedProject reshared_projects = 2;
 188    repeated RejoinedProject rejoined_projects = 3;
 189}
 190
 191message ResharedProject {
 192    uint64 id = 1;
 193    repeated Collaborator collaborators = 2;
 194}
 195
 196message RejoinedProject {
 197    uint64 id = 1;
 198    repeated WorktreeMetadata worktrees = 2;
 199    repeated Collaborator collaborators = 3;
 200    repeated LanguageServer language_servers = 4;
 201}
 202
 203message LeaveRoom {}
 204
 205message Room {
 206    uint64 id = 1;
 207    repeated Participant participants = 2;
 208    repeated PendingParticipant pending_participants = 3;
 209    repeated Follower followers = 4;
 210    string live_kit_room = 5;
 211}
 212
 213message Participant {
 214    uint64 user_id = 1;
 215    PeerId peer_id = 2;
 216    repeated ParticipantProject projects = 3;
 217    ParticipantLocation location = 4;
 218}
 219
 220message PendingParticipant {
 221    uint64 user_id = 1;
 222    uint64 calling_user_id = 2;
 223    optional uint64 initial_project_id = 3;
 224}
 225
 226message ParticipantProject {
 227    uint64 id = 1;
 228    repeated string worktree_root_names = 2;
 229}
 230
 231message Follower {
 232    PeerId leader_id = 1;
 233    PeerId follower_id = 2;
 234    uint64 project_id = 3;
 235}
 236
 237message ParticipantLocation {
 238    oneof variant {
 239        SharedProject shared_project = 1;
 240        UnsharedProject unshared_project = 2;
 241        External external = 3;
 242    }
 243    
 244    message SharedProject {
 245        uint64 id = 1;
 246    }
 247    
 248    message UnsharedProject {}
 249    
 250    message External {}
 251}
 252
 253message Call {
 254    uint64 room_id = 1;
 255    uint64 called_user_id = 2;
 256    optional uint64 initial_project_id = 3;
 257}
 258
 259message IncomingCall {
 260    uint64 room_id = 1;
 261    uint64 calling_user_id = 2;
 262    repeated uint64 participant_user_ids = 3;
 263    optional ParticipantProject initial_project = 4;
 264}
 265
 266message CallCanceled {
 267    uint64 room_id = 1;
 268}
 269
 270message CancelCall {
 271    uint64 room_id = 1;
 272    uint64 called_user_id = 2;
 273}
 274
 275message DeclineCall {
 276    uint64 room_id = 1;
 277}
 278
 279message UpdateParticipantLocation {
 280    uint64 room_id = 1;
 281    ParticipantLocation location = 2;
 282}
 283
 284message RoomUpdated {
 285    Room room = 1;
 286}
 287
 288message LiveKitConnectionInfo {
 289    string server_url = 1;
 290    string token = 2;
 291}
 292
 293message ShareProject {
 294    uint64 room_id = 1;
 295    repeated WorktreeMetadata worktrees = 2;
 296}
 297
 298message ShareProjectResponse {
 299    uint64 project_id = 1;
 300}
 301
 302message UnshareProject {
 303    uint64 project_id = 1;
 304}
 305
 306message UpdateProject {
 307    uint64 project_id = 1;
 308    repeated WorktreeMetadata worktrees = 2;
 309}
 310
 311message JoinProject {
 312    uint64 project_id = 1;
 313}
 314
 315message JoinProjectResponse {
 316    uint32 replica_id = 1;
 317    repeated WorktreeMetadata worktrees = 2;
 318    repeated Collaborator collaborators = 3;
 319    repeated LanguageServer language_servers = 4;
 320}
 321
 322message LeaveProject {
 323    uint64 project_id = 1;
 324}
 325
 326message UpdateWorktree {
 327    uint64 project_id = 1;
 328    uint64 worktree_id = 2;
 329    string root_name = 3;
 330    repeated Entry updated_entries = 4;
 331    repeated uint64 removed_entries = 5;
 332    uint64 scan_id = 6;
 333    bool is_last_update = 7;
 334    string abs_path = 8;
 335}
 336
 337message CreateProjectEntry {
 338    uint64 project_id = 1;
 339    uint64 worktree_id = 2;
 340    string path = 3;
 341    bool is_directory = 4;
 342}
 343
 344message RenameProjectEntry {
 345    uint64 project_id = 1;
 346    uint64 entry_id = 2;
 347    string new_path = 3;
 348}
 349
 350message CopyProjectEntry {
 351    uint64 project_id = 1;
 352    uint64 entry_id = 2;
 353    string new_path = 3;
 354}
 355
 356message DeleteProjectEntry {
 357    uint64 project_id = 1;
 358    uint64 entry_id = 2;
 359}
 360
 361message ProjectEntryResponse {
 362    Entry entry = 1;
 363    uint64 worktree_scan_id = 2;
 364}
 365
 366message AddProjectCollaborator {
 367    uint64 project_id = 1;
 368    Collaborator collaborator = 2;
 369}
 370
 371message UpdateProjectCollaborator {
 372    uint64 project_id = 1;
 373    PeerId old_peer_id = 2;
 374    PeerId new_peer_id = 3;
 375}
 376
 377message RemoveProjectCollaborator {
 378    uint64 project_id = 1;
 379    PeerId peer_id = 2;
 380}
 381
 382message GetDefinition {
 383     uint64 project_id = 1;
 384     uint64 buffer_id = 2;
 385     Anchor position = 3;
 386     repeated VectorClockEntry version = 4;
 387 }
 388
 389message GetDefinitionResponse {
 390    repeated LocationLink links = 1;
 391}
 392
 393message GetTypeDefinition {
 394     uint64 project_id = 1;
 395     uint64 buffer_id = 2;
 396     Anchor position = 3;
 397     repeated VectorClockEntry version = 4;
 398 }
 399
 400message GetTypeDefinitionResponse {
 401    repeated LocationLink links = 1;
 402}
 403
 404message GetReferences {
 405     uint64 project_id = 1;
 406     uint64 buffer_id = 2;
 407     Anchor position = 3;
 408     repeated VectorClockEntry version = 4;
 409 }
 410
 411message GetReferencesResponse {
 412    repeated Location locations = 1;
 413}
 414
 415message GetDocumentHighlights {
 416     uint64 project_id = 1;
 417     uint64 buffer_id = 2;
 418     Anchor position = 3;
 419     repeated VectorClockEntry version = 4;
 420 }
 421
 422message GetDocumentHighlightsResponse {
 423    repeated DocumentHighlight highlights = 1;
 424}
 425
 426message Location {
 427    uint64 buffer_id = 1;
 428    Anchor start = 2;
 429    Anchor end = 3;
 430}
 431
 432message LocationLink {
 433    optional Location origin = 1;
 434    Location target = 2;
 435}
 436
 437message DocumentHighlight {
 438    Kind kind = 1;
 439    Anchor start = 2;
 440    Anchor end = 3;
 441
 442    enum Kind {
 443        Text = 0;
 444        Read = 1;
 445        Write = 2;
 446    }
 447}
 448
 449message GetProjectSymbols {
 450    uint64 project_id = 1;
 451    string query = 2;
 452}
 453
 454message GetProjectSymbolsResponse {
 455    repeated Symbol symbols = 4;
 456}
 457
 458message Symbol {
 459    uint64 source_worktree_id = 1;
 460    uint64 worktree_id = 2;
 461    string language_server_name = 3;
 462    string name = 4;
 463    int32 kind = 5;
 464    string path = 6;
 465    // Cannot use generate anchors for unopend files,
 466    // so we are forced to use point coords instead
 467    PointUtf16 start = 7;
 468    PointUtf16 end = 8;
 469    bytes signature = 9;
 470}
 471
 472message OpenBufferForSymbol {
 473    uint64 project_id = 1;
 474    Symbol symbol = 2;
 475}
 476
 477message OpenBufferForSymbolResponse {
 478    uint64 buffer_id = 1;
 479}
 480
 481message OpenBufferByPath {
 482    uint64 project_id = 1;
 483    uint64 worktree_id = 2;
 484    string path = 3;
 485}
 486
 487message OpenBufferById {
 488    uint64 project_id = 1;
 489    uint64 id = 2;
 490}
 491
 492message OpenBufferResponse {
 493    uint64 buffer_id = 1;
 494}
 495
 496message CreateBufferForPeer {
 497    uint64 project_id = 1;
 498    PeerId peer_id = 2;
 499    oneof variant {
 500        BufferState state = 3;
 501        BufferChunk chunk = 4;
 502    }
 503}
 504
 505message UpdateBuffer {
 506    uint64 project_id = 1;
 507    uint64 buffer_id = 2;
 508    repeated Operation operations = 3;
 509}
 510
 511message UpdateBufferFile {
 512    uint64 project_id = 1;
 513    uint64 buffer_id = 2;
 514    File file = 3;
 515}
 516
 517message SaveBuffer {
 518    uint64 project_id = 1;
 519    uint64 buffer_id = 2;
 520    repeated VectorClockEntry version = 3;
 521}
 522
 523message BufferSaved {
 524    uint64 project_id = 1;
 525    uint64 buffer_id = 2;
 526    repeated VectorClockEntry version = 3;
 527    Timestamp mtime = 4;
 528    string fingerprint = 5;
 529}
 530
 531message BufferReloaded {
 532    uint64 project_id = 1;
 533    uint64 buffer_id = 2;
 534    repeated VectorClockEntry version = 3;
 535    Timestamp mtime = 4;
 536    string fingerprint = 5;
 537    LineEnding line_ending = 6;
 538}
 539
 540message ReloadBuffers {
 541    uint64 project_id = 1;
 542    repeated uint64 buffer_ids = 2;
 543}
 544
 545message ReloadBuffersResponse {
 546    ProjectTransaction transaction = 1;
 547}
 548
 549message SynchronizeBuffers {
 550    uint64 project_id = 1;
 551    repeated BufferVersion buffers = 2;
 552}
 553
 554message SynchronizeBuffersResponse {
 555    repeated BufferVersion buffers = 1;
 556}
 557
 558message BufferVersion {
 559    uint64 id = 1;
 560    repeated VectorClockEntry version = 2;
 561}
 562
 563enum FormatTrigger {
 564    Save = 0;
 565    Manual = 1;
 566}
 567
 568message FormatBuffers {
 569    uint64 project_id = 1;
 570    FormatTrigger trigger = 2;
 571    repeated uint64 buffer_ids = 3;
 572}
 573
 574message FormatBuffersResponse {
 575    ProjectTransaction transaction = 1;
 576}
 577
 578message GetCompletions {
 579    uint64 project_id = 1;
 580    uint64 buffer_id = 2;
 581    Anchor position = 3;
 582    repeated VectorClockEntry version = 4;
 583}
 584
 585message GetCompletionsResponse {
 586    repeated Completion completions = 1;
 587    repeated VectorClockEntry version = 2;
 588}
 589
 590message ApplyCompletionAdditionalEdits {
 591    uint64 project_id = 1;
 592    uint64 buffer_id = 2;
 593    Completion completion = 3;
 594}
 595
 596message ApplyCompletionAdditionalEditsResponse {
 597    Transaction transaction = 1;
 598}
 599
 600message Completion {
 601    Anchor old_start = 1;
 602    Anchor old_end = 2;
 603    string new_text = 3;
 604    bytes lsp_completion = 4;
 605}
 606
 607message GetCodeActions {
 608    uint64 project_id = 1;
 609    uint64 buffer_id = 2;
 610    Anchor start = 3;
 611    Anchor end = 4;
 612    repeated VectorClockEntry version = 5;
 613}
 614
 615message GetCodeActionsResponse {
 616    repeated CodeAction actions = 1;
 617    repeated VectorClockEntry version = 2;
 618}
 619
 620message GetHover {
 621    uint64 project_id = 1;
 622    uint64 buffer_id = 2;
 623    Anchor position = 3;
 624    repeated VectorClockEntry version = 5;
 625}
 626
 627message GetHoverResponse {
 628    optional Anchor start = 1;
 629    optional Anchor end = 2;
 630    repeated HoverBlock contents = 3;
 631}
 632
 633message HoverBlock {
 634    string text = 1;
 635    optional string language = 2;
 636}
 637
 638message ApplyCodeAction {
 639    uint64 project_id = 1;
 640    uint64 buffer_id = 2;
 641    CodeAction action = 3;
 642}
 643
 644message ApplyCodeActionResponse {
 645    ProjectTransaction transaction = 1;
 646}
 647
 648message PrepareRename {
 649    uint64 project_id = 1;
 650    uint64 buffer_id = 2;
 651    Anchor position = 3;
 652    repeated VectorClockEntry version = 4;
 653}
 654
 655message PrepareRenameResponse {
 656    bool can_rename = 1;
 657    Anchor start = 2;
 658    Anchor end = 3;
 659    repeated VectorClockEntry version = 4;
 660}
 661
 662message PerformRename {
 663    uint64 project_id = 1;
 664    uint64 buffer_id = 2;
 665    Anchor position = 3;
 666    string new_name = 4;
 667    repeated VectorClockEntry version = 5;
 668}
 669
 670message PerformRenameResponse {
 671    ProjectTransaction transaction = 2;
 672}
 673
 674message SearchProject {
 675    uint64 project_id = 1;
 676    string query = 2;
 677    bool regex = 3;
 678    bool whole_word = 4;
 679    bool case_sensitive = 5;
 680}
 681
 682message SearchProjectResponse {
 683    repeated Location locations = 1;
 684}
 685
 686message CodeAction {
 687    Anchor start = 1;
 688    Anchor end = 2;
 689    bytes lsp_action = 3;
 690}
 691
 692message ProjectTransaction {
 693    repeated uint64 buffer_ids = 1;
 694    repeated Transaction transactions = 2;
 695}
 696
 697message Transaction {
 698    LocalTimestamp id = 1;
 699    repeated LocalTimestamp edit_ids = 2;
 700    repeated VectorClockEntry start = 3;
 701}
 702
 703message LocalTimestamp {
 704    uint32 replica_id = 1;
 705    uint32 value = 2;
 706}
 707
 708message LanguageServer {
 709    uint64 id = 1;
 710    string name = 2;
 711}
 712
 713message StartLanguageServer {
 714    uint64 project_id = 1;
 715    LanguageServer server = 2;
 716}
 717
 718message UpdateDiagnosticSummary {
 719    uint64 project_id = 1;
 720    uint64 worktree_id = 2;
 721    DiagnosticSummary summary = 3;
 722}
 723
 724message DiagnosticSummary {
 725    string path = 1;
 726    uint64 language_server_id = 2;
 727    uint32 error_count = 3;
 728    uint32 warning_count = 4;
 729}
 730
 731message UpdateLanguageServer {
 732    uint64 project_id = 1;
 733    uint64 language_server_id = 2;
 734    oneof variant {
 735        LspWorkStart work_start = 3;
 736        LspWorkProgress work_progress = 4;
 737        LspWorkEnd work_end = 5;
 738        LspDiskBasedDiagnosticsUpdating disk_based_diagnostics_updating = 6;
 739        LspDiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 7;
 740    }
 741}
 742
 743message LspWorkStart {
 744    string token = 1;
 745    optional string message = 2;
 746    optional uint32 percentage = 3;
 747}
 748
 749message LspWorkProgress {
 750    string token = 1;
 751    optional string message = 2;
 752    optional uint32 percentage = 3;
 753}
 754
 755message LspWorkEnd {
 756    string token = 1;
 757}
 758
 759message LspDiskBasedDiagnosticsUpdating {}
 760
 761message LspDiskBasedDiagnosticsUpdated {}
 762
 763message GetChannels {}
 764
 765message GetChannelsResponse {
 766    repeated Channel channels = 1;
 767}
 768
 769message JoinChannel {
 770    uint64 channel_id = 1;
 771}
 772
 773message JoinChannelResponse {
 774    repeated ChannelMessage messages = 1;
 775    bool done = 2;
 776}
 777
 778message LeaveChannel {
 779    uint64 channel_id = 1;
 780}
 781
 782message GetUsers {
 783    repeated uint64 user_ids = 1;
 784}
 785
 786message FuzzySearchUsers {
 787    string query = 1;
 788}
 789
 790message UsersResponse {
 791    repeated User users = 1;
 792}
 793
 794message RequestContact {
 795    uint64 responder_id = 1;
 796}
 797
 798message RemoveContact {
 799    uint64 user_id = 1;
 800}
 801
 802message RespondToContactRequest {
 803    uint64 requester_id = 1;
 804    ContactRequestResponse response = 2;
 805}
 806
 807enum ContactRequestResponse {
 808    Accept = 0;
 809    Decline = 1;
 810    Block = 2;
 811    Dismiss = 3;
 812}
 813
 814message SendChannelMessage {
 815    uint64 channel_id = 1;
 816    string body = 2;
 817    Nonce nonce = 3;
 818}
 819
 820message SendChannelMessageResponse {
 821    ChannelMessage message = 1;
 822}
 823
 824message ChannelMessageSent {
 825    uint64 channel_id = 1;
 826    ChannelMessage message = 2;
 827}
 828
 829message GetChannelMessages {
 830    uint64 channel_id = 1;
 831    uint64 before_message_id = 2;
 832}
 833
 834message GetChannelMessagesResponse {
 835    repeated ChannelMessage messages = 1;
 836    bool done = 2;
 837}
 838
 839message UpdateContacts {
 840    repeated Contact contacts = 1;
 841    repeated uint64 remove_contacts = 2;
 842    repeated IncomingContactRequest incoming_requests = 3;
 843    repeated uint64 remove_incoming_requests = 4;
 844    repeated uint64 outgoing_requests = 5;
 845    repeated uint64 remove_outgoing_requests = 6;
 846}
 847
 848message UpdateInviteInfo {
 849    string url = 1;
 850    uint32 count = 2;
 851}
 852
 853message ShowContacts {}
 854
 855message IncomingContactRequest {
 856    uint64 requester_id = 1;
 857    bool should_notify = 2;
 858}
 859
 860message UpdateDiagnostics {
 861    uint32 replica_id = 1;
 862    uint32 lamport_timestamp = 2;
 863    repeated Diagnostic diagnostics = 3;
 864}
 865
 866message Follow {
 867    uint64 project_id = 1;
 868    PeerId leader_id = 2;
 869}
 870
 871message FollowResponse {
 872    optional ViewId active_view_id = 1;
 873    repeated View views = 2;
 874}
 875
 876message UpdateFollowers {
 877    uint64 project_id = 1;
 878    repeated PeerId follower_ids = 2;
 879    oneof variant {
 880        UpdateActiveView update_active_view = 3;
 881        View create_view = 4;
 882        UpdateView update_view = 5;
 883    }
 884}
 885
 886message Unfollow {
 887    uint64 project_id = 1;
 888    PeerId leader_id = 2;
 889}
 890
 891message GetPrivateUserInfo {}
 892
 893message GetPrivateUserInfoResponse {
 894    string metrics_id = 1;
 895    bool staff = 2;
 896}
 897
 898// Entities
 899
 900message ViewId {
 901    PeerId creator = 1;
 902    uint64 id = 2;
 903}
 904
 905message UpdateActiveView {
 906    optional ViewId id = 1;
 907    optional PeerId leader_id = 2;
 908}
 909
 910message UpdateView {
 911    ViewId id = 1;
 912    optional PeerId leader_id = 2;
 913
 914    oneof variant {
 915        Editor editor = 3;
 916    }
 917
 918    message Editor {
 919        repeated ExcerptInsertion inserted_excerpts = 1;
 920        repeated uint64 deleted_excerpts = 2;
 921        repeated Selection selections = 3;
 922        optional Selection pending_selection = 4;
 923        EditorAnchor scroll_top_anchor = 5;
 924        float scroll_x = 6;
 925        float scroll_y = 7;
 926    }
 927}
 928
 929message View {
 930    ViewId id = 1;
 931    optional PeerId leader_id = 2;
 932
 933    oneof variant {
 934        Editor editor = 3;
 935    }
 936
 937    message Editor {
 938        bool singleton = 1;
 939        optional string title = 2;
 940        repeated Excerpt excerpts = 3;
 941        repeated Selection selections = 4;
 942        optional Selection pending_selection = 5;
 943        EditorAnchor scroll_top_anchor = 6;
 944        float scroll_x = 7;
 945        float scroll_y = 8;
 946    }
 947}
 948
 949message Collaborator {
 950    PeerId peer_id = 1;
 951    uint32 replica_id = 2;
 952    uint64 user_id = 3;
 953}
 954
 955message User {
 956    uint64 id = 1;
 957    string github_login = 2;
 958    string avatar_url = 3;
 959}
 960
 961message File {
 962    uint64 worktree_id = 1;
 963    uint64 entry_id = 2;
 964    string path = 3;
 965    Timestamp mtime = 4;
 966    bool is_deleted = 5;
 967}
 968
 969message Entry {
 970    uint64 id = 1;
 971    bool is_dir = 2;
 972    string path = 3;
 973    uint64 inode = 4;
 974    Timestamp mtime = 5;
 975    bool is_symlink = 6;
 976    bool is_ignored = 7;
 977}
 978
 979message BufferState {
 980    uint64 id = 1;
 981    optional File file = 2;
 982    string base_text = 3;
 983    optional string diff_base = 4;
 984    LineEnding line_ending = 5;
 985    repeated VectorClockEntry saved_version = 6;
 986    string saved_version_fingerprint = 7;
 987    Timestamp saved_mtime = 8;
 988}
 989
 990message BufferChunk {
 991    uint64 buffer_id = 1;
 992    repeated Operation operations = 2;
 993    bool is_last = 3;
 994}
 995
 996enum LineEnding {
 997    Unix = 0;
 998    Windows = 1;
 999}
1000
1001message Selection {
1002    uint64 id = 1;
1003    EditorAnchor start = 2;
1004    EditorAnchor end = 3;
1005    bool reversed = 4;
1006}
1007
1008message EditorAnchor {
1009    uint64 excerpt_id = 1;
1010    Anchor anchor = 2;
1011}
1012
1013enum CursorShape {
1014    CursorBar = 0;
1015    CursorBlock = 1;
1016    CursorUnderscore = 2;
1017    CursorHollow = 3;
1018}
1019
1020message ExcerptInsertion {
1021    Excerpt excerpt = 1;
1022    optional uint64 previous_excerpt_id = 2;
1023}
1024
1025message Excerpt {
1026    uint64 id = 1;
1027    uint64 buffer_id = 2;
1028    Anchor context_start = 3;
1029    Anchor context_end = 4;
1030    Anchor primary_start = 5;
1031    Anchor primary_end = 6;
1032}
1033
1034message Anchor {
1035    uint32 replica_id = 1;
1036    uint32 local_timestamp = 2;
1037    uint64 offset = 3;
1038    Bias bias = 4;
1039    optional uint64 buffer_id = 5;
1040}
1041
1042enum Bias {
1043    Left = 0;
1044    Right = 1;
1045}
1046
1047message Diagnostic {
1048    Anchor start = 1;
1049    Anchor end = 2;
1050    Severity severity = 3;
1051    string message = 4;
1052    optional string code = 5;
1053    uint64 group_id = 6;
1054    bool is_primary = 7;
1055    bool is_valid = 8;
1056    bool is_disk_based = 9;
1057    bool is_unnecessary = 10;
1058
1059    enum Severity {
1060        None = 0;
1061        Error = 1;
1062        Warning = 2;
1063        Information = 3;
1064        Hint = 4;
1065    }
1066}
1067
1068message Operation {
1069    oneof variant {
1070        Edit edit = 1;
1071        Undo undo = 2;
1072        UpdateSelections update_selections = 3;
1073        UpdateDiagnostics update_diagnostics = 4;
1074        UpdateCompletionTriggers update_completion_triggers = 5;
1075    }
1076
1077    message Edit {
1078        uint32 replica_id = 1;
1079        uint32 local_timestamp = 2;
1080        uint32 lamport_timestamp = 3;
1081        repeated VectorClockEntry version = 4;
1082        repeated Range ranges = 5;
1083        repeated string new_text = 6;
1084    }
1085
1086    message Undo {
1087        uint32 replica_id = 1;
1088        uint32 local_timestamp = 2;
1089        uint32 lamport_timestamp = 3;
1090        repeated VectorClockEntry version = 4;
1091        repeated UndoCount counts = 5;
1092    }
1093
1094    message UpdateSelections {
1095        uint32 replica_id = 1;
1096        uint32 lamport_timestamp = 2;
1097        repeated Selection selections = 3;
1098        bool line_mode = 4;
1099        CursorShape cursor_shape = 5;
1100    }
1101
1102    message UpdateCompletionTriggers {
1103        uint32 replica_id = 1;
1104        uint32 lamport_timestamp = 2;
1105        repeated string triggers = 3;
1106    }
1107}
1108
1109message UndoMapEntry {
1110    uint32 replica_id = 1;
1111    uint32 local_timestamp = 2;
1112    repeated UndoCount counts = 3;
1113}
1114
1115message UndoCount {
1116    uint32 replica_id = 1;
1117    uint32 local_timestamp = 2;
1118    uint32 count = 3;
1119}
1120
1121message VectorClockEntry {
1122    uint32 replica_id = 1;
1123    uint32 timestamp = 2;
1124}
1125
1126message Timestamp {
1127    uint64 seconds = 1;
1128    uint32 nanos = 2;
1129}
1130
1131message Range {
1132    uint64 start = 1;
1133    uint64 end = 2;
1134}
1135
1136message PointUtf16 {
1137    uint32 row = 1;
1138    uint32 column = 2;
1139}
1140
1141message Nonce {
1142    uint64 upper_half = 1;
1143    uint64 lower_half = 2;
1144}
1145
1146message Channel {
1147    uint64 id = 1;
1148    string name = 2;
1149}
1150
1151message ChannelMessage {
1152    uint64 id = 1;
1153    string body = 2;
1154    uint64 timestamp = 3;
1155    uint64 sender_id = 4;
1156    Nonce nonce = 5;
1157}
1158
1159message Contact {
1160    uint64 user_id = 1;
1161    bool online = 2;
1162    bool busy = 3;
1163    bool should_notify = 4;
1164}
1165
1166message WorktreeMetadata {
1167    uint64 id = 1;
1168    string root_name = 2;
1169    bool visible = 3;
1170    string abs_path = 4;
1171}
1172
1173message UpdateDiffBase {
1174    uint64 project_id = 1;
1175    uint64 buffer_id = 2;
1176    optional string diff_base = 3;
1177}