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