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    Point start = 7;
 416    Point 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    uint32 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    uint32 leader_id = 2;
 803}
 804
 805message FollowResponse {
 806    optional uint64 active_view_id = 1;
 807    repeated View views = 2;
 808}
 809
 810message UpdateFollowers {
 811    uint64 project_id = 1;
 812    repeated uint32 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    uint32 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 UpdateActiveView {
 835    optional uint64 id = 1;
 836    optional uint32 leader_id = 2;
 837}
 838
 839message UpdateView {
 840    uint64 id = 1;
 841    optional uint32 leader_id = 2;
 842
 843    oneof variant {
 844        Editor editor = 3;
 845    }
 846
 847    message Editor {
 848        repeated Selection selections = 1;
 849        Anchor scroll_top_anchor = 2;
 850        float scroll_x = 3;
 851        float scroll_y = 4;
 852    }
 853}
 854
 855message View {
 856    uint64 id = 1;
 857    optional uint32 leader_id = 2;
 858
 859    oneof variant {
 860        Editor editor = 3;
 861    }
 862
 863    message Editor {
 864        uint64 buffer_id = 1;
 865        repeated Selection selections = 2;
 866        Anchor scroll_top_anchor = 3;
 867        float scroll_x = 4;
 868        float scroll_y = 5;
 869    }
 870}
 871
 872message Collaborator {
 873    uint32 peer_id = 1;
 874    uint32 replica_id = 2;
 875    uint64 user_id = 3;
 876}
 877
 878message User {
 879    uint64 id = 1;
 880    string github_login = 2;
 881    string avatar_url = 3;
 882}
 883
 884message File {
 885    uint64 worktree_id = 1;
 886    uint64 entry_id = 2;
 887    string path = 3;
 888    Timestamp mtime = 4;
 889    bool is_deleted = 5;
 890}
 891
 892message Entry {
 893    uint64 id = 1;
 894    bool is_dir = 2;
 895    bytes path = 3;
 896    uint64 inode = 4;
 897    Timestamp mtime = 5;
 898    bool is_symlink = 6;
 899    bool is_ignored = 7;
 900}
 901
 902message BufferState {
 903    uint64 id = 1;
 904    optional File file = 2;
 905    string base_text = 3;
 906    optional string diff_base = 4;
 907    LineEnding line_ending = 5;
 908}
 909
 910message BufferChunk {
 911    uint64 buffer_id = 1;
 912    repeated Operation operations = 2;
 913    bool is_last = 3;
 914}
 915
 916enum LineEnding {
 917    Unix = 0;
 918    Windows = 1;
 919}
 920
 921message SelectionSet {
 922    uint32 replica_id = 1;
 923    repeated Selection selections = 2;
 924    uint32 lamport_timestamp = 3;
 925    bool line_mode = 4;
 926    CursorShape cursor_shape = 5;
 927}
 928
 929message Selection {
 930    uint64 id = 1;
 931    Anchor start = 2;
 932    Anchor end = 3;
 933    bool reversed = 4;
 934}
 935
 936enum CursorShape {
 937    CursorBar = 0;
 938    CursorBlock = 1;
 939    CursorUnderscore = 2;
 940    CursorHollow = 3;
 941}
 942
 943message Anchor {
 944    uint32 replica_id = 1;
 945    uint32 local_timestamp = 2;
 946    uint64 offset = 3;
 947    Bias bias = 4;
 948    optional uint64 buffer_id = 5;
 949}
 950
 951enum Bias {
 952    Left = 0;
 953    Right = 1;
 954}
 955
 956message Diagnostic {
 957    Anchor start = 1;
 958    Anchor end = 2;
 959    Severity severity = 3;
 960    string message = 4;
 961    optional string code = 5;
 962    uint64 group_id = 6;
 963    bool is_primary = 7;
 964    bool is_valid = 8;
 965    bool is_disk_based = 9;
 966    bool is_unnecessary = 10;
 967
 968    enum Severity {
 969        None = 0;
 970        Error = 1;
 971        Warning = 2;
 972        Information = 3;
 973        Hint = 4;
 974    }
 975}
 976
 977message Operation {
 978    oneof variant {
 979        Edit edit = 1;
 980        Undo undo = 2;
 981        UpdateSelections update_selections = 3;
 982        UpdateDiagnostics update_diagnostics = 4;
 983        UpdateCompletionTriggers update_completion_triggers = 5;
 984    }
 985
 986    message Edit {
 987        uint32 replica_id = 1;
 988        uint32 local_timestamp = 2;
 989        uint32 lamport_timestamp = 3;
 990        repeated VectorClockEntry version = 4;
 991        repeated Range ranges = 5;
 992        repeated string new_text = 6;
 993    }
 994
 995    message Undo {
 996        uint32 replica_id = 1;
 997        uint32 local_timestamp = 2;
 998        uint32 lamport_timestamp = 3;
 999        repeated VectorClockEntry version = 4;
1000        repeated UndoCount counts = 5;
1001    }
1002
1003    message UpdateSelections {
1004        uint32 replica_id = 1;
1005        uint32 lamport_timestamp = 2;
1006        repeated Selection selections = 3;
1007        bool line_mode = 4;
1008        CursorShape cursor_shape = 5;
1009    }
1010
1011    message UpdateCompletionTriggers {
1012        uint32 replica_id = 1;
1013        uint32 lamport_timestamp = 2;
1014        repeated string triggers = 3;
1015    }
1016}
1017
1018message UndoMapEntry {
1019    uint32 replica_id = 1;
1020    uint32 local_timestamp = 2;
1021    repeated UndoCount counts = 3;
1022}
1023
1024message UndoCount {
1025    uint32 replica_id = 1;
1026    uint32 local_timestamp = 2;
1027    uint32 count = 3;
1028}
1029
1030message VectorClockEntry {
1031    uint32 replica_id = 1;
1032    uint32 timestamp = 2;
1033}
1034
1035message Timestamp {
1036    uint64 seconds = 1;
1037    uint32 nanos = 2;
1038}
1039
1040message Range {
1041    uint64 start = 1;
1042    uint64 end = 2;
1043}
1044
1045message Point {
1046    uint32 row = 1;
1047    uint32 column = 2;
1048}
1049
1050message Nonce {
1051    uint64 upper_half = 1;
1052    uint64 lower_half = 2;
1053}
1054
1055message Channel {
1056    uint64 id = 1;
1057    string name = 2;
1058}
1059
1060message ChannelMessage {
1061    uint64 id = 1;
1062    string body = 2;
1063    uint64 timestamp = 3;
1064    uint64 sender_id = 4;
1065    Nonce nonce = 5;
1066}
1067
1068message Contact {
1069    uint64 user_id = 1;
1070    bool online = 2;
1071    bool busy = 3;
1072    bool should_notify = 4;
1073}
1074
1075message WorktreeMetadata {
1076    uint64 id = 1;
1077    string root_name = 2;
1078    bool visible = 3;
1079    bytes abs_path = 4;
1080}
1081
1082message UpdateDiffBase {
1083    uint64 project_id = 1;
1084    uint64 buffer_id = 2;
1085    optional string diff_base = 3;
1086}