Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show status mesage if a visualisation is closed due to engine error. #6937

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions app/gui/src/presenter/graph/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::presenter::graph::AstNodeId;
use crate::presenter::graph::ViewNodeId;

use enso_frp as frp;
use ensogl::application::View;
use ide_view as view;
use ide_view::graph_editor::component::node as node_view;
use ide_view::graph_editor::component::visualization as visualization_view;
Expand Down Expand Up @@ -110,11 +111,12 @@ impl Model {
/// endpoint.
fn handle_controller_failure(
&self,
failure_endpoint: &frp::Source<ViewNodeId>,
failure_endpoint: &frp::Source<(ViewNodeId, String)>,
node: AstNodeId,
message: String,
) {
if let Some(node_view) = self.state.view_id_of_ast_node(node) {
failure_endpoint.emit(node_view);
failure_endpoint.emit((node_view, message));
}
}

Expand Down Expand Up @@ -179,6 +181,7 @@ impl Visualization {
state,
});

let app = &view.app().frp;
frp::extend! { network
eval view.visualization_shown (((node, metadata)) model.visualization_shown(*node, metadata.clone()));
eval view.visualization_hidden ((node) model.visualization_hidden(*node));
Expand All @@ -188,12 +191,13 @@ impl Visualization {

update <- source::<(ViewNodeId, visualization_view::Data)>();
error_update <- source::<(ViewNodeId, visualization_view::Data)>();
visualization_failure <- source::<ViewNodeId>();
error_vis_failure <- source::<ViewNodeId>();
visualization_failure <- source::<(ViewNodeId,String)>();
error_vis_failure <- source::<(ViewNodeId,String)>();

view.set_visualization_data <+ update;
view.set_error_visualization_data <+ error_update;
view.disable_visualization <+ visualization_failure;
view.disable_visualization <+ visualization_failure._0();
app.show_notification <+ visualization_failure._1();

eval_ view.visualization_registry_reload_requested (model.load_visualizations());
}
Expand All @@ -214,7 +218,7 @@ impl Visualization {
notifier: impl Stream<Item = manager::Notification> + Unpin + 'static,
manager: Rc<Manager>,
update_endpoint: frp::Source<(ViewNodeId, visualization_view::Data)>,
failure_endpoint: frp::Source<ViewNodeId>,
failure_endpoint: frp::Source<(ViewNodeId, String)>,
) -> Self {
let weak = Rc::downgrade(&self.model);
spawn_stream_handler(weak, notifier, move |notification, model| {
Expand All @@ -225,7 +229,13 @@ impl Visualization {
}
manager::Notification::FailedToAttach { visualization, error } => {
error!("Visualization {} failed to attach: {error}.", visualization.id);
model.handle_controller_failure(&failure_endpoint, visualization.expression_id);
let message =
format!("Failed to open visualization because of an error: {error}.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {error} messages should already have a dot at the end.

model.handle_controller_failure(
&failure_endpoint,
visualization.expression_id,
message,
);
}
manager::Notification::FailedToDetach { visualization, error } => {
error!("Visualization {} failed to detach: {error}.", visualization.id);
Expand All @@ -245,11 +255,17 @@ impl Visualization {
"Visualization {} failed to be modified: {error}. Will hide it in GUI.",
desired.id
);
let message =
format!("Failed to modify visualization because of an error: {error}.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
format!("Failed to modify visualization because of an error: {error}.");
format!("Failed to modify visualization because of an error: {error}");

// Actually it would likely have more sense if we had just restored the previous
// visualization, as its LS state should be preserved. However, we already
// scrapped it on the GUI side and we don't even know its
// path anymore.
model.handle_controller_failure(&failure_endpoint, desired.expression_id);
model.handle_controller_failure(
&failure_endpoint,
desired.expression_id,
message,
);
}
}
std::future::ready(())
Expand Down
4 changes: 4 additions & 0 deletions app/gui/view/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ impl View {
eval_ frp.switch_view_to_welcome_screen(model.switch_view_to_welcome_screen());
offset_y <- all(&init,&offset_y)._1();
eval offset_y ((offset_y) model.status_bar.set_y(*offset_y));

model.status_bar.add_event <+ app.frp.show_notification.map(|message| {
message.into()
});
}
init.emit(());
Self { model, frp }
Expand Down
5 changes: 4 additions & 1 deletion lib/rust/ensogl/core/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ crate::define_endpoints_2! {
show_system_cursor(),
/// Hide the system mouse cursor.
hide_system_cursor(),
/// Show a notification.
show_notification(String),
}
Output {
tooltip(tooltip::Style)
tooltip(tooltip::Style),
notification(String),
}
}

Expand Down