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