Compare commits
13 commits
main
...
remote-lsp
Author | SHA1 | Date | |
---|---|---|---|
![]() |
03ba256d96 | ||
![]() |
679c24282d | ||
![]() |
e75e30b25f | ||
![]() |
d433406103 | ||
![]() |
775160a199 | ||
![]() |
cc680d280d | ||
![]() |
25ed82c994 | ||
![]() |
9d1e2f5278 | ||
![]() |
dc6377b8bc | ||
![]() |
13c8d4e052 | ||
![]() |
1cc491a919 | ||
![]() |
ab5da3af83 | ||
![]() |
848d1101d3 |
23 changed files with 861 additions and 363 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -9211,8 +9211,10 @@ dependencies = [
|
|||
"gpui",
|
||||
"itertools 0.14.0",
|
||||
"language",
|
||||
"log",
|
||||
"lsp",
|
||||
"project",
|
||||
"proto",
|
||||
"release_channel",
|
||||
"serde_json",
|
||||
"settings",
|
||||
|
@ -13500,6 +13502,7 @@ dependencies = [
|
|||
"language",
|
||||
"language_extension",
|
||||
"language_model",
|
||||
"language_tools",
|
||||
"languages",
|
||||
"libc",
|
||||
"log",
|
||||
|
|
|
@ -25,7 +25,7 @@ parking_lot.workspace = true
|
|||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
ui.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
workspace-hack.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -28,7 +28,7 @@ serde.workspace = true
|
|||
serde_json.workspace = true
|
||||
text.workspace = true
|
||||
util.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
workspace-hack.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -19,7 +19,7 @@ itertools.workspace = true
|
|||
settings.workspace = true
|
||||
theme.workspace = true
|
||||
ui.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
zed_actions.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
|
||||
|
|
|
@ -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(
|
||||
&mut self,
|
||||
project: Entity<Project>,
|
||||
|
|
|
@ -476,7 +476,8 @@ impl Server {
|
|||
.add_request_handler(forward_mutating_project_request::<proto::GitChangeBranch>)
|
||||
.add_request_handler(forward_mutating_project_request::<proto::CheckForPushedCommits>)
|
||||
.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)
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ sum_tree.workspace = true
|
|||
task.workspace = true
|
||||
ui.workspace = true
|
||||
util.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
workspace-hack.workspace = true
|
||||
itertools.workspace = true
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ ui.workspace = true
|
|||
url.workspace = true
|
||||
util.workspace = true
|
||||
uuid.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
zed_actions.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
|
||||
|
|
|
@ -22,15 +22,17 @@ futures.workspace = true
|
|||
gpui.workspace = true
|
||||
itertools.workspace = true
|
||||
language.workspace = true
|
||||
log.workspace = true
|
||||
lsp.workspace = true
|
||||
project.workspace = true
|
||||
proto.workspace = true
|
||||
serde_json.workspace = true
|
||||
settings.workspace = true
|
||||
theme.workspace = true
|
||||
tree-sitter.workspace = true
|
||||
ui.workspace = true
|
||||
util.workspace = true
|
||||
workspace.workspace = true
|
||||
workspace = { path = "../workspace", default-features = false }
|
||||
zed_actions.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod key_context_view;
|
||||
mod lsp_log;
|
||||
pub mod lsp_log;
|
||||
pub mod lsp_tool;
|
||||
mod syntax_tree_view;
|
||||
|
||||
|
@ -14,7 +14,7 @@ use ui::{Context, Window};
|
|||
use workspace::{Item, ItemHandle, SplitDirection, Workspace};
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
lsp_log::init(cx);
|
||||
lsp_log::init(true, cx);
|
||||
syntax_tree_view::init(cx);
|
||||
key_context_view::init(cx);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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));
|
||||
|
||||
let _rust_buffer = project
|
||||
|
|
|
@ -122,8 +122,7 @@ impl LanguageServerState {
|
|||
let lsp_logs = cx
|
||||
.try_global::<GlobalLogStore>()
|
||||
.and_then(|lsp_logs| lsp_logs.0.upgrade());
|
||||
let lsp_store = self.lsp_store.upgrade();
|
||||
let Some((lsp_logs, lsp_store)) = lsp_logs.zip(lsp_store) else {
|
||||
let Some(lsp_logs) = lsp_logs else {
|
||||
return menu;
|
||||
};
|
||||
|
||||
|
@ -210,10 +209,7 @@ impl LanguageServerState {
|
|||
};
|
||||
|
||||
let server_selector = server_info.server_selector();
|
||||
// TODO currently, Zed remote does not work well with the LSP logs
|
||||
// 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 has_logs = lsp_logs.read(cx).has_server_logs(&server_selector);
|
||||
|
||||
let status_color = server_info
|
||||
.binary_status
|
||||
|
|
|
@ -977,7 +977,9 @@ impl LocalLspStore {
|
|||
this.update(&mut cx, |_, cx| {
|
||||
cx.emit(LspStoreEvent::LanguageServerLog(
|
||||
server_id,
|
||||
LanguageServerLogType::Trace(params.verbose),
|
||||
LanguageServerLogType::Trace {
|
||||
verbose_info: params.verbose,
|
||||
},
|
||||
params.message,
|
||||
));
|
||||
})
|
||||
|
@ -3482,13 +3484,13 @@ pub struct LspStore {
|
|||
buffer_store: Entity<BufferStore>,
|
||||
worktree_store: Entity<WorktreeStore>,
|
||||
pub languages: Arc<LanguageRegistry>,
|
||||
language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>,
|
||||
pub language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>,
|
||||
active_entry: Option<ProjectEntryId>,
|
||||
_maintain_workspace_config: (Task<Result<()>>, watch::Sender<()>),
|
||||
_maintain_buffer_languages: Task<()>,
|
||||
diagnostic_summaries:
|
||||
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_code_lens: HashMap<BufferId, CodeLensData>,
|
||||
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)?;
|
||||
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.
|
||||
|
@ -12677,45 +12683,69 @@ impl PartialEq for LanguageServerPromptRequest {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum LanguageServerLogType {
|
||||
Log(MessageType),
|
||||
Trace(Option<String>),
|
||||
Trace { verbose_info: Option<String> },
|
||||
Rpc { received: bool },
|
||||
}
|
||||
|
||||
impl LanguageServerLogType {
|
||||
pub fn to_proto(&self) -> proto::language_server_log::LogType {
|
||||
match self {
|
||||
Self::Log(log_type) => {
|
||||
let message_type = match *log_type {
|
||||
MessageType::ERROR => 1,
|
||||
MessageType::WARNING => 2,
|
||||
MessageType::INFO => 3,
|
||||
MessageType::LOG => 4,
|
||||
use proto::log_message::LogLevel;
|
||||
let level = match *log_type {
|
||||
MessageType::ERROR => LogLevel::Error,
|
||||
MessageType::WARNING => LogLevel::Warning,
|
||||
MessageType::INFO => LogLevel::Info,
|
||||
MessageType::LOG => LogLevel::Log,
|
||||
other => {
|
||||
log::warn!("Unknown lsp log message type: {:?}", other);
|
||||
4
|
||||
log::warn!("Unknown lsp log message type: {other:?}");
|
||||
LogLevel::Log
|
||||
}
|
||||
};
|
||||
proto::language_server_log::LogType::LogMessageType(message_type)
|
||||
}
|
||||
Self::Trace(message) => {
|
||||
proto::language_server_log::LogType::LogTrace(proto::LspLogTrace {
|
||||
message: message.clone(),
|
||||
proto::language_server_log::LogType::Log(proto::LogMessage {
|
||||
level: level as i32,
|
||||
})
|
||||
}
|
||||
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 {
|
||||
use proto::log_message::LogLevel;
|
||||
use proto::rpc_message;
|
||||
match log_type {
|
||||
proto::language_server_log::LogType::LogMessageType(message_type) => {
|
||||
Self::Log(match message_type {
|
||||
1 => MessageType::ERROR,
|
||||
2 => MessageType::WARNING,
|
||||
3 => MessageType::INFO,
|
||||
4 => MessageType::LOG,
|
||||
_ => MessageType::LOG,
|
||||
})
|
||||
}
|
||||
proto::language_server_log::LogType::LogTrace(trace) => Self::Trace(trace.message),
|
||||
proto::language_server_log::LogType::Log(message_type) => Self::Log(
|
||||
match LogLevel::from_i32(message_type.level).unwrap_or(LogLevel::Log) {
|
||||
LogLevel::Error => MessageType::ERROR,
|
||||
LogLevel::Warning => MessageType::WARNING,
|
||||
LogLevel::Info => MessageType::INFO,
|
||||
LogLevel::Log => MessageType::LOG,
|
||||
},
|
||||
),
|
||||
proto::language_server_log::LogType::Trace(trace_message) => Self::Trace {
|
||||
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,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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_update_worktree);
|
||||
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(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::UpdateBuffer>,
|
||||
|
|
|
@ -610,11 +610,36 @@ message ServerMetadataUpdated {
|
|||
message LanguageServerLog {
|
||||
uint64 project_id = 1;
|
||||
uint64 language_server_id = 2;
|
||||
string message = 3;
|
||||
oneof log_type {
|
||||
uint32 log_message_type = 3;
|
||||
LspLogTrace log_trace = 4;
|
||||
LogMessage log = 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 {
|
||||
|
@ -932,3 +957,16 @@ message MultiLspQuery {
|
|||
message MultiLspQueryResponse {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -396,7 +396,8 @@ message Envelope {
|
|||
GitCloneResponse git_clone_response = 364;
|
||||
|
||||
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;
|
||||
|
|
|
@ -312,7 +312,8 @@ messages!(
|
|||
(GetDefaultBranch, Background),
|
||||
(GetDefaultBranchResponse, Background),
|
||||
(GitClone, Background),
|
||||
(GitCloneResponse, Background)
|
||||
(GitCloneResponse, Background),
|
||||
(ToggleLspLogs, Background),
|
||||
);
|
||||
|
||||
request_messages!(
|
||||
|
@ -481,7 +482,8 @@ request_messages!(
|
|||
(GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
|
||||
(PullWorkspaceDiagnostics, Ack),
|
||||
(GetDefaultBranch, GetDefaultBranchResponse),
|
||||
(GitClone, GitCloneResponse)
|
||||
(GitClone, GitCloneResponse),
|
||||
(ToggleLspLogs, Ack),
|
||||
);
|
||||
|
||||
lsp_messages!(
|
||||
|
@ -612,6 +614,7 @@ entity_messages!(
|
|||
GitReset,
|
||||
GitCheckoutFiles,
|
||||
SetIndexText,
|
||||
ToggleLspLogs,
|
||||
|
||||
Push,
|
||||
Fetch,
|
||||
|
|
|
@ -43,6 +43,7 @@ gpui_tokio.workspace = true
|
|||
http_client.workspace = true
|
||||
language.workspace = true
|
||||
language_extension.workspace = true
|
||||
language_tools.workspace = true
|
||||
languages.workspace = true
|
||||
log.workspace = true
|
||||
lsp.workspace = true
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use ::proto::{FromProto, ToProto};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use language_tools::lsp_log::{GlobalLogStore, LanguageServerKind};
|
||||
use lsp::LanguageServerId;
|
||||
|
||||
use extension::ExtensionHostProxy;
|
||||
use extension_host::headless_host::HeadlessExtensionStore;
|
||||
|
@ -65,6 +67,7 @@ impl HeadlessProject {
|
|||
settings::init(cx);
|
||||
language::init(cx);
|
||||
project::Project::init_settings(cx);
|
||||
language_tools::lsp_log::init(false, cx);
|
||||
}
|
||||
|
||||
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_find_search_candidates);
|
||||
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_message_handler(BufferStore::handle_close_buffer);
|
||||
|
@ -298,11 +302,40 @@ impl HeadlessProject {
|
|||
|
||||
fn on_lsp_store_event(
|
||||
&mut self,
|
||||
_lsp_store: Entity<LspStore>,
|
||||
lsp_store: Entity<LspStore>,
|
||||
event: &LspStoreEvent,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
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 {
|
||||
language_server_id,
|
||||
name,
|
||||
|
@ -326,16 +359,6 @@ impl HeadlessProject {
|
|||
})
|
||||
.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) => {
|
||||
let request = self.session.request(proto::LanguageServerPromptRequest {
|
||||
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>,
|
||||
_: TypedEnvelope<proto::OpenServerSettings>,
|
||||
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>,
|
||||
envelope: TypedEnvelope<proto::FindSearchCandidates>,
|
||||
mut cx: AsyncApp,
|
||||
|
@ -594,7 +641,7 @@ impl HeadlessProject {
|
|||
Ok(response)
|
||||
}
|
||||
|
||||
pub async fn handle_list_remote_directory(
|
||||
async fn handle_list_remote_directory(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::ListRemoteDirectory>,
|
||||
cx: AsyncApp,
|
||||
|
@ -626,7 +673,7 @@ impl HeadlessProject {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn handle_get_path_metadata(
|
||||
async fn handle_get_path_metadata(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::GetPathMetadata>,
|
||||
cx: AsyncApp,
|
||||
|
@ -644,7 +691,7 @@ impl HeadlessProject {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn handle_shutdown_remote_server(
|
||||
async fn handle_shutdown_remote_server(
|
||||
_this: Entity<Self>,
|
||||
_envelope: TypedEnvelope<proto::ShutdownRemoteServer>,
|
||||
cx: AsyncApp,
|
||||
|
|
|
@ -13,6 +13,7 @@ path = "src/workspace.rs"
|
|||
doctest = false
|
||||
|
||||
[features]
|
||||
default = ["call"]
|
||||
test-support = [
|
||||
"call/test-support",
|
||||
"client/test-support",
|
||||
|
@ -29,7 +30,7 @@ test-support = [
|
|||
any_vec.workspace = true
|
||||
anyhow.workspace = true
|
||||
async-recursion.workspace = true
|
||||
call.workspace = true
|
||||
call = { workspace = true, optional = true }
|
||||
client.workspace = true
|
||||
clock.workspace = true
|
||||
collections.workspace = true
|
||||
|
|
|
@ -4,11 +4,14 @@ use crate::{
|
|||
workspace_settings::{PaneSplitDirectionHorizontal, PaneSplitDirectionVertical},
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
use call::{ActiveCall, ParticipantLocation};
|
||||
|
||||
use collections::HashMap;
|
||||
use gpui::{
|
||||
Along, AnyView, AnyWeakView, Axis, Bounds, Entity, Hsla, IntoElement, MouseButton, Pixels,
|
||||
Point, StyleRefinement, WeakEntity, Window, point, size,
|
||||
Along, AnyView, AnyWeakView, Axis, Bounds, Entity, Hsla, IntoElement, Pixels, Point,
|
||||
StyleRefinement, WeakEntity, Window, point, size,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use project::Project;
|
||||
|
@ -197,6 +200,7 @@ pub enum Member {
|
|||
pub struct PaneRenderContext<'a> {
|
||||
pub project: &'a Entity<Project>,
|
||||
pub follower_states: &'a HashMap<CollaboratorId, FollowerState>,
|
||||
#[cfg(feature = "call")]
|
||||
pub active_call: Option<&'a Entity<ActiveCall>>,
|
||||
pub active_pane: &'a Entity<Pane>,
|
||||
pub app_state: &'a Arc<AppState>,
|
||||
|
@ -258,6 +262,11 @@ impl PaneLeaderDecorator for PaneRenderContext<'_> {
|
|||
let mut leader_color;
|
||||
let status_box;
|
||||
match leader_id {
|
||||
#[cfg(not(feature = "call"))]
|
||||
CollaboratorId::PeerId(_) => {
|
||||
return LeaderDecoration::default();
|
||||
}
|
||||
#[cfg(feature = "call")]
|
||||
CollaboratorId::PeerId(peer_id) => {
|
||||
let Some(leader) = self.active_call.as_ref().and_then(|call| {
|
||||
let room = call.read(cx).room()?.read(cx);
|
||||
|
@ -315,7 +324,7 @@ impl PaneLeaderDecorator for PaneRenderContext<'_> {
|
|||
|this, (leader_project_id, leader_user_id)| {
|
||||
let app_state = self.app_state.clone();
|
||||
this.cursor_pointer().on_mouse_down(
|
||||
MouseButton::Left,
|
||||
gpui::MouseButton::Left,
|
||||
move |_, _, cx| {
|
||||
crate::join_in_room_project(
|
||||
leader_project_id,
|
||||
|
|
|
@ -9,6 +9,7 @@ pub mod pane_group;
|
|||
mod path_list;
|
||||
mod persistence;
|
||||
pub mod searchable;
|
||||
#[cfg(feature = "call")]
|
||||
pub mod shared_screen;
|
||||
mod status_bar;
|
||||
pub mod tasks;
|
||||
|
@ -22,11 +23,17 @@ pub use dock::Panel;
|
|||
pub use path_list::PathList;
|
||||
pub use toast_layer::{ToastAction, ToastLayer, ToastView};
|
||||
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
#[cfg(feature = "call")]
|
||||
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::{
|
||||
ChannelId, Client, ErrorExt, Status, TypedEnvelope, UserStore,
|
||||
proto::{self, ErrorCode, PanelId, PeerId},
|
||||
ChannelId, Client, ErrorExt, TypedEnvelope, UserStore,
|
||||
proto::{self, PanelId, PeerId},
|
||||
};
|
||||
use collections::{HashMap, HashSet, hash_map};
|
||||
use dock::{Dock, DockPosition, PanelButtons, PanelHandle, RESIZE_HANDLE_SIZE};
|
||||
|
@ -79,7 +86,6 @@ use schemars::JsonSchema;
|
|||
use serde::Deserialize;
|
||||
use session::AppSession;
|
||||
use settings::{Settings, update_settings_file};
|
||||
use shared_screen::SharedScreen;
|
||||
use sqlez::{
|
||||
bindable::{Bind, Column, StaticColumnCount},
|
||||
statement::Statement,
|
||||
|
@ -886,6 +892,7 @@ impl Global for GlobalAppState {}
|
|||
|
||||
pub struct WorkspaceStore {
|
||||
workspaces: HashSet<WindowHandle<Workspace>>,
|
||||
#[cfg(feature = "call")]
|
||||
client: Arc<Client>,
|
||||
_subscriptions: Vec<client::Subscription>,
|
||||
}
|
||||
|
@ -1117,6 +1124,7 @@ pub struct Workspace {
|
|||
window_edited: bool,
|
||||
last_window_title: Option<String>,
|
||||
dirty_items: HashMap<EntityId, Subscription>,
|
||||
#[cfg(feature = "call")]
|
||||
active_call: Option<(Entity<ActiveCall>, Vec<Subscription>)>,
|
||||
leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>,
|
||||
database_id: Option<WorkspaceId>,
|
||||
|
@ -1158,6 +1166,7 @@ pub struct FollowerState {
|
|||
|
||||
struct FollowerView {
|
||||
view: Box<dyn FollowableItemHandle>,
|
||||
#[cfg(feature = "call")]
|
||||
location: Option<proto::PanelId>,
|
||||
}
|
||||
|
||||
|
@ -1357,10 +1366,15 @@ impl Workspace {
|
|||
|
||||
let session_id = app_state.session.read(cx).id().to_owned();
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
let mut active_call = None;
|
||||
if let Some(call) = ActiveCall::try_global(cx) {
|
||||
let subscriptions = vec![cx.subscribe_in(&call, window, Self::on_active_call_event)];
|
||||
active_call = Some((call, subscriptions));
|
||||
#[cfg(feature = "call")]
|
||||
{
|
||||
if let Some(call) = ActiveCall::try_global(cx) {
|
||||
let subscriptions =
|
||||
vec![cx.subscribe_in(&call, window, Self::on_active_call_event)];
|
||||
active_call = Some((call, subscriptions));
|
||||
}
|
||||
}
|
||||
|
||||
let (serializable_items_tx, serializable_items_rx) =
|
||||
|
@ -1446,6 +1460,7 @@ impl Workspace {
|
|||
window_edited: false,
|
||||
last_window_title: None,
|
||||
dirty_items: Default::default(),
|
||||
#[cfg(feature = "call")]
|
||||
active_call,
|
||||
database_id: workspace_id,
|
||||
app_state,
|
||||
|
@ -2250,6 +2265,7 @@ impl Workspace {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<bool>> {
|
||||
#[cfg(feature = "call")]
|
||||
let active_call = self.active_call().cloned();
|
||||
|
||||
// On Linux and Windows, closing the last window should restore the last workspace.
|
||||
|
@ -2258,51 +2274,58 @@ impl Workspace {
|
|||
&& cx.windows().len() == 1;
|
||||
|
||||
cx.spawn_in(window, async move |this, cx| {
|
||||
let workspace_count = cx.update(|_window, cx| {
|
||||
cx.windows()
|
||||
.iter()
|
||||
.filter(|window| window.downcast::<Workspace>().is_some())
|
||||
.count()
|
||||
})?;
|
||||
|
||||
if let Some(active_call) = active_call
|
||||
&& workspace_count == 1
|
||||
&& active_call.read_with(cx, |call, _| call.room().is_some())?
|
||||
#[cfg(feature = "call")]
|
||||
{
|
||||
if close_intent == CloseIntent::CloseWindow {
|
||||
let answer = cx.update(|window, cx| {
|
||||
window.prompt(
|
||||
PromptLevel::Warning,
|
||||
"Do you want to leave the current call?",
|
||||
None,
|
||||
&["Close window and hang up", "Cancel"],
|
||||
cx,
|
||||
)
|
||||
})?;
|
||||
let workspace_count = cx.update(|_window, cx| {
|
||||
cx.windows()
|
||||
.iter()
|
||||
.filter(|window| window.downcast::<Workspace>().is_some())
|
||||
.count()
|
||||
})?;
|
||||
if let Some(active_call) = active_call
|
||||
&& workspace_count == 1
|
||||
&& active_call.read_with(cx, |call, _| call.room().is_some())?
|
||||
{
|
||||
if close_intent == CloseIntent::CloseWindow {
|
||||
let answer = cx.update(|window, cx| {
|
||||
window.prompt(
|
||||
PromptLevel::Warning,
|
||||
"Do you want to leave the current call?",
|
||||
None,
|
||||
&["Close window and hang up", "Cancel"],
|
||||
cx,
|
||||
)
|
||||
})?;
|
||||
|
||||
if answer.await.log_err() == Some(1) {
|
||||
return anyhow::Ok(false);
|
||||
} else {
|
||||
active_call
|
||||
.update(cx, |call, cx| call.hang_up(cx))?
|
||||
.await
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
if close_intent == CloseIntent::ReplaceWindow {
|
||||
_ = active_call.update(cx, |this, cx| {
|
||||
let workspace = cx
|
||||
.windows()
|
||||
.iter()
|
||||
.filter_map(|window| window.downcast::<Workspace>())
|
||||
.next()
|
||||
.unwrap();
|
||||
let project = workspace.read(cx)?.project.clone();
|
||||
if project.read(cx).is_shared() {
|
||||
this.unshare_project(project, cx)?;
|
||||
if answer.await.log_err() == Some(1) {
|
||||
return anyhow::Ok(false);
|
||||
} else {
|
||||
{
|
||||
active_call
|
||||
.update(cx, |call, cx| call.hang_up(cx))?
|
||||
.await
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
Ok::<_, anyhow::Error>(())
|
||||
})?;
|
||||
}
|
||||
if close_intent == CloseIntent::ReplaceWindow {
|
||||
#[cfg(feature = "call")]
|
||||
{
|
||||
_ = active_call.update(cx, |active_call, cx| {
|
||||
let workspace = cx
|
||||
.windows()
|
||||
.iter()
|
||||
.filter_map(|window| window.downcast::<Workspace>())
|
||||
.next()
|
||||
.unwrap();
|
||||
let project = workspace.read(cx)?.project.clone();
|
||||
if project.read(cx).is_shared() {
|
||||
active_call.unshare_project(project, cx)?;
|
||||
}
|
||||
Ok::<_, anyhow::Error>(())
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3486,6 +3509,7 @@ impl Workspace {
|
|||
item
|
||||
}
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
pub fn open_shared_screen(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
|
@ -3907,8 +3931,11 @@ impl Workspace {
|
|||
pane.update(cx, |pane, _| {
|
||||
pane.track_alternate_file_items();
|
||||
});
|
||||
if *local {
|
||||
self.unfollow_in_pane(pane, window, cx);
|
||||
#[cfg(feature = "call")]
|
||||
{
|
||||
if *local {
|
||||
self.unfollow_in_pane(pane, window, cx);
|
||||
}
|
||||
}
|
||||
serialize_workspace = *focus_changed || pane != self.active_pane();
|
||||
if pane == self.active_pane() {
|
||||
|
@ -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(
|
||||
&mut self,
|
||||
pane: &Entity<Pane>,
|
||||
|
@ -4122,6 +4160,7 @@ impl Workspace {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
pub fn start_following(
|
||||
&mut self,
|
||||
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(
|
||||
&mut self,
|
||||
_: &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(
|
||||
&mut self,
|
||||
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(
|
||||
&mut self,
|
||||
leader_id: impl Into<CollaboratorId>,
|
||||
|
@ -4595,6 +4665,7 @@ impl Workspace {
|
|||
anyhow::bail!("no id for view");
|
||||
};
|
||||
let id = ViewId::from_proto(id)?;
|
||||
#[cfg(feature = "call")]
|
||||
let panel_id = view.panel_id.and_then(proto::PanelId::from_i32);
|
||||
|
||||
let pane = this.update(cx, |this, _cx| {
|
||||
|
@ -4667,6 +4738,7 @@ impl Workspace {
|
|||
id,
|
||||
FollowerView {
|
||||
view: item,
|
||||
#[cfg(feature = "call")]
|
||||
location: panel_id,
|
||||
},
|
||||
);
|
||||
|
@ -4721,6 +4793,7 @@ impl Workspace {
|
|||
view.map(|view| {
|
||||
entry.insert(FollowerView {
|
||||
view,
|
||||
#[cfg(feature = "call")]
|
||||
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(
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
|
@ -4952,6 +5036,7 @@ impl Workspace {
|
|||
item_to_activate
|
||||
}
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
fn shared_screen_for_peer(
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
|
@ -5002,10 +5087,12 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
pub fn active_call(&self) -> Option<&Entity<ActiveCall>> {
|
||||
self.active_call.as_ref().map(|(call, _)| call)
|
||||
}
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
fn on_active_call_event(
|
||||
&mut self,
|
||||
_: &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(
|
||||
follower_states: &HashMap<CollaboratorId, FollowerState>,
|
||||
pane: &Entity<Pane>,
|
||||
|
@ -6384,6 +6482,7 @@ impl Render for Workspace {
|
|||
&PaneRenderContext {
|
||||
follower_states:
|
||||
&self.follower_states,
|
||||
#[cfg(feature = "call")]
|
||||
active_call: self.active_call(),
|
||||
active_pane: &self.active_pane,
|
||||
app_state: &self.app_state,
|
||||
|
@ -6448,6 +6547,7 @@ impl Render for Workspace {
|
|||
&PaneRenderContext {
|
||||
follower_states:
|
||||
&self.follower_states,
|
||||
#[cfg(feature = "call")]
|
||||
active_call: self.active_call(),
|
||||
active_pane: &self.active_pane,
|
||||
app_state: &self.app_state,
|
||||
|
@ -6510,6 +6610,7 @@ impl Render for Workspace {
|
|||
&PaneRenderContext {
|
||||
follower_states:
|
||||
&self.follower_states,
|
||||
#[cfg(feature = "call")]
|
||||
active_call: self.active_call(),
|
||||
active_pane: &self.active_pane,
|
||||
app_state: &self.app_state,
|
||||
|
@ -6558,6 +6659,7 @@ impl Render for Workspace {
|
|||
&PaneRenderContext {
|
||||
follower_states:
|
||||
&self.follower_states,
|
||||
#[cfg(feature = "call")]
|
||||
active_call: self.active_call(),
|
||||
active_pane: &self.active_pane,
|
||||
app_state: &self.app_state,
|
||||
|
@ -6631,10 +6733,22 @@ impl WorkspaceStore {
|
|||
client.add_request_handler(cx.weak_entity(), Self::handle_follow),
|
||||
client.add_message_handler(cx.weak_entity(), Self::handle_update_followers),
|
||||
],
|
||||
#[cfg(feature = "call")]
|
||||
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(
|
||||
&self,
|
||||
project_id: Option<u64>,
|
||||
|
@ -6800,6 +6914,7 @@ actions!(
|
|||
]
|
||||
);
|
||||
|
||||
#[cfg(feature = "call")]
|
||||
async fn join_channel_internal(
|
||||
channel_id: ChannelId,
|
||||
app_state: &Arc<AppState>,
|
||||
|
@ -6947,6 +7062,17 @@ async fn join_channel_internal(
|
|||
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(
|
||||
channel_id: ChannelId,
|
||||
app_state: Arc<AppState>,
|
||||
|
@ -7299,6 +7425,7 @@ pub fn open_ssh_project_with_new_connection(
|
|||
cx,
|
||||
)
|
||||
})?;
|
||||
// TODO kb register here instead?
|
||||
|
||||
open_ssh_project_inner(
|
||||
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(
|
||||
project_id: u64,
|
||||
follow_user_id: u64,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue