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