zed.proto

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