zed.proto

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