Merge branch 'main' into multi-server-completions-tailwind

This commit is contained in:
Julia 2023-08-30 22:41:12 -04:00
commit ff3865a4ad
427 changed files with 43123 additions and 12861 deletions

View file

@ -23,7 +23,7 @@ async-tungstenite = "0.16"
base64 = "0.13"
futures.workspace = true
parking_lot.workspace = true
prost = "0.8"
prost.workspace = true
rand.workspace = true
rsa = "0.4"
serde.workspace = true

View file

@ -102,17 +102,6 @@ message Envelope {
SearchProject search_project = 80;
SearchProjectResponse search_project_response = 81;
GetChannels get_channels = 82;
GetChannelsResponse get_channels_response = 83;
JoinChannel join_channel = 84;
JoinChannelResponse join_channel_response = 85;
LeaveChannel leave_channel = 86;
SendChannelMessage send_channel_message = 87;
SendChannelMessageResponse send_channel_message_response = 88;
ChannelMessageSent channel_message_sent = 89;
GetChannelMessages get_channel_messages = 90;
GetChannelMessagesResponse get_channel_messages_response = 91;
UpdateContacts update_contacts = 92;
UpdateInviteInfo update_invite_info = 93;
ShowContacts show_contacts = 94;
@ -139,7 +128,29 @@ message Envelope {
InlayHints inlay_hints = 116;
InlayHintsResponse inlay_hints_response = 117;
ResolveInlayHint resolve_inlay_hint = 137;
ResolveInlayHintResponse resolve_inlay_hint_response = 138;
RefreshInlayHints refresh_inlay_hints = 118;
CreateChannel create_channel = 119;
ChannelResponse channel_response = 120;
InviteChannelMember invite_channel_member = 121;
RemoveChannelMember remove_channel_member = 122;
RespondToChannelInvite respond_to_channel_invite = 123;
UpdateChannels update_channels = 124;
JoinChannel join_channel = 125;
RemoveChannel remove_channel = 126;
GetChannelMembers get_channel_members = 127;
GetChannelMembersResponse get_channel_members_response = 128;
SetChannelMemberAdmin set_channel_member_admin = 129;
RenameChannel rename_channel = 130;
JoinChannelBuffer join_channel_buffer = 131;
JoinChannelBufferResponse join_channel_buffer_response = 132;
UpdateChannelBuffer update_channel_buffer = 133;
LeaveChannelBuffer leave_channel_buffer = 134;
AddChannelBufferCollaborator add_channel_buffer_collaborator = 135;
RemoveChannelBufferCollaborator remove_channel_buffer_collaborator = 136;
}
}
@ -174,7 +185,8 @@ message JoinRoom {
message JoinRoomResponse {
Room room = 1;
optional LiveKitConnectionInfo live_kit_connection_info = 2;
optional uint64 channel_id = 2;
optional LiveKitConnectionInfo live_kit_connection_info = 3;
}
message RejoinRoom {
@ -408,6 +420,16 @@ message RemoveProjectCollaborator {
PeerId peer_id = 2;
}
message AddChannelBufferCollaborator {
uint64 channel_id = 1;
Collaborator collaborator = 2;
}
message RemoveChannelBufferCollaborator {
uint64 channel_id = 1;
PeerId peer_id = 2;
}
message GetDefinition {
uint64 project_id = 1;
uint64 buffer_id = 2;
@ -537,6 +559,11 @@ message UpdateBuffer {
repeated Operation operations = 3;
}
message UpdateChannelBuffer {
uint64 channel_id = 1;
repeated Operation operations = 2;
}
message UpdateBufferFile {
uint64 project_id = 1;
uint64 buffer_id = 2;
@ -730,6 +757,7 @@ message InlayHint {
bool padding_left = 4;
bool padding_right = 5;
InlayHintTooltip tooltip = 6;
ResolveState resolve_state = 7;
}
message InlayHintLabel {
@ -746,7 +774,10 @@ message InlayHintLabelParts {
message InlayHintLabelPart {
string value = 1;
InlayHintLabelPartTooltip tooltip = 2;
Location location = 3;
optional string location_url = 3;
PointUtf16 location_range_start = 4;
PointUtf16 location_range_end = 5;
optional uint64 language_server_id = 6;
}
message InlayHintTooltip {
@ -763,12 +794,39 @@ message InlayHintLabelPartTooltip {
}
}
message ResolveState {
State state = 1;
LspResolveState lsp_resolve_state = 2;
enum State {
Resolved = 0;
CanResolve = 1;
Resolving = 2;
}
message LspResolveState {
string value = 1;
uint64 server_id = 2;
}
}
message ResolveInlayHint {
uint64 project_id = 1;
uint64 buffer_id = 2;
uint64 language_server_id = 3;
InlayHint hint = 4;
}
message ResolveInlayHintResponse {
InlayHint hint = 1;
}
message RefreshInlayHints {
uint64 project_id = 1;
}
message MarkupContent {
string kind = 1;
bool is_markdown = 1;
string value = 2;
}
@ -868,25 +926,105 @@ message LspDiskBasedDiagnosticsUpdating {}
message LspDiskBasedDiagnosticsUpdated {}
message GetChannels {}
message GetChannelsResponse {
message UpdateChannels {
repeated Channel channels = 1;
repeated uint64 remove_channels = 2;
repeated Channel channel_invitations = 3;
repeated uint64 remove_channel_invitations = 4;
repeated ChannelParticipants channel_participants = 5;
repeated ChannelPermission channel_permissions = 6;
}
message ChannelPermission {
uint64 channel_id = 1;
bool is_admin = 2;
}
message ChannelParticipants {
uint64 channel_id = 1;
repeated uint64 participant_user_ids = 2;
}
message JoinChannel {
uint64 channel_id = 1;
}
message JoinChannelResponse {
repeated ChannelMessage messages = 1;
bool done = 2;
message RemoveChannel {
uint64 channel_id = 1;
}
message LeaveChannel {
message GetChannelMembers {
uint64 channel_id = 1;
}
message GetChannelMembersResponse {
repeated ChannelMember members = 1;
}
message ChannelMember {
uint64 user_id = 1;
bool admin = 2;
Kind kind = 3;
enum Kind {
Member = 0;
Invitee = 1;
AncestorMember = 2;
}
}
message CreateChannel {
string name = 1;
optional uint64 parent_id = 2;
}
message ChannelResponse {
Channel channel = 1;
}
message InviteChannelMember {
uint64 channel_id = 1;
uint64 user_id = 2;
bool admin = 3;
}
message RemoveChannelMember {
uint64 channel_id = 1;
uint64 user_id = 2;
}
message SetChannelMemberAdmin {
uint64 channel_id = 1;
uint64 user_id = 2;
bool admin = 3;
}
message RenameChannel {
uint64 channel_id = 1;
string name = 2;
}
message JoinChannelBuffer {
uint64 channel_id = 1;
}
message JoinChannelBufferResponse {
uint64 buffer_id = 1;
uint32 replica_id = 2;
string base_text = 3;
repeated Operation operations = 4;
repeated Collaborator collaborators = 5;
}
message LeaveChannelBuffer {
uint64 channel_id = 1;
}
message RespondToChannelInvite {
uint64 channel_id = 1;
bool accept = 2;
}
message GetUsers {
repeated uint64 user_ids = 1;
}
@ -919,31 +1057,6 @@ enum ContactRequestResponse {
Dismiss = 3;
}
message SendChannelMessage {
uint64 channel_id = 1;
string body = 2;
Nonce nonce = 3;
}
message SendChannelMessageResponse {
ChannelMessage message = 1;
}
message ChannelMessageSent {
uint64 channel_id = 1;
ChannelMessage message = 2;
}
message GetChannelMessages {
uint64 channel_id = 1;
uint64 before_message_id = 2;
}
message GetChannelMessagesResponse {
repeated ChannelMessage messages = 1;
bool done = 2;
}
message UpdateContacts {
repeated Contact contacts = 1;
repeated uint64 remove_contacts = 2;
@ -1002,6 +1115,7 @@ message GetPrivateUserInfo {}
message GetPrivateUserInfoResponse {
string metrics_id = 1;
bool staff = 2;
repeated string flags = 3;
}
// Entities
@ -1041,6 +1155,7 @@ message View {
oneof variant {
Editor editor = 3;
ChannelView channel_view = 4;
}
message Editor {
@ -1053,6 +1168,11 @@ message View {
float scroll_x = 7;
float scroll_y = 8;
}
message ChannelView {
uint64 channel_id = 1;
Editor editor = 2;
}
}
message Collaborator {
@ -1103,7 +1223,6 @@ enum GitStatus {
Conflict = 2;
}
message BufferState {
uint64 id = 1;
optional File file = 2;
@ -1275,14 +1394,7 @@ message Nonce {
message Channel {
uint64 id = 1;
string name = 2;
}
message ChannelMessage {
uint64 id = 1;
string body = 2;
uint64 timestamp = 3;
uint64 sender_id = 4;
Nonce nonce = 5;
optional uint64 parent_id = 3;
}
message Contact {

View file

@ -171,12 +171,12 @@ impl Peer {
let this = self.clone();
let response_channels = connection_state.response_channels.clone();
let handle_io = async move {
tracing::debug!(%connection_id, "handle io future: start");
tracing::trace!(%connection_id, "handle io future: start");
let _end_connection = util::defer(|| {
response_channels.lock().take();
this.connections.write().remove(&connection_id);
tracing::debug!(%connection_id, "handle io future: end");
tracing::trace!(%connection_id, "handle io future: end");
});
// Send messages on this frequency so the connection isn't closed.
@ -188,68 +188,68 @@ impl Peer {
futures::pin_mut!(receive_timeout);
loop {
tracing::debug!(%connection_id, "outer loop iteration start");
tracing::trace!(%connection_id, "outer loop iteration start");
let read_message = reader.read().fuse();
futures::pin_mut!(read_message);
loop {
tracing::debug!(%connection_id, "inner loop iteration start");
tracing::trace!(%connection_id, "inner loop iteration start");
futures::select_biased! {
outgoing = outgoing_rx.next().fuse() => match outgoing {
Some(outgoing) => {
tracing::debug!(%connection_id, "outgoing rpc message: writing");
tracing::trace!(%connection_id, "outgoing rpc message: writing");
futures::select_biased! {
result = writer.write(outgoing).fuse() => {
tracing::debug!(%connection_id, "outgoing rpc message: done writing");
tracing::trace!(%connection_id, "outgoing rpc message: done writing");
result.context("failed to write RPC message")?;
tracing::debug!(%connection_id, "keepalive interval: resetting after sending message");
tracing::trace!(%connection_id, "keepalive interval: resetting after sending message");
keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse());
}
_ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "outgoing rpc message: writing timed out");
tracing::trace!(%connection_id, "outgoing rpc message: writing timed out");
Err(anyhow!("timed out writing message"))?;
}
}
}
None => {
tracing::debug!(%connection_id, "outgoing rpc message: channel closed");
tracing::trace!(%connection_id, "outgoing rpc message: channel closed");
return Ok(())
},
},
_ = keepalive_timer => {
tracing::debug!(%connection_id, "keepalive interval: pinging");
tracing::trace!(%connection_id, "keepalive interval: pinging");
futures::select_biased! {
result = writer.write(proto::Message::Ping).fuse() => {
tracing::debug!(%connection_id, "keepalive interval: done pinging");
tracing::trace!(%connection_id, "keepalive interval: done pinging");
result.context("failed to send keepalive")?;
tracing::debug!(%connection_id, "keepalive interval: resetting after pinging");
tracing::trace!(%connection_id, "keepalive interval: resetting after pinging");
keepalive_timer.set(create_timer(KEEPALIVE_INTERVAL).fuse());
}
_ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "keepalive interval: pinging timed out");
tracing::trace!(%connection_id, "keepalive interval: pinging timed out");
Err(anyhow!("timed out sending keepalive"))?;
}
}
}
incoming = read_message => {
let incoming = incoming.context("error reading rpc message from socket")?;
tracing::debug!(%connection_id, "incoming rpc message: received");
tracing::debug!(%connection_id, "receive timeout: resetting");
tracing::trace!(%connection_id, "incoming rpc message: received");
tracing::trace!(%connection_id, "receive timeout: resetting");
receive_timeout.set(create_timer(RECEIVE_TIMEOUT).fuse());
if let proto::Message::Envelope(incoming) = incoming {
tracing::debug!(%connection_id, "incoming rpc message: processing");
tracing::trace!(%connection_id, "incoming rpc message: processing");
futures::select_biased! {
result = incoming_tx.send(incoming).fuse() => match result {
Ok(_) => {
tracing::debug!(%connection_id, "incoming rpc message: processed");
tracing::trace!(%connection_id, "incoming rpc message: processed");
}
Err(_) => {
tracing::debug!(%connection_id, "incoming rpc message: channel closed");
tracing::trace!(%connection_id, "incoming rpc message: channel closed");
return Ok(())
}
},
_ = create_timer(WRITE_TIMEOUT).fuse() => {
tracing::debug!(%connection_id, "incoming rpc message: processing timed out");
tracing::trace!(%connection_id, "incoming rpc message: processing timed out");
Err(anyhow!("timed out processing incoming message"))?
}
}
@ -257,7 +257,7 @@ impl Peer {
break;
},
_ = receive_timeout => {
tracing::debug!(%connection_id, "receive timeout: delay between messages too long");
tracing::trace!(%connection_id, "receive timeout: delay between messages too long");
Err(anyhow!("delay between messages too long"))?
}
}
@ -274,13 +274,13 @@ impl Peer {
let response_channels = response_channels.clone();
async move {
let message_id = incoming.id;
tracing::debug!(?incoming, "incoming message future: start");
tracing::trace!(?incoming, "incoming message future: start");
let _end = util::defer(move || {
tracing::debug!(%connection_id, message_id, "incoming message future: end");
tracing::trace!(%connection_id, message_id, "incoming message future: end");
});
if let Some(responding_to) = incoming.responding_to {
tracing::debug!(
tracing::trace!(
%connection_id,
message_id,
responding_to,
@ -290,7 +290,7 @@ impl Peer {
if let Some(tx) = channel {
let requester_resumed = oneshot::channel();
if let Err(error) = tx.send((incoming, requester_resumed.0)) {
tracing::debug!(
tracing::trace!(
%connection_id,
message_id,
responding_to = responding_to,
@ -299,14 +299,14 @@ impl Peer {
);
}
tracing::debug!(
tracing::trace!(
%connection_id,
message_id,
responding_to,
"incoming response: waiting to resume requester"
);
let _ = requester_resumed.1.await;
tracing::debug!(
tracing::trace!(
%connection_id,
message_id,
responding_to,
@ -323,7 +323,7 @@ impl Peer {
None
} else {
tracing::debug!(%connection_id, message_id, "incoming message: received");
tracing::trace!(%connection_id, message_id, "incoming message: received");
proto::build_typed_envelope(connection_id, incoming).or_else(|| {
tracing::error!(
%connection_id,

View file

@ -1,3 +1,5 @@
#![allow(non_snake_case)]
use super::{entity_messages, messages, request_messages, ConnectionId, TypedEnvelope};
use anyhow::{anyhow, Result};
use async_tungstenite::tungstenite::Message as WebSocketMessage;
@ -141,9 +143,10 @@ messages!(
(Call, Foreground),
(CallCanceled, Foreground),
(CancelCall, Foreground),
(ChannelMessageSent, Foreground),
(CopyProjectEntry, Foreground),
(CreateBufferForPeer, Foreground),
(CreateChannel, Foreground),
(ChannelResponse, Foreground),
(CreateProjectEntry, Foreground),
(CreateRoom, Foreground),
(CreateRoomResponse, Foreground),
@ -156,10 +159,6 @@ messages!(
(FormatBuffers, Foreground),
(FormatBuffersResponse, Foreground),
(FuzzySearchUsers, Foreground),
(GetChannelMessages, Foreground),
(GetChannelMessagesResponse, Foreground),
(GetChannels, Foreground),
(GetChannelsResponse, Foreground),
(GetCodeActions, Background),
(GetCodeActionsResponse, Background),
(GetHover, Background),
@ -179,14 +178,12 @@ messages!(
(GetUsers, Foreground),
(Hello, Foreground),
(IncomingCall, Foreground),
(InviteChannelMember, Foreground),
(UsersResponse, Foreground),
(JoinChannel, Foreground),
(JoinChannelResponse, Foreground),
(JoinProject, Foreground),
(JoinProjectResponse, Foreground),
(JoinRoom, Foreground),
(JoinRoomResponse, Foreground),
(LeaveChannel, Foreground),
(LeaveProject, Foreground),
(LeaveRoom, Foreground),
(OpenBufferById, Background),
@ -200,6 +197,8 @@ messages!(
(OnTypeFormattingResponse, Background),
(InlayHints, Background),
(InlayHintsResponse, Background),
(ResolveInlayHint, Background),
(ResolveInlayHintResponse, Background),
(RefreshInlayHints, Foreground),
(Ping, Foreground),
(PrepareRename, Background),
@ -209,18 +208,21 @@ messages!(
(RejoinRoom, Foreground),
(RejoinRoomResponse, Foreground),
(RemoveContact, Foreground),
(RemoveChannelMember, Foreground),
(ReloadBuffers, Foreground),
(ReloadBuffersResponse, Foreground),
(RemoveProjectCollaborator, Foreground),
(RenameProjectEntry, Foreground),
(RequestContact, Foreground),
(RespondToContactRequest, Foreground),
(RespondToChannelInvite, Foreground),
(JoinChannel, Foreground),
(RoomUpdated, Foreground),
(SaveBuffer, Foreground),
(RenameChannel, Foreground),
(SetChannelMemberAdmin, Foreground),
(SearchProject, Background),
(SearchProjectResponse, Background),
(SendChannelMessage, Foreground),
(SendChannelMessageResponse, Foreground),
(ShareProject, Foreground),
(ShareProjectResponse, Foreground),
(ShowContacts, Foreground),
@ -233,6 +235,8 @@ messages!(
(UpdateBuffer, Foreground),
(UpdateBufferFile, Foreground),
(UpdateContacts, Foreground),
(RemoveChannel, Foreground),
(UpdateChannels, Foreground),
(UpdateDiagnosticSummary, Foreground),
(UpdateFollowers, Foreground),
(UpdateInviteInfo, Foreground),
@ -245,6 +249,14 @@ messages!(
(UpdateDiffBase, Foreground),
(GetPrivateUserInfo, Foreground),
(GetPrivateUserInfoResponse, Foreground),
(GetChannelMembers, Foreground),
(GetChannelMembersResponse, Foreground),
(JoinChannelBuffer, Foreground),
(JoinChannelBufferResponse, Foreground),
(LeaveChannelBuffer, Background),
(UpdateChannelBuffer, Foreground),
(RemoveChannelBufferCollaborator, Foreground),
(AddChannelBufferCollaborator, Foreground),
);
request_messages!(
@ -258,13 +270,12 @@ request_messages!(
(CopyProjectEntry, ProjectEntryResponse),
(CreateProjectEntry, ProjectEntryResponse),
(CreateRoom, CreateRoomResponse),
(CreateChannel, ChannelResponse),
(DeclineCall, Ack),
(DeleteProjectEntry, ProjectEntryResponse),
(ExpandProjectEntry, ExpandProjectEntryResponse),
(Follow, FollowResponse),
(FormatBuffers, FormatBuffersResponse),
(GetChannelMessages, GetChannelMessagesResponse),
(GetChannels, GetChannelsResponse),
(GetCodeActions, GetCodeActionsResponse),
(GetHover, GetHoverResponse),
(GetCompletions, GetCompletionsResponse),
@ -276,7 +287,7 @@ request_messages!(
(GetProjectSymbols, GetProjectSymbolsResponse),
(FuzzySearchUsers, UsersResponse),
(GetUsers, UsersResponse),
(JoinChannel, JoinChannelResponse),
(InviteChannelMember, Ack),
(JoinProject, JoinProjectResponse),
(JoinRoom, JoinRoomResponse),
(LeaveRoom, Ack),
@ -290,15 +301,22 @@ request_messages!(
(PrepareRename, PrepareRenameResponse),
(OnTypeFormatting, OnTypeFormattingResponse),
(InlayHints, InlayHintsResponse),
(ResolveInlayHint, ResolveInlayHintResponse),
(RefreshInlayHints, Ack),
(ReloadBuffers, ReloadBuffersResponse),
(RequestContact, Ack),
(RemoveChannelMember, Ack),
(RemoveContact, Ack),
(RespondToContactRequest, Ack),
(RespondToChannelInvite, Ack),
(SetChannelMemberAdmin, Ack),
(GetChannelMembers, GetChannelMembersResponse),
(JoinChannel, JoinRoomResponse),
(RemoveChannel, Ack),
(RenameProjectEntry, ProjectEntryResponse),
(RenameChannel, ChannelResponse),
(SaveBuffer, BufferSaved),
(SearchProject, SearchProjectResponse),
(SendChannelMessage, SendChannelMessageResponse),
(ShareProject, ShareProjectResponse),
(SynchronizeBuffers, SynchronizeBuffersResponse),
(Test, Test),
@ -306,6 +324,8 @@ request_messages!(
(UpdateParticipantLocation, Ack),
(UpdateProject, Ack),
(UpdateWorktree, Ack),
(JoinChannelBuffer, JoinChannelBufferResponse),
(LeaveChannelBuffer, Ack)
);
entity_messages!(
@ -338,6 +358,7 @@ entity_messages!(
PerformRename,
OnTypeFormatting,
InlayHints,
ResolveInlayHint,
RefreshInlayHints,
PrepareRename,
ReloadBuffers,
@ -361,7 +382,12 @@ entity_messages!(
UpdateDiffBase
);
entity_messages!(channel_id, ChannelMessageSent);
entity_messages!(
channel_id,
UpdateChannelBuffer,
RemoveChannelBufferCollaborator,
AddChannelBufferCollaborator
);
const KIB: usize = 1024;
const MIB: usize = KIB * 1024;

View file

@ -6,4 +6,4 @@ pub use conn::Connection;
pub use peer::*;
mod macros;
pub const PROTOCOL_VERSION: u32 = 60;
pub const PROTOCOL_VERSION: u32 = 61;