Compare commits

...
Sign in to create a new pull request.

13 commits

Author SHA1 Message Date
Kirill Bulatov
03ba256d96 Fix ssh message sending 2025-08-26 10:39:57 +03:00
Kirill Bulatov
679c24282d Simplify 2025-08-26 09:58:13 +03:00
Kirill Bulatov
e75e30b25f Pass LSP RPC logs up to ssh log store 2025-08-26 08:42:13 +03:00
Kirill Bulatov
d433406103 One less remote usage 2025-08-26 08:42:13 +03:00
Kirill Bulatov
775160a199 cfg-out call-related workspace functionality 2025-08-26 08:42:13 +03:00
Kirill Bulatov
cc680d280d zzz 2025-08-26 08:42:13 +03:00
Kirill Bulatov
25ed82c994 Move call into a separate feature in the workspace 2025-08-26 08:42:13 +03:00
Kirill Bulatov
9d1e2f5278 Register log-related actions for all kinds of projects 2025-08-26 08:42:13 +03:00
Ben Kunkle
dc6377b8bc fix handling of verbose 2025-08-26 08:42:13 +03:00
Kirill Bulatov
13c8d4e052 Properly show the binary stats
Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: Lukas Wirth <lukas@zed.dev>
2025-08-26 08:42:13 +03:00
Kirill Bulatov
1cc491a919 Disable log storing in the remote LspLog storage
Co-authored-by: Lukas Wirth <lukas@zed.dev>
Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-08-26 08:42:13 +03:00
Kirill Bulatov
ab5da3af83 Add messages and handlers for RPC log toggling
Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: Lukas Wirth <lukas@zed.dev>
2025-08-26 08:42:12 +03:00
Ben Kunkle
848d1101d3 wip 2025-08-26 08:42:12 +03:00
23 changed files with 861 additions and 363 deletions

3
Cargo.lock generated
View file

@ -9211,8 +9211,10 @@ dependencies = [
"gpui", "gpui",
"itertools 0.14.0", "itertools 0.14.0",
"language", "language",
"log",
"lsp", "lsp",
"project", "project",
"proto",
"release_channel", "release_channel",
"serde_json", "serde_json",
"settings", "settings",
@ -13500,6 +13502,7 @@ dependencies = [
"language", "language",
"language_extension", "language_extension",
"language_model", "language_model",
"language_tools",
"languages", "languages",
"libc", "libc",
"log", "log",

View file

@ -25,7 +25,7 @@ parking_lot.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
ui.workspace = true ui.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
workspace-hack.workspace = true workspace-hack.workspace = true
[dev-dependencies] [dev-dependencies]

View file

@ -28,7 +28,7 @@ serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
text.workspace = true text.workspace = true
util.workspace = true util.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
workspace-hack.workspace = true workspace-hack.workspace = true
[dev-dependencies] [dev-dependencies]

View file

@ -19,7 +19,7 @@ itertools.workspace = true
settings.workspace = true settings.workspace = true
theme.workspace = true theme.workspace = true
ui.workspace = true ui.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
zed_actions.workspace = true zed_actions.workspace = true
workspace-hack.workspace = true workspace-hack.workspace = true

View file

@ -394,6 +394,16 @@ impl ActiveCall {
} }
} }
#[cfg(not(feature = "call"))]
pub fn unshare_project(
&mut self,
_project: Entity<Project>,
_cx: &mut Context<Self>,
) -> Result<()> {
Ok(())
}
#[cfg(feature = "call")]
pub fn unshare_project( pub fn unshare_project(
&mut self, &mut self,
project: Entity<Project>, project: Entity<Project>,

View file

@ -476,7 +476,8 @@ impl Server {
.add_request_handler(forward_mutating_project_request::<proto::GitChangeBranch>) .add_request_handler(forward_mutating_project_request::<proto::GitChangeBranch>)
.add_request_handler(forward_mutating_project_request::<proto::CheckForPushedCommits>) .add_request_handler(forward_mutating_project_request::<proto::CheckForPushedCommits>)
.add_message_handler(broadcast_project_message_from_host::<proto::AdvertiseContexts>) .add_message_handler(broadcast_project_message_from_host::<proto::AdvertiseContexts>)
.add_message_handler(update_context); .add_message_handler(update_context)
.add_request_handler(forward_mutating_project_request::<proto::ToggleLspLogs>);
Arc::new(server) Arc::new(server)
} }

View file

@ -50,7 +50,7 @@ sum_tree.workspace = true
task.workspace = true task.workspace = true
ui.workspace = true ui.workspace = true
util.workspace = true util.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
workspace-hack.workspace = true workspace-hack.workspace = true
itertools.workspace = true itertools.workspace = true

View file

@ -89,7 +89,7 @@ ui.workspace = true
url.workspace = true url.workspace = true
util.workspace = true util.workspace = true
uuid.workspace = true uuid.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
zed_actions.workspace = true zed_actions.workspace = true
workspace-hack.workspace = true workspace-hack.workspace = true

View file

@ -22,15 +22,17 @@ futures.workspace = true
gpui.workspace = true gpui.workspace = true
itertools.workspace = true itertools.workspace = true
language.workspace = true language.workspace = true
log.workspace = true
lsp.workspace = true lsp.workspace = true
project.workspace = true project.workspace = true
proto.workspace = true
serde_json.workspace = true serde_json.workspace = true
settings.workspace = true settings.workspace = true
theme.workspace = true theme.workspace = true
tree-sitter.workspace = true tree-sitter.workspace = true
ui.workspace = true ui.workspace = true
util.workspace = true util.workspace = true
workspace.workspace = true workspace = { path = "../workspace", default-features = false }
zed_actions.workspace = true zed_actions.workspace = true
workspace-hack.workspace = true workspace-hack.workspace = true

View file

@ -1,5 +1,5 @@
mod key_context_view; mod key_context_view;
mod lsp_log; pub mod lsp_log;
pub mod lsp_tool; pub mod lsp_tool;
mod syntax_tree_view; mod syntax_tree_view;
@ -14,7 +14,7 @@ use ui::{Context, Window};
use workspace::{Item, ItemHandle, SplitDirection, Workspace}; use workspace::{Item, ItemHandle, SplitDirection, Workspace};
pub fn init(cx: &mut App) { pub fn init(cx: &mut App) {
lsp_log::init(cx); lsp_log::init(true, cx);
syntax_tree_view::init(cx); syntax_tree_view::init(cx);
key_context_view::init(cx); key_context_view::init(cx);
} }

View file

@ -9,12 +9,15 @@ use gpui::{
use itertools::Itertools; use itertools::Itertools;
use language::{LanguageServerId, language_settings::SoftWrap}; use language::{LanguageServerId, language_settings::SoftWrap};
use lsp::{ use lsp::{
IoKind, LanguageServer, LanguageServerName, LanguageServerSelector, MessageType, IoKind, LanguageServer, LanguageServerBinary, LanguageServerName, LanguageServerSelector,
SetTraceParams, TraceValue, notification::SetTrace, MessageType, SetTraceParams, TraceValue, notification::SetTrace,
};
use project::{
LspStore, Project, WorktreeId, lsp_store::LanguageServerLogType, search::SearchQuery,
}; };
use project::{Project, WorktreeId, search::SearchQuery};
use std::{any::TypeId, borrow::Cow, sync::Arc}; use std::{any::TypeId, borrow::Cow, sync::Arc};
use ui::{Button, Checkbox, ContextMenu, Label, PopoverMenu, ToggleState, prelude::*}; use ui::{Button, Checkbox, ContextMenu, Label, PopoverMenu, ToggleState, prelude::*};
use util::ResultExt as _;
use workspace::{ use workspace::{
SplitDirection, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, WorkspaceId, SplitDirection, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, WorkspaceId,
item::{Item, ItemHandle}, item::{Item, ItemHandle},
@ -28,6 +31,7 @@ const RECEIVE_LINE: &str = "\n// Receive:";
const MAX_STORED_LOG_ENTRIES: usize = 2000; const MAX_STORED_LOG_ENTRIES: usize = 2000;
pub struct LogStore { pub struct LogStore {
store_logs: bool,
projects: HashMap<WeakEntity<Project>, ProjectState>, projects: HashMap<WeakEntity<Project>, ProjectState>,
language_servers: HashMap<LanguageServerId, LanguageServerState>, language_servers: HashMap<LanguageServerId, LanguageServerState>,
copilot_log_subscription: Option<lsp::Subscription>, copilot_log_subscription: Option<lsp::Subscription>,
@ -75,6 +79,7 @@ impl Message for LogMessage {
pub(super) struct TraceMessage { pub(super) struct TraceMessage {
message: String, message: String,
is_verbose: bool,
} }
impl AsRef<str> for TraceMessage { impl AsRef<str> for TraceMessage {
@ -84,7 +89,15 @@ impl AsRef<str> for TraceMessage {
} }
impl Message for TraceMessage { impl Message for TraceMessage {
type Level = (); type Level = TraceValue;
fn should_include(&self, level: Self::Level) -> bool {
match level {
TraceValue::Off => false,
TraceValue::Messages => !self.is_verbose,
TraceValue::Verbose => true,
}
}
} }
struct RpcMessage { struct RpcMessage {
@ -101,7 +114,7 @@ impl Message for RpcMessage {
type Level = (); type Level = ();
} }
pub(super) struct LanguageServerState { pub struct LanguageServerState {
name: Option<LanguageServerName>, name: Option<LanguageServerName>,
worktree_id: Option<WorktreeId>, worktree_id: Option<WorktreeId>,
kind: LanguageServerKind, kind: LanguageServerKind,
@ -117,20 +130,16 @@ pub(super) struct LanguageServerState {
pub enum LanguageServerKind { pub enum LanguageServerKind {
Local { project: WeakEntity<Project> }, Local { project: WeakEntity<Project> },
Remote { project: WeakEntity<Project> }, Remote { project: WeakEntity<Project> },
LocalSsh { lsp_store: WeakEntity<LspStore> },
Global, Global,
} }
impl LanguageServerKind {
fn is_remote(&self) -> bool {
matches!(self, LanguageServerKind::Remote { .. })
}
}
impl std::fmt::Debug for LanguageServerKind { impl std::fmt::Debug for LanguageServerKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
LanguageServerKind::Local { .. } => write!(f, "LanguageServerKind::Local"), LanguageServerKind::Local { .. } => write!(f, "LanguageServerKind::Local"),
LanguageServerKind::Remote { .. } => write!(f, "LanguageServerKind::Remote"), LanguageServerKind::Remote { .. } => write!(f, "LanguageServerKind::Remote"),
LanguageServerKind::LocalSsh { .. } => write!(f, "LanguageServerKind::LocalSsh"),
LanguageServerKind::Global => write!(f, "LanguageServerKind::Global"), LanguageServerKind::Global => write!(f, "LanguageServerKind::Global"),
} }
} }
@ -141,12 +150,13 @@ impl LanguageServerKind {
match self { match self {
Self::Local { project } => Some(project), Self::Local { project } => Some(project),
Self::Remote { project } => Some(project), Self::Remote { project } => Some(project),
Self::LocalSsh { .. } => None,
Self::Global { .. } => None, Self::Global { .. } => None,
} }
} }
} }
struct LanguageServerRpcState { pub struct LanguageServerRpcState {
rpc_messages: VecDeque<RpcMessage>, rpc_messages: VecDeque<RpcMessage>,
last_message_kind: Option<MessageKind>, last_message_kind: Option<MessageKind>,
} }
@ -183,6 +193,13 @@ pub enum LogKind {
} }
impl LogKind { impl LogKind {
fn from_server_log_type(log_type: &LanguageServerLogType) -> Self {
match log_type {
LanguageServerLogType::Log(_) => Self::Logs,
LanguageServerLogType::Trace { .. } => Self::Trace,
LanguageServerLogType::Rpc { .. } => Self::Rpc,
}
}
fn label(&self) -> &'static str { fn label(&self) -> &'static str {
match self { match self {
LogKind::Rpc => RPC_MESSAGES, LogKind::Rpc => RPC_MESSAGES,
@ -212,28 +229,23 @@ actions!(
] ]
); );
pub(super) struct GlobalLogStore(pub WeakEntity<LogStore>); pub struct GlobalLogStore(pub WeakEntity<LogStore>);
impl Global for GlobalLogStore {} impl Global for GlobalLogStore {}
pub fn init(cx: &mut App) { pub fn init(store_logs: bool, cx: &mut App) {
let log_store = cx.new(LogStore::new); let log_store = cx.new(|cx| LogStore::new(store_logs, cx));
cx.set_global(GlobalLogStore(log_store.downgrade())); cx.set_global(GlobalLogStore(log_store.downgrade()));
cx.observe_new(move |workspace: &mut Workspace, _, cx| { cx.observe_new(move |workspace: &mut Workspace, _, cx| {
let project = workspace.project();
if project.read(cx).is_local() || project.read(cx).is_via_ssh() {
log_store.update(cx, |store, cx| { log_store.update(cx, |store, cx| {
store.add_project(project, cx); store.add_project(workspace.project(), cx);
}); });
}
let log_store = log_store.clone(); let log_store = log_store.clone();
workspace.register_action(move |workspace, _: &OpenLanguageServerLogs, window, cx| { workspace.register_action(move |workspace, _: &OpenLanguageServerLogs, window, cx| {
let project = workspace.project().read(cx);
if project.is_local() || project.is_via_ssh() {
let project = workspace.project().clone();
let log_store = log_store.clone(); let log_store = log_store.clone();
let project = workspace.project().clone();
get_or_create_tool( get_or_create_tool(
workspace, workspace,
SplitDirection::Right, SplitDirection::Right,
@ -241,30 +253,29 @@ pub fn init(cx: &mut App) {
cx, cx,
move |window, cx| LspLogView::new(project, log_store, window, cx), move |window, cx| LspLogView::new(project, log_store, window, cx),
); );
}
}); });
}) })
.detach(); .detach();
} }
impl LogStore { impl LogStore {
pub fn new(cx: &mut Context<Self>) -> Self { pub fn new(store_logs: bool, cx: &mut Context<Self>) -> Self {
let (io_tx, mut io_rx) = mpsc::unbounded(); let (io_tx, mut io_rx) = mpsc::unbounded();
let copilot_subscription = Copilot::global(cx).map(|copilot| { let copilot_subscription = Copilot::global(cx).map(|copilot| {
let copilot = &copilot; let copilot = &copilot;
cx.subscribe(copilot, |this, copilot, edit_prediction_event, cx| { cx.subscribe(copilot, |log_store, copilot, edit_prediction_event, cx| {
if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event
&& let Some(server) = copilot.read(cx).language_server() && let Some(server) = copilot.read(cx).language_server()
{ {
let server_id = server.server_id(); let server_id = server.server_id();
let weak_this = cx.weak_entity(); let weak_lsp_store = cx.weak_entity();
this.copilot_log_subscription = log_store.copilot_log_subscription =
Some(server.on_notification::<copilot::request::LogMessage, _>( Some(server.on_notification::<copilot::request::LogMessage, _>(
move |params, cx| { move |params, cx| {
weak_this weak_lsp_store
.update(cx, |this, cx| { .update(cx, |lsp_store, cx| {
this.add_language_server_log( lsp_store.add_language_server_log(
server_id, server_id,
MessageType::LOG, MessageType::LOG,
&params.message, &params.message,
@ -274,8 +285,9 @@ impl LogStore {
.ok(); .ok();
}, },
)); ));
let name = LanguageServerName::new_static("copilot"); let name = LanguageServerName::new_static("copilot");
this.add_language_server( log_store.add_language_server(
LanguageServerKind::Global, LanguageServerKind::Global,
server.server_id(), server.server_id(),
Some(name), Some(name),
@ -287,26 +299,27 @@ impl LogStore {
}) })
}); });
let this = Self { let log_store = Self {
copilot_log_subscription: None, copilot_log_subscription: None,
_copilot_subscription: copilot_subscription, _copilot_subscription: copilot_subscription,
projects: HashMap::default(), projects: HashMap::default(),
language_servers: HashMap::default(), language_servers: HashMap::default(),
store_logs,
io_tx, io_tx,
}; };
cx.spawn(async move |this, cx| { cx.spawn(async move |log_store, cx| {
while let Some((server_id, io_kind, message)) = io_rx.next().await { while let Some((server_id, io_kind, message)) = io_rx.next().await {
if let Some(this) = this.upgrade() { if let Some(log_store) = log_store.upgrade() {
this.update(cx, |this, cx| { log_store.update(cx, |log_store, cx| {
this.on_io(server_id, io_kind, &message, cx); log_store.on_io(server_id, io_kind, &message, cx);
})?; })?;
} }
} }
anyhow::Ok(()) anyhow::Ok(())
}) })
.detach_and_log_err(cx); .detach_and_log_err(cx);
this log_store
} }
pub fn add_project(&mut self, project: &Entity<Project>, cx: &mut Context<Self>) { pub fn add_project(&mut self, project: &Entity<Project>, cx: &mut Context<Self>) {
@ -320,20 +333,19 @@ impl LogStore {
this.language_servers this.language_servers
.retain(|_, state| state.kind.project() != Some(&weak_project)); .retain(|_, state| state.kind.project() != Some(&weak_project));
}), }),
cx.subscribe(project, |this, project, event, cx| { cx.subscribe(project, move |log_store, project, event, cx| {
let server_kind = if project.read(cx).is_via_ssh() { let server_kind = if project.read(cx).is_local() {
LanguageServerKind::Remote {
project: project.downgrade(),
}
} else {
LanguageServerKind::Local { LanguageServerKind::Local {
project: project.downgrade(), project: project.downgrade(),
} }
} else {
LanguageServerKind::Remote {
project: project.downgrade(),
}
}; };
match event { match event {
project::Event::LanguageServerAdded(id, name, worktree_id) => { project::Event::LanguageServerAdded(id, name, worktree_id) => {
this.add_language_server( log_store.add_language_server(
server_kind, server_kind,
*id, *id,
Some(name.clone()), Some(name.clone()),
@ -347,16 +359,36 @@ impl LogStore {
); );
} }
project::Event::LanguageServerRemoved(id) => { project::Event::LanguageServerRemoved(id) => {
this.remove_language_server(*id, cx); log_store.remove_language_server(*id, cx);
} }
project::Event::LanguageServerLog(id, typ, message) => { project::Event::LanguageServerLog(id, typ, message) => {
this.add_language_server(server_kind, *id, None, None, None, cx); log_store.add_language_server(
server_kind,
*id,
None,
None,
None,
cx,
);
match typ { match typ {
project::LanguageServerLogType::Log(typ) => { project::LanguageServerLogType::Log(typ) => {
this.add_language_server_log(*id, *typ, message, cx); log_store.add_language_server_log(*id, *typ, message, cx);
} }
project::LanguageServerLogType::Trace(_) => { project::LanguageServerLogType::Trace { verbose_info } => {
this.add_language_server_trace(*id, message, cx); log_store.add_language_server_trace(
*id,
message,
verbose_info.clone(),
cx,
);
}
project::LanguageServerLogType::Rpc { received } => {
let kind = if *received {
MessageKind::Receive
} else {
MessageKind::Send
};
log_store.add_language_server_rpc(*id, kind, message, cx);
} }
} }
} }
@ -375,7 +407,7 @@ impl LogStore {
self.language_servers.get_mut(&id) self.language_servers.get_mut(&id)
} }
fn add_language_server( pub fn add_language_server(
&mut self, &mut self,
kind: LanguageServerKind, kind: LanguageServerKind,
server_id: LanguageServerId, server_id: LanguageServerId,
@ -426,20 +458,35 @@ impl LogStore {
message: &str, message: &str,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Option<()> { ) -> Option<()> {
let store_logs = self.store_logs;
let language_server_state = self.get_language_server_state(id)?; let language_server_state = self.get_language_server_state(id)?;
let log_lines = &mut language_server_state.log_messages; let log_lines = &mut language_server_state.log_messages;
Self::add_language_server_message( let message = message.trim_end().to_string();
log_lines, if !store_logs {
// Send all messages regardless of the visibility in case of not storing, to notify the receiver anyway
self.emit_event(
Event::NewServerLogEntry {
id, id,
LogMessage { kind: LanguageServerLogType::Log(typ),
message: message.trim_end().to_string(), text: message,
typ,
}, },
language_server_state.log_level,
LogKind::Logs,
cx, cx,
); );
} else if let Some(new_message) = Self::push_new_message(
log_lines,
LogMessage { message, typ },
language_server_state.log_level,
) {
self.emit_event(
Event::NewServerLogEntry {
id,
kind: LanguageServerLogType::Log(typ),
text: new_message,
},
cx,
);
}
Some(()) Some(())
} }
@ -447,46 +494,133 @@ impl LogStore {
&mut self, &mut self,
id: LanguageServerId, id: LanguageServerId,
message: &str, message: &str,
verbose_info: Option<String>,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Option<()> { ) -> Option<()> {
let store_logs = self.store_logs;
let language_server_state = self.get_language_server_state(id)?; let language_server_state = self.get_language_server_state(id)?;
let log_lines = &mut language_server_state.trace_messages; let log_lines = &mut language_server_state.trace_messages;
Self::add_language_server_message( if !store_logs {
log_lines, // Send all messages regardless of the visibility in case of not storing, to notify the receiver anyway
self.emit_event(
Event::NewServerLogEntry {
id, id,
TraceMessage { kind: LanguageServerLogType::Trace { verbose_info },
message: message.trim().to_string(), text: message.trim().to_string(),
}, },
(),
LogKind::Trace,
cx, cx,
); );
} else if let Some(new_message) = Self::push_new_message(
log_lines,
TraceMessage {
message: message.trim().to_string(),
is_verbose: false,
},
TraceValue::Messages,
) {
if let Some(verbose_message) = verbose_info.as_ref() {
Self::push_new_message(
log_lines,
TraceMessage {
message: verbose_message.clone(),
is_verbose: true,
},
TraceValue::Verbose,
);
}
self.emit_event(
Event::NewServerLogEntry {
id,
kind: LanguageServerLogType::Trace { verbose_info },
text: new_message,
},
cx,
);
}
Some(()) Some(())
} }
fn add_language_server_message<T: Message>( fn push_new_message<T: Message>(
log_lines: &mut VecDeque<T>, log_lines: &mut VecDeque<T>,
id: LanguageServerId,
message: T, message: T,
current_severity: <T as Message>::Level, current_severity: <T as Message>::Level,
kind: LogKind, ) -> Option<String> {
cx: &mut Context<Self>,
) {
while log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES { while log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES {
log_lines.pop_front(); log_lines.pop_front();
} }
let text = message.as_ref().to_string();
let visible = message.should_include(current_severity); let visible = message.should_include(current_severity);
let visible_message = visible.then(|| message.as_ref().to_string());
log_lines.push_back(message); log_lines.push_back(message);
visible_message
if visible {
cx.emit(Event::NewServerLogEntry { id, kind, text });
cx.notify();
}
} }
fn remove_language_server(&mut self, id: LanguageServerId, cx: &mut Context<Self>) { fn add_language_server_rpc(
&mut self,
language_server_id: LanguageServerId,
kind: MessageKind,
message: &str,
cx: &mut Context<'_, Self>,
) {
let store_logs = self.store_logs;
let Some(state) = self
.get_language_server_state(language_server_id)
.and_then(|state| state.rpc_state.as_mut())
else {
return;
};
let mut line_before_message_to_send = None;
let rpc_log_lines = &mut state.rpc_messages;
if state.last_message_kind != Some(kind) {
while rpc_log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES {
rpc_log_lines.pop_front();
}
let line_before_message = match kind {
MessageKind::Send => SEND_LINE,
MessageKind::Receive => RECEIVE_LINE,
};
if store_logs {
rpc_log_lines.push_back(RpcMessage {
message: line_before_message.to_string(),
});
}
line_before_message_to_send = Some(line_before_message);
}
while rpc_log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES {
rpc_log_lines.pop_front();
}
if store_logs {
rpc_log_lines.push_back(RpcMessage {
message: message.trim().to_owned(),
});
}
let received = kind == MessageKind::Receive;
if let Some(line_before_message) = line_before_message_to_send {
self.emit_event(
Event::NewServerLogEntry {
id: language_server_id,
kind: LanguageServerLogType::Rpc { received },
text: line_before_message.to_string(),
},
cx,
);
}
self.emit_event(
Event::NewServerLogEntry {
id: language_server_id,
kind: LanguageServerLogType::Rpc { received },
text: message.to_owned(),
},
cx,
);
}
pub fn remove_language_server(&mut self, id: LanguageServerId, cx: &mut Context<Self>) {
self.language_servers.remove(&id); self.language_servers.remove(&id);
cx.notify(); cx.notify();
} }
@ -516,11 +650,11 @@ impl LogStore {
None None
} }
} }
LanguageServerKind::Global => Some(*id), LanguageServerKind::Global | LanguageServerKind::LocalSsh { .. } => Some(*id),
}) })
} }
fn enable_rpc_trace_for_language_server( pub fn enable_rpc_trace_for_language_server(
&mut self, &mut self,
server_id: LanguageServerId, server_id: LanguageServerId,
) -> Option<&mut LanguageServerRpcState> { ) -> Option<&mut LanguageServerRpcState> {
@ -663,51 +797,47 @@ impl LogStore {
} }
}; };
let state = self
.get_language_server_state(language_server_id)?
.rpc_state
.as_mut()?;
let kind = if is_received { let kind = if is_received {
MessageKind::Receive MessageKind::Receive
} else { } else {
MessageKind::Send MessageKind::Send
}; };
let rpc_log_lines = &mut state.rpc_messages; self.add_language_server_rpc(language_server_id, kind, message, cx);
if state.last_message_kind != Some(kind) {
while rpc_log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES {
rpc_log_lines.pop_front();
}
let line_before_message = match kind {
MessageKind::Send => SEND_LINE,
MessageKind::Receive => RECEIVE_LINE,
};
rpc_log_lines.push_back(RpcMessage {
message: line_before_message.to_string(),
});
cx.emit(Event::NewServerLogEntry {
id: language_server_id,
kind: LogKind::Rpc,
text: line_before_message.to_string(),
});
}
while rpc_log_lines.len() + 1 >= MAX_STORED_LOG_ENTRIES {
rpc_log_lines.pop_front();
}
let message = message.trim();
rpc_log_lines.push_back(RpcMessage {
message: message.to_string(),
});
cx.emit(Event::NewServerLogEntry {
id: language_server_id,
kind: LogKind::Rpc,
text: message.to_string(),
});
cx.notify(); cx.notify();
Some(()) Some(())
} }
fn emit_event(&mut self, e: Event, cx: &mut Context<Self>) {
match &e {
Event::NewServerLogEntry { id, kind, text } => {
if let Some(state) = self.get_language_server_state(*id) {
let downstream_client = match &state.kind {
LanguageServerKind::Remote { project }
| LanguageServerKind::Local { project } => project
.upgrade()
.map(|project| project.read(cx).lsp_store()),
LanguageServerKind::LocalSsh { lsp_store } => lsp_store.upgrade(),
LanguageServerKind::Global => None,
}
.and_then(|lsp_store| lsp_store.read(cx).downstream_client());
if let Some((client, project_id)) = downstream_client {
log::error!("|||||||||| {text}");
client
.send(proto::LanguageServerLog {
project_id,
language_server_id: id.to_proto(),
message: text.clone(),
log_type: Some(kind.to_proto()),
})
.ok();
}
}
}
}
cx.emit(e);
}
} }
impl LspLogView { impl LspLogView {
@ -751,13 +881,14 @@ impl LspLogView {
cx.notify(); cx.notify();
}); });
let events_subscriptions = cx.subscribe_in(
&log_store, let events_subscriptions =
window, cx.subscribe_in(&log_store, window, move |log_view, _, e, window, cx| {
move |log_view, _, e, window, cx| match e { log::error!("@@@@@@ {e:?}");
match e {
Event::NewServerLogEntry { id, kind, text } => { Event::NewServerLogEntry { id, kind, text } => {
if log_view.current_server_id == Some(*id) if log_view.current_server_id == Some(*id)
&& *kind == log_view.active_entry_kind && LogKind::from_server_log_type(kind) == log_view.active_entry_kind
{ {
log_view.editor.update(cx, |editor, cx| { log_view.editor.update(cx, |editor, cx| {
editor.set_read_only(false); editor.set_read_only(false);
@ -791,8 +922,8 @@ impl LspLogView {
}); });
} }
} }
}, }
); });
let (editor, editor_subscriptions) = Self::editor_for_logs(String::new(), window, cx); let (editor, editor_subscriptions) = Self::editor_for_logs(String::new(), window, cx);
let focus_handle = cx.focus_handle(); let focus_handle = cx.focus_handle();
@ -800,7 +931,7 @@ impl LspLogView {
window.focus(&log_view.editor.focus_handle(cx)); window.focus(&log_view.editor.focus_handle(cx));
}); });
let mut this = Self { let mut lsp_log_view = Self {
focus_handle, focus_handle,
editor, editor,
editor_subscriptions, editor_subscriptions,
@ -815,9 +946,9 @@ impl LspLogView {
], ],
}; };
if let Some(server_id) = server_id { if let Some(server_id) = server_id {
this.show_logs_for_server(server_id, window, cx); lsp_log_view.show_logs_for_server(server_id, window, cx);
} }
this lsp_log_view
} }
fn editor_for_logs( fn editor_for_logs(
@ -838,7 +969,7 @@ impl LspLogView {
} }
fn editor_for_server_info( fn editor_for_server_info(
server: &LanguageServer, info: ServerInfo,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> (Entity<Editor>, Vec<Subscription>) { ) -> (Entity<Editor>, Vec<Subscription>) {
@ -853,22 +984,21 @@ impl LspLogView {
* Capabilities: {CAPABILITIES} * Capabilities: {CAPABILITIES}
* Configuration: {CONFIGURATION}", * Configuration: {CONFIGURATION}",
NAME = server.name(), NAME = info.name,
ID = server.server_id(), ID = info.id,
BINARY = server.binary(), BINARY = info.binary.as_ref().map_or_else(
WORKSPACE_FOLDERS = server || "Unknown".to_string(),
.workspace_folders() |bin| bin.path.as_path().to_string_lossy().to_string()
.into_iter() ),
.filter_map(|path| path WORKSPACE_FOLDERS = info.workspace_folders.join(", "),
.to_file_path() CAPABILITIES = serde_json::to_string_pretty(&info.capabilities)
.ok()
.map(|path| path.to_string_lossy().into_owned()))
.collect::<Vec<_>>()
.join(", "),
CAPABILITIES = serde_json::to_string_pretty(&server.capabilities())
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")), .unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
CONFIGURATION = serde_json::to_string_pretty(server.configuration()) CONFIGURATION = info
.unwrap_or_else(|e| format!("Failed to serialize configuration: {e}")), .configuration
.map(|configuration| serde_json::to_string_pretty(&configuration))
.transpose()
.unwrap_or_else(|e| Some(format!("Failed to serialize configuration: {e}")))
.unwrap_or_else(|| "Unknown".to_string()),
); );
let editor = initialize_new_editor(server_info, false, window, cx); let editor = initialize_new_editor(server_info, false, window, cx);
let editor_subscription = cx.subscribe( let editor_subscription = cx.subscribe(
@ -891,7 +1021,9 @@ impl LspLogView {
.language_servers .language_servers
.iter() .iter()
.map(|(server_id, state)| match &state.kind { .map(|(server_id, state)| match &state.kind {
LanguageServerKind::Local { .. } | LanguageServerKind::Remote { .. } => { LanguageServerKind::Local { .. }
| LanguageServerKind::Remote { .. }
| LanguageServerKind::LocalSsh { .. } => {
let worktree_root_name = state let worktree_root_name = state
.worktree_id .worktree_id
.and_then(|id| self.project.read(cx).worktree_for_id(id, cx)) .and_then(|id| self.project.read(cx).worktree_for_id(id, cx))
@ -1003,11 +1135,17 @@ impl LspLogView {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let trace_level = self
.log_store
.update(cx, |this, _| {
Some(this.get_language_server_state(server_id)?.trace_level)
})
.unwrap_or(TraceValue::Messages);
let log_contents = self let log_contents = self
.log_store .log_store
.read(cx) .read(cx)
.server_trace(server_id) .server_trace(server_id)
.map(|v| log_contents(v, ())); .map(|v| log_contents(v, trace_level));
if let Some(log_contents) = log_contents { if let Some(log_contents) = log_contents {
self.current_server_id = Some(server_id); self.current_server_id = Some(server_id);
self.active_entry_kind = LogKind::Trace; self.active_entry_kind = LogKind::Trace;
@ -1025,6 +1163,7 @@ impl LspLogView {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
self.toggle_rpc_trace_for_server(server_id, true, window, cx);
let rpc_log = self.log_store.update(cx, |log_store, _| { let rpc_log = self.log_store.update(cx, |log_store, _| {
log_store log_store
.enable_rpc_trace_for_language_server(server_id) .enable_rpc_trace_for_language_server(server_id)
@ -1069,12 +1208,33 @@ impl LspLogView {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
self.log_store.update(cx, |log_store, _| { self.log_store.update(cx, |log_store, cx| {
if enabled { if enabled {
log_store.enable_rpc_trace_for_language_server(server_id); log_store.enable_rpc_trace_for_language_server(server_id);
} else { } else {
log_store.disable_rpc_trace_for_language_server(server_id); log_store.disable_rpc_trace_for_language_server(server_id);
} }
if let Some(server_state) = log_store.language_servers.get(&server_id) {
if let LanguageServerKind::Remote { project } = &server_state.kind {
project
.update(cx, |project, cx| {
if let Some((client, project_id)) =
project.lsp_store().read(cx).upstream_client()
{
client
.send(proto::ToggleLspLogs {
project_id,
log_type: proto::toggle_lsp_logs::LogType::Rpc as i32,
server_id: server_id.to_proto(),
enabled,
})
.log_err();
}
})
.ok();
}
};
}); });
if !enabled && Some(server_id) == self.current_server_id { if !enabled && Some(server_id) == self.current_server_id {
self.show_logs_for_server(server_id, window, cx); self.show_logs_for_server(server_id, window, cx);
@ -1113,13 +1273,38 @@ impl LspLogView {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let lsp_store = self.project.read(cx).lsp_store(); let Some(server_info) = self
let Some(server) = lsp_store.read(cx).language_server_for_id(server_id) else { .project
.read(cx)
.lsp_store()
.update(cx, |lsp_store, _| {
lsp_store
.language_server_for_id(server_id)
.as_ref()
.map(|language_server| ServerInfo::new(language_server))
.or_else(move || {
let capabilities =
lsp_store.lsp_server_capabilities.get(&server_id)?.clone();
let name = lsp_store
.language_server_statuses
.get(&server_id)
.map(|status| status.name.clone())?;
Some(ServerInfo {
id: server_id,
capabilities,
binary: None,
name,
workspace_folders: Vec::new(),
configuration: None,
})
})
})
else {
return; return;
}; };
self.current_server_id = Some(server_id); self.current_server_id = Some(server_id);
self.active_entry_kind = LogKind::ServerInfo; self.active_entry_kind = LogKind::ServerInfo;
let (editor, editor_subscriptions) = Self::editor_for_server_info(&server, window, cx); let (editor, editor_subscriptions) = Self::editor_for_server_info(server_info, window, cx);
self.editor = editor; self.editor = editor;
self.editor_subscriptions = editor_subscriptions; self.editor_subscriptions = editor_subscriptions;
cx.notify(); cx.notify();
@ -1416,7 +1601,6 @@ impl Render for LspLogToolbarItemView {
let view_selector = current_server.map(|server| { let view_selector = current_server.map(|server| {
let server_id = server.server_id; let server_id = server.server_id;
let is_remote = server.server_kind.is_remote();
let rpc_trace_enabled = server.rpc_trace_enabled; let rpc_trace_enabled = server.rpc_trace_enabled;
let log_view = log_view.clone(); let log_view = log_view.clone();
PopoverMenu::new("LspViewSelector") PopoverMenu::new("LspViewSelector")
@ -1438,8 +1622,7 @@ impl Render for LspLogToolbarItemView {
view.show_logs_for_server(server_id, window, cx); view.show_logs_for_server(server_id, window, cx);
}), }),
) )
.when(!is_remote, |this| { .entry(
this.entry(
SERVER_TRACE, SERVER_TRACE,
None, None,
window.handler_for(&log_view, move |view, window, cx| { window.handler_for(&log_view, move |view, window, cx| {
@ -1486,7 +1669,6 @@ impl Render for LspLogToolbarItemView {
view.show_rpc_trace_for_server(server_id, window, cx); view.show_rpc_trace_for_server(server_id, window, cx);
}), }),
) )
})
.entry( .entry(
SERVER_INFO, SERVER_INFO,
None, None,
@ -1696,12 +1878,6 @@ const SERVER_LOGS: &str = "Server Logs";
const SERVER_TRACE: &str = "Server Trace"; const SERVER_TRACE: &str = "Server Trace";
const SERVER_INFO: &str = "Server Info"; const SERVER_INFO: &str = "Server Info";
impl Default for LspLogToolbarItemView {
fn default() -> Self {
Self::new()
}
}
impl LspLogToolbarItemView { impl LspLogToolbarItemView {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
@ -1734,10 +1910,41 @@ impl LspLogToolbarItemView {
} }
} }
struct ServerInfo {
id: LanguageServerId,
capabilities: lsp::ServerCapabilities,
binary: Option<LanguageServerBinary>,
name: LanguageServerName,
workspace_folders: Vec<String>,
configuration: Option<serde_json::Value>,
}
impl ServerInfo {
fn new(server: &LanguageServer) -> Self {
Self {
id: server.server_id(),
capabilities: server.capabilities(),
binary: Some(server.binary().clone()),
name: server.name(),
workspace_folders: server
.workspace_folders()
.into_iter()
.filter_map(|path| {
path.to_file_path()
.ok()
.map(|path| path.to_string_lossy().into_owned())
})
.collect::<Vec<_>>(),
configuration: Some(server.configuration().clone()),
}
}
}
#[derive(Debug)]
pub enum Event { pub enum Event {
NewServerLogEntry { NewServerLogEntry {
id: LanguageServerId, id: LanguageServerId,
kind: LogKind, kind: LanguageServerLogType,
text: String, text: String,
}, },
} }

View file

@ -51,7 +51,7 @@ async fn test_lsp_logs(cx: &mut TestAppContext) {
}, },
); );
let log_store = cx.new(LogStore::new); let log_store = cx.new(|cx| LogStore::new(true, cx));
log_store.update(cx, |store, cx| store.add_project(&project, cx)); log_store.update(cx, |store, cx| store.add_project(&project, cx));
let _rust_buffer = project let _rust_buffer = project

View file

@ -122,8 +122,7 @@ impl LanguageServerState {
let lsp_logs = cx let lsp_logs = cx
.try_global::<GlobalLogStore>() .try_global::<GlobalLogStore>()
.and_then(|lsp_logs| lsp_logs.0.upgrade()); .and_then(|lsp_logs| lsp_logs.0.upgrade());
let lsp_store = self.lsp_store.upgrade(); let Some(lsp_logs) = lsp_logs else {
let Some((lsp_logs, lsp_store)) = lsp_logs.zip(lsp_store) else {
return menu; return menu;
}; };
@ -210,10 +209,7 @@ impl LanguageServerState {
}; };
let server_selector = server_info.server_selector(); let server_selector = server_info.server_selector();
// TODO currently, Zed remote does not work well with the LSP logs let has_logs = lsp_logs.read(cx).has_server_logs(&server_selector);
// https://github.com/zed-industries/zed/issues/28557
let has_logs = lsp_store.read(cx).as_local().is_some()
&& lsp_logs.read(cx).has_server_logs(&server_selector);
let status_color = server_info let status_color = server_info
.binary_status .binary_status

View file

@ -977,7 +977,9 @@ impl LocalLspStore {
this.update(&mut cx, |_, cx| { this.update(&mut cx, |_, cx| {
cx.emit(LspStoreEvent::LanguageServerLog( cx.emit(LspStoreEvent::LanguageServerLog(
server_id, server_id,
LanguageServerLogType::Trace(params.verbose), LanguageServerLogType::Trace {
verbose_info: params.verbose,
},
params.message, params.message,
)); ));
}) })
@ -3482,13 +3484,13 @@ pub struct LspStore {
buffer_store: Entity<BufferStore>, buffer_store: Entity<BufferStore>,
worktree_store: Entity<WorktreeStore>, worktree_store: Entity<WorktreeStore>,
pub languages: Arc<LanguageRegistry>, pub languages: Arc<LanguageRegistry>,
language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>, pub language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>,
active_entry: Option<ProjectEntryId>, active_entry: Option<ProjectEntryId>,
_maintain_workspace_config: (Task<Result<()>>, watch::Sender<()>), _maintain_workspace_config: (Task<Result<()>>, watch::Sender<()>),
_maintain_buffer_languages: Task<()>, _maintain_buffer_languages: Task<()>,
diagnostic_summaries: diagnostic_summaries:
HashMap<WorktreeId, HashMap<Arc<Path>, HashMap<LanguageServerId, DiagnosticSummary>>>, HashMap<WorktreeId, HashMap<Arc<Path>, HashMap<LanguageServerId, DiagnosticSummary>>>,
pub(super) lsp_server_capabilities: HashMap<LanguageServerId, lsp::ServerCapabilities>, pub lsp_server_capabilities: HashMap<LanguageServerId, lsp::ServerCapabilities>,
lsp_document_colors: HashMap<BufferId, DocumentColorData>, lsp_document_colors: HashMap<BufferId, DocumentColorData>,
lsp_code_lens: HashMap<BufferId, CodeLensData>, lsp_code_lens: HashMap<BufferId, CodeLensData>,
running_lsp_requests: HashMap<TypeId, (Global, HashMap<LspRequestId, Task<()>>)>, running_lsp_requests: HashMap<TypeId, (Global, HashMap<LspRequestId, Task<()>>)>,
@ -12168,6 +12170,10 @@ impl LspStore {
let data = self.lsp_code_lens.get_mut(&buffer_id)?; let data = self.lsp_code_lens.get_mut(&buffer_id)?;
Some(data.update.take()?.1) Some(data.update.take()?.1)
} }
pub fn downstream_client(&self) -> Option<(AnyProtoClient, u64)> {
self.downstream_client.clone()
}
} }
// Registration with registerOptions as null, should fallback to true. // Registration with registerOptions as null, should fallback to true.
@ -12677,45 +12683,69 @@ impl PartialEq for LanguageServerPromptRequest {
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum LanguageServerLogType { pub enum LanguageServerLogType {
Log(MessageType), Log(MessageType),
Trace(Option<String>), Trace { verbose_info: Option<String> },
Rpc { received: bool },
} }
impl LanguageServerLogType { impl LanguageServerLogType {
pub fn to_proto(&self) -> proto::language_server_log::LogType { pub fn to_proto(&self) -> proto::language_server_log::LogType {
match self { match self {
Self::Log(log_type) => { Self::Log(log_type) => {
let message_type = match *log_type { use proto::log_message::LogLevel;
MessageType::ERROR => 1, let level = match *log_type {
MessageType::WARNING => 2, MessageType::ERROR => LogLevel::Error,
MessageType::INFO => 3, MessageType::WARNING => LogLevel::Warning,
MessageType::LOG => 4, MessageType::INFO => LogLevel::Info,
MessageType::LOG => LogLevel::Log,
other => { other => {
log::warn!("Unknown lsp log message type: {:?}", other); log::warn!("Unknown lsp log message type: {other:?}");
4 LogLevel::Log
} }
}; };
proto::language_server_log::LogType::LogMessageType(message_type) proto::language_server_log::LogType::Log(proto::LogMessage {
} level: level as i32,
Self::Trace(message) => {
proto::language_server_log::LogType::LogTrace(proto::LspLogTrace {
message: message.clone(),
}) })
} }
Self::Trace { verbose_info } => {
proto::language_server_log::LogType::Trace(proto::TraceMessage {
verbose_info: verbose_info.to_owned(),
})
}
Self::Rpc { received } => {
let kind = if *received {
proto::rpc_message::Kind::Received
} else {
proto::rpc_message::Kind::Sent
};
let kind = kind as i32;
proto::language_server_log::LogType::Rpc(proto::RpcMessage { kind })
}
} }
} }
pub fn from_proto(log_type: proto::language_server_log::LogType) -> Self { pub fn from_proto(log_type: proto::language_server_log::LogType) -> Self {
use proto::log_message::LogLevel;
use proto::rpc_message;
match log_type { match log_type {
proto::language_server_log::LogType::LogMessageType(message_type) => { proto::language_server_log::LogType::Log(message_type) => Self::Log(
Self::Log(match message_type { match LogLevel::from_i32(message_type.level).unwrap_or(LogLevel::Log) {
1 => MessageType::ERROR, LogLevel::Error => MessageType::ERROR,
2 => MessageType::WARNING, LogLevel::Warning => MessageType::WARNING,
3 => MessageType::INFO, LogLevel::Info => MessageType::INFO,
4 => MessageType::LOG, LogLevel::Log => MessageType::LOG,
_ => MessageType::LOG, },
}) ),
} proto::language_server_log::LogType::Trace(trace_message) => Self::Trace {
proto::language_server_log::LogType::LogTrace(trace) => Self::Trace(trace.message), verbose_info: trace_message.verbose_info,
},
proto::language_server_log::LogType::Rpc(message) => Self::Rpc {
received: match rpc_message::Kind::from_i32(message.kind)
.unwrap_or(rpc_message::Kind::Received)
{
rpc_message::Kind::Received => true,
rpc_message::Kind::Sent => false,
},
},
} }
} }
} }

View file

@ -1355,6 +1355,7 @@ impl Project {
ssh_proto.subscribe_to_entity(SSH_PROJECT_ID, &this.settings_observer); ssh_proto.subscribe_to_entity(SSH_PROJECT_ID, &this.settings_observer);
ssh_proto.subscribe_to_entity(SSH_PROJECT_ID, &this.git_store); ssh_proto.subscribe_to_entity(SSH_PROJECT_ID, &this.git_store);
ssh_proto.add_entity_message_handler(Self::handle_toggle_lsp_logs);
ssh_proto.add_entity_message_handler(Self::handle_create_buffer_for_peer); ssh_proto.add_entity_message_handler(Self::handle_create_buffer_for_peer);
ssh_proto.add_entity_message_handler(Self::handle_update_worktree); ssh_proto.add_entity_message_handler(Self::handle_update_worktree);
ssh_proto.add_entity_message_handler(Self::handle_update_project); ssh_proto.add_entity_message_handler(Self::handle_update_project);
@ -4629,6 +4630,16 @@ impl Project {
})? })?
} }
// TODO kb
async fn handle_toggle_lsp_logs(
_this: Entity<Self>,
_envelope: TypedEnvelope<proto::ToggleLspLogs>,
_cx: AsyncApp,
) -> Result<()> {
log::error!("##########PPPPPPPPPPPPPPPproject##########################");
Ok(())
}
async fn handle_update_buffer_from_ssh( async fn handle_update_buffer_from_ssh(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::UpdateBuffer>, envelope: TypedEnvelope<proto::UpdateBuffer>,

View file

@ -610,11 +610,36 @@ message ServerMetadataUpdated {
message LanguageServerLog { message LanguageServerLog {
uint64 project_id = 1; uint64 project_id = 1;
uint64 language_server_id = 2; uint64 language_server_id = 2;
string message = 3;
oneof log_type { oneof log_type {
uint32 log_message_type = 3; LogMessage log = 4;
LspLogTrace log_trace = 4; TraceMessage trace = 5;
RpcMessage rpc = 6;
}
}
message LogMessage {
LogLevel level = 1;
enum LogLevel {
LOG = 0;
INFO = 1;
WARNING = 2;
ERROR = 3;
}
}
message TraceMessage {
optional string verbose_info = 1;
}
message RpcMessage {
Kind kind = 1;
enum Kind {
RECEIVED = 0;
SENT = 1;
} }
string message = 5;
} }
message LspLogTrace { message LspLogTrace {
@ -932,3 +957,16 @@ message MultiLspQuery {
message MultiLspQueryResponse { message MultiLspQueryResponse {
repeated LspResponse responses = 1; repeated LspResponse responses = 1;
} }
message ToggleLspLogs {
uint64 project_id = 1;
LogType log_type = 2;
uint64 server_id = 3;
bool enabled = 4;
enum LogType {
LOG = 0;
TRACE = 1;
RPC = 2;
}
}

View file

@ -396,7 +396,8 @@ message Envelope {
GitCloneResponse git_clone_response = 364; GitCloneResponse git_clone_response = 364;
LspQuery lsp_query = 365; LspQuery lsp_query = 365;
LspQueryResponse lsp_query_response = 366; // current max LspQueryResponse lsp_query_response = 366;
ToggleLspLogs toggle_lsp_logs = 367; // current max
} }
reserved 87 to 88; reserved 87 to 88;

View file

@ -312,7 +312,8 @@ messages!(
(GetDefaultBranch, Background), (GetDefaultBranch, Background),
(GetDefaultBranchResponse, Background), (GetDefaultBranchResponse, Background),
(GitClone, Background), (GitClone, Background),
(GitCloneResponse, Background) (GitCloneResponse, Background),
(ToggleLspLogs, Background),
); );
request_messages!( request_messages!(
@ -481,7 +482,8 @@ request_messages!(
(GetDocumentDiagnostics, GetDocumentDiagnosticsResponse), (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
(PullWorkspaceDiagnostics, Ack), (PullWorkspaceDiagnostics, Ack),
(GetDefaultBranch, GetDefaultBranchResponse), (GetDefaultBranch, GetDefaultBranchResponse),
(GitClone, GitCloneResponse) (GitClone, GitCloneResponse),
(ToggleLspLogs, Ack),
); );
lsp_messages!( lsp_messages!(
@ -612,6 +614,7 @@ entity_messages!(
GitReset, GitReset,
GitCheckoutFiles, GitCheckoutFiles,
SetIndexText, SetIndexText,
ToggleLspLogs,
Push, Push,
Fetch, Fetch,

View file

@ -43,6 +43,7 @@ gpui_tokio.workspace = true
http_client.workspace = true http_client.workspace = true
language.workspace = true language.workspace = true
language_extension.workspace = true language_extension.workspace = true
language_tools.workspace = true
languages.workspace = true languages.workspace = true
log.workspace = true log.workspace = true
lsp.workspace = true lsp.workspace = true

View file

@ -1,5 +1,7 @@
use ::proto::{FromProto, ToProto}; use ::proto::{FromProto, ToProto};
use anyhow::{Context as _, Result, anyhow}; use anyhow::{Context as _, Result, anyhow};
use language_tools::lsp_log::{GlobalLogStore, LanguageServerKind};
use lsp::LanguageServerId;
use extension::ExtensionHostProxy; use extension::ExtensionHostProxy;
use extension_host::headless_host::HeadlessExtensionStore; use extension_host::headless_host::HeadlessExtensionStore;
@ -65,6 +67,7 @@ impl HeadlessProject {
settings::init(cx); settings::init(cx);
language::init(cx); language::init(cx);
project::Project::init_settings(cx); project::Project::init_settings(cx);
language_tools::lsp_log::init(false, cx);
} }
pub fn new( pub fn new(
@ -235,6 +238,7 @@ impl HeadlessProject {
session.add_entity_request_handler(Self::handle_open_new_buffer); session.add_entity_request_handler(Self::handle_open_new_buffer);
session.add_entity_request_handler(Self::handle_find_search_candidates); session.add_entity_request_handler(Self::handle_find_search_candidates);
session.add_entity_request_handler(Self::handle_open_server_settings); session.add_entity_request_handler(Self::handle_open_server_settings);
session.add_entity_message_handler(Self::handle_toggle_lsp_logs);
session.add_entity_request_handler(BufferStore::handle_update_buffer); session.add_entity_request_handler(BufferStore::handle_update_buffer);
session.add_entity_message_handler(BufferStore::handle_close_buffer); session.add_entity_message_handler(BufferStore::handle_close_buffer);
@ -298,11 +302,40 @@ impl HeadlessProject {
fn on_lsp_store_event( fn on_lsp_store_event(
&mut self, &mut self,
_lsp_store: Entity<LspStore>, lsp_store: Entity<LspStore>,
event: &LspStoreEvent, event: &LspStoreEvent,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
match event { match event {
LspStoreEvent::LanguageServerAdded(id, name, worktree_id) => {
let log_store = cx
.try_global::<GlobalLogStore>()
.and_then(|lsp_logs| lsp_logs.0.upgrade());
if let Some(log_store) = log_store {
log_store.update(cx, |log_store, cx| {
log_store.add_language_server(
LanguageServerKind::LocalSsh {
lsp_store: self.lsp_store.downgrade(),
},
*id,
Some(name.clone()),
*worktree_id,
lsp_store.read(cx).language_server_for_id(*id),
cx,
);
});
}
}
LspStoreEvent::LanguageServerRemoved(id) => {
let log_store = cx
.try_global::<GlobalLogStore>()
.and_then(|lsp_logs| lsp_logs.0.upgrade());
if let Some(log_store) = log_store {
log_store.update(cx, |log_store, cx| {
log_store.remove_language_server(*id, cx);
});
}
}
LspStoreEvent::LanguageServerUpdate { LspStoreEvent::LanguageServerUpdate {
language_server_id, language_server_id,
name, name,
@ -326,16 +359,6 @@ impl HeadlessProject {
}) })
.log_err(); .log_err();
} }
LspStoreEvent::LanguageServerLog(language_server_id, log_type, message) => {
self.session
.send(proto::LanguageServerLog {
project_id: SSH_PROJECT_ID,
language_server_id: language_server_id.to_proto(),
message: message.clone(),
log_type: Some(log_type.to_proto()),
})
.log_err();
}
LspStoreEvent::LanguageServerPrompt(prompt) => { LspStoreEvent::LanguageServerPrompt(prompt) => {
let request = self.session.request(proto::LanguageServerPromptRequest { let request = self.session.request(proto::LanguageServerPromptRequest {
project_id: SSH_PROJECT_ID, project_id: SSH_PROJECT_ID,
@ -509,7 +532,31 @@ impl HeadlessProject {
}) })
} }
pub async fn handle_open_server_settings( async fn handle_toggle_lsp_logs(
_: Entity<Self>,
envelope: TypedEnvelope<proto::ToggleLspLogs>,
mut cx: AsyncApp,
) -> Result<()> {
let server_id = LanguageServerId::from_proto(envelope.payload.server_id);
let lsp_logs = cx
.update(|cx| {
cx.try_global::<GlobalLogStore>()
.and_then(|lsp_logs| lsp_logs.0.upgrade())
})?
.context("lsp logs store is missing")?;
lsp_logs.update(&mut cx, |lsp_logs, _| {
// we do not support any other log toggling yet
if envelope.payload.enabled {
lsp_logs.enable_rpc_trace_for_language_server(server_id);
} else {
lsp_logs.disable_rpc_trace_for_language_server(server_id);
}
})?;
Ok(())
}
async fn handle_open_server_settings(
this: Entity<Self>, this: Entity<Self>,
_: TypedEnvelope<proto::OpenServerSettings>, _: TypedEnvelope<proto::OpenServerSettings>,
mut cx: AsyncApp, mut cx: AsyncApp,
@ -562,7 +609,7 @@ impl HeadlessProject {
}) })
} }
pub async fn handle_find_search_candidates( async fn handle_find_search_candidates(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::FindSearchCandidates>, envelope: TypedEnvelope<proto::FindSearchCandidates>,
mut cx: AsyncApp, mut cx: AsyncApp,
@ -594,7 +641,7 @@ impl HeadlessProject {
Ok(response) Ok(response)
} }
pub async fn handle_list_remote_directory( async fn handle_list_remote_directory(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::ListRemoteDirectory>, envelope: TypedEnvelope<proto::ListRemoteDirectory>,
cx: AsyncApp, cx: AsyncApp,
@ -626,7 +673,7 @@ impl HeadlessProject {
}) })
} }
pub async fn handle_get_path_metadata( async fn handle_get_path_metadata(
this: Entity<Self>, this: Entity<Self>,
envelope: TypedEnvelope<proto::GetPathMetadata>, envelope: TypedEnvelope<proto::GetPathMetadata>,
cx: AsyncApp, cx: AsyncApp,
@ -644,7 +691,7 @@ impl HeadlessProject {
}) })
} }
pub async fn handle_shutdown_remote_server( async fn handle_shutdown_remote_server(
_this: Entity<Self>, _this: Entity<Self>,
_envelope: TypedEnvelope<proto::ShutdownRemoteServer>, _envelope: TypedEnvelope<proto::ShutdownRemoteServer>,
cx: AsyncApp, cx: AsyncApp,

View file

@ -13,6 +13,7 @@ path = "src/workspace.rs"
doctest = false doctest = false
[features] [features]
default = ["call"]
test-support = [ test-support = [
"call/test-support", "call/test-support",
"client/test-support", "client/test-support",
@ -29,7 +30,7 @@ test-support = [
any_vec.workspace = true any_vec.workspace = true
anyhow.workspace = true anyhow.workspace = true
async-recursion.workspace = true async-recursion.workspace = true
call.workspace = true call = { workspace = true, optional = true }
client.workspace = true client.workspace = true
clock.workspace = true clock.workspace = true
collections.workspace = true collections.workspace = true

View file

@ -4,11 +4,14 @@ use crate::{
workspace_settings::{PaneSplitDirectionHorizontal, PaneSplitDirectionVertical}, workspace_settings::{PaneSplitDirectionHorizontal, PaneSplitDirectionVertical},
}; };
use anyhow::Result; use anyhow::Result;
#[cfg(feature = "call")]
use call::{ActiveCall, ParticipantLocation}; use call::{ActiveCall, ParticipantLocation};
use collections::HashMap; use collections::HashMap;
use gpui::{ use gpui::{
Along, AnyView, AnyWeakView, Axis, Bounds, Entity, Hsla, IntoElement, MouseButton, Pixels, Along, AnyView, AnyWeakView, Axis, Bounds, Entity, Hsla, IntoElement, Pixels, Point,
Point, StyleRefinement, WeakEntity, Window, point, size, StyleRefinement, WeakEntity, Window, point, size,
}; };
use parking_lot::Mutex; use parking_lot::Mutex;
use project::Project; use project::Project;
@ -197,6 +200,7 @@ pub enum Member {
pub struct PaneRenderContext<'a> { pub struct PaneRenderContext<'a> {
pub project: &'a Entity<Project>, pub project: &'a Entity<Project>,
pub follower_states: &'a HashMap<CollaboratorId, FollowerState>, pub follower_states: &'a HashMap<CollaboratorId, FollowerState>,
#[cfg(feature = "call")]
pub active_call: Option<&'a Entity<ActiveCall>>, pub active_call: Option<&'a Entity<ActiveCall>>,
pub active_pane: &'a Entity<Pane>, pub active_pane: &'a Entity<Pane>,
pub app_state: &'a Arc<AppState>, pub app_state: &'a Arc<AppState>,
@ -258,6 +262,11 @@ impl PaneLeaderDecorator for PaneRenderContext<'_> {
let mut leader_color; let mut leader_color;
let status_box; let status_box;
match leader_id { match leader_id {
#[cfg(not(feature = "call"))]
CollaboratorId::PeerId(_) => {
return LeaderDecoration::default();
}
#[cfg(feature = "call")]
CollaboratorId::PeerId(peer_id) => { CollaboratorId::PeerId(peer_id) => {
let Some(leader) = self.active_call.as_ref().and_then(|call| { let Some(leader) = self.active_call.as_ref().and_then(|call| {
let room = call.read(cx).room()?.read(cx); let room = call.read(cx).room()?.read(cx);
@ -315,7 +324,7 @@ impl PaneLeaderDecorator for PaneRenderContext<'_> {
|this, (leader_project_id, leader_user_id)| { |this, (leader_project_id, leader_user_id)| {
let app_state = self.app_state.clone(); let app_state = self.app_state.clone();
this.cursor_pointer().on_mouse_down( this.cursor_pointer().on_mouse_down(
MouseButton::Left, gpui::MouseButton::Left,
move |_, _, cx| { move |_, _, cx| {
crate::join_in_room_project( crate::join_in_room_project(
leader_project_id, leader_project_id,

View file

@ -9,6 +9,7 @@ pub mod pane_group;
mod path_list; mod path_list;
mod persistence; mod persistence;
pub mod searchable; pub mod searchable;
#[cfg(feature = "call")]
pub mod shared_screen; pub mod shared_screen;
mod status_bar; mod status_bar;
pub mod tasks; pub mod tasks;
@ -22,11 +23,17 @@ pub use dock::Panel;
pub use path_list::PathList; pub use path_list::PathList;
pub use toast_layer::{ToastAction, ToastLayer, ToastView}; pub use toast_layer::{ToastAction, ToastLayer, ToastView};
use anyhow::{Context as _, Result, anyhow}; #[cfg(feature = "call")]
use call::{ActiveCall, call_settings::CallSettings}; use call::{ActiveCall, call_settings::CallSettings};
#[cfg(feature = "call")]
use client::{Status, proto::ErrorCode};
#[cfg(feature = "call")]
use shared_screen::SharedScreen;
use anyhow::{Context as _, Result, anyhow};
use client::{ use client::{
ChannelId, Client, ErrorExt, Status, TypedEnvelope, UserStore, ChannelId, Client, ErrorExt, TypedEnvelope, UserStore,
proto::{self, ErrorCode, PanelId, PeerId}, proto::{self, PanelId, PeerId},
}; };
use collections::{HashMap, HashSet, hash_map}; use collections::{HashMap, HashSet, hash_map};
use dock::{Dock, DockPosition, PanelButtons, PanelHandle, RESIZE_HANDLE_SIZE}; use dock::{Dock, DockPosition, PanelButtons, PanelHandle, RESIZE_HANDLE_SIZE};
@ -79,7 +86,6 @@ use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use session::AppSession; use session::AppSession;
use settings::{Settings, update_settings_file}; use settings::{Settings, update_settings_file};
use shared_screen::SharedScreen;
use sqlez::{ use sqlez::{
bindable::{Bind, Column, StaticColumnCount}, bindable::{Bind, Column, StaticColumnCount},
statement::Statement, statement::Statement,
@ -886,6 +892,7 @@ impl Global for GlobalAppState {}
pub struct WorkspaceStore { pub struct WorkspaceStore {
workspaces: HashSet<WindowHandle<Workspace>>, workspaces: HashSet<WindowHandle<Workspace>>,
#[cfg(feature = "call")]
client: Arc<Client>, client: Arc<Client>,
_subscriptions: Vec<client::Subscription>, _subscriptions: Vec<client::Subscription>,
} }
@ -1117,6 +1124,7 @@ pub struct Workspace {
window_edited: bool, window_edited: bool,
last_window_title: Option<String>, last_window_title: Option<String>,
dirty_items: HashMap<EntityId, Subscription>, dirty_items: HashMap<EntityId, Subscription>,
#[cfg(feature = "call")]
active_call: Option<(Entity<ActiveCall>, Vec<Subscription>)>, active_call: Option<(Entity<ActiveCall>, Vec<Subscription>)>,
leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>, leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>,
database_id: Option<WorkspaceId>, database_id: Option<WorkspaceId>,
@ -1158,6 +1166,7 @@ pub struct FollowerState {
struct FollowerView { struct FollowerView {
view: Box<dyn FollowableItemHandle>, view: Box<dyn FollowableItemHandle>,
#[cfg(feature = "call")]
location: Option<proto::PanelId>, location: Option<proto::PanelId>,
} }
@ -1357,11 +1366,16 @@ impl Workspace {
let session_id = app_state.session.read(cx).id().to_owned(); let session_id = app_state.session.read(cx).id().to_owned();
#[cfg(feature = "call")]
let mut active_call = None; let mut active_call = None;
#[cfg(feature = "call")]
{
if let Some(call) = ActiveCall::try_global(cx) { if let Some(call) = ActiveCall::try_global(cx) {
let subscriptions = vec![cx.subscribe_in(&call, window, Self::on_active_call_event)]; let subscriptions =
vec![cx.subscribe_in(&call, window, Self::on_active_call_event)];
active_call = Some((call, subscriptions)); active_call = Some((call, subscriptions));
} }
}
let (serializable_items_tx, serializable_items_rx) = let (serializable_items_tx, serializable_items_rx) =
mpsc::unbounded::<Box<dyn SerializableItemHandle>>(); mpsc::unbounded::<Box<dyn SerializableItemHandle>>();
@ -1446,6 +1460,7 @@ impl Workspace {
window_edited: false, window_edited: false,
last_window_title: None, last_window_title: None,
dirty_items: Default::default(), dirty_items: Default::default(),
#[cfg(feature = "call")]
active_call, active_call,
database_id: workspace_id, database_id: workspace_id,
app_state, app_state,
@ -2250,6 +2265,7 @@ impl Workspace {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Task<Result<bool>> { ) -> Task<Result<bool>> {
#[cfg(feature = "call")]
let active_call = self.active_call().cloned(); let active_call = self.active_call().cloned();
// On Linux and Windows, closing the last window should restore the last workspace. // On Linux and Windows, closing the last window should restore the last workspace.
@ -2258,13 +2274,14 @@ impl Workspace {
&& cx.windows().len() == 1; && cx.windows().len() == 1;
cx.spawn_in(window, async move |this, cx| { cx.spawn_in(window, async move |this, cx| {
#[cfg(feature = "call")]
{
let workspace_count = cx.update(|_window, cx| { let workspace_count = cx.update(|_window, cx| {
cx.windows() cx.windows()
.iter() .iter()
.filter(|window| window.downcast::<Workspace>().is_some()) .filter(|window| window.downcast::<Workspace>().is_some())
.count() .count()
})?; })?;
if let Some(active_call) = active_call if let Some(active_call) = active_call
&& workspace_count == 1 && workspace_count == 1
&& active_call.read_with(cx, |call, _| call.room().is_some())? && active_call.read_with(cx, |call, _| call.room().is_some())?
@ -2283,14 +2300,18 @@ impl Workspace {
if answer.await.log_err() == Some(1) { if answer.await.log_err() == Some(1) {
return anyhow::Ok(false); return anyhow::Ok(false);
} else { } else {
{
active_call active_call
.update(cx, |call, cx| call.hang_up(cx))? .update(cx, |call, cx| call.hang_up(cx))?
.await .await
.log_err(); .log_err();
} }
} }
}
if close_intent == CloseIntent::ReplaceWindow { if close_intent == CloseIntent::ReplaceWindow {
_ = active_call.update(cx, |this, cx| { #[cfg(feature = "call")]
{
_ = active_call.update(cx, |active_call, cx| {
let workspace = cx let workspace = cx
.windows() .windows()
.iter() .iter()
@ -2299,12 +2320,14 @@ impl Workspace {
.unwrap(); .unwrap();
let project = workspace.read(cx)?.project.clone(); let project = workspace.read(cx)?.project.clone();
if project.read(cx).is_shared() { if project.read(cx).is_shared() {
this.unshare_project(project, cx)?; active_call.unshare_project(project, cx)?;
} }
Ok::<_, anyhow::Error>(()) Ok::<_, anyhow::Error>(())
})?; })?;
} }
} }
}
}
let save_result = this let save_result = this
.update_in(cx, |this, window, cx| { .update_in(cx, |this, window, cx| {
@ -3486,6 +3509,7 @@ impl Workspace {
item item
} }
#[cfg(feature = "call")]
pub fn open_shared_screen( pub fn open_shared_screen(
&mut self, &mut self,
peer_id: PeerId, peer_id: PeerId,
@ -3907,9 +3931,12 @@ impl Workspace {
pane.update(cx, |pane, _| { pane.update(cx, |pane, _| {
pane.track_alternate_file_items(); pane.track_alternate_file_items();
}); });
#[cfg(feature = "call")]
{
if *local { if *local {
self.unfollow_in_pane(pane, window, cx); self.unfollow_in_pane(pane, window, cx);
} }
}
serialize_workspace = *focus_changed || pane != self.active_pane(); serialize_workspace = *focus_changed || pane != self.active_pane();
if pane == self.active_pane() { if pane == self.active_pane() {
self.active_item_path_changed(window, cx); self.active_item_path_changed(window, cx);
@ -3973,6 +4000,17 @@ impl Workspace {
} }
} }
#[cfg(not(feature = "call"))]
pub fn unfollow_in_pane(
&mut self,
_pane: &Entity<Pane>,
_window: &mut Window,
_cx: &mut Context<Workspace>,
) -> Option<CollaboratorId> {
None
}
#[cfg(feature = "call")]
pub fn unfollow_in_pane( pub fn unfollow_in_pane(
&mut self, &mut self,
pane: &Entity<Pane>, pane: &Entity<Pane>,
@ -4122,6 +4160,7 @@ impl Workspace {
cx.notify(); cx.notify();
} }
#[cfg(feature = "call")]
pub fn start_following( pub fn start_following(
&mut self, &mut self,
leader_id: impl Into<CollaboratorId>, leader_id: impl Into<CollaboratorId>,
@ -4185,6 +4224,16 @@ impl Workspace {
} }
} }
#[cfg(not(feature = "call"))]
pub fn follow_next_collaborator(
&mut self,
_: &FollowNextCollaborator,
_window: &mut Window,
_cx: &mut Context<Self>,
) {
}
#[cfg(feature = "call")]
pub fn follow_next_collaborator( pub fn follow_next_collaborator(
&mut self, &mut self,
_: &FollowNextCollaborator, _: &FollowNextCollaborator,
@ -4233,6 +4282,16 @@ impl Workspace {
} }
} }
#[cfg(not(feature = "call"))]
pub fn follow(
&mut self,
_leader_id: impl Into<CollaboratorId>,
_window: &mut Window,
_cx: &mut Context<Self>,
) {
}
#[cfg(feature = "call")]
pub fn follow( pub fn follow(
&mut self, &mut self,
leader_id: impl Into<CollaboratorId>, leader_id: impl Into<CollaboratorId>,
@ -4285,6 +4344,17 @@ impl Workspace {
} }
} }
#[cfg(not(feature = "call"))]
pub fn unfollow(
&mut self,
_leader_id: impl Into<CollaboratorId>,
_window: &mut Window,
_cx: &mut Context<Self>,
) -> Option<()> {
None
}
#[cfg(feature = "call")]
pub fn unfollow( pub fn unfollow(
&mut self, &mut self,
leader_id: impl Into<CollaboratorId>, leader_id: impl Into<CollaboratorId>,
@ -4595,6 +4665,7 @@ impl Workspace {
anyhow::bail!("no id for view"); anyhow::bail!("no id for view");
}; };
let id = ViewId::from_proto(id)?; let id = ViewId::from_proto(id)?;
#[cfg(feature = "call")]
let panel_id = view.panel_id.and_then(proto::PanelId::from_i32); let panel_id = view.panel_id.and_then(proto::PanelId::from_i32);
let pane = this.update(cx, |this, _cx| { let pane = this.update(cx, |this, _cx| {
@ -4667,6 +4738,7 @@ impl Workspace {
id, id,
FollowerView { FollowerView {
view: item, view: item,
#[cfg(feature = "call")]
location: panel_id, location: panel_id,
}, },
); );
@ -4721,6 +4793,7 @@ impl Workspace {
view.map(|view| { view.map(|view| {
entry.insert(FollowerView { entry.insert(FollowerView {
view, view,
#[cfg(feature = "call")]
location: None, location: None,
}) })
}) })
@ -4911,6 +4984,17 @@ impl Workspace {
) )
} }
#[cfg(not(feature = "call"))]
fn active_item_for_peer(
&self,
_peer_id: PeerId,
_window: &mut Window,
_cx: &mut Context<Self>,
) -> Option<(Option<PanelId>, Box<dyn ItemHandle>)> {
None
}
#[cfg(feature = "call")]
fn active_item_for_peer( fn active_item_for_peer(
&self, &self,
peer_id: PeerId, peer_id: PeerId,
@ -4952,6 +5036,7 @@ impl Workspace {
item_to_activate item_to_activate
} }
#[cfg(feature = "call")]
fn shared_screen_for_peer( fn shared_screen_for_peer(
&self, &self,
peer_id: PeerId, peer_id: PeerId,
@ -5002,10 +5087,12 @@ impl Workspace {
} }
} }
#[cfg(feature = "call")]
pub fn active_call(&self) -> Option<&Entity<ActiveCall>> { pub fn active_call(&self) -> Option<&Entity<ActiveCall>> {
self.active_call.as_ref().map(|(call, _)| call) self.active_call.as_ref().map(|(call, _)| call)
} }
#[cfg(feature = "call")]
fn on_active_call_event( fn on_active_call_event(
&mut self, &mut self,
_: &Entity<ActiveCall>, _: &Entity<ActiveCall>,
@ -5918,6 +6005,17 @@ impl Workspace {
} }
} }
#[cfg(not(feature = "call"))]
fn leader_border_for_pane(
_follower_states: &HashMap<CollaboratorId, FollowerState>,
_pane: &Entity<Pane>,
_: &Window,
_cx: &App,
) -> Option<Div> {
None
}
#[cfg(feature = "call")]
fn leader_border_for_pane( fn leader_border_for_pane(
follower_states: &HashMap<CollaboratorId, FollowerState>, follower_states: &HashMap<CollaboratorId, FollowerState>,
pane: &Entity<Pane>, pane: &Entity<Pane>,
@ -6384,6 +6482,7 @@ impl Render for Workspace {
&PaneRenderContext { &PaneRenderContext {
follower_states: follower_states:
&self.follower_states, &self.follower_states,
#[cfg(feature = "call")]
active_call: self.active_call(), active_call: self.active_call(),
active_pane: &self.active_pane, active_pane: &self.active_pane,
app_state: &self.app_state, app_state: &self.app_state,
@ -6448,6 +6547,7 @@ impl Render for Workspace {
&PaneRenderContext { &PaneRenderContext {
follower_states: follower_states:
&self.follower_states, &self.follower_states,
#[cfg(feature = "call")]
active_call: self.active_call(), active_call: self.active_call(),
active_pane: &self.active_pane, active_pane: &self.active_pane,
app_state: &self.app_state, app_state: &self.app_state,
@ -6510,6 +6610,7 @@ impl Render for Workspace {
&PaneRenderContext { &PaneRenderContext {
follower_states: follower_states:
&self.follower_states, &self.follower_states,
#[cfg(feature = "call")]
active_call: self.active_call(), active_call: self.active_call(),
active_pane: &self.active_pane, active_pane: &self.active_pane,
app_state: &self.app_state, app_state: &self.app_state,
@ -6558,6 +6659,7 @@ impl Render for Workspace {
&PaneRenderContext { &PaneRenderContext {
follower_states: follower_states:
&self.follower_states, &self.follower_states,
#[cfg(feature = "call")]
active_call: self.active_call(), active_call: self.active_call(),
active_pane: &self.active_pane, active_pane: &self.active_pane,
app_state: &self.app_state, app_state: &self.app_state,
@ -6631,10 +6733,22 @@ impl WorkspaceStore {
client.add_request_handler(cx.weak_entity(), Self::handle_follow), client.add_request_handler(cx.weak_entity(), Self::handle_follow),
client.add_message_handler(cx.weak_entity(), Self::handle_update_followers), client.add_message_handler(cx.weak_entity(), Self::handle_update_followers),
], ],
#[cfg(feature = "call")]
client, client,
} }
} }
#[cfg(not(feature = "call"))]
pub fn update_followers(
&self,
_project_id: Option<u64>,
_update: proto::update_followers::Variant,
_cx: &App,
) -> Option<()> {
None
}
#[cfg(feature = "call")]
pub fn update_followers( pub fn update_followers(
&self, &self,
project_id: Option<u64>, project_id: Option<u64>,
@ -6800,6 +6914,7 @@ actions!(
] ]
); );
#[cfg(feature = "call")]
async fn join_channel_internal( async fn join_channel_internal(
channel_id: ChannelId, channel_id: ChannelId,
app_state: &Arc<AppState>, app_state: &Arc<AppState>,
@ -6947,6 +7062,17 @@ async fn join_channel_internal(
anyhow::Ok(false) anyhow::Ok(false)
} }
#[cfg(not(feature = "call"))]
pub fn join_channel(
_channel_id: ChannelId,
_app_state: Arc<AppState>,
_requesting_window: Option<WindowHandle<Workspace>>,
_cx: &mut App,
) -> Task<Result<()>> {
Task::ready(Ok(()))
}
#[cfg(feature = "call")]
pub fn join_channel( pub fn join_channel(
channel_id: ChannelId, channel_id: ChannelId,
app_state: Arc<AppState>, app_state: Arc<AppState>,
@ -7299,6 +7425,7 @@ pub fn open_ssh_project_with_new_connection(
cx, cx,
) )
})?; })?;
// TODO kb register here instead?
open_ssh_project_inner( open_ssh_project_inner(
project, project,
@ -7454,6 +7581,17 @@ fn serialize_ssh_project(
}) })
} }
#[cfg(not(feature = "call"))]
pub fn join_in_room_project(
_project_id: u64,
_follow_user_id: u64,
_app_state: Arc<AppState>,
_cx: &mut App,
) -> Task<Result<()>> {
Task::ready(Ok(()))
}
#[cfg(feature = "call")]
pub fn join_in_room_project( pub fn join_in_room_project(
project_id: u64, project_id: u64,
follow_user_id: u64, follow_user_id: u64,