diff --git a/app/gui/controller/engine-protocol/src/language_server/types.rs b/app/gui/controller/engine-protocol/src/language_server/types.rs index 3bd1dab1084a..09935b1d876e 100644 --- a/app/gui/controller/engine-protocol/src/language_server/types.rs +++ b/app/gui/controller/engine-protocol/src/language_server/types.rs @@ -306,8 +306,8 @@ pub enum DiagnosticType { #[allow(missing_docs)] #[serde(rename_all = "camelCase")] pub struct Diagnostic { - kind: DiagnosticType, - message: String, + pub kind: DiagnosticType, + pub message: String, path: Option, location: Option, expression_id: Option, diff --git a/app/gui/src/model/project.rs b/app/gui/src/model/project.rs index 2d6fcd699884..6138e9809cdb 100644 --- a/app/gui/src/model/project.rs +++ b/app/gui/src/model/project.rs @@ -164,12 +164,17 @@ pub type Synchronized = synchronized::Project; // ==================== /// Notification emitted by the project model. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum Notification { /// One of the backend connections has been lost. ConnectionLost(BackendConnection), /// Indicates that the project VCS status has changed. VcsStatusChanged(VcsStatus), + /// Any message to be displayed as a notification + Message { + /// text of the message + message: String, + }, } /// Denotes one of backend connections used by a project. diff --git a/app/gui/src/model/project/synchronized.rs b/app/gui/src/model/project/synchronized.rs index 9e060ed9e9e0..335a5449617f 100644 --- a/app/gui/src/model/project/synchronized.rs +++ b/app/gui/src/model/project/synchronized.rs @@ -18,6 +18,7 @@ use engine_protocol::language_server; use engine_protocol::language_server::response; use engine_protocol::language_server::CapabilityRegistration; use engine_protocol::language_server::ContentRoot; +use engine_protocol::language_server::DiagnosticType; use engine_protocol::language_server::ExpressionUpdates; use engine_protocol::language_server::FileEditList; use engine_protocol::language_server::MethodPointer; @@ -526,7 +527,23 @@ impl Project { let execution_update = ExecutionUpdate::ExpressionUpdates(updates); execution_update_handler(context_id, execution_update); } - Event::Notification(Notification::ExecutionStatus(_)) => {} + Event::Notification(Notification::ExecutionStatus(status)) => { + if status.diagnostics.len() > 0 { + let fst = &status.diagnostics[0]; + if fst.kind == DiagnosticType::Error { + let notification = model::project::Notification::Message { + message: fst.message.as_str().to_owned(), + }; + publisher.notify(notification); + } + error!( + "Evaluation failed in context {}. {:?}: {}", + status.context_id, + fst.kind, + fst.message.as_str() + ); + } + } Event::Notification(Notification::ExecutionComplete { context_id }) => { execution_update_handler(context_id, ExecutionUpdate::Completed); } diff --git a/app/gui/src/presenter/project.rs b/app/gui/src/presenter/project.rs index d5901b5922bb..3645774f7273 100644 --- a/app/gui/src/presenter/project.rs +++ b/app/gui/src/presenter/project.rs @@ -421,6 +421,10 @@ impl Project { Notification::VcsStatusChanged(VcsStatus::Clean) => { model.set_project_changed(false); } + Notification::Message { message } => { + let message = view::status_bar::event::Label::from(message); + model.status_bar.add_event(message); + } }; std::future::ready(()) });