Move r-a status into the activity indicator (#32726)

Deals with the noisy pop-ups by moving r-a **status messages** into the
activity indicator, where the rest of the LSP statuses is displayed.


https://github.com/user-attachments/assets/e16fb374-d34d-4d03-b5f1-41f71f61c7c7


https://github.com/user-attachments/assets/67c611aa-8b73-4adb-a76d-b0c8ce3e2f94

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Kirill Bulatov 2025-06-14 01:33:02 +03:00 committed by GitHub
parent 1edaeebae5
commit baefec3849
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 247 additions and 136 deletions

View file

@ -41,8 +41,9 @@ use itertools::Itertools as _;
use language::{
Bias, BinaryStatus, Buffer, BufferSnapshot, CachedLspAdapter, CodeLabel, Diagnostic,
DiagnosticEntry, DiagnosticSet, DiagnosticSourceKind, Diff, File as _, Language, LanguageName,
LanguageRegistry, LanguageToolchainStore, LocalFile, LspAdapter, LspAdapterDelegate, Patch,
PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction, Unclipped,
LanguageRegistry, LanguageServerStatusUpdate, LanguageToolchainStore, LocalFile, LspAdapter,
LspAdapterDelegate, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction,
Unclipped,
language_settings::{
FormatOnSave, Formatter, LanguageSettings, SelectedFormatter, language_settings,
},
@ -10744,7 +10745,7 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate {
fn update_status(&self, server_name: LanguageServerName, status: language::BinaryStatus) {
self.language_registry
.update_lsp_status(server_name, status);
.update_lsp_status(server_name, LanguageServerStatusUpdate::Binary(status));
}
fn registered_lsp_adapters(&self) -> Vec<Arc<dyn LspAdapter>> {

View file

@ -1,12 +1,11 @@
use ::serde::{Deserialize, Serialize};
use anyhow::Context as _;
use gpui::{App, Entity, PromptLevel, Task, WeakEntity};
use gpui::{App, Entity, SharedString, Task, WeakEntity};
use language::{LanguageServerStatusUpdate, ServerHealth};
use lsp::LanguageServer;
use rpc::proto;
use crate::{
LanguageServerPromptRequest, LspStore, LspStoreEvent, Project, ProjectPath, lsp_store,
};
use crate::{LspStore, Project, ProjectPath, lsp_store};
pub const RUST_ANALYZER_NAME: &str = "rust-analyzer";
pub const CARGO_DIAGNOSTICS_SOURCE_NAME: &str = "rustc";
@ -17,20 +16,10 @@ pub const CARGO_DIAGNOSTICS_SOURCE_NAME: &str = "rustc";
#[derive(Debug)]
enum ServerStatus {}
/// Other(String) variant to handle unknown values due to this still being experimental
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
enum ServerHealthStatus {
Ok,
Warning,
Error,
Other(String),
}
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
struct ServerStatusParams {
pub health: ServerHealthStatus,
pub health: ServerHealth,
pub message: Option<String>,
}
@ -45,40 +34,28 @@ pub fn register_notifications(lsp_store: WeakEntity<LspStore>, language_server:
language_server
.on_notification::<ServerStatus, _>({
let name = name.to_string();
let name = name.clone();
move |params, cx| {
let name = name.to_string();
if let Some(ref message) = params.message {
let message = message.trim();
if !message.is_empty() {
let formatted_message = format!(
"Language server {name} (id {server_id}) status update: {message}"
);
match params.health {
ServerHealthStatus::Ok => log::info!("{formatted_message}"),
ServerHealthStatus::Warning => log::warn!("{formatted_message}"),
ServerHealthStatus::Error => {
log::error!("{formatted_message}");
let (tx, _rx) = smol::channel::bounded(1);
let request = LanguageServerPromptRequest {
level: PromptLevel::Critical,
message: params.message.unwrap_or_default(),
actions: Vec::new(),
response_channel: tx,
lsp_name: name.clone(),
};
lsp_store
.update(cx, |_, cx| {
cx.emit(LspStoreEvent::LanguageServerPrompt(request));
})
.ok();
}
ServerHealthStatus::Other(status) => {
log::info!("Unknown server health: {status}\n{formatted_message}")
}
}
}
let status = params.message;
let log_message =
format!("Language server {name} (id {server_id}) status update: {status:?}");
match &params.health {
ServerHealth::Ok => log::info!("{log_message}"),
ServerHealth::Warning => log::warn!("{log_message}"),
ServerHealth::Error => log::error!("{log_message}"),
}
lsp_store
.update(cx, |lsp_store, _| {
lsp_store.languages.update_lsp_status(
name.clone(),
LanguageServerStatusUpdate::Health(
params.health,
status.map(SharedString::from),
),
);
})
.ok();
}
})
.detach();