Skip to content

Commit

Permalink
Delayed Visualization Attaching (enso-org/ide#1825)
Browse files Browse the repository at this point in the history
Original commit: enso-org/ide@3985f1e
  • Loading branch information
mwu-tow authored Sep 23, 2021
1 parent ebdebec commit 64a636f
Show file tree
Hide file tree
Showing 21 changed files with 1,206 additions and 360 deletions.
12 changes: 11 additions & 1 deletion ide/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Next Release

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment

- [Visualizations will be attached after project is ready.][1825] This addresses
a rare issue when initially opened visualizations were automatically closed
rather than filled with data.

[1825]: https://github.com/enso-org/ide/pull/1825

# Enso 2.0.0-alpha.16 (2021-09-16)

<br/>![New Features](/docs/assets/tags/new_features.svg)
Expand Down Expand Up @@ -51,7 +61,7 @@

- [Visualization previews are disabled.][1817] Previously, hovering over a
node's output port for more than four seconds would temporarily reveal the
node's visualization. This behavior is disabled now
node's visualization. This behavior is disabled now.

[1817]: https://github.com/enso-org/ide/pull/1817

Expand Down
24 changes: 23 additions & 1 deletion ide/src/rust/ide/lib/enso-protocol/src/language_server/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ pub enum Notification {
/// execution context.
#[serde(rename = "executionContext/executionFailed")]
ExecutionFailed(ExecutionFailed),

/// Sent from the server to the client to inform about the successful execution of a context.
#[serde(rename = "executionContext/executionComplete")]
#[serde(rename_all="camelCase")]
#[allow(missing_docs)]
ExecutionComplete{context_id:ContextId},

/// Sent from the server to the client to inform about a status of execution.
#[serde(rename = "executionContext/executionStatus")]
ExecutionStatus(ExecutionStatus),

/// Sent from server to the client to inform abouth the change in the suggestions database.
/// Sent from server to the client to inform about the change in the suggestions database.
#[serde(rename = "search/suggestionsDatabaseUpdates")]
SuggestionDatabaseUpdates(SuggestionDatabaseUpdatesEvent),

Expand Down Expand Up @@ -1090,4 +1096,20 @@ pub mod test {
payload : ExpressionUpdatePayload::Panic {trace,message}
}
}

#[test]
fn deserialize_execution_complete() {
use std::str::FromStr;
let text = r#"{
"jsonrpc" : "2.0",
"method" : "executionContext/executionComplete",
"params" : {"contextId":"5a85125a-2dc5-45c8-84fc-679bc9fc4b00"}
}"#;

let notification = serde_json::from_str::<Notification>(text).unwrap();
let expected = Notification::ExecutionComplete {
context_id : ContextId::from_str("5a85125a-2dc5-45c8-84fc-679bc9fc4b00").unwrap()
};
assert_eq!(notification,expected);
}
}
10 changes: 10 additions & 0 deletions ide/src/rust/ide/lib/utils/src/test/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ pub trait StreamTestExt<S:?Sized + Stream> {
}
}

/// Asserts that stream has exactly one value ready and returns it.
///
/// Same caveats apply as for `test_poll_next`.
fn expect_one(&mut self) -> S::Item
where S::Item:Debug {
let ret = self.expect_next();
self.expect_pending();
ret
}

/// Asserts that stream has terminated.
///
/// Same caveats apply as for `test_poll_next`.
Expand Down
12 changes: 12 additions & 0 deletions ide/src/rust/ide/src/controller/graph/executed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,25 @@ impl Handle {
Handle {logger,graph,execution_ctx,project,notifier}
}

/// See [`model::ExecutionContext::when_ready`].
pub fn when_ready(&self) -> StaticBoxFuture<Option<()>> {
self.execution_ctx.when_ready()
}

/// See [`model::ExecutionContext::attach_visualization`].
pub async fn attach_visualization
(&self, visualization:Visualization)
-> FallibleResult<impl Stream<Item=VisualizationUpdateData>> {
self.execution_ctx.attach_visualization(visualization).await
}

/// See [`model::ExecutionContext::modify_visualization`].
pub fn modify_visualization
(&self, id:VisualizationId, expression:Option<String>, module:Option<model::module::QualifiedName>)
-> BoxFuture<FallibleResult> {
self.execution_ctx.modify_visualization(id,expression,module)
}

/// See [`model::ExecutionContext::detach_visualization`].
pub async fn detach_visualization(&self, id:VisualizationId) -> FallibleResult<Visualization> {
self.execution_ctx.detach_visualization(id).await
Expand Down
20 changes: 10 additions & 10 deletions ide/src/rust/ide/src/controller/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::prelude::*;

use crate::controller::graph::executed::Notification as GraphNotification;
use crate::controller::ide::StatusNotificationPublisher;
use crate::double_representation::project;
use crate::model::module::QualifiedName;
Expand Down Expand Up @@ -154,7 +153,7 @@ impl Project {
let main_module_text = controller::Text::new(&self.logger,&project,file_path).await?;
let main_graph = controller::ExecutedGraph::new(&self.logger,project,method).await?;

self.init_call_stack_from_metadata(&main_module_model, &main_graph).await;
self.init_call_stack_from_metadata(&main_module_model,&main_graph).await;
self.notify_about_compiling_process(&main_graph);
self.display_warning_on_unsupported_engine_version()?;

Expand Down Expand Up @@ -213,15 +212,16 @@ impl Project {
}

fn notify_about_compiling_process(&self, graph:&controller::ExecutedGraph) {
let status_notif = self.status_notifications.clone_ref();
let compiling_process = status_notif.publish_background_task(COMPILING_STDLIB_LABEL);
let notifications = graph.subscribe();
let mut computed_value_notif = notifications.filter(|notification|
futures::future::ready(matches!(notification, GraphNotification::ComputedValueInfo(_)))
);
let status_notifier = self.status_notifications.clone_ref();
let compiling_process = status_notifier.publish_background_task(COMPILING_STDLIB_LABEL);
let execution_ready = graph.when_ready();
let logger = self.logger.clone_ref();
executor::global::spawn(async move {
computed_value_notif.next().await;
status_notif.published_background_task_finished(compiling_process);
if execution_ready.await.is_some() {
status_notifier.published_background_task_finished(compiling_process);
} else {
warning!(logger, "Executed graph dropped before first successful execution!")
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion ide/src/rust/ide/src/controller/searcher/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl<'a> RootCategoryBuilder<'a> {
let name = name.into();
let parent = self.root_category_id;
let category_id = self.list_builder.built_list.subcategories.len();
self.list_builder.built_list.subcategories.push(Subcategory {name,parent,icon});
self.list_builder.built_list.subcategories.push(Subcategory {name,icon,parent});
CategoryBuilder { list_builder:self.list_builder, category_id}
}
}
Expand Down
1 change: 1 addition & 0 deletions ide/src/rust/ide/src/ide/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub mod project;
pub mod file_system;
pub mod visualization;

use crate::prelude::*;

Expand Down
Loading

0 comments on commit 64a636f

Please sign in to comment.