Skip to content

Commit

Permalink
Consolidate logic for protobuf message handling between ssh and web s…
Browse files Browse the repository at this point in the history
…ocket clients (zed-industries#17185)

This is a refactor to prepare for adding LSP support in SSH remote
projects.

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
  • Loading branch information
3 people authored Sep 1, 2024
1 parent 144793b commit b8e6098
Show file tree
Hide file tree
Showing 20 changed files with 1,349 additions and 1,310 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/assistant/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub fn init(
})
.detach();

context_store::init(&client);
context_store::init(&client.clone().into());
prompt_library::init(cx);
init_language_model_settings(cx);
assistant_slash_command::init(cx);
Expand Down
3 changes: 2 additions & 1 deletion crates/assistant/src/context_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
prompts::PromptBuilder, Context, ContextEvent, ContextId, ContextOperation, ContextVersion,
SavedContext, SavedContextMetadata,
};
use ::proto::AnyProtoClient;
use anyhow::{anyhow, Context as _, Result};
use client::{proto, telemetry::Telemetry, Client, TypedEnvelope};
use clock::ReplicaId;
Expand All @@ -25,7 +26,7 @@ use std::{
};
use util::{ResultExt, TryFutureExt};

pub fn init(client: &Arc<Client>) {
pub fn init(client: &AnyProtoClient) {
client.add_model_message_handler(ContextStore::handle_advertise_contexts);
client.add_model_request_handler(ContextStore::handle_open_context);
client.add_model_request_handler(ContextStore::handle_create_context);
Expand Down
4 changes: 2 additions & 2 deletions crates/channel/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ mod channel_store_tests;

pub fn init(client: &Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
channel_store::init(client, user_store, cx);
channel_buffer::init(client);
channel_chat::init(client);
channel_buffer::init(&client.clone().into());
channel_chat::init(&client.clone().into());
}
4 changes: 2 additions & 2 deletions crates/channel/src/channel_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use collections::HashMap;
use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task};
use language::proto::serialize_version;
use rpc::{
proto::{self, PeerId},
proto::{self, AnyProtoClient, PeerId},
TypedEnvelope,
};
use std::{sync::Arc, time::Duration};
Expand All @@ -14,7 +14,7 @@ use util::ResultExt;

pub const ACKNOWLEDGE_DEBOUNCE_INTERVAL: Duration = Duration::from_millis(250);

pub(crate) fn init(client: &Arc<Client>) {
pub(crate) fn init(client: &AnyProtoClient) {
client.add_model_message_handler(ChannelBuffer::handle_update_channel_buffer);
client.add_model_message_handler(ChannelBuffer::handle_update_channel_buffer_collaborators);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/channel/src/channel_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use gpui::{
AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel,
};
use rand::prelude::*;
use rpc::proto::AnyProtoClient;
use std::{
ops::{ControlFlow, Range},
sync::Arc,
Expand Down Expand Up @@ -95,7 +96,7 @@ pub enum ChannelChatEvent {
}

impl EventEmitter<ChannelChatEvent> for ChannelChat {}
pub fn init(client: &Arc<Client>) {
pub fn init(client: &AnyProtoClient) {
client.add_model_message_handler(ChannelChat::handle_message_sent);
client.add_model_message_handler(ChannelChat::handle_message_removed);
client.add_model_message_handler(ChannelChat::handle_message_updated);
Expand Down
Loading

0 comments on commit b8e6098

Please sign in to comment.