diff --git a/crates/assistant2/src/assistant.rs b/crates/assistant2/src/assistant.rs index 910eeda9e115d853cfe2a7ccaea041245050484e..871ab131e5f68600db81dbc3bee643d558b5e361 100644 --- a/crates/assistant2/src/assistant.rs +++ b/crates/assistant2/src/assistant.rs @@ -12,7 +12,7 @@ use chrono::{DateTime, Local}; use collections::HashMap; use fs::Fs; use futures::StreamExt; -use gpui::{actions, AppContext}; +use gpui::{actions, AppContext, SharedString}; use regex::Regex; use serde::{Deserialize, Serialize}; use std::{cmp::Reverse, ffi::OsStr, path::PathBuf, sync::Arc}; @@ -47,7 +47,7 @@ struct MessageMetadata { enum MessageStatus { Pending, Done, - Error(Arc), + Error(SharedString), } #[derive(Serialize, Deserialize)] diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 359056d9d3d4826cbd9014261e0325c67069acd4..79ebb6602d77776ee30f905cacba3ce6434e9512 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -1628,8 +1628,9 @@ impl Conversation { metadata.status = MessageStatus::Done; } Err(error) => { - metadata.status = - MessageStatus::Error(error.to_string().trim().into()); + metadata.status = MessageStatus::Error(SharedString::from( + error.to_string().trim().to_string(), + )); } } cx.notify(); @@ -2273,7 +2274,7 @@ impl ConversationEditor { Some( div() .id("error") - .tooltip(move |cx| Tooltip::text(&error, cx)) + .tooltip(move |cx| Tooltip::text(error.clone(), cx)) .child(IconElement::new(Icon::XCircle)), ) } else { diff --git a/crates/channel2/src/channel_store.rs b/crates/channel2/src/channel_store.rs index 5fcc2b95668f423eac3d1874cb15c444e63bb0dd..1bd987274c6b9d7b5267458c7cc59d2e75be2be6 100644 --- a/crates/channel2/src/channel_store.rs +++ b/crates/channel2/src/channel_store.rs @@ -8,7 +8,8 @@ use collections::{hash_map, HashMap, HashSet}; use db::RELEASE_CHANNEL; use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt}; use gpui::{ - AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task, WeakModel, + AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, SharedString, Task, + WeakModel, }; use rpc::{ proto::{self, ChannelVisibility}, @@ -46,7 +47,7 @@ pub struct ChannelStore { #[derive(Clone, Debug, PartialEq)] pub struct Channel { pub id: ChannelId, - pub name: String, + pub name: SharedString, pub visibility: proto::ChannelVisibility, pub role: proto::ChannelRole, pub unseen_note_version: Option<(u64, clock::Global)>, @@ -895,14 +896,16 @@ impl ChannelStore { .channel_invitations .binary_search_by_key(&channel.id, |c| c.id) { - Ok(ix) => Arc::make_mut(&mut self.channel_invitations[ix]).name = channel.name, + Ok(ix) => { + Arc::make_mut(&mut self.channel_invitations[ix]).name = channel.name.into() + } Err(ix) => self.channel_invitations.insert( ix, Arc::new(Channel { id: channel.id, visibility: channel.visibility(), role: channel.role(), - name: channel.name, + name: channel.name.into(), unseen_note_version: None, unseen_message_id: None, parent_path: channel.parent_path, diff --git a/crates/channel2/src/channel_store/channel_index.rs b/crates/channel2/src/channel_store/channel_index.rs index 97b2ab6318630113a90e674313a3dba9fd66d79e..2682cf6ae290b5729672645f9cdfc1a7e25b4933 100644 --- a/crates/channel2/src/channel_store/channel_index.rs +++ b/crates/channel2/src/channel_store/channel_index.rs @@ -104,7 +104,7 @@ impl<'a> ChannelPathsInsertGuard<'a> { existing_channel.visibility = channel_proto.visibility(); existing_channel.role = channel_proto.role(); - existing_channel.name = channel_proto.name; + existing_channel.name = channel_proto.name.into(); } else { self.channels_by_id.insert( channel_proto.id, @@ -112,7 +112,7 @@ impl<'a> ChannelPathsInsertGuard<'a> { id: channel_proto.id, visibility: channel_proto.visibility(), role: channel_proto.role(), - name: channel_proto.name, + name: channel_proto.name.into(), unseen_note_version: None, unseen_message_id: None, parent_path: channel_proto.parent_path, @@ -146,11 +146,11 @@ fn channel_path_sorting_key<'a>( let (parent_path, name) = channels_by_id .get(&id) .map_or((&[] as &[_], None), |channel| { - (channel.parent_path.as_slice(), Some(channel.name.as_str())) + (channel.parent_path.as_slice(), Some(channel.name.as_ref())) }); parent_path .iter() - .filter_map(|id| Some(channels_by_id.get(id)?.name.as_str())) + .filter_map(|id| Some(channels_by_id.get(id)?.name.as_ref())) .chain(name) } diff --git a/crates/collab2/src/tests/channel_tests.rs b/crates/collab2/src/tests/channel_tests.rs index 8ce5d99b80d3c630a81181e5f03f78d385186a10..49e7060301a4279adda4439aa39784b066ed76dd 100644 --- a/crates/collab2/src/tests/channel_tests.rs +++ b/crates/collab2/src/tests/channel_tests.rs @@ -7,7 +7,7 @@ use call::ActiveCall; use channel::{ChannelId, ChannelMembership, ChannelStore}; use client::User; use futures::future::try_join_all; -use gpui::{BackgroundExecutor, Model, TestAppContext}; +use gpui::{BackgroundExecutor, Model, SharedString, TestAppContext}; use rpc::{ proto::{self, ChannelRole}, RECEIVE_TIMEOUT, @@ -46,13 +46,13 @@ async fn test_core_channels( &[ ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Admin, }, ExpectedChannel { id: channel_b_id, - name: "channel-b".to_string(), + name: "channel-b".into(), depth: 1, role: ChannelRole::Admin, }, @@ -92,7 +92,7 @@ async fn test_core_channels( cx_b, &[ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Member, }], @@ -140,13 +140,13 @@ async fn test_core_channels( &[ ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), role: ChannelRole::Member, depth: 0, }, ExpectedChannel { id: channel_b_id, - name: "channel-b".to_string(), + name: "channel-b".into(), role: ChannelRole::Member, depth: 1, }, @@ -168,19 +168,19 @@ async fn test_core_channels( &[ ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), role: ChannelRole::Member, depth: 0, }, ExpectedChannel { id: channel_b_id, - name: "channel-b".to_string(), + name: "channel-b".into(), role: ChannelRole::Member, depth: 1, }, ExpectedChannel { id: channel_c_id, - name: "channel-c".to_string(), + name: "channel-c".into(), role: ChannelRole::Member, depth: 2, }, @@ -211,19 +211,19 @@ async fn test_core_channels( &[ ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Admin, }, ExpectedChannel { id: channel_b_id, - name: "channel-b".to_string(), + name: "channel-b".into(), depth: 1, role: ChannelRole::Admin, }, ExpectedChannel { id: channel_c_id, - name: "channel-c".to_string(), + name: "channel-c".into(), depth: 2, role: ChannelRole::Admin, }, @@ -245,7 +245,7 @@ async fn test_core_channels( cx_a, &[ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Admin, }], @@ -255,7 +255,7 @@ async fn test_core_channels( cx_b, &[ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Admin, }], @@ -278,7 +278,7 @@ async fn test_core_channels( cx_a, &[ExpectedChannel { id: channel_a_id, - name: "channel-a".to_string(), + name: "channel-a".into(), depth: 0, role: ChannelRole::Admin, }], @@ -309,7 +309,7 @@ async fn test_core_channels( cx_a, &[ExpectedChannel { id: channel_a_id, - name: "channel-a-renamed".to_string(), + name: "channel-a-renamed".into(), depth: 0, role: ChannelRole::Admin, }], @@ -418,7 +418,7 @@ async fn test_channel_room( cx_b, &[ExpectedChannel { id: zed_id, - name: "zed".to_string(), + name: "zed".into(), depth: 0, role: ChannelRole::Member, }], @@ -680,7 +680,7 @@ async fn test_permissions_update_while_invited( &[ExpectedChannel { depth: 0, id: rust_id, - name: "rust".to_string(), + name: "rust".into(), role: ChannelRole::Member, }], ); @@ -708,7 +708,7 @@ async fn test_permissions_update_while_invited( &[ExpectedChannel { depth: 0, id: rust_id, - name: "rust".to_string(), + name: "rust".into(), role: ChannelRole::Member, }], ); @@ -747,7 +747,7 @@ async fn test_channel_rename( &[ExpectedChannel { depth: 0, id: rust_id, - name: "rust-archive".to_string(), + name: "rust-archive".into(), role: ChannelRole::Admin, }], ); @@ -759,7 +759,7 @@ async fn test_channel_rename( &[ExpectedChannel { depth: 0, id: rust_id, - name: "rust-archive".to_string(), + name: "rust-archive".into(), role: ChannelRole::Member, }], ); @@ -888,7 +888,7 @@ async fn test_lost_channel_creation( &[ExpectedChannel { depth: 0, id: channel_id, - name: "x".to_string(), + name: "x".into(), role: ChannelRole::Member, }], ); @@ -912,13 +912,13 @@ async fn test_lost_channel_creation( ExpectedChannel { depth: 0, id: channel_id, - name: "x".to_string(), + name: "x".into(), role: ChannelRole::Admin, }, ExpectedChannel { depth: 1, id: subchannel_id, - name: "subchannel".to_string(), + name: "subchannel".into(), role: ChannelRole::Admin, }, ], @@ -943,13 +943,13 @@ async fn test_lost_channel_creation( ExpectedChannel { depth: 0, id: channel_id, - name: "x".to_string(), + name: "x".into(), role: ChannelRole::Member, }, ExpectedChannel { depth: 1, id: subchannel_id, - name: "subchannel".to_string(), + name: "subchannel".into(), role: ChannelRole::Member, }, ], @@ -1221,13 +1221,13 @@ async fn test_channel_membership_notifications( ExpectedChannel { depth: 0, id: zed_channel, - name: "zed".to_string(), + name: "zed".into(), role: ChannelRole::Guest, }, ExpectedChannel { depth: 1, id: vim_channel, - name: "vim".to_string(), + name: "vim".into(), role: ChannelRole::Member, }, ], @@ -1250,13 +1250,13 @@ async fn test_channel_membership_notifications( ExpectedChannel { depth: 0, id: zed_channel, - name: "zed".to_string(), + name: "zed".into(), role: ChannelRole::Guest, }, ExpectedChannel { depth: 1, id: vim_channel, - name: "vim".to_string(), + name: "vim".into(), role: ChannelRole::Guest, }, ], @@ -1476,7 +1476,7 @@ async fn test_channel_moving( struct ExpectedChannel { depth: usize, id: ChannelId, - name: String, + name: SharedString, role: ChannelRole, } @@ -1515,7 +1515,7 @@ fn assert_channels( .ordered_channels() .map(|(depth, channel)| ExpectedChannel { depth, - name: channel.name.clone(), + name: channel.name.clone().into(), id: channel.id, role: channel.role, }) diff --git a/crates/collab2/src/tests/random_channel_buffer_tests.rs b/crates/collab2/src/tests/random_channel_buffer_tests.rs index 14b5da028795ace3b0c779353f4a7cf092c954a5..f980f7d9086a15329983243590911e482864532c 100644 --- a/crates/collab2/src/tests/random_channel_buffer_tests.rs +++ b/crates/collab2/src/tests/random_channel_buffer_tests.rs @@ -3,7 +3,7 @@ use crate::db::ChannelRole; use super::{run_randomized_test, RandomizedTest, TestClient, TestError, TestServer, UserTestPlan}; use anyhow::Result; use async_trait::async_trait; -use gpui::{BackgroundExecutor, TestAppContext}; +use gpui::{BackgroundExecutor, SharedString, TestAppContext}; use rand::prelude::*; use serde_derive::{Deserialize, Serialize}; use std::{ @@ -30,13 +30,13 @@ struct RandomChannelBufferTest; #[derive(Clone, Serialize, Deserialize)] enum ChannelBufferOperation { JoinChannelNotes { - channel_name: String, + channel_name: SharedString, }, LeaveChannelNotes { - channel_name: String, + channel_name: SharedString, }, EditChannelNotes { - channel_name: String, + channel_name: SharedString, edits: Vec<(Range, Arc)>, }, Noop, diff --git a/crates/collab_ui2/src/chat_panel.rs b/crates/collab_ui2/src/chat_panel.rs index e9e2610a8604355d1ea480de81eb01ad64d8471f..eb99c3e6a27e88e7af6f0e94fa2795501ac2ecbd 100644 --- a/crates/collab_ui2/src/chat_panel.rs +++ b/crates/collab_ui2/src/chat_panel.rs @@ -1,983 +1,694 @@ -// use crate::{ -// channel_view::ChannelView, is_channels_feature_enabled, render_avatar, ChatPanelSettings, -// }; -// use anyhow::Result; -// use call::ActiveCall; -// use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore}; -// use client::Client; -// use collections::HashMap; -// use db::kvp::KEY_VALUE_STORE; -// use editor::Editor; -// use gpui::{ -// actions, -// elements::*, -// platform::{CursorStyle, MouseButton}, -// serde_json, -// views::{ItemType, Select, SelectStyle}, -// AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelHandle, Subscription, Task, View, -// ViewContext, ViewHandle, WeakViewHandle, -// }; -// use language::LanguageRegistry; -// use menu::Confirm; -// use message_editor::MessageEditor; -// use project::Fs; -// use rich_text::RichText; -// use serde::{Deserialize, Serialize}; -// use settings::SettingsStore; -// use std::sync::Arc; -// use theme::{IconButton, Theme}; -// use time::{OffsetDateTime, UtcOffset}; -// use util::{ResultExt, TryFutureExt}; -// use workspace::{ -// dock::{DockPosition, Panel}, -// Workspace, -// }; - -// mod message_editor; - -// const MESSAGE_LOADING_THRESHOLD: usize = 50; -// const CHAT_PANEL_KEY: &'static str = "ChatPanel"; - -// pub struct ChatPanel { -// client: Arc, -// channel_store: ModelHandle, -// languages: Arc, -// active_chat: Option<(ModelHandle, Subscription)>, -// message_list: ListState, -// input_editor: ViewHandle, -// channel_select: ViewHandle, -// ) -> AnyElement