Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Simplify livekit config so that cargo check Just Works (#21661)
Mikayla Makide939e718a7f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 46e7ab7d516..8a191303242 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -129,8 +129,9 @@ jobs:run: |cargo build --workspace --bins --all-featurescargo check -p gpui --features "macos-blade"- cargo check -p workspace --features "livekit-cross-platform"+ cargo check -p workspacecargo build -p remote_server+ script/check-rust-livekit-macoslinux_tests:timeout-minutes: 60@@ -162,8 +163,10 @@ jobs:- name: Run testsuses: ./.github/actions/run_tests- - name: Build Zed- run: cargo build -p zed+ - name: Build other binaries and features+ run: |+ cargo build -p zed+ cargo check -p workspacebuild_remote_server:timeout-minutes: 60diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.tomlindex e7bc8b44a30..9ba10e56ba3 100644--- a/crates/call/Cargo.toml+++ b/crates/call/Cargo.toml@@ -21,8 +21,6 @@ test-support = ["project/test-support","util/test-support"]-livekit-macos = ["livekit_client_macos"]-livekit-cross-platform = ["livekit_client"][dependencies]anyhow.workspace = true@@ -42,8 +40,12 @@ serde.workspace = trueserde_derive.workspace = truesettings.workspace = trueutil.workspace = true-livekit_client_macos = { workspace = true, optional = true }-livekit_client = { workspace = true, optional = true }++[target.'cfg(target_os = "macos")'.dependencies]+livekit_client_macos = { workspace = true }++[target.'cfg(not(target_os = "macos"))'.dependencies]+livekit_client = { workspace = true }[dev-dependencies]client = { workspace = true, features = ["test-support"] }diff --git a/crates/call/src/call.rs b/crates/call/src/call.rsindex 9fdce4b8ba8..5e212d35b7c 100644--- a/crates/call/src/call.rs+++ b/crates/call/src/call.rs@@ -1,41 +1,13 @@pub mod call_settings;-#[cfg(any(- all(target_os = "macos", feature = "livekit-macos"),- all(- not(target_os = "macos"),- feature = "livekit-macos",- not(feature = "livekit-cross-platform")- )-))]+#[cfg(target_os = "macos")]mod macos;-#[cfg(any(- all(target_os = "macos", feature = "livekit-macos"),- all(- not(target_os = "macos"),- feature = "livekit-macos",- not(feature = "livekit-cross-platform")- )-))]+#[cfg(target_os = "macos")]pub use macos::*;-#[cfg(any(- all(- target_os = "macos",- feature = "livekit-cross-platform",- not(feature = "livekit-macos"),- ),- all(not(target_os = "macos"), feature = "livekit-cross-platform"),-))]+#[cfg(not(target_os = "macos"))]mod cross_platform;-#[cfg(any(- all(- target_os = "macos",- feature = "livekit-cross-platform",- not(feature = "livekit-macos"),- ),- all(not(target_os = "macos"), feature = "livekit-cross-platform"),-))]+#[cfg(not(target_os = "macos"))]pub use cross_platform::*;diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.tomlindex be2dfb06bdb..3b17ed8dabd 100644--- a/crates/workspace/Cargo.toml+++ b/crates/workspace/Cargo.toml@@ -24,8 +24,6 @@ test-support = ["gpui/test-support","fs/test-support",]-livekit-macos = ["call/livekit-macos"]-livekit-cross-platform = ["call/livekit-cross-platform"][dependencies]anyhow.workspace = truediff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rsindex f7a1ccf760b..1d17cfa1455 100644--- a/crates/workspace/src/shared_screen.rs+++ b/crates/workspace/src/shared_screen.rs@@ -1,282 +1,11 @@-#[cfg(any(- all(- target_os = "macos",- feature = "livekit-cross-platform",- not(feature = "livekit-macos"),- ),- all(not(target_os = "macos"), feature = "livekit-cross-platform"),-))]-mod cross_platform {- use crate::{- item::{Item, ItemEvent},- ItemNavHistory, WorkspaceId,- };- use call::{RemoteVideoTrack, RemoteVideoTrackView};- use client::{proto::PeerId, User};- use gpui::{- div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,- ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext,- WindowContext,- };- use std::sync::Arc;- use ui::{prelude::*, Icon, IconName};+#[cfg(target_os = "macos")]+mod macos;- pub enum Event {- Close,- }-- pub struct SharedScreen {- pub peer_id: PeerId,- user: Arc<User>,- nav_history: Option<ItemNavHistory>,- view: View<RemoteVideoTrackView>,- focus: FocusHandle,- }-- impl SharedScreen {- pub fn new(- track: RemoteVideoTrack,- peer_id: PeerId,- user: Arc<User>,- cx: &mut ViewContext<Self>,- ) -> Self {- let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx));- cx.subscribe(&view, |_, _, ev, cx| match ev {- call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),- })- .detach();- Self {- view,- peer_id,- user,- nav_history: Default::default(),- focus: cx.focus_handle(),- }- }- }-- impl EventEmitter<Event> for SharedScreen {}-- impl FocusableView for SharedScreen {- fn focus_handle(&self, _: &AppContext) -> FocusHandle {- self.focus.clone()- }- }- impl Render for SharedScreen {- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {- div()- .bg(cx.theme().colors().editor_background)- .track_focus(&self.focus)- .key_context("SharedScreen")- .size_full()- .child(self.view.clone())- }- }-- impl Item for SharedScreen {- type Event = Event;-- fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {- Some(format!("{}'s screen", self.user.github_login).into())- }-- fn deactivated(&mut self, cx: &mut ViewContext<Self>) {- if let Some(nav_history) = self.nav_history.as_mut() {- nav_history.push::<()>(None, cx);- }- }-- fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {- Some(Icon::new(IconName::Screen))- }-- fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {- Some(format!("{}'s screen", self.user.github_login).into())- }-- fn telemetry_event_text(&self) -> Option<&'static str> {- None- }-- fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {- self.nav_history = Some(history);- }-- fn clone_on_split(- &self,- _workspace_id: Option<WorkspaceId>,- cx: &mut ViewContext<Self>,- ) -> Option<View<Self>> {- Some(cx.new_view(|cx| Self {- view: self.view.update(cx, |view, cx| view.clone(cx)),- peer_id: self.peer_id,- user: self.user.clone(),- nav_history: Default::default(),- focus: cx.focus_handle(),- }))- }+#[cfg(target_os = "macos")]+pub use macos::*;- fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {- match event {- Event::Close => f(ItemEvent::CloseItem),- }- }- }-}+#[cfg(not(target_os = "macos"))]+mod cross_platform;-#[cfg(any(- all(- target_os = "macos",- feature = "livekit-cross-platform",- not(feature = "livekit-macos"),- ),- all(not(target_os = "macos"), feature = "livekit-cross-platform"),-))]+#[cfg(not(target_os = "macos"))]pub use cross_platform::*;--#[cfg(any(- all(target_os = "macos", feature = "livekit-macos"),- all(- not(target_os = "macos"),- feature = "livekit-macos",- not(feature = "livekit-cross-platform")- )-))]-mod macos {- use crate::{- item::{Item, ItemEvent},- ItemNavHistory, WorkspaceId,- };- use anyhow::Result;- use call::participant::{Frame, RemoteVideoTrack};- use client::{proto::PeerId, User};- use futures::StreamExt;- use gpui::{- div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,- ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext,- WindowContext,- };- use std::sync::{Arc, Weak};- use ui::{prelude::*, Icon, IconName};-- pub enum Event {- Close,- }-- pub struct SharedScreen {- track: Weak<RemoteVideoTrack>,- frame: Option<Frame>,- pub peer_id: PeerId,- user: Arc<User>,- nav_history: Option<ItemNavHistory>,- _maintain_frame: Task<Result<()>>,- focus: FocusHandle,- }-- impl SharedScreen {- pub fn new(- track: Arc<RemoteVideoTrack>,- peer_id: PeerId,- user: Arc<User>,- cx: &mut ViewContext<Self>,- ) -> Self {- cx.focus_handle();- let mut frames = track.frames();- Self {- track: Arc::downgrade(&track),- frame: None,- peer_id,- user,- nav_history: Default::default(),- _maintain_frame: cx.spawn(|this, mut cx| async move {- while let Some(frame) = frames.next().await {- this.update(&mut cx, |this, cx| {- this.frame = Some(frame);- cx.notify();- })?;- }- this.update(&mut cx, |_, cx| cx.emit(Event::Close))?;- Ok(())- }),- focus: cx.focus_handle(),- }- }- }-- impl EventEmitter<Event> for SharedScreen {}-- impl FocusableView for SharedScreen {- fn focus_handle(&self, _: &AppContext) -> FocusHandle {- self.focus.clone()- }- }- impl Render for SharedScreen {- fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {- div()- .bg(cx.theme().colors().editor_background)- .track_focus(&self.focus)- .key_context("SharedScreen")- .size_full()- .children(- self.frame- .as_ref()- .map(|frame| surface(frame.image()).size_full()),- )- }- }-- impl Item for SharedScreen {- type Event = Event;-- fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {- Some(format!("{}'s screen", self.user.github_login).into())- }-- fn deactivated(&mut self, cx: &mut ViewContext<Self>) {- if let Some(nav_history) = self.nav_history.as_mut() {- nav_history.push::<()>(None, cx);- }- }-- fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {- Some(Icon::new(IconName::Screen))- }-- fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {- Some(format!("{}'s screen", self.user.github_login).into())- }-- fn telemetry_event_text(&self) -> Option<&'static str> {- None- }-- fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {- self.nav_history = Some(history);- }-- fn clone_on_split(- &self,- _workspace_id: Option<WorkspaceId>,- cx: &mut ViewContext<Self>,- ) -> Option<View<Self>> {- let track = self.track.upgrade()?;- Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx)))- }-- fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {- match event {- Event::Close => f(ItemEvent::CloseItem),- }- }- }-}--#[cfg(any(- all(target_os = "macos", feature = "livekit-macos"),- all(- not(target_os = "macos"),- feature = "livekit-macos",- not(feature = "livekit-cross-platform")- )-))]-pub use macos::*;diff --git a/crates/workspace/src/shared_screen/cross_platform.rs b/crates/workspace/src/shared_screen/cross_platform.rsnew file mode 100644index 00000000000..285946cce07--- /dev/null+++ b/crates/workspace/src/shared_screen/cross_platform.rs@@ -0,0 +1,114 @@+use crate::{+ item::{Item, ItemEvent},+ ItemNavHistory, WorkspaceId,+};+use call::{RemoteVideoTrack, RemoteVideoTrackView};+use client::{proto::PeerId, User};+use gpui::{+ div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ParentElement,+ Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext,+};+use std::sync::Arc;+use ui::{prelude::*, Icon, IconName};++pub enum Event {+ Close,+}++pub struct SharedScreen {+ pub peer_id: PeerId,+ user: Arc<User>,+ nav_history: Option<ItemNavHistory>,+ view: View<RemoteVideoTrackView>,+ focus: FocusHandle,+}++impl SharedScreen {+ pub fn new(+ track: RemoteVideoTrack,+ peer_id: PeerId,+ user: Arc<User>,+ cx: &mut ViewContext<Self>,+ ) -> Self {+ let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx));+ cx.subscribe(&view, |_, _, ev, cx| match ev {+ call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),+ })+ .detach();+ Self {+ view,+ peer_id,+ user,+ nav_history: Default::default(),+ focus: cx.focus_handle(),+ }+ }+}++impl EventEmitter<Event> for SharedScreen {}++impl FocusableView for SharedScreen {+ fn focus_handle(&self, _: &AppContext) -> FocusHandle {+ self.focus.clone()+ }+}+impl Render for SharedScreen {+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {+ div()+ .bg(cx.theme().colors().editor_background)+ .track_focus(&self.focus)+ .key_context("SharedScreen")+ .size_full()+ .child(self.view.clone())+ }+}++impl Item for SharedScreen {+ type Event = Event;++ fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {+ Some(format!("{}'s screen", self.user.github_login).into())+ }++ fn deactivated(&mut self, cx: &mut ViewContext<Self>) {+ if let Some(nav_history) = self.nav_history.as_mut() {+ nav_history.push::<()>(None, cx);+ }+ }++ fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {+ Some(Icon::new(IconName::Screen))+ }++ fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {+ Some(format!("{}'s screen", self.user.github_login).into())+ }++ fn telemetry_event_text(&self) -> Option<&'static str> {+ None+ }++ fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {+ self.nav_history = Some(history);+ }++ fn clone_on_split(+ &self,+ _workspace_id: Option<WorkspaceId>,+ cx: &mut ViewContext<Self>,+ ) -> Option<View<Self>> {+ Some(cx.new_view(|cx| Self {+ view: self.view.update(cx, |view, cx| view.clone(cx)),+ peer_id: self.peer_id,+ user: self.user.clone(),+ nav_history: Default::default(),+ focus: cx.focus_handle(),+ }))+ }++ fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {+ match event {+ Event::Close => f(ItemEvent::CloseItem),+ }+ }+}diff --git a/crates/workspace/src/shared_screen/macos.rs b/crates/workspace/src/shared_screen/macos.rsnew file mode 100644index 00000000000..ad0b4c42754--- /dev/null+++ b/crates/workspace/src/shared_screen/macos.rs@@ -0,0 +1,126 @@+use crate::{+ item::{Item, ItemEvent},+ ItemNavHistory, WorkspaceId,+};+use anyhow::Result;+use call::participant::{Frame, RemoteVideoTrack};+use client::{proto::PeerId, User};+use futures::StreamExt;+use gpui::{+ div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement,+ ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext,+ WindowContext,+};+use std::sync::{Arc, Weak};+use ui::{prelude::*, Icon, IconName};++pub enum Event {+ Close,+}++pub struct SharedScreen {+ track: Weak<RemoteVideoTrack>,+ frame: Option<Frame>,+ pub peer_id: PeerId,+ user: Arc<User>,+ nav_history: Option<ItemNavHistory>,+ _maintain_frame: Task<Result<()>>,+ focus: FocusHandle,+}++impl SharedScreen {+ pub fn new(+ track: Arc<RemoteVideoTrack>,+ peer_id: PeerId,+ user: Arc<User>,+ cx: &mut ViewContext<Self>,+ ) -> Self {+ cx.focus_handle();+ let mut frames = track.frames();+ Self {+ track: Arc::downgrade(&track),+ frame: None,+ peer_id,+ user,+ nav_history: Default::default(),+ _maintain_frame: cx.spawn(|this, mut cx| async move {+ while let Some(frame) = frames.next().await {+ this.update(&mut cx, |this, cx| {+ this.frame = Some(frame);+ cx.notify();+ })?;+ }+ this.update(&mut cx, |_, cx| cx.emit(Event::Close))?;+ Ok(())+ }),+ focus: cx.focus_handle(),+ }+ }+}++impl EventEmitter<Event> for SharedScreen {}++impl FocusableView for SharedScreen {+ fn focus_handle(&self, _: &AppContext) -> FocusHandle {+ self.focus.clone()+ }+}+impl Render for SharedScreen {+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {+ div()+ .bg(cx.theme().colors().editor_background)+ .track_focus(&self.focus)+ .key_context("SharedScreen")+ .size_full()+ .children(+ self.frame+ .as_ref()+ .map(|frame| surface(frame.image()).size_full()),+ )+ }+}++impl Item for SharedScreen {+ type Event = Event;++ fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {+ Some(format!("{}'s screen", self.user.github_login).into())+ }++ fn deactivated(&mut self, cx: &mut ViewContext<Self>) {+ if let Some(nav_history) = self.nav_history.as_mut() {+ nav_history.push::<()>(None, cx);+ }+ }++ fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {+ Some(Icon::new(IconName::Screen))+ }++ fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> {+ Some(format!("{}'s screen", self.user.github_login).into())+ }++ fn telemetry_event_text(&self) -> Option<&'static str> {+ None+ }++ fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {+ self.nav_history = Some(history);+ }++ fn clone_on_split(+ &self,+ _workspace_id: Option<WorkspaceId>,+ cx: &mut ViewContext<Self>,+ ) -> Option<View<Self>> {+ let track = self.track.upgrade()?;+ Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx)))+ }++ fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) {+ match event {+ Event::Close => f(ItemEvent::CloseItem),+ }+ }+}diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex 9a672757a68..2220cc7be09 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -127,12 +127,6 @@ welcome.workspace = trueworkspace.workspace = truezed_actions.workspace = true-[target.'cfg(target_os = "macos")'.dependencies]-workspace = { workspace = true, features = ["livekit-macos"] }--[target.'cfg(not(target_os = "macos"))'.dependencies]-workspace = { workspace = true, features = ["livekit-cross-platform"] }-[target.'cfg(target_os = "windows")'.dependencies]windows.workspace = truediff --git a/script/check-rust-livekit-macos b/script/check-rust-livekit-macosnew file mode 100755index 00000000000..e2d0f9cf62d--- /dev/null+++ b/script/check-rust-livekit-macos@@ -0,0 +1,19 @@+#!/bin/bash+++set -exuo pipefail++git apply script/patches/use-cross-platform-livekit.patch++# Re-enable error skipping for this check, so that we can unapply the patch+set +e++cargo check -p workspace+exit_code=$?++# Disable error skipping again+set -e++git apply -R script/patches/use-cross-platform-livekit.patch++exit "$exit_code"diff --git a/script/patches/use-cross-platform-livekit.patch b/script/patches/use-cross-platform-livekit.patchnew file mode 100644index 00000000000..81dcca80f63--- /dev/null+++ b/script/patches/use-cross-platform-livekit.patch@@ -0,0 +1,59 @@+diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.toml+index 9ba10e56ba..bb69440691 100644+--- a/crates/call/Cargo.toml++++ b/crates/call/Cargo.toml+@@ -41,10 +41,10 @@ serde_derive.workspace = true+ settings.workspace = true+ util.workspace = true++-[target.'cfg(target_os = "macos")'.dependencies]++[target.'cfg(any())'.dependencies]+ livekit_client_macos = { workspace = true }++-[target.'cfg(not(target_os = "macos"))'.dependencies]++[target.'cfg(all())'.dependencies]+ livekit_client = { workspace = true }++ [dev-dependencies]+diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs+index 5e212d35b7..a8f9e8f43e 100644+--- a/crates/call/src/call.rs++++ b/crates/call/src/call.rs+@@ -1,13 +1,13 @@+ pub mod call_settings;++-#[cfg(target_os = "macos")]++#[cfg(any())]+ mod macos;++-#[cfg(target_os = "macos")]++#[cfg(any())]+ pub use macos::*;++-#[cfg(not(target_os = "macos"))]++#[cfg(all())]+ mod cross_platform;++-#[cfg(not(target_os = "macos"))]++#[cfg(all())]+ pub use cross_platform::*;+diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs+index 1d17cfa145..f845234987 100644+--- a/crates/workspace/src/shared_screen.rs++++ b/crates/workspace/src/shared_screen.rs+@@ -1,11 +1,11 @@+-#[cfg(target_os = "macos")]++#[cfg(any())]+ mod macos;++-#[cfg(target_os = "macos")]++#[cfg(any())]+ pub use macos::*;++-#[cfg(not(target_os = "macos"))]++#[cfg(all())]+ mod cross_platform;++-#[cfg(not(target_os = "macos"))]++#[cfg(all())]+ pub use cross_platform::*;diff --git a/typos.toml b/typos.tomlindex dc724dd50d5..50f3aadd0a7 100644--- a/typos.toml+++ b/typos.toml@@ -43,6 +43,8 @@ extend-exclude = ["docs/theme/css/",# Spellcheck triggers on `|Fixe[sd]|` regex part."script/danger/dangerfile.ts",+ # Hashes are not typos+ "script/patches/use-cross-platform-livekit.patch"][default]