-
Notifications
You must be signed in to change notification settings - Fork 323
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
Ability to change the execution environment between design and live. #6341
Ability to change the execution environment between design and live. #6341
Conversation
Michael Mauderer reports a new STANDUP for today (2023-04-18): Progress: Updated the PR for this task: integrated with the now existing backend API and merged with already implemented functionality on develop. It should be finished by 2023-04-19. Next Day: Next day I will be working on the #6179 task. Do the same for 6179 |
#[derive(Hash, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display)] | ||
pub enum ExecutionEnvironment { | ||
/// Allows editing the graph, but the `Output` context is disabled, so it prevents accidental | ||
/// changes. | ||
Design, | ||
/// Unrestricted, live editing of data. | ||
Live, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I believe we have the strings "design" and "live" hardcoded somewhere in the previous PR.
- I don't think that hardcoding that as enum is a good option, as these 2 options are temporary and we will allow users defining custom modes. So we should keep the current mode in string-like struct instead.
- This will also make all of helper functions simpler, such as
list_all_imstrings
. - Function
list_all
is similar to a function in previous PR, which was already listing all available execution environments, we should unify these codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here they need to be hard-codes as enum, as this is the current LS protocol. The UI elements can handle arbitrary labels. So, would suggest this to be refactored appropriately once custom modes are implemented.
fn try_from(value: &str) -> core::result::Result<Self, Self::Error> { | ||
match value { | ||
"design" | "Design" => Ok(ExecutionEnvironment::Design), | ||
"live" | "Live" => Ok(ExecutionEnvironment::Live), | ||
_ => Err(()), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to be error prone, why don't we just do value.to_lowercase()
instead?
@@ -308,6 +313,16 @@ impl model::execution_context::API for ExecutionContext { | |||
fn rename_method_pointers(&self, old_project_name: String, new_project_name: String) { | |||
self.model.rename_method_pointers(old_project_name, new_project_name); | |||
} | |||
|
|||
fn set_mode(&self, mode: ExecutionEnvironment) -> BoxFuture<FallibleResult> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes the var with exec env is called environment
, sometimes mode
. This is a minor inconsistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope I spotted the last ones I missed. Will double-check again.
app/gui/src/presenter/project.rs
Outdated
} | ||
}); | ||
} else { | ||
error!("Invalid execution mode: {mode:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming inconsistency - execution mode is not a valid name anymore.
fn make_entries() -> execution_mode_selector::ExecutionModes { | ||
Rc::new(vec!["development".to_string(), "production".to_string()]) | ||
fn make_entries() -> ExecutionEnvironments { | ||
Rc::new(vec!["Design".to_string().into(), "Live".to_string().into()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another hardcoded place with the modes. I would like to ask that all mode names will be defined ONLY in one place in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want all of them in one place only because of crate dependencies: we have a simple demo scene for a chooser that can take arbitrary labels. This element and its demo scene do not need to know about the language server protocol that contains our current ExecutionEnvironment
and its valid values. So, it makes sense to just use fixed dummy values there. We can unify those dummy values between the two demo scenes, but I would argue against introducing a dependency on the LS protocol.
"Live".to_string().into(), | ||
"Design".to_string().into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yet another place with mode names. I know this is an example, but as we are keeping it sync'ed with the names, it should probably use the same names defined in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(see above)
execution_environment_state <- all(out.execution_environment,frp.set_available_execution_environments); | ||
|
||
execution_environment_toggled <- execution_environment_state.sample(&frp.toggle_execution_environment); | ||
toggled_execution_environment <- execution_environment_toggled.map(|(mode,available)| get_next_execution_environment(mode,available)).unwrap(); | ||
|
||
external_execution_environment_update <- any(selected_execution_environment,toggled_execution_environment); | ||
execution_environment_selector.set_execution_environment <+ external_execution_environment_update; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100 chars
init <- source::<()>(); | ||
size_update <- all(init,execution_environment_selector.size,inputs.space_for_window_buttons); | ||
eval size_update ([model]((_,size,gap_size)) { | ||
let y_offset = MACOS_TRAFFIC_LIGHTS_VERTICAL_CENTER; | ||
let traffic_light_width = traffic_lights_gap_width(); | ||
|
||
let execution_environment_selector_x = gap_size.x + traffic_light_width; | ||
model.execution_environment_selector.set_x(execution_environment_selector_x); | ||
let breadcrumb_gap_width = execution_environment_selector_x + size.x + TOP_BAR_ITEM_MARGIN; | ||
model.breadcrumbs.gap_width(breadcrumb_gap_width); | ||
|
||
model.execution_environment_selector.set_y(y_offset + size.y / 2.0); | ||
model.breadcrumbs.set_y(y_offset + component::breadcrumbs::HEIGHT / 2.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try to use auto-layout instead? I believe the auto-layout would make it a lot simpler. Or is it impossible to be used because of some reasons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto layout would require some larger refactoring we want to avoid doing right now. Some of these components are part of the application and some are part of the graph editor. We should at some point unify them, use layouts and get rid of the constants. Please also note that this is old code that just got moved.
use ensogl::application::shortcut::ActionType::*; | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no sections
…_execution_environment_between_design_and_live_on_shortcut # Conflicts: # app/gui/src/presenter/project.rs # app/gui/view/examples/execution-environment-dropdown/src/lib.rs # app/gui/view/examples/interface/src/lib.rs # app/gui/view/execution-environment-selector/src/lib.rs # app/gui/view/execution-environment-selector/src/play_button.rs
CHANGELOG.md
Outdated
- - [The IDE UI element for selecting the execution mode of the | ||
project is now sending messages to the backend.][6341]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double -
/// Execution environment of the context. | ||
pub execution_environment: Rc<Cell<ExecutionEnvironment>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be in Rc
? This model does not implement CloneRef
, and other fields are just RefCell
s without being wrapped in Rc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
@@ -174,12 +181,12 @@ impl display::Object for Model { | |||
|
|||
|
|||
// ============================= | |||
// === ExecutionModeDropdown === | |||
// === ExecutionEnvironmentDropdown === |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust //=================
length above and below.
eval selected_entry ([model] (execution_mode) { | ||
// TODO(#5930): Revisit when connecting with externally set execution mode | ||
let play_button_visibility = match execution_mode.as_str() { | ||
"design" => true, | ||
"live" => false, | ||
_ => { | ||
error!("Play button: invalid execution mode"); | ||
false | ||
} | ||
}; | ||
let play_button_visibility = matches!(execution_mode.to_lowercase().as_str(), "design"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why TODO
was removed? The logic hasn't changed, has it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is implementing the referenced issue (5930) and it appears there is nothing else to do, so no point in keeping the reference to a son to be closed task. This probably should be revisited when we get the custom modes that Wojciech mentioned din one of his other comments.
I guess if we really want to be prepared for it, we could already an API that allows us to set which execution environments should show the play button, but for the current spec that is not needed.
app/gui/view/graph-editor/src/lib.rs
Outdated
profiling_button: component::profiling::Button, | ||
styles_frp: StyleWatchFrp, | ||
selection_controller: selection::Controller, | ||
execution_environment_selector: execution_environment_selector::ExecutionEnvironmentSelector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would import ExecutionEnvironmentSelector
, as the module name is just repeated information.
…_execution_environment_between_design_and_live_on_shortcut # Conflicts: # app/gui/src/presenter/project.rs # app/gui/view/graph-editor/src/lib.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA Review: 🔴
- Read-only mode is broken. See the comment below.
- Changing the execution environment doesn't update the icons on nodes. It might be solved later in Finish execution contexts integration in IDE #6353, so not blocking the merge. I will try to find the needed code change for that later.
- (minor side issue) The dropdown is shifted to the side, I believe it should be displayed more to the left, probably align with the green box. I will create a separate issue for that.
- At the project's opening, we send a
setExecutionEnvironment
message (sometimes even two of them). They fail, probably because the engine is not yet ready. I think we shouldn't send them, the engine assumes the project is in adesign
environment by default.
// TODO(#5930): Temporary shortcut for testing different execution environments | ||
toggle_execution_environment(), | ||
/// Set the execution environmenta available to the graph. | ||
set_available_execution_environments (Rc<Vec<execution_environment_selector::ExecutionEnvironment>>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_available_execution_environments (Rc<Vec<execution_environment_selector::ExecutionEnvironment>>), | |
set_available_execution_environments (Rc<Vec<ExecutionEnvironment>>), |
// === Profiling Mode === | ||
(Press, "", "cmd p", "toggle_profiling_mode"), | ||
// === Execution Mode === | ||
(Press, "", "shift ctrl e", "toggle_execution_environment"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this new shortcut to the documentation (shortcuts.md
)
(as a debug shortcut)
app/gui/src/presenter/project.rs
Outdated
@@ -385,22 +404,26 @@ impl Project { | |||
eval_ view.execution_context_restart(model.execution_context_restart()); | |||
|
|||
view.set_read_only <+ view.toggle_read_only.map(f_!(model.toggle_read_only())); | |||
eval graph_view.execution_environment((mode) model.execution_environment_changed(mode)); | |||
|
|||
eval_ view.toggle_read_only(model.toggle_read_only()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this line is needed? We already have
view.set_read_only <+ view.toggle_read_only.map(f_!(model.toggle_read_only()));
slightly above. I see that read-only mode is broken in a weird way (after toggling it twice removing nodes works, but dragging edges doesn't)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a merge error and the line is removed now.
…_execution_environment_between_design_and_live_on_shortcut
…_execution_environment_between_design_and_live_on_shortcut
QA Report 🟢We are merging it since we need this functionality as soon as possible. However, a few issues must be addressed in the next PR. @MichaelMauderer
|
…6341) Integrate the UI for electing the Execution Environment with the Language Server and unify existing uses. Implements #5930 + actual integration instead of just mocking it. https://user-images.githubusercontent.com/1428930/232919438-6e1e295a-34fe-4756-86a4-5f5d8f718fa0.mp4 # Important Notes The console output is only emitted as part of the `INFO` level. A better check would be to look at the messages sent to the backend in the developer console.
* develop: Passing events to sub-widgets in List Editor and refactoring of the slider component. (#6433) Revert "Cloud/desktop mode switcher (#6308)" (#6444) Widgets integrated with graph nodes (#6347) Table Visualization and display text changes. (#6382) Skip redundant compilations (#6436) Add parse extensions to Text type. #6330 (#6404) Cloud/desktop mode switcher (#6308) Replace Table should_equal with should_equal_verbose (#6405) Rollback event handling changes for the mouse (#6396) Dashboard directory interactivity (#6279) Ability to change the execution environment between design and live. (#6341) Implementation of elements adding to List Editor and a lot of internal API (#6390) Drop method exported from WASM + removing leaks. (#6365) Turn null into UnexpectedExpression when Union type is incomplete (#6415)
Follow up to #6341 (comment) . Contains some refactoring and solves some left over to-dos in the code.
Pull Request Description
Integrate the UI for electing the Execution Environment with the Language Server and unify existing uses. Implements #5930 + actual integration instead of just mocking it.
Peek.2023-04-18.23-32.mp4
Important Notes
The console output is only emitted as part of the
INFO
level. A better check would be to look at the messages sent to the backend in the developer console.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.