Remove dead code in client, call, channel, and collab (#67126)

## Summary

Removes unused code. No behavior changes.

- `client`:
- unused `UserStore` methods, including `contact_updates_done`, the only
sender of `UpdateContacts::Wait`, so the variant also goes
  - `Telemetry::report_assistant_event` and `has_checksum_seed`
  - `Client::override_rpc_url`
  - `InviteInfo`
  - four `zed_urls` helpers
- `call`, `channel`: unused `Room` and `ChannelStore` helpers. The
collaborators handler no longer emits `CollaboratorsChanged` and
notifies twice, because `replace_collaborators` already does both.
- `collab`: unused DB types, `ChannelRole` predicates, and `Config` and
`ConnectionPool` helpers. `return Err(..)?;` becomes `Err(..)?;`.
- `livekit_api`: the empty `LiveKitParticipantUpdate`.
- `#[allow]`s that no longer suppress anything, including in `id_type!`
and the `non_snake_case` ones in `proto` and `rpc`.

## Testing

- `./script/clippy`
- `cargo test -p client -p call -p channel -p collab -p rpc -p proto -p
livekit_api` (Postgres-backed DB tests not run locally)

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- N/A
This commit is contained in:
Parker Loflin
2026-11-18 09:49:23 +00:00
committed by GitHub
parent 1ab8b9abfb
commit 881c618a6a
26 changed files with 20 additions and 271 deletions
-22
View File
@@ -612,18 +612,6 @@ impl Room {
.map(|participant| participant.role)
}
pub fn contains_guests(&self) -> bool {
self.local_participant.role == proto::ChannelRole::Guest
|| self
.remote_participants
.values()
.any(|p| p.role == proto::ChannelRole::Guest)
}
pub fn local_participant_is_admin(&self) -> bool {
self.local_participant.role == proto::ChannelRole::Admin
}
pub fn local_participant_is_guest(&self) -> bool {
self.local_participant.role == proto::ChannelRole::Guest
}
@@ -653,10 +641,6 @@ impl Room {
&self.pending_participants
}
pub fn contains_participant(&self, user_id: u64) -> bool {
self.participant_user_ids.contains(&user_id)
}
pub fn followers_for(&self, leader_id: PeerId, project_id: u64) -> &[PeerId] {
self.follows_by_leader_id_project_id
.get(&(leader_id, project_id))
@@ -1350,12 +1334,6 @@ impl Room {
})
}
pub fn is_sharing_mic(&self) -> bool {
self.live_kit
.as_ref()
.is_some_and(|live_kit| !matches!(live_kit.microphone_track, LocalTrack::None))
}
pub fn is_muted(&self) -> bool {
self.live_kit.as_ref().is_some_and(|live_kit| {
matches!(live_kit.microphone_track, LocalTrack::None)
-2
View File
@@ -188,8 +188,6 @@ impl ChannelBuffer {
) -> Result<()> {
this.update(&mut cx, |this, cx| {
this.replace_collaborators(message.payload.collaborators, cx);
cx.emit(ChannelBufferEvent::CollaboratorsChanged);
cx.notify();
});
Ok(())
}
-18
View File
@@ -312,14 +312,6 @@ impl ChannelStore {
self.channel_index.by_id().len()
}
/// Returns the index of a channel ID in the list of unique channels
pub fn index_of_channel(&self, channel_id: ChannelId) -> Option<usize> {
self.channel_index
.by_id()
.keys()
.position(|id| *id == channel_id)
}
/// Returns an iterator over all unique channels
pub fn channels(&self) -> impl '_ + Iterator<Item = &Arc<Channel>> {
self.channel_index.by_id().values()
@@ -341,16 +333,6 @@ impl ChannelStore {
self.channel_index.by_id().get(channel_id)
}
pub fn channel_at(&self, ix: usize) -> Option<&Arc<Channel>> {
self.channel_index.by_id().values().nth(ix)
}
pub fn has_channel_invitation(&self, channel_id: ChannelId) -> bool {
self.channel_invitations
.iter()
.any(|channel| channel.id == channel_id)
}
pub fn channel_invitations(&self) -> &[Arc<Channel>] {
&self.channel_invitations
}
-8
View File
@@ -216,12 +216,10 @@ pub struct Client {
message_to_client_handlers: Mutex<Vec<MessageToClientHandler>>,
sign_out_tx: Mutex<Option<mpsc::UnboundedSender<()>>>,
#[allow(clippy::type_complexity)]
#[cfg(any(test, feature = "test-support"))]
authenticate:
RwLock<Option<Box<dyn 'static + Send + Sync + Fn(&AsyncApp) -> Task<Result<Credentials>>>>>,
#[allow(clippy::type_complexity)]
#[cfg(any(test, feature = "test-support"))]
establish_connection: RwLock<
Option<
@@ -642,12 +640,6 @@ impl Client {
self
}
#[cfg(any(test, feature = "test-support"))]
pub fn override_rpc_url(&self, url: Url) -> &Self {
*self.rpc_url.write() = Some(url);
self
}
pub fn global(cx: &App) -> Arc<Self> {
cx.global::<GlobalClient>().0.clone()
}
+1 -27
View File
@@ -19,7 +19,7 @@ use std::io::Write;
use std::sync::LazyLock;
use std::time::Instant;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use telemetry_events::{AssistantEventData, AssistantPhase, Event, EventRequestBody, EventWrapper};
use telemetry_events::{Event, EventRequestBody, EventWrapper};
pub struct TelemetrySubscription {
pub historical_events: Result<HistoricalEvents>,
@@ -382,10 +382,6 @@ impl Telemetry {
})
}
pub fn has_checksum_seed(&self) -> bool {
ZED_CLIENT_CHECKSUM_SEED.is_some()
}
pub fn start(
self: &Arc<Self>,
system_id: Option<String>,
@@ -426,28 +422,6 @@ impl Telemetry {
drop(state);
}
pub fn report_assistant_event(self: &Arc<Self>, event: AssistantEventData) {
let event_type = match event.phase {
AssistantPhase::Response => "Assistant Responded",
AssistantPhase::Invoked => "Assistant Invoked",
AssistantPhase::Accepted => "Assistant Response Accepted",
AssistantPhase::Rejected => "Assistant Response Rejected",
};
telemetry::event!(
event_type,
conversation_id = event.conversation_id,
kind = event.kind,
phase = event.phase,
message_id = event.message_id,
model = event.model,
model_provider = event.model_provider,
response_latency = event.response_latency,
error_message = event.error_message,
language_name = event.language_name,
);
}
pub fn log_edit_event(self: &Arc<Self>, environment: &'static str, is_via_ssh: bool) {
static LAST_EVENT_TIME: Mutex<Option<Instant>> = Mutex::new(None);
-54
View File
@@ -128,12 +128,6 @@ pub struct UserStore {
weak_self: WeakEntity<Self>,
}
#[derive(Clone)]
pub struct InviteInfo {
pub count: u32,
pub url: Arc<str>,
}
pub enum Event {
Contact {
user: Arc<User>,
@@ -157,7 +151,6 @@ impl EventEmitter<Event> for UserStore {}
enum UpdateContacts {
Update(proto::UpdateContacts),
Wait(postage::barrier::Sender),
Clear(postage::barrier::Sender),
}
@@ -339,10 +332,6 @@ impl UserStore {
fn update_contacts(&mut self, message: UpdateContacts, cx: &Context<Self>) -> Task<Result<()>> {
match message {
UpdateContacts::Wait(barrier) => {
drop(barrier);
Task::ready(Ok(()))
}
UpdateContacts::Clear(barrier) => {
self.contacts.clear();
self.incoming_contact_requests.clear();
@@ -515,12 +504,6 @@ impl UserStore {
self.perform_contact_request(user_id, proto::RemoveContact { user_id }, cx)
}
pub fn has_incoming_contact_request(&self, user_id: u64) -> bool {
self.incoming_contact_requests
.iter()
.any(|user| user.legacy_id == user_id)
}
pub fn respond_to_contact_request(
&mut self,
requester_id: u64,
@@ -541,24 +524,6 @@ impl UserStore {
)
}
pub fn dismiss_contact_request(
&self,
requester_id: u64,
cx: &Context<Self>,
) -> Task<Result<()>> {
let client = self.client.upgrade();
cx.spawn(async move |_, _| {
client
.context("can't upgrade client reference")?
.request(proto::RespondToContactRequest {
requester_id,
response: proto::ContactRequestResponse::Dismiss as i32,
})
.await?;
Ok(())
})
}
fn perform_contact_request<T: RequestMessage>(
&mut self,
user_id: u64,
@@ -600,16 +565,6 @@ impl UserStore {
}
}
pub fn contact_updates_done(&self) -> impl Future<Output = ()> {
let (tx, mut rx) = postage::barrier::channel();
self.update_contacts_tx
.unbounded_send(UpdateContacts::Wait(tx))
.unwrap();
async move {
rx.next().await;
}
}
pub fn get_users(
&self,
user_ids: Vec<u64>,
@@ -657,15 +612,6 @@ impl UserStore {
self.users.get(&user_id).cloned()
}
pub fn get_user_optimistic(&self, user_id: u64, cx: &Context<Self>) -> Option<Arc<User>> {
if let Some(user) = self.users.get(&user_id).cloned() {
return Some(user);
}
self.get_user(user_id, cx).detach_and_log_err(cx);
None
}
pub fn get_user(&self, user_id: u64, cx: &Context<Self>) -> Task<Result<Arc<User>>> {
if let Some(user) = self.users.get(&user_id).cloned() {
return Task::ready(Ok(user));
-21
View File
@@ -47,28 +47,11 @@ pub fn upgrade_to_zed_pro_url(cx: &App) -> String {
format!("{server_url}/account/upgrade", server_url = server_url(cx))
}
/// Returns the URL to Zed's terms of service.
pub fn terms_of_service(cx: &App) -> String {
format!("{server_url}/terms-of-service", server_url = server_url(cx))
}
/// Returns the URL to Zed AI's privacy and security docs.
pub fn ai_privacy_and_security(cx: &App) -> String {
format!(
"{docs_url}/ai/privacy-and-security",
docs_url = docs_url(cx)
)
}
/// Returns the URL to Zed's edit prediction documentation.
pub fn edit_prediction_docs(cx: &App) -> String {
format!("{docs_url}/ai/edit-prediction", docs_url = docs_url(cx))
}
pub fn skills_docs(cx: &App) -> String {
format!("{docs_url}/ai/skills", docs_url = docs_url(cx))
}
/// Returns the URL to Zed's Agent sandboxing documentation.
///
/// Pass `section` to deep-link to a specific section anchor on the page (for
@@ -97,7 +80,3 @@ pub fn acp_registry_blog(cx: &App) -> String {
server_url = server_url(cx)
)
}
pub fn shared_agent_thread_url(session_id: &str) -> String {
format!("zed://agent/shared/{}", session_id)
}
-38
View File
@@ -321,50 +321,12 @@ impl Contact {
pub type NotificationBatch = Vec<(UserId, proto::Notification)>;
pub struct CreatedChannelMessage {
pub message_id: MessageId,
pub participant_connection_ids: HashSet<ConnectionId>,
pub notifications: NotificationBatch,
}
pub struct UpdatedChannelMessage {
pub message_id: MessageId,
pub participant_connection_ids: Vec<ConnectionId>,
pub notifications: NotificationBatch,
pub reply_to_message_id: Option<MessageId>,
pub timestamp: PrimitiveDateTime,
pub deleted_mention_notification_ids: Vec<NotificationId>,
pub updated_mention_notifications: Vec<rpc::proto::Notification>,
}
#[derive(Clone, Debug, PartialEq, Eq, FromQueryResult, Serialize, Deserialize)]
pub struct Invite {
pub email_address: String,
pub email_confirmation_code: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct NewSignup {
pub email_address: String,
pub platform_mac: bool,
pub platform_windows: bool,
pub platform_linux: bool,
pub editor_features: Vec<String>,
pub programming_languages: Vec<String>,
pub device_id: Option<String>,
pub added_to_mailing_list: bool,
pub created_at: Option<DateTime>,
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, FromQueryResult)]
pub struct WaitlistSummary {
pub count: i64,
pub linux_count: i64,
pub mac_count: i64,
pub windows_count: i64,
pub unknown_count: i64,
}
/// The result of creating a new user.
#[derive(Debug)]
pub struct NewUserResult {
-25
View File
@@ -21,24 +21,17 @@ macro_rules! id_type {
Deserialize,
DeriveValueType,
)]
#[allow(missing_docs)]
#[serde(transparent)]
pub struct $name(pub i32);
impl $name {
#[allow(unused)]
#[allow(missing_docs)]
pub const MAX: Self = Self(i32::MAX);
#[allow(unused)]
#[allow(missing_docs)]
pub fn from_proto(value: u64) -> Self {
debug_assert!(value != 0);
Self(value as i32)
}
#[allow(unused)]
#[allow(missing_docs)]
pub fn to_proto(self) -> u64 {
self.0 as u64
}
@@ -182,24 +175,6 @@ impl ChannelRole {
}
}
/// True if the role allows access to all descendant channels
pub fn can_see_all_descendants(&self) -> bool {
use ChannelRole::*;
match self {
Admin | Member => true,
Guest | Talker | Banned => false,
}
}
/// True if the role only allows access to public descendant channels
pub fn can_only_see_public_descendants(&self) -> bool {
use ChannelRole::*;
match self {
Guest | Talker => true,
Admin | Member | Banned => false,
}
}
/// True if the role can share screen/microphone/projects into rooms.
pub fn can_use_microphone(&self) -> bool {
use ChannelRole::*;
-1
View File
@@ -1003,7 +1003,6 @@ enum QueryOperationSerializationVersion {
}
mod storage {
#![allow(non_snake_case)]
use prost::Message;
pub const SERIALIZATION_VERSION: i32 = 1;
+8 -8
View File
@@ -53,14 +53,14 @@ impl Database {
.await?
.context("could not find participant")?;
if participant.room_id != room_id {
return Err(anyhow!("shared project on unexpected room"))?;
Err(anyhow!("shared project on unexpected room"))?;
}
if !participant
.role
.unwrap_or(ChannelRole::Member)
.can_edit_projects()
{
return Err(anyhow!("guests cannot share projects"))?;
Err(anyhow!("guests cannot share projects"))?;
}
let project = project::ActiveModel {
@@ -233,7 +233,7 @@ impl Database {
if update.removed_entries.len() > proto::MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE
|| update.updated_entries.len() > proto::MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE
{
return Err(anyhow!(
Err(anyhow!(
"invalid worktree update. removed entries: {}, updated entries: {}",
update.removed_entries.len(),
update.updated_entries.len()
@@ -530,7 +530,7 @@ impl Database {
.await?
.context("no such project")?;
if project.host_connection()? != connection {
return Err(anyhow!("can't update a project hosted by someone else"))?;
Err(anyhow!("can't update a project hosted by someone else"))?;
}
// Update summary.
@@ -580,7 +580,7 @@ impl Database {
.await?
.context("no such project")?;
if project.host_connection()? != connection {
return Err(anyhow!("can't update a project hosted by someone else"))?;
Err(anyhow!("can't update a project hosted by someone else"))?;
}
// Add the newly-started language server.
@@ -635,7 +635,7 @@ impl Database {
.await?
.context("no such project")?;
if project.host_connection()? != connection {
return Err(anyhow!("can't update a project hosted by someone else"))?;
Err(anyhow!("can't update a project hosted by someone else"))?;
}
if let Some(content) = &update.content {
@@ -1135,12 +1135,12 @@ impl Database {
match capability {
Capability::ReadWrite => {
if !role.can_edit_projects() {
return Err(anyhow!("not authorized to edit projects"))?;
Err(anyhow!("not authorized to edit projects"))?;
}
}
Capability::ReadOnly => {
if !role.can_read_projects() {
return Err(anyhow!("not authorized to read projects"))?;
Err(anyhow!("not authorized to read projects"))?;
}
}
}
+2 -2
View File
@@ -496,7 +496,7 @@ impl Database {
.exec(&*tx)
.await?;
if participant_update.rows_affected == 0 {
return Err(anyhow!("room does not exist or was already joined"))?;
Err(anyhow!("room does not exist or was already joined"))?;
}
let mut reshared_projects = Vec::new();
@@ -507,7 +507,7 @@ impl Database {
.await?
.context("project does not exist")?;
if project.host_user_id != Some(user_id) {
return Err(anyhow!("no such project"))?;
Err(anyhow!("no such project"))?;
}
let mut collaborators = project
-13
View File
@@ -140,19 +140,6 @@ pub struct Config {
}
impl Config {
pub fn is_development(&self) -> bool {
self.zed_environment == "development".into()
}
/// Returns the base `zed.dev` URL.
pub fn zed_dot_dev_url(&self) -> &str {
match self.zed_environment.as_ref() {
"development" => "http://localhost:3000",
"staging" => "https://staging.zed.dev",
_ => "https://zed.dev",
}
}
/// Returns the base Zed Cloud URL.
pub fn zed_cloud_url(&self) -> &str {
match self.zed_environment.as_ref() {
+2 -2
View File
@@ -1759,7 +1759,7 @@ async fn call(
.has_contact(calling_user_id, called_user_id)
.await?
{
return Err(anyhow!("cannot call a user who isn't a contact"))?;
Err(anyhow!("cannot call a user who isn't a contact"))?;
}
let incoming_call = {
@@ -2809,7 +2809,7 @@ async fn request_contact(
let requester_id = session.user_id();
let responder_id = UserId::from_proto(request.responder_id);
if requester_id == responder_id {
return Err(anyhow!("cannot add yourself as a contact"))?;
Err(anyhow!("cannot add yourself as a contact"))?;
}
let notifications = session
-12
View File
@@ -97,18 +97,6 @@ impl ConnectionPool {
self.connections.values()
}
pub fn user_connections(&self, user_id: UserId) -> impl Iterator<Item = &Connection> + '_ {
self.connected_users
.get(&user_id)
.into_iter()
.flat_map(|state| {
state
.connection_ids
.iter()
.flat_map(|cid| self.connections.get(cid))
})
}
pub fn user_connection_ids(&self, user_id: UserId) -> impl Iterator<Item = ConnectionId> + '_ {
self.connected_users
.get(&user_id)
@@ -793,7 +793,7 @@ async fn test_channel_buffer_operations_lost_on_reconnect(
let edit_task = cx_a.spawn({
let buffer = buffer_for_edit;
async move |mut cx| {
let _ = buffer.update(&mut cx, |buffer, cx| {
buffer.update(&mut cx, |buffer, cx| {
buffer.edit([(2..2, "c")], None, cx);
});
}
@@ -35,12 +35,12 @@ fn room_participants(room: &Entity<Room>, cx: &mut TestAppContext) -> RoomPartic
let mut remote = room
.remote_participants()
.values()
.map(|participant| participant.user.username.clone().to_string())
.map(|participant| participant.user.username.to_string())
.collect::<Vec<_>>();
let mut pending = room
.pending_participants()
.iter()
.map(|user| user.username.clone().to_string())
.map(|user| user.username.to_string())
.collect::<Vec<_>>();
remote.sort();
pending.sort();
@@ -7362,7 +7362,6 @@ async fn test_document_symbols(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont
..lsp::ServerCapabilities::default()
};
client_a.language_registry().add(rust_lang());
#[allow(deprecated)]
let mut fake_language_servers = client_a.language_registry().register_fake_lsp(
"Rust",
FakeLspAdapter {
@@ -1,4 +1,3 @@
#![allow(clippy::reversed_empty_ranges)]
use crate::TestServer;
use call::{ActiveCall, Room};
use client::ChannelId;
@@ -7277,7 +7277,7 @@ async fn test_contacts(
.iter()
.map(|contact| {
(
contact.user.username.clone().to_string(),
contact.user.username.to_string(),
if contact.online { "online" } else { "offline" },
if contact.busy { "busy" } else { "free" },
)
@@ -733,17 +733,17 @@ impl TestClient {
current: store
.contacts()
.iter()
.map(|contact| contact.user.username.clone().to_string())
.map(|contact| contact.user.username.to_string())
.collect(),
outgoing_requests: store
.outgoing_contact_requests()
.iter()
.map(|user| user.username.clone().to_string())
.map(|user| user.username.to_string())
.collect(),
incoming_requests: store
.incoming_contact_requests()
.iter()
.map(|user| user.username.clone().to_string())
.map(|user| user.username.to_string())
.collect(),
})
}
-2
View File
@@ -23,8 +23,6 @@ pub trait Client: Send + Sync {
fn guest_token(&self, room: &str, identity: &str) -> Result<String>;
}
pub struct LiveKitParticipantUpdate {}
#[derive(Clone)]
pub struct LiveKitClient {
http: reqwest::Client,
-2
View File
@@ -1,5 +1,3 @@
#![allow(non_snake_case)]
pub mod error;
mod macros;
mod typed_envelope;
-1
View File
@@ -46,7 +46,6 @@ impl Connection {
killed,
);
#[allow(clippy::type_complexity)]
fn channel(
killed: Arc<AtomicBool>,
executor: gpui::BackgroundExecutor,
-2
View File
@@ -1,5 +1,3 @@
#![allow(non_snake_case)]
pub use ::proto::*;
use async_tungstenite::tungstenite::Message as WebSocketMessage;
-2
View File
@@ -68,7 +68,6 @@ pub struct ConnectionState {
#[serde(skip)]
outgoing_tx: mpsc::UnboundedSender<Message>,
next_message_id: Arc<AtomicU32>,
#[allow(clippy::type_complexity)]
#[serde(skip)]
response_channels: Arc<
Mutex<
@@ -80,7 +79,6 @@ pub struct ConnectionState {
>,
>,
>,
#[allow(clippy::type_complexity)]
#[serde(skip)]
stream_response_channels: Arc<
Mutex<