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