Merge branch 'zed2-room' into zed2

This commit is contained in:
Antonio Scandurra 2023-10-26 11:57:11 +02:00
commit 6172cd9015
14 changed files with 2311 additions and 27 deletions

28
Cargo.lock generated
View file

@ -1126,6 +1126,32 @@ dependencies = [
"util",
]
[[package]]
name = "call2"
version = "0.1.0"
dependencies = [
"anyhow",
"async-broadcast",
"audio2",
"client2",
"collections",
"fs",
"futures 0.3.28",
"gpui2",
"language2",
"live_kit_client",
"log",
"media",
"postage",
"project2",
"schemars",
"serde",
"serde_derive",
"serde_json",
"settings2",
"util",
]
[[package]]
name = "cap-fs-ext"
version = "0.24.4"
@ -10736,6 +10762,7 @@ dependencies = [
"async-tar",
"async-trait",
"backtrace",
"call2",
"chrono",
"cli",
"client2",
@ -10765,6 +10792,7 @@ dependencies = [
"num_cpus",
"parking_lot 0.11.2",
"postage",
"project2",
"rand 0.8.5",
"regex",
"rpc",

View file

@ -8,6 +8,7 @@ members = [
"crates/auto_update",
"crates/breadcrumbs",
"crates/call",
"crates/call2",
"crates/channel",
"crates/cli",
"crates/client",

View file

@ -78,12 +78,17 @@ impl Audio {
Self { tx }
}
pub fn play_sound(&self, sound: Sound, cx: &mut AppContext) {
pub fn play_sound(sound: Sound, cx: &mut AppContext) {
if !cx.has_global::<Self>() {
return;
}
let Some(source) = SoundRegistry::global(cx).get(sound.file()).log_err() else {
return;
};
self.tx
let this = cx.global::<Self>();
this.tx
.unbounded_send(Box::new(move |state| {
if let Some(output_handle) = state.ensure_output_exists() {
output_handle.play_raw(source).log_err();
@ -92,8 +97,14 @@ impl Audio {
.ok();
}
pub fn end_call(&self) {
self.tx
pub fn end_call(cx: &AppContext) {
if !cx.has_global::<Self>() {
return;
}
let this = cx.global::<Self>();
this.tx
.unbounded_send(Box::new(move |state| state.take()))
.ok();
}

52
crates/call2/Cargo.toml Normal file
View file

@ -0,0 +1,52 @@
[package]
name = "call2"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/call2.rs"
doctest = false
[features]
test-support = [
"client2/test-support",
"collections/test-support",
"gpui2/test-support",
"live_kit_client/test-support",
"project2/test-support",
"util/test-support"
]
[dependencies]
audio2 = { path = "../audio2" }
client2 = { path = "../client2" }
collections = { path = "../collections" }
gpui2 = { path = "../gpui2" }
log.workspace = true
live_kit_client = { path = "../live_kit_client" }
fs = { path = "../fs" }
language2 = { path = "../language2" }
media = { path = "../media" }
project2 = { path = "../project2" }
settings2 = { path = "../settings2" }
util = { path = "../util" }
anyhow.workspace = true
async-broadcast = "0.4"
futures.workspace = true
postage.workspace = true
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_derive.workspace = true
[dev-dependencies]
client2 = { path = "../client2", features = ["test-support"] }
fs = { path = "../fs", features = ["test-support"] }
language2 = { path = "../language2", features = ["test-support"] }
collections = { path = "../collections", features = ["test-support"] }
gpui2 = { path = "../gpui2", features = ["test-support"] }
live_kit_client = { path = "../live_kit_client", features = ["test-support"] }
project2 = { path = "../project2", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] }

465
crates/call2/src/call2.rs Normal file
View file

@ -0,0 +1,465 @@
pub mod call_settings;
pub mod participant;
pub mod room;
use anyhow::{anyhow, Result};
use audio2::Audio;
use call_settings::CallSettings;
use client2::{
proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore,
ZED_ALWAYS_ACTIVE,
};
use collections::HashSet;
use futures::{future::Shared, FutureExt};
use gpui2::{
AppContext, AsyncAppContext, Context, EventEmitter, Handle, ModelContext, Subscription, Task,
WeakHandle,
};
use postage::watch;
use project2::Project;
use settings2::Settings;
use std::sync::Arc;
pub use participant::ParticipantLocation;
pub use room::Room;
pub fn init(client: Arc<Client>, user_store: Handle<UserStore>, cx: &mut AppContext) {
CallSettings::register(cx);
let active_call = cx.entity(|cx| ActiveCall::new(client, user_store, cx));
cx.set_global(active_call);
}
#[derive(Clone)]
pub struct IncomingCall {
pub room_id: u64,
pub calling_user: Arc<User>,
pub participants: Vec<Arc<User>>,
pub initial_project: Option<proto::ParticipantProject>,
}
/// Singleton global maintaining the user's participation in a room across workspaces.
pub struct ActiveCall {
room: Option<(Handle<Room>, Vec<Subscription>)>,
pending_room_creation: Option<Shared<Task<Result<Handle<Room>, Arc<anyhow::Error>>>>>,
location: Option<WeakHandle<Project>>,
pending_invites: HashSet<u64>,
incoming_call: (
watch::Sender<Option<IncomingCall>>,
watch::Receiver<Option<IncomingCall>>,
),
client: Arc<Client>,
user_store: Handle<UserStore>,
_subscriptions: Vec<client2::Subscription>,
}
impl EventEmitter for ActiveCall {
type Event = room::Event;
}
impl ActiveCall {
fn new(
client: Arc<Client>,
user_store: Handle<UserStore>,
cx: &mut ModelContext<Self>,
) -> Self {
Self {
room: None,
pending_room_creation: None,
location: None,
pending_invites: Default::default(),
incoming_call: watch::channel(),
_subscriptions: vec![
client.add_request_handler(cx.weak_handle(), Self::handle_incoming_call),
client.add_message_handler(cx.weak_handle(), Self::handle_call_canceled),
],
client,
user_store,
}
}
pub fn channel_id(&self, cx: &AppContext) -> Option<u64> {
self.room()?.read(cx).channel_id()
}
async fn handle_incoming_call(
this: Handle<Self>,
envelope: TypedEnvelope<proto::IncomingCall>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<proto::Ack> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let call = IncomingCall {
room_id: envelope.payload.room_id,
participants: user_store
.update(&mut cx, |user_store, cx| {
user_store.get_users(envelope.payload.participant_user_ids, cx)
})?
.await?,
calling_user: user_store
.update(&mut cx, |user_store, cx| {
user_store.get_user(envelope.payload.calling_user_id, cx)
})?
.await?,
initial_project: envelope.payload.initial_project,
};
this.update(&mut cx, |this, _| {
*this.incoming_call.0.borrow_mut() = Some(call);
})?;
Ok(proto::Ack {})
}
async fn handle_call_canceled(
this: Handle<Self>,
envelope: TypedEnvelope<proto::CallCanceled>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |this, _| {
let mut incoming_call = this.incoming_call.0.borrow_mut();
if incoming_call
.as_ref()
.map_or(false, |call| call.room_id == envelope.payload.room_id)
{
incoming_call.take();
}
})?;
Ok(())
}
pub fn global(cx: &AppContext) -> Handle<Self> {
cx.global::<Handle<Self>>().clone()
}
pub fn invite(
&mut self,
called_user_id: u64,
initial_project: Option<Handle<Project>>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
if !self.pending_invites.insert(called_user_id) {
return Task::ready(Err(anyhow!("user was already invited")));
}
cx.notify();
let room = if let Some(room) = self.room().cloned() {
Some(Task::ready(Ok(room)).shared())
} else {
self.pending_room_creation.clone()
};
let invite = if let Some(room) = room {
cx.spawn(move |_, mut cx| async move {
let room = room.await.map_err(|err| anyhow!("{:?}", err))?;
let initial_project_id = if let Some(initial_project) = initial_project {
Some(
room.update(&mut cx, |room, cx| room.share_project(initial_project, cx))?
.await?,
)
} else {
None
};
room.update(&mut cx, move |room, cx| {
room.call(called_user_id, initial_project_id, cx)
})?
.await?;
anyhow::Ok(())
})
} else {
let client = self.client.clone();
let user_store = self.user_store.clone();
let room = cx
.spawn(move |this, mut cx| async move {
let create_room = async {
let room = cx
.update(|cx| {
Room::create(
called_user_id,
initial_project,
client,
user_store,
cx,
)
})?
.await?;
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx))?
.await?;
anyhow::Ok(room)
};
let room = create_room.await;
this.update(&mut cx, |this, _| this.pending_room_creation = None)?;
room.map_err(Arc::new)
})
.shared();
self.pending_room_creation = Some(room.clone());
cx.executor().spawn(async move {
room.await.map_err(|err| anyhow!("{:?}", err))?;
anyhow::Ok(())
})
};
cx.spawn(move |this, mut cx| async move {
let result = invite.await;
if result.is_ok() {
this.update(&mut cx, |this, cx| this.report_call_event("invite", cx))?;
} else {
// TODO: Resport collaboration error
}
this.update(&mut cx, |this, cx| {
this.pending_invites.remove(&called_user_id);
cx.notify();
})?;
result
})
}
pub fn cancel_invite(
&mut self,
called_user_id: u64,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
let room_id = if let Some(room) = self.room() {
room.read(cx).id()
} else {
return Task::ready(Err(anyhow!("no active call")));
};
let client = self.client.clone();
cx.executor().spawn(async move {
client
.request(proto::CancelCall {
room_id,
called_user_id,
})
.await?;
anyhow::Ok(())
})
}
pub fn incoming(&self) -> watch::Receiver<Option<IncomingCall>> {
self.incoming_call.1.clone()
}
pub fn accept_incoming(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
if self.room.is_some() {
return Task::ready(Err(anyhow!("cannot join while on another call")));
}
let call = if let Some(call) = self.incoming_call.1.borrow().clone() {
call
} else {
return Task::ready(Err(anyhow!("no incoming call")));
};
let join = Room::join(&call, self.client.clone(), self.user_store.clone(), cx);
cx.spawn(|this, mut cx| async move {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.report_call_event("accept incoming", cx)
})?;
Ok(())
})
}
pub fn decline_incoming(&mut self, cx: &mut ModelContext<Self>) -> Result<()> {
let call = self
.incoming_call
.0
.borrow_mut()
.take()
.ok_or_else(|| anyhow!("no incoming call"))?;
report_call_event_for_room("decline incoming", call.room_id, None, &self.client, cx);
self.client.send(proto::DeclineCall {
room_id: call.room_id,
})?;
Ok(())
}
pub fn join_channel(
&mut self,
channel_id: u64,
cx: &mut ModelContext<Self>,
) -> Task<Result<Handle<Room>>> {
if let Some(room) = self.room().cloned() {
if room.read(cx).channel_id() == Some(channel_id) {
return Task::ready(Ok(room));
} else {
room.update(cx, |room, cx| room.clear_state(cx));
}
}
let join = Room::join_channel(channel_id, self.client.clone(), self.user_store.clone(), cx);
cx.spawn(|this, mut cx| async move {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.report_call_event("join channel", cx)
})?;
Ok(room)
})
}
pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
cx.notify();
self.report_call_event("hang up", cx);
Audio::end_call(cx);
if let Some((room, _)) = self.room.take() {
room.update(cx, |room, cx| room.leave(cx))
} else {
Task::ready(Ok(()))
}
}
pub fn share_project(
&mut self,
project: Handle<Project>,
cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> {
if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("share project", cx);
room.update(cx, |room, cx| room.share_project(project, cx))
} else {
Task::ready(Err(anyhow!("no active call")))
}
}
pub fn unshare_project(
&mut self,
project: Handle<Project>,
cx: &mut ModelContext<Self>,
) -> Result<()> {
if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("unshare project", cx);
room.update(cx, |room, cx| room.unshare_project(project, cx))
} else {
Err(anyhow!("no active call"))
}
}
pub fn location(&self) -> Option<&WeakHandle<Project>> {
self.location.as_ref()
}
pub fn set_location(
&mut self,
project: Option<&Handle<Project>>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
if project.is_some() || !*ZED_ALWAYS_ACTIVE {
self.location = project.map(|project| project.downgrade());
if let Some((room, _)) = self.room.as_ref() {
return room.update(cx, |room, cx| room.set_location(project, cx));
}
}
Task::ready(Ok(()))
}
fn set_room(
&mut self,
room: Option<Handle<Room>>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
if room.as_ref() != self.room.as_ref().map(|room| &room.0) {
cx.notify();
if let Some(room) = room {
if room.read(cx).status().is_offline() {
self.room = None;
Task::ready(Ok(()))
} else {
let subscriptions = vec![
cx.observe(&room, |this, room, cx| {
if room.read(cx).status().is_offline() {
this.set_room(None, cx).detach_and_log_err(cx);
}
cx.notify();
}),
cx.subscribe(&room, |_, _, event, cx| cx.emit(event.clone())),
];
self.room = Some((room.clone(), subscriptions));
let location = self
.location
.as_ref()
.and_then(|location| location.upgrade());
room.update(cx, |room, cx| room.set_location(location.as_ref(), cx))
}
} else {
self.room = None;
Task::ready(Ok(()))
}
} else {
Task::ready(Ok(()))
}
}
pub fn room(&self) -> Option<&Handle<Room>> {
self.room.as_ref().map(|(room, _)| room)
}
pub fn client(&self) -> Arc<Client> {
self.client.clone()
}
pub fn pending_invites(&self) -> &HashSet<u64> {
&self.pending_invites
}
pub fn report_call_event(&self, operation: &'static str, cx: &AppContext) {
if let Some(room) = self.room() {
let room = room.read(cx);
report_call_event_for_room(operation, room.id(), room.channel_id(), &self.client, cx);
}
}
}
pub fn report_call_event_for_room(
operation: &'static str,
room_id: u64,
channel_id: Option<u64>,
client: &Arc<Client>,
cx: &AppContext,
) {
let telemetry = client.telemetry();
let telemetry_settings = *TelemetrySettings::get_global(cx);
let event = ClickhouseEvent::Call {
operation,
room_id: Some(room_id),
channel_id,
};
telemetry.report_clickhouse_event(event, telemetry_settings);
}
pub fn report_call_event_for_channel(
operation: &'static str,
channel_id: u64,
client: &Arc<Client>,
cx: &AppContext,
) {
let room = ActiveCall::global(cx).read(cx).room();
let telemetry = client.telemetry();
let telemetry_settings = *TelemetrySettings::get_global(cx);
let event = ClickhouseEvent::Call {
operation,
room_id: room.map(|r| r.read(cx).id()),
channel_id: Some(channel_id),
};
telemetry.report_clickhouse_event(event, telemetry_settings);
}

View file

@ -0,0 +1,32 @@
use anyhow::Result;
use gpui2::AppContext;
use schemars::JsonSchema;
use serde_derive::{Deserialize, Serialize};
use settings2::Settings;
#[derive(Deserialize, Debug)]
pub struct CallSettings {
pub mute_on_join: bool,
}
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
pub struct CallSettingsContent {
pub mute_on_join: Option<bool>,
}
impl Settings for CallSettings {
const KEY: Option<&'static str> = Some("calls");
type FileContent = CallSettingsContent;
fn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
_cx: &mut AppContext,
) -> Result<Self>
where
Self: Sized,
{
Self::load_via_json_merge(default_value, user_values)
}
}

View file

@ -0,0 +1,69 @@
use anyhow::{anyhow, Result};
use client2::ParticipantIndex;
use client2::{proto, User};
use collections::HashMap;
use gpui2::WeakHandle;
pub use live_kit_client::Frame;
use live_kit_client::RemoteAudioTrack;
use project2::Project;
use std::{fmt, sync::Arc};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ParticipantLocation {
SharedProject { project_id: u64 },
UnsharedProject,
External,
}
impl ParticipantLocation {
pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
match location.and_then(|l| l.variant) {
Some(proto::participant_location::Variant::SharedProject(project)) => {
Ok(Self::SharedProject {
project_id: project.id,
})
}
Some(proto::participant_location::Variant::UnsharedProject(_)) => {
Ok(Self::UnsharedProject)
}
Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
None => Err(anyhow!("participant location was not provided")),
}
}
}
#[derive(Clone, Default)]
pub struct LocalParticipant {
pub projects: Vec<proto::ParticipantProject>,
pub active_project: Option<WeakHandle<Project>>,
}
#[derive(Clone, Debug)]
pub struct RemoteParticipant {
pub user: Arc<User>,
pub peer_id: proto::PeerId,
pub projects: Vec<proto::ParticipantProject>,
pub location: ParticipantLocation,
pub participant_index: ParticipantIndex,
pub muted: bool,
pub speaking: bool,
pub video_tracks: HashMap<live_kit_client::Sid, Arc<RemoteVideoTrack>>,
pub audio_tracks: HashMap<live_kit_client::Sid, Arc<RemoteAudioTrack>>,
}
#[derive(Clone)]
pub struct RemoteVideoTrack {
pub(crate) live_kit_track: Arc<live_kit_client::RemoteVideoTrack>,
}
impl fmt::Debug for RemoteVideoTrack {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RemoteVideoTrack").finish()
}
}
impl RemoteVideoTrack {
pub fn frames(&self) -> async_broadcast::Receiver<Frame> {
self.live_kit_track.frames()
}
}

1605
crates/call2/src/room.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -323,6 +323,12 @@ impl<T> PartialEq for Handle<T> {
impl<T> Eq for Handle<T> {}
impl<T> PartialEq<WeakHandle<T>> for Handle<T> {
fn eq(&self, other: &WeakHandle<T>) -> bool {
self.entity_id() == other.entity_id()
}
}
#[derive(Clone)]
pub struct AnyWeakHandle {
pub(crate) entity_id: EntityId,
@ -444,3 +450,9 @@ impl<T> PartialEq for WeakHandle<T> {
}
impl<T> Eq for WeakHandle<T> {}
impl<T> PartialEq<Handle<T>> for WeakHandle<T> {
fn eq(&self, other: &Handle<T>) -> bool {
self.entity_id() == other.entity_id()
}
}

View file

@ -150,6 +150,10 @@ pub struct Room {
_delegate: RoomDelegate,
}
// SAFETY: LiveKit objects are thread-safe: https://github.com/livekit/client-sdk-swift#thread-safety
unsafe impl Send for Room {}
unsafe impl Sync for Room {}
impl Room {
pub fn new() -> Arc<Self> {
Arc::new_cyclic(|weak_room| {

View file

@ -58,7 +58,7 @@ use project_settings::{LspSettings, ProjectSettings};
use rand::prelude::*;
use search::SearchQuery;
use serde::Serialize;
use settings2::{SettingsStore, Settings};
use settings2::{Settings, SettingsStore};
use sha2::{Digest, Sha256};
use similar::{ChangeTag, TextDiff};
use smol::channel::{Receiver, Sender};

View file

@ -19,7 +19,7 @@ path = "src/main.rs"
# activity_indicator = { path = "../activity_indicator" }
# auto_update = { path = "../auto_update" }
# breadcrumbs = { path = "../breadcrumbs" }
# call = { path = "../call" }
call2 = { path = "../call2" }
# channel = { path = "../channel" }
cli = { path = "../cli" }
# collab_ui = { path = "../collab_ui" }
@ -52,7 +52,7 @@ node_runtime = { path = "../node_runtime" }
# assistant = { path = "../assistant" }
# outline = { path = "../outline" }
# plugin_runtime = { path = "../plugin_runtime",optional = true }
# project = { path = "../project" }
project2 = { path = "../project2" }
# project_panel = { path = "../project_panel" }
# project_symbols = { path = "../project_symbols" }
# quick_action_bar = { path = "../quick_action_bar" }
@ -140,14 +140,14 @@ urlencoding = "2.1.2"
uuid.workspace = true
[dev-dependencies]
# call = { path = "../call", features = ["test-support"] }
call2 = { path = "../call2", features = ["test-support"] }
# client = { path = "../client", features = ["test-support"] }
# editor = { path = "../editor", features = ["test-support"] }
# gpui = { path = "../gpui", features = ["test-support"] }
gpui2 = { path = "../gpui2", features = ["test-support"] }
# language = { path = "../language", features = ["test-support"] }
language2 = { path = "../language2", features = ["test-support"] }
# lsp = { path = "../lsp", features = ["test-support"] }
# project = { path = "../project", features = ["test-support"] }
project2 = { path = "../project2", features = ["test-support"] }
# rpc = { path = "../rpc", features = ["test-support"] }
# settings = { path = "../settings", features = ["test-support"] }
# text = { path = "../text", features = ["test-support"] }

View file

@ -2,16 +2,17 @@
#![allow(non_snake_case)]
use crate::open_listener::{OpenListener, OpenRequest};
use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, Context as _, Result};
use backtrace::Backtrace;
use cli::{
ipc::{self, IpcSender},
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
};
use client2::UserStore;
use db2::kvp::KEY_VALUE_STORE;
use fs2::RealFs;
use futures::{channel::mpsc, SinkExt, StreamExt};
use gpui2::{App, AppContext, AsyncAppContext, SemanticVersion, Task};
use gpui2::{App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
use isahc::{prelude::Configurable, Request};
use language2::LanguageRegistry;
use log::LevelFilter;
@ -111,26 +112,26 @@ fn main() {
handle_settings_file_changes(user_settings_file_rx, cx);
// handle_keymap_file_changes(user_keymap_file_rx, cx);
// let client = client2::Client::new(http.clone(), cx);
let languages = LanguageRegistry::new(login_shell_env_loaded);
let client = client2::Client::new(http.clone(), cx);
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
let copilot_language_server_id = languages.next_language_server_id();
// languages.set_executor(cx.background().clone());
// languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
// let languages = Arc::new(languages);
languages.set_executor(cx.executor().clone());
languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
let languages = Arc::new(languages);
let node_runtime = RealNodeRuntime::new(http.clone());
// languages::init(languages.clone(), node_runtime.clone(), cx);
// let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
language2::init(cx);
let user_store = cx.entity(|cx| UserStore::new(client.clone(), http.clone(), cx));
// let workspace_store = cx.add_model(|cx| WorkspaceStore::new(client.clone(), cx));
// cx.set_global(client.clone());
cx.set_global(client.clone());
theme2::init(cx);
// context_menu::init(cx);
// project::Project::init(&client, cx);
// client::init(&client, cx);
project2::Project::init(&client, cx);
client2::init(&client, cx);
// command_palette::init(cx);
// language::init(cx);
language2::init(cx);
// editor::init(cx);
// go_to_line::init(cx);
// file_finder::init(cx);
@ -167,7 +168,7 @@ fn main() {
// client.telemetry().start(installation_id, session_id, cx);
// todo!("app_state")
let app_state = Arc::new(AppState);
let app_state = Arc::new(AppState { client, user_store });
// let app_state = Arc::new(AppState {
// languages,
// client: client.clone(),
@ -193,7 +194,7 @@ fn main() {
// theme_selector::init(cx);
// activity_indicator::init(cx);
// language_tools::init(cx);
// call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
call2::init(app_state.client.clone(), app_state.user_store.clone(), cx);
// collab_ui::init(&app_state, cx);
// feedback::init(cx);
// welcome::init(cx);

View file

@ -3,7 +3,8 @@ mod only_instance;
mod open_listener;
pub use assets::*;
use gpui2::AsyncAppContext;
use client2::{Client, UserStore};
use gpui2::{AsyncAppContext, Handle};
pub use only_instance::*;
pub use open_listener::*;
@ -44,7 +45,10 @@ pub fn connect_to_cli(
Ok((async_request_rx, response_tx))
}
pub struct AppState;
pub struct AppState {
pub client: Arc<Client>,
pub user_store: Handle<UserStore>,
}
pub async fn handle_cli_connection(
(mut requests, _responses): (mpsc::Receiver<CliRequest>, IpcSender<CliResponse>),