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