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